11 Commits
0.0.3 ... 0.0.4

13 changed files with 372 additions and 331 deletions

View File

@@ -17,7 +17,8 @@ steps:
- ${DRONE_TAG} - ${DRONE_TAG}
- latest - latest
build_args: build_args:
- BUILD_TAG=${DRONE_TAG} - VERSION=${DRONE_TAG}
- BUILD_TIME=${DRONE_BUILD_FINISHED}
- name: build-worker - name: build-worker
image: plugins/docker image: plugins/docker
settings: settings:

View File

@@ -2,7 +2,7 @@ FROM node:22-alpine AS front-base
# Install dependencies only when needed # Install dependencies only when needed
FROM front-base AS front-deps FROM front-base AS front-deps
RUN apk add --no-cache libc6-compat RUN apk add --no-cache gcompat
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN corepack enable pnpm && pnpm i && pnpm --filter=015-front deploy dist RUN corepack enable pnpm && pnpm i && pnpm --filter=015-front deploy dist
@@ -26,7 +26,8 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o backend
FROM front-base AS runner FROM front-base AS runner
ARG BUILD_TAG ARG VERSION
ARG BUILD_TIME
WORKDIR /app WORKDIR /app
RUN apk add --no-cache curl openssl RUN apk add --no-cache curl openssl
ENV NODE_ENV production ENV NODE_ENV production
@@ -43,6 +44,8 @@ COPY 015.sh /app/015.sh
ENV PORT=80 HOST=0.0.0.0 ENV PORT=80 HOST=0.0.0.0
ENV SITE_URL="http://localhost" ENV SITE_URL="http://localhost"
ENV UPLOAD_PATH="/uploads" ENV UPLOAD_PATH="/uploads"
ENV VERSION=${VERSION}
ENV BUILD_TIME=${BUILD_TIME}
EXPOSE 80 EXPOSE 80

View File

@@ -1,3 +1,20 @@
# 015 # 015
这里是send企划 这里是send企划
功能:
- ✅ 前端计算hash和秒传
- ✅ 并发切片上传 (使用webWorker计算)
- ✅ 文件上传/文本上传和分享
- ✅ 上传统计页面
- ✅ 多语言支持
- ✅ 最大上传限制
- ✅ 后端有队列系统和worker处理文件
todo:
- 断点续传(后端计算已上传部分并返回)
- 图片格式转换 压缩
- 图片ocr 复制
- xx转markdown
- 文本翻译/总结
- 支持上传多文件

View File

@@ -14,7 +14,6 @@ import (
"github.com/hibiken/asynq" "github.com/hibiken/asynq"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/spf13/cast"
) )
func CreateUploadTask(c echo.Context) error { func CreateUploadTask(c echo.Context) error {
@@ -41,8 +40,10 @@ func CreateUploadTask(c echo.Context) error {
"chunk_size": fileInfo.ChunkSize, "chunk_size": fileInfo.ChunkSize,
}) })
} }
maxStorageSize, err := utils.GetFileSize(utils.GetEnv("MAX_LOCALSTORAGE_SIZE"))
maxStorageSize := cast.ToInt64(utils.GetEnv("MAX_LOCALSTORAGE_SIZE")) if err != nil {
return utils.HTTPErrorHandler(c, err)
}
fileInfoMap, err := models.GetRedisFileInfoAll() fileInfoMap, err := models.GetRedisFileInfoAll()
if err != nil { if err != nil {
return utils.HTTPErrorHandler(c, err) return utils.HTTPErrorHandler(c, err)
@@ -56,7 +57,7 @@ func CreateUploadTask(c echo.Context) error {
} }
totalSize += fileInfo.FileSize totalSize += fileInfo.FileSize
} }
if totalSize+r.FileSize > maxStorageSize { if totalSize+r.FileSize > int64(maxStorageSize) {
return utils.HTTPErrorHandler(c, errors.New("存储空间不足")) return utils.HTTPErrorHandler(c, errors.New("存储空间不足"))
} }

View File

@@ -9,6 +9,7 @@ import (
"github.com/hibiken/asynq" "github.com/hibiken/asynq"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/samber/lo" "github.com/samber/lo"
"github.com/spf13/cast"
) )
type FileChartData struct { type FileChartData struct {
@@ -83,7 +84,8 @@ func GetStat(c echo.Context) error {
}) })
return utils.HTTPSuccessHandler(c, map[string]any{ return utils.HTTPSuccessHandler(c, map[string]any{
"version": "0.1.0", "version": utils.GetEnvWithDefault("VERSION", "dev"),
"build_time": cast.ToInt(utils.GetEnvWithDefault("BUILD_TIME", cast.ToString(time.Now().Unix()))),
"max_limit": map[string]any{ "max_limit": map[string]any{
"file_size": maxStorageSize, "file_size": maxStorageSize,
}, },

View File

@@ -50,7 +50,7 @@
--card-foreground: oklch(0.129 0.042 264.695); --card-foreground: oklch(0.129 0.042 264.695);
--popover: oklch(1 0 0); --popover: oklch(1 0 0);
--popover-foreground: oklch(0.129 0.042 264.695); --popover-foreground: oklch(0.129 0.042 264.695);
--primary: oklch(0.208 0.042 265.755); --primary: oklch(0.4349 0.0673 257.47);
--primary-foreground: oklch(0.984 0.003 247.858); --primary-foreground: oklch(0.984 0.003 247.858);
--secondary: oklch(0.968 0.007 247.896); --secondary: oklch(0.968 0.007 247.896);
--secondary-foreground: oklch(0.208 0.042 265.755); --secondary-foreground: oklch(0.208 0.042 265.755);

View File

@@ -1,9 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import CircularProgress from '@/components/CircularProgress.vue' import CircularProgress from '@/components/CircularProgress.vue'
import { chunk, shuffle, times } from 'lodash-es' import { chunk, get, shuffle, times } from 'lodash-es'
import { cx } from 'class-variance-authority' import { cx } from 'class-variance-authority'
import calcFileHash from '@/lib/calcFileHash'
import { filesize } from 'filesize' import { filesize } from 'filesize'
import { toast } from 'vue-sonner'
import asyncWorker from '~/lib/asyncWorker'
import calcFileHashWorker from '~/lib/calcFileHashWorker?worker'
const props = defineProps<{ const props = defineProps<{
data: { file: File; config: any; handle_type: string } data: { file: File; config: any; handle_type: string }
}>() }>()
@@ -28,12 +30,13 @@ const successCount = computed(() => fileSliceUploadStatusList.value.filter((item
const alreadyUploadSize = computed(() => successCount.value * chunkSize.value) const alreadyUploadSize = computed(() => successCount.value * chunkSize.value)
const uploadProgress = computed(() => Math.round((alreadyUploadSize.value / (props?.data?.file?.size || 0)) * 100)) const uploadProgress = computed(() => Math.round((alreadyUploadSize.value / (props?.data?.file?.size || 0)) * 100))
useAsyncState(async () => { const { error } = useAsyncState(async () => {
const { file } = props.data || {} const { file } = props.data || {}
if (!file) return if (!file) return
const { size, type = 'application/octet-stream' } = file || {} const { size, type = 'application/octet-stream' } = file || {}
const now = Date.now() const now = Date.now()
const hash = await calcFileHash({ file }) const res = await asyncWorker(calcFileHashWorker, { data: { file } })
const { hash } = res?.data || {}
if (hash) { if (hash) {
step.value = 'upload' step.value = 'upload'
calcHashTime.value = Date.now() - now calcHashTime.value = Date.now() - now
@@ -49,7 +52,7 @@ useAsyncState(async () => {
method: 'POST', method: 'POST',
body: { body: {
size, size,
mime_type: type, mime_type: get(type, '', 'application/octet-stream'),
hash, hash,
}, },
}) })
@@ -122,6 +125,13 @@ useAsyncState(async () => {
form.setFieldValue('file_id', id) form.setFieldValue('file_id', id)
emit('change', 'result') emit('change', 'result')
}, null) }, null)
watch(error, (newVal) => {
if (newVal) {
toast.error('上传失败')
}
emit('change', 'input')
})
</script> </script>
<template> <template>
<div class="flex flex-col gap-3"> <div class="flex flex-col gap-3">

14
front/lib/asyncWorker.ts Normal file
View File

@@ -0,0 +1,14 @@
const asyncWorker = (w: new () => Worker, opts: { data: any }) => {
const { data } = opts || {}
return new Promise<MessageEvent>((resolve, reject) => {
const worker = new w()
worker.postMessage(data || {})
worker.onmessage = (e: MessageEvent) => {
resolve(e)
}
worker.onerror = (e: ErrorEvent) => {
reject(e)
}
})
}
export default asyncWorker

View File

@@ -1,44 +1,47 @@
import SparkMD5 from 'spark-md5'; import { noop } from 'lodash-es'
import { noop } from 'lodash-es'; import { md5 } from 'js-md5'
interface CalcFileHashProps { interface CalcFileHashProps {
file: File; file: File
onProgress?: (current: number) => void; onProgress?: (current: number) => void
chunkSize?: number; chunkSize?: number
} }
const calcFileHash = async (props: CalcFileHashProps) => { const calcFileHash = async (props: CalcFileHashProps) => {
const { file, onProgress = noop, chunkSize = 100 } = props || {}; const { file, onProgress = noop, chunkSize = 100 } = props || {}
const finalChunkSize = chunkSize * 1024 * 1024; const blob = await file.arrayBuffer()
const chunks = Math.ceil(file.size / finalChunkSize); const hash = md5(blob)
const spark = new SparkMD5.ArrayBuffer(); // 使用 SparkMD5 增量计算哈希 return hash
const fileReader = new FileReader(); // const finalChunkSize = chunkSize * 1024 * 1024;
// const chunks = Math.ceil(file.size / finalChunkSize);
// const spark = new SparkMD5.ArrayBuffer(); // 使用 SparkMD5 增量计算哈希
// const fileReader = new FileReader();
const readChunk = (start: number): Promise<ArrayBuffer> => { // const readChunk = (start: number): Promise<ArrayBuffer> => {
return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
const chunk = file.slice(start, start + finalChunkSize); // const chunk = file.slice(start, Math.min(start + finalChunkSize, file.size));
fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer); // fileReader.onload = (e) => resolve(e.target?.result as ArrayBuffer);
fileReader.onerror = reject; // fileReader.onerror = reject;
fileReader.readAsArrayBuffer(chunk); // fileReader.readAsArrayBuffer(chunk);
}); // });
}; // };
try { // try {
const progressCallback = (current: number) => { // const progressCallback = (current: number) => {
const percentage = Math.round((current / chunks) * 100); // const percentage = Math.round((current / chunks) * 100);
onProgress(percentage); // onProgress(percentage);
}; // };
for (let i = 0; i < chunks; i++) { // for (let i = 0; i < chunks; i++) {
const chunk = await readChunk(i * chunkSize); // const chunk = await readChunk(i * chunkSize);
spark.append(chunk); // spark.append(chunk);
progressCallback(i + 1); // progressCallback(i + 1);
} // }
return spark.end(); // return spark.end();
} catch (error) { // } catch (error) {
throw error; // throw error;
} // }
} }
export default calcFileHash; export default calcFileHash

View File

@@ -0,0 +1,8 @@
import calcFileHash from './calcFileHash'
// 监听主线程消息
self.onmessage = async (e: MessageEvent<{ file: File }>) => {
const { file } = e.data || {}
const hash = await calcFileHash({ file })
self.postMessage({ hash })
}

View File

@@ -1,70 +1,71 @@
{ {
"name": "015-front", "name": "015-front",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "nuxt build", "build": "nuxt build",
"dev": "nuxt dev", "dev": "nuxt dev",
"generate": "nuxt generate", "generate": "nuxt generate",
"preview": "nuxt preview", "preview": "nuxt preview",
"postinstall": "nuxt prepare" "postinstall": "nuxt prepare"
}, },
"dependencies": { "dependencies": {
"@nuxt/image": "1.10.0", "@nuxt/image": "1.10.0",
"@nuxtjs/i18n": "9.5.5", "@nuxtjs/i18n": "9.5.5",
"@pinia/nuxt": "^0.11.0", "@pinia/nuxt": "^0.11.0",
"@tailwindcss/postcss": "^4.1.3", "@tailwindcss/postcss": "^4.1.3",
"@tailwindcss/vite": "^4.1.3", "@tailwindcss/vite": "^4.1.3",
"@tanstack/vue-query": "^5.76.0", "@tanstack/vue-query": "^5.76.0",
"@tiptap/extension-blockquote": "^2.11.7", "@tiptap/extension-blockquote": "^2.11.7",
"@tiptap/extension-bold": "^2.11.7", "@tiptap/extension-bold": "^2.11.7",
"@tiptap/extension-heading": "^2.11.7", "@tiptap/extension-heading": "^2.11.7",
"@tiptap/extension-italic": "^2.11.7", "@tiptap/extension-italic": "^2.11.7",
"@tiptap/extension-paragraph": "^2.11.7", "@tiptap/extension-paragraph": "^2.11.7",
"@tiptap/extension-placeholder": "^2.11.7", "@tiptap/extension-placeholder": "^2.11.7",
"@tiptap/extension-strike": "^2.11.7", "@tiptap/extension-strike": "^2.11.7",
"@tiptap/extension-text": "^2.11.7", "@tiptap/extension-text": "^2.11.7",
"@tiptap/pm": "^2.11.7", "@tiptap/pm": "^2.11.7",
"@tiptap/starter-kit": "^2.11.7", "@tiptap/starter-kit": "^2.11.7",
"@tiptap/vue-3": "^2.11.7", "@tiptap/vue-3": "^2.11.7",
"@unovis/ts": "^1.5.1", "@unovis/ts": "^1.5.1",
"@unovis/vue": "^1.5.1", "@unovis/vue": "^1.5.1",
"@vee-validate/nuxt": "^4.15.0", "@vee-validate/nuxt": "^4.15.0",
"@vee-validate/rules": "^4.15.0", "@vee-validate/rules": "^4.15.0",
"axios": "^1.8.4", "axios": "^1.8.4",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"dayjs": "^1.11.13", "dayjs": "^1.11.13",
"filesize": "^10.1.6", "filesize": "^10.1.6",
"lodash-es": "^4.17.21", "js-md5": "^0.8.3",
"lucide-vue-next": "^0.487.0", "lodash-es": "^4.17.21",
"markdown-it": "^14.1.0", "lucide-vue-next": "^0.487.0",
"motion-v": "1.0.0-beta.2", "markdown-it": "^14.1.0",
"nuxt": "^3.17.4", "motion-v": "1.0.0-beta.2",
"nuxt-lucide-icons": "1.0.5", "nuxt": "^3.17.4",
"pinia": "^3.0.2", "nuxt-lucide-icons": "1.0.5",
"qrcode": "^1.5.4", "pinia": "^3.0.2",
"reka-ui": "^2.2.0", "qrcode": "^1.5.4",
"vue": "^3.5.16", "reka-ui": "^2.2.0",
"vue-router": "^4.5.1", "shadcn-nuxt": "2.0.1",
"vue-sonner": "^1.3.2", "spark-md5": "^3.0.2",
"shadcn-nuxt": "2.0.1", "tailwind-merge": "^3.2.0",
"spark-md5": "^3.0.2", "tailwindcss": "^4.1.3",
"tailwind-merge": "^3.2.0", "tiptap-markdown": "^0.8.10",
"tailwindcss": "^4.1.3", "tw-animate-css": "^1.2.5",
"tiptap-markdown": "^0.8.10", "vaul-vue": "^0.4.1",
"tw-animate-css": "^1.2.5", "vue": "^3.5.16",
"vaul-vue": "^0.4.1" "vue-router": "^4.5.1",
}, "vue-sonner": "^1.3.2"
"packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b", },
"devDependencies": { "packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
"@nuxtjs/tailwindcss": "^6.13.2", "devDependencies": {
"@tailwindcss/typography": "^0.5.16", "@nuxtjs/tailwindcss": "^6.13.2",
"@types/markdown-it": "^14.1.2", "@tailwindcss/typography": "^0.5.16",
"@types/qrcode": "^1.5.5", "@types/lodash-es": "^4.17.12",
"@types/lodash-es": "^4.17.12", "@types/markdown-it": "^14.1.2",
"@types/spark-md5": "^3.0.5", "@types/qrcode": "^1.5.5",
"@vueuse/core": "^13.0.0", "@types/spark-md5": "^3.0.5",
"@vueuse/nuxt": "^13.0.0" "@vueuse/core": "^13.0.0",
} "@vueuse/nuxt": "^13.0.0"
}
} }

View File

@@ -1,240 +1,213 @@
<script setup lang="ts"> <script setup lang="ts">
import { CurveType } from "@unovis/ts"; import { CurveType } from '@unovis/ts'
import { AreaChart } from "@/components/ui/chart-area"; import { AreaChart } from '@/components/ui/chart-area'
import { cx } from "class-variance-authority"; import { cx } from 'class-variance-authority'
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from '@tanstack/vue-query'
import { Skeleton } from "@/components/ui/skeleton"; import { Skeleton } from '@/components/ui/skeleton'
import AboutChartTooltip from "@/components/AboutChartTooltip.vue"; import AboutChartTooltip from '@/components/AboutChartTooltip.vue'
import { filesize } from "filesize"; import { filesize } from 'filesize'
import SparkMD5 from "spark-md5"; import SparkMD5 from 'spark-md5'
import useMyAppConfig from "@/composables/useMyAppConfig"; import useMyAppConfig from '@/composables/useMyAppConfig'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import Progress from '~/components/ui/progress/Progress.vue'
const appConfig = useMyAppConfig(); dayjs.extend(relativeTime)
const { site_title, site_desc } = appConfig.value || {};
const appConfig = useMyAppConfig()
const { site_title, site_desc } = appConfig.value || {}
const { data, isLoading } = useQuery({ const { data, isLoading } = useQuery({
queryKey: ["stat"], queryKey: ['stat'],
queryFn: async () => { queryFn: async () => {
const data = await $fetch<{ data: any }>("/api/stat"); const data = await $fetch<{ data: any }>('/api/stat')
return data.data; return data.data
}, },
}); })
const { t } = useI18n(); const { t } = useI18n()
const chartTabs = computed(() => { const chartTabs = computed(() => {
return [ return [
{ {
label: t("about.file"), label: t('about.file'),
value: "storage", value: 'storage',
total: total: data.value?.chart?.storage?.reduce((acc: number, curr: { file_size: number; file_num: number }) => acc + curr.file_num, 0) ?? 0,
data.value?.chart?.storage?.reduce( },
(acc: number, curr: { file_size: number; file_num: number }) => {
acc + curr.file_num, label: t('about.task'),
0, value: 'queue',
) ?? 0, total:
}, data.value?.chart?.queue?.reduce(
{ (acc: number, curr: { processed: number; failed: number }) => acc + curr.processed + curr.failed,
label: t("about.task"), 0
value: "queue", ) ?? 0,
total: },
data.value?.chart?.queue?.reduce( ]
(acc: number, curr: { processed: number; failed: number }) => })
acc + curr.processed + curr.failed,
0,
) ?? 0,
},
];
});
const currentFileSize = computed(() => { const currentFileSize = computed(() => {
return ( return data.value?.chart?.storage?.reduce((acc: number, curr: { file_size: number; file_num: number }) => acc + curr.file_size, 0) ?? 0
data.value?.chart?.storage?.reduce( })
(acc: number, curr: { file_size: number; file_num: number }) =>
acc + curr.file_size,
0,
) ?? 0
);
});
const currentChartTab = ref<"storage" | "queue">("storage"); const currentChartTab = ref<'storage' | 'queue'>('storage')
const currentChartData = computed(() => { const currentChartData = computed(() => {
const { storage, queue } = data.value?.chart || {}; const { storage, queue } = data.value?.chart || {}
if (currentChartTab.value === "storage") { if (currentChartTab.value === 'storage') {
return {
data: storage,
index: 'date',
categories: ['file_size', 'file_num'],
colors: ['#22d3ee', '#c084fc'],
}
}
return { return {
data: storage, data: queue,
index: "date", index: 'date',
categories: ["file_size", "file_num"], categories: ['processed', 'failed'],
colors: ["#22d3ee", "#c084fc"], colors: ['#4ade80', '#f87171'],
}; }
} })
return {
data: queue,
index: "date",
categories: ["processed", "failed"],
colors: ["#4ade80", "#f87171"],
};
});
const genUserAvatar = ({ email }: { email: string }) => { const genUserAvatar = ({ email }: { email: string }) => {
if (!email) { if (!email) {
return "/logo.png"; return '/logo.png'
} }
return `https://www.gravatar.com/avatar/${SparkMD5.hash(email)}?d=retro`; return `https://www.gravatar.com/avatar/${SparkMD5.hash(email)}?d=retro`
}; }
const handleUserClick = ({ url, email }: { url: string; email: string }) => { const handleUserClick = ({ url, email }: { url: string; email: string }) => {
if (url) { if (url) {
return navigateTo(url, { external: true }); return navigateTo(url, { external: true })
} }
if (email) { if (email) {
return navigateTo(`mailto:${email}`, { external: true }); return navigateTo(`mailto:${email}`, { external: true })
} }
return null; return null
}; }
const users = computed(() => { const users = computed(() => {
const { email, name, url } = data.value?.admin || {}; const { email, name, url } = data.value?.admin || {}
return [ return [
...(!!name ...(!!name
? [ ? [
{ {
title: t("about.admin"), title: t('about.admin'),
email, email,
name, name,
url: url ?? (email ? `mailto:${email}` : null), url: url ?? (email ? `mailto:${email}` : null),
}, },
] ]
: []), : []),
{ {
title: t("about.author"), title: t('about.author'),
name: "keven1024", name: 'keven1024',
email: "keven@fudaoyuan.icu", email: 'keven@fudaoyuan.icu',
url: "https://github.com/keven1024", url: 'https://github.com/keven1024',
}, },
]; ]
}); })
</script> </script>
<template> <template>
<div <div class="rounded-xl p-5 bg-white/50 backdrop-blur-xl w-full lg:w-200 my-5 flex flex-col gap-5">
class="rounded-xl p-5 bg-white/50 backdrop-blur-xl w-full lg:w-200 my-5 flex flex-col gap-5" <div class="text-xl font-normal">{{ t('about.title') }}</div>
> <div class="flex flex-col gap-2 items-center">
<div class="text-xl font-normal">{{ t("about.title") }}</div> <NuxtImg src="/logo.png" class="size-20 rounded-xl" />
<div class="flex flex-col gap-2 items-center"> <div class="text-xl">{{ site_title ?? '015' }}</div>
<NuxtImg src="/logo.png" class="size-20 rounded-xl" /> <div class="text-sm opacity-75 text-center px-5">
<div class="text-xl">{{ site_title ?? "015" }}</div> {{ site_desc ?? t('seo.desc') }}
<div class="text-sm opacity-75 text-center px-5">
{{ site_desc ?? t("seo.desc") }}
</div>
</div>
<div class="font-semibold">{{ t("about.systemInfo") }}</div>
<template v-if="isLoading">
<div class="flex flex-row gap-2">
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
</div>
</template>
<template v-else>
<div class="grid grid-cols-2 gap-2">
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
<div class="opacity-75 text-xs">{{ t("about.systemVersion") }}</div>
<div class="text-xl font-semibold">
{{ data?.version ?? "dev" }}
</div>
</div>
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
<div class="opacity-75 text-xs">{{ t("about.storage") }}</div>
<div class="text-right flex flex-row items-baseline">
<span class="text-lg font-semibold">{{
filesize(currentFileSize ?? 0)
}}</span>
<span class="text-md opacity-75"
>/ {{ filesize(data?.max_limit?.file_size ?? 0) }}</span
>
</div>
<div class="rounded-full w-full h-1 bg-black/10">
<div
class="rounded-full h-full bg-blue-500"
:style="{
width: `${(currentFileSize / (data?.max_limit?.file_size ?? 0)) * 100}%`,
}"
></div>
</div>
</div>
</div>
</template>
<div class="font-semibold">{{ t("about.analysis") }}</div>
<template v-if="isLoading">
<div class="flex flex-row gap-2">
<Skeleton class="w-full h-96 rounded-xl" />
</div>
</template>
<template v-else>
<div class="flex flex-col gap-2 bg-white/50 w-full rounded-xl py-5">
<div class="flex flex-row gap-2 px-5">
<div
:class="
cx(
'rounded-md min-w-30 flex flex-col px-3 py-1.5 cursor-pointer',
currentChartTab === tab.value && 'bg-black/10',
)
"
v-for="tab in chartTabs"
:key="tab.value"
@click="
() => {
currentChartTab = tab.value as 'storage' | 'queue';
}
"
>
<div class="opacity-75 text-xs">{{ tab.label }}</div>
<div class="text-lg font-semibold">{{ tab.total }}</div>
</div>
</div>
<AreaChart
v-if="currentChartData"
class="h-64 w-full"
:key="currentChartTab"
:index="currentChartData.index"
:data="currentChartData.data"
:categories="currentChartData.categories"
:show-grid-line="false"
:show-legend="false"
:show-y-axis="true"
:show-x-axis="true"
:colors="currentChartData.colors"
:custom-tooltip="AboutChartTooltip"
:curve-type="CurveType.CatmullRom"
/>
</div>
</template>
<template v-if="isLoading">
<div class="flex flex-row gap-2">
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
</div>
</template>
<template v-else>
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
<div class="flex flex-col gap-3" v-for="user in users" :key="user.name">
<div class="font-semibold">{{ user.title }}</div>
<div
class="rounded-xl bg-white/50 hover:bg-white/40 flex-1 flex flex-row items-center gap-2 p-3 cursor-pointer"
@click="
() => {
handleUserClick(user);
}
"
>
<div class="size-10 rounded-full bg-white/50">
<NuxtImg
:src="genUserAvatar(user)"
class="size-full rounded-full"
/>
</div> </div>
<div class="text-md font-semibold">{{ user.name }}</div>
</div>
</div> </div>
</div> <div class="font-semibold">{{ t('about.systemInfo') }}</div>
</template> <template v-if="isLoading">
</div> <div class="flex flex-row gap-2">
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
</div>
</template>
<template v-else>
<div class="grid grid-cols-2 gap-2">
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
<div class="opacity-75 text-xs">{{ t('about.systemVersion') }}</div>
<div class="text-xl font-semibold flex items-center gap-1">
{{ data?.version ?? 'dev' }}
<span class="text-xs px-2 py-0.5 rounded bg-primary/20 text-primary">{{ dayjs(data?.build_time * 1000).fromNow() }}</span>
</div>
</div>
<div class="rounded-xl bg-white/50 flex-1 flex flex-col p-3">
<div class="opacity-75 text-xs">{{ t('about.storage') }}</div>
<div class="text-right flex flex-row items-baseline">
<span class="text-lg font-semibold">{{ filesize(currentFileSize ?? 0) }}</span>
<span class="text-md opacity-75">/ {{ filesize(data?.max_limit?.file_size ?? 0) }}</span>
</div>
<Progress class="h-1" :model-value="(currentFileSize / (data?.max_limit?.file_size ?? 0)) * 100" />
</div>
</div>
</template>
<div class="font-semibold">{{ t('about.analysis') }}</div>
<template v-if="isLoading">
<div class="flex flex-row gap-2">
<Skeleton class="w-full h-96 rounded-xl" />
</div>
</template>
<template v-else>
<div class="flex flex-col gap-2 bg-white/50 w-full rounded-xl py-5">
<div class="flex flex-row gap-2 px-5">
<div
:class="cx('rounded-md min-w-30 flex flex-col px-3 py-1.5 cursor-pointer', currentChartTab === tab.value && 'bg-black/10')"
v-for="tab in chartTabs"
:key="tab.value"
@click="
() => {
currentChartTab = tab.value as 'storage' | 'queue'
}
"
>
<div class="opacity-75 text-xs">{{ tab.label }}</div>
<div class="text-lg font-semibold">{{ tab.total }}</div>
</div>
</div>
<AreaChart
v-if="currentChartData"
class="h-64 w-full"
:key="currentChartTab"
:index="currentChartData.index"
:data="currentChartData.data"
:categories="currentChartData.categories"
:show-grid-line="false"
:show-legend="false"
:show-y-axis="true"
:show-x-axis="true"
:colors="currentChartData.colors"
:custom-tooltip="AboutChartTooltip"
:curve-type="CurveType.CatmullRom"
/>
</div>
</template>
<template v-if="isLoading">
<div class="flex flex-row gap-2">
<Skeleton class="w-full h-20 rounded-xl" v-for="i in 2" :key="i" />
</div>
</template>
<template v-else>
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
<div class="flex flex-col gap-3" v-for="user in users" :key="user.name">
<div class="font-semibold">{{ user.title }}</div>
<div
class="rounded-xl bg-white/50 hover:bg-white/40 flex-1 flex flex-row items-center gap-2 p-3 cursor-pointer"
@click="
() => {
handleUserClick(user)
}
"
>
<div class="size-10 rounded-full bg-white/50">
<NuxtImg :src="genUserAvatar(user)" class="size-full rounded-full" />
</div>
<div class="text-md font-semibold">{{ user.name }}</div>
</div>
</div>
</div>
</template>
</div>
</template> </template>

8
pnpm-lock.yaml generated
View File

@@ -101,6 +101,9 @@ importers:
filesize: filesize:
specifier: ^10.1.6 specifier: ^10.1.6
version: 10.1.6 version: 10.1.6
js-md5:
specifier: ^0.8.3
version: 0.8.3
lodash-es: lodash-es:
specifier: ^4.17.21 specifier: ^4.17.21
version: 4.17.21 version: 4.17.21
@@ -4262,6 +4265,9 @@ packages:
resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==}
hasBin: true hasBin: true
js-md5@0.8.3:
resolution: {integrity: sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==}
js-tokens@4.0.0: js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
@@ -11284,6 +11290,8 @@ snapshots:
jiti@2.4.2: {} jiti@2.4.2: {}
js-md5@0.8.3: {}
js-tokens@4.0.0: {} js-tokens@4.0.0: {}
js-tokens@9.0.1: {} js-tokens@9.0.1: {}