From 0d78754366be95c14881d0343816201ab6481339 Mon Sep 17 00:00:00 2001 From: engigu Date: Tue, 13 Jan 2026 20:17:00 +0800 Subject: [PATCH] fix: url prefix page redirect --- configs/config.example.ini | 5 ++++ web/src/views/dashboard/Dashboard.vue | 41 +++++++++++++++++++++++++-- web/vite.config.ts | 16 +++++++++-- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/configs/config.example.ini b/configs/config.example.ini index a81e66e..6993c7f 100644 --- a/configs/config.example.ini +++ b/configs/config.example.ini @@ -13,3 +13,8 @@ user = root password = dbname = ql_panel table_prefix = baihu_ + + +[security] +secret = baihu_secret_key_change_me + diff --git a/web/src/views/dashboard/Dashboard.vue b/web/src/views/dashboard/Dashboard.vue index 7c42515..666c746 100644 --- a/web/src/views/dashboard/Dashboard.vue +++ b/web/src/views/dashboard/Dashboard.vue @@ -8,6 +8,7 @@ import ApexCharts from 'apexcharts' const router = useRouter() const stats = ref({ tasks: 0, today_execs: 0, envs: 0, logs: 0, scheduled: 0, running: 0 }) +const displayStats = ref({ tasks: 0, today_execs: 0, envs: 0, logs: 0, scheduled: 0, running: 0 }) const sendStats = ref([]) const taskStats = ref([]) const chartsLoaded = ref(false) @@ -31,6 +32,42 @@ const statItems = [ const isDark = ref(document.documentElement.classList.contains('dark')) +// 数字滚动动画 +function animateNumber(key: keyof Stats, target: number) { + const start = displayStats.value[key] + const duration = 800 // 动画持续时间 + const startTime = performance.now() + + function update(currentTime: number) { + const elapsed = currentTime - startTime + const progress = Math.min(elapsed / duration, 1) + + // 使用 easeOutCubic 缓动函数 + const easeProgress = 1 - Math.pow(1 - progress, 3) + + displayStats.value[key] = Math.round(start + (target - start) * easeProgress) + + if (progress < 1) { + requestAnimationFrame(update) + } else { + displayStats.value[key] = target + } + } + + requestAnimationFrame(update) +} + +// 更新统计数据并触发动画 +function updateStats(newStats: Stats) { + Object.keys(newStats).forEach((key) => { + const statKey = key as keyof Stats + if (newStats[statKey] !== stats.value[statKey]) { + animateNumber(statKey, newStats[statKey]) + } + }) + stats.value = newStats +} + function getTextColor() { return isDark.value ? '#94a3b8' : '#64748b' } @@ -364,7 +401,7 @@ onMounted(async () => { api.dashboard.sendStats(chartDays.value), api.dashboard.taskStats(chartDays.value) ]) - stats.value = statsData + updateStats(statsData) sendStats.value = sendStatsData taskStats.value = taskStatsData @@ -416,7 +453,7 @@ onUnmounted(() => { -
{{ stats[item.key as keyof Stats] }}
+
{{ displayStats[item.key as keyof Stats] }}
diff --git a/web/vite.config.ts b/web/vite.config.ts index 02c5ed7..1222e6f 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -19,6 +19,18 @@ export default defineConfig({ } } }, - // 支持通过环境变量设置 base URL(开发时测试用) - base: process.env.VITE_BASE_URL || '/' + build: { + // 使用相对路径,这样可以部署在任何路径下 + // 资源引用会使用 ./assets/ 而不是 /assets/ + rollupOptions: { + output: { + // 确保资源使用相对路径 + assetFileNames: 'assets/[name]-[hash][extname]', + chunkFileNames: 'assets/[name]-[hash].js', + entryFileNames: 'assets/[name]-[hash].js' + } + } + }, + // 使用相对路径作为 base,这样资源会相对于 HTML 文件加载 + base: './' })