完善 2026 主题的移动端与桌面端交互体验,修复多项可访问性和信息展示问题。 - 允许浏览器缩放,补充焦点样式、按钮名称、表单标签和对话框键盘焦点管理\n- 支持 reduced-motion,扩大公共页、后台导航、记录列表和分页控件的触控区域\n- 优化系统设置分区导航、密码显示、字段语义和底部粘性保存栏\n- 压缩移动文件列表操作区,改善桌面表格滚动可达性和统计值截断\n- 优化仪表盘指标、趋势摘要、进度条语义及中英文文案
690 lines
27 KiB
Vue
690 lines
27 KiB
Vue
<template>
|
|
<div class="p-4 sm:p-6">
|
|
<div class="mb-6 flex flex-col gap-2 sm:flex-row sm:items-end sm:justify-between">
|
|
<div>
|
|
<p class="text-sm" :class="[mutedTextClass]">{{ t('admin.dashboard.adminLabel') }}</p>
|
|
<h2 class="text-2xl font-bold" :class="[primaryTextClass]">
|
|
{{ t('admin.dashboard.title') }}
|
|
</h2>
|
|
<p class="mt-1 text-xs" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.lastUpdated', { time: lastUpdatedText }) }}
|
|
</p>
|
|
</div>
|
|
<BaseButton variant="secondary" :loading="isDashboardRefreshing" @click="refreshDashboardPage">
|
|
<template #icon>
|
|
<RefreshCwIcon class="mr-2 h-4 w-4" />
|
|
</template>
|
|
{{
|
|
isDashboardRefreshing ? t('admin.dashboard.refreshing') : t('admin.dashboard.refresh')
|
|
}}
|
|
</BaseButton>
|
|
</div>
|
|
|
|
<div
|
|
v-if="errorMessage"
|
|
class="mb-6 rounded-[30px] border px-4 py-3 text-sm"
|
|
:class="[
|
|
isDarkMode
|
|
? 'border-red-900/50 bg-red-950/30 text-red-200'
|
|
: 'border-red-200 bg-red-50 text-red-700'
|
|
]"
|
|
>
|
|
{{ errorMessage }}
|
|
</div>
|
|
|
|
<div class="grid grid-cols-2 gap-3 sm:gap-4 xl:grid-cols-4">
|
|
<StatCard
|
|
:title="t('admin.dashboard.totalFiles')"
|
|
:value="dashboardData.totalFiles"
|
|
:icon="FilesIcon"
|
|
icon-color="indigo"
|
|
>
|
|
<template #description>
|
|
{{ t('admin.dashboard.yesterdayShares', { count: dashboardData.yesterdayCount }) }}
|
|
</template>
|
|
</StatCard>
|
|
|
|
<StatCard
|
|
:title="t('admin.dashboard.storageSpace')"
|
|
:value="dashboardData.storageUsedText"
|
|
:icon="HardDriveIcon"
|
|
icon-color="purple"
|
|
>
|
|
<template #description>
|
|
{{ t('admin.dashboard.todayIncrease', { count: dashboardData.todaySizeText }) }}
|
|
</template>
|
|
</StatCard>
|
|
|
|
<StatCard
|
|
:title="t('admin.dashboard.todayShares')"
|
|
:value="dashboardData.todayCount"
|
|
:icon="UploadCloudIcon"
|
|
icon-color="green"
|
|
>
|
|
<template #description>
|
|
{{ t('admin.dashboard.yesterdayShares', { count: dashboardData.yesterdayCount }) }}
|
|
</template>
|
|
</StatCard>
|
|
|
|
<StatCard
|
|
:title="t('admin.dashboard.totalRetrievals')"
|
|
:value="dashboardData.usedCount"
|
|
:icon="DownloadCloudIcon"
|
|
icon-color="blue"
|
|
>
|
|
<template #description>
|
|
{{ t('admin.dashboard.serverUptime') }} {{ dashboardData.sysUptimeText }}
|
|
</template>
|
|
</StatCard>
|
|
</div>
|
|
|
|
<div v-if="dashboardData.hasExtendedStats" class="mt-6 grid grid-cols-1 gap-6 2xl:grid-cols-3">
|
|
<section
|
|
class="theme-2026-card theme-2026-card-hover rounded-[24px] p-4 shadow-md transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg sm:rounded-[30px] sm:p-5 2xl:col-span-2"
|
|
:class="[panelClass, cardHoverClass]"
|
|
>
|
|
<div class="mb-4 flex items-center justify-between sm:mb-5">
|
|
<div>
|
|
<h3 class="text-lg font-semibold" :class="[primaryTextClass]">
|
|
{{ t('admin.dashboard.fileHealth') }}
|
|
</h3>
|
|
<p class="text-sm" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.fileHealthDesc') }}
|
|
</p>
|
|
</div>
|
|
<ActivityIcon
|
|
class="h-5 w-5"
|
|
:class="[isDarkMode ? 'text-[#b8d4dc]' : 'text-[#5f8796]']"
|
|
/>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-3 gap-2 sm:gap-4">
|
|
<MetricProgress
|
|
:label="t('admin.dashboard.activeFileRatio')"
|
|
:value="dashboardData.activeRatio"
|
|
:detail="`${dashboardData.activeCount} / ${dashboardData.totalFiles}`"
|
|
tone="green"
|
|
/>
|
|
<MetricProgress
|
|
:label="t('admin.dashboard.fileShareRatio')"
|
|
:value="dashboardData.fileRatio"
|
|
:detail="t('admin.dashboard.binaryFiles', { count: dashboardData.fileCount })"
|
|
tone="indigo"
|
|
/>
|
|
<MetricProgress
|
|
:label="t('admin.dashboard.textShareRatio')"
|
|
:value="dashboardData.textRatio"
|
|
:detail="t('admin.dashboard.textShares', { count: dashboardData.textCount })"
|
|
tone="purple"
|
|
/>
|
|
</div>
|
|
|
|
<div class="mt-4 grid grid-cols-2 gap-2 sm:mt-6 sm:gap-3 xl:grid-cols-3 2xl:grid-cols-5">
|
|
<button
|
|
v-for="action in healthActions"
|
|
:key="action.key"
|
|
type="button"
|
|
class="theme-2026-card-hover group flex min-h-20 flex-col justify-between rounded-[20px] border p-3 text-left shadow-sm transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md sm:min-h-24 sm:rounded-[30px] sm:p-4"
|
|
:class="getHealthActionClass(action.tone)"
|
|
@click="openHealthQueue(action.health)"
|
|
>
|
|
<span class="flex items-start justify-between gap-3">
|
|
<span>
|
|
<span class="block text-xl font-semibold sm:text-2xl">{{ action.count }}</span>
|
|
<span class="mt-1 block text-sm font-medium">{{ action.label }}</span>
|
|
</span>
|
|
<component :is="getHealthActionIcon(action.tone)" class="h-5 w-5 shrink-0" />
|
|
</span>
|
|
<span class="mt-2 flex items-center justify-between gap-2 text-xs sm:mt-3">
|
|
<span class="hidden line-clamp-2 sm:block">{{ action.description }}</span>
|
|
<ArrowRightIcon
|
|
class="h-4 w-4 shrink-0 transition-transform group-hover:translate-x-0.5"
|
|
/>
|
|
</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="mt-4 grid grid-cols-2 gap-2 sm:mt-6 sm:gap-4">
|
|
<div
|
|
class="theme-2026-card-hover rounded-[20px] border p-3 shadow-sm transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md sm:rounded-[30px] sm:p-4 sm:shadow-md"
|
|
:class="[subtlePanelClass, cardHoverClass]"
|
|
>
|
|
<p class="text-sm" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.expiredFiles') }}
|
|
</p>
|
|
<div class="mt-2 flex items-end justify-between">
|
|
<strong class="text-3xl" :class="[primaryTextClass]">
|
|
{{ dashboardData.expiredCount }}
|
|
</strong>
|
|
<span class="text-sm" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.needCleanup') }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
class="theme-2026-card-hover rounded-[20px] border p-3 shadow-sm transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md sm:rounded-[30px] sm:p-4 sm:shadow-md"
|
|
:class="[subtlePanelClass, cardHoverClass]"
|
|
>
|
|
<p class="text-sm" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.chunkedFiles') }}
|
|
</p>
|
|
<div class="mt-2 flex items-end justify-between">
|
|
<strong class="text-3xl" :class="[primaryTextClass]">
|
|
{{ dashboardData.chunkedCount }}
|
|
</strong>
|
|
<span class="text-sm" :class="[mutedTextClass]">
|
|
{{ dashboardData.enableChunk ? t('common.enabled') : t('common.disabled') }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section
|
|
class="theme-2026-card theme-2026-card-hover rounded-[24px] p-4 shadow-md transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg sm:rounded-[30px] sm:p-5"
|
|
:class="[panelClass, cardHoverClass]"
|
|
>
|
|
<div class="mb-5">
|
|
<h3 class="text-lg font-semibold" :class="[primaryTextClass]">
|
|
{{ t('admin.dashboard.storagePolicy') }}
|
|
</h3>
|
|
<p class="text-sm" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.storagePolicyDesc') }}
|
|
</p>
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
<PolicyRow
|
|
:label="t('admin.dashboard.storageBackend')"
|
|
:value="dashboardData.storageBackend"
|
|
/>
|
|
<PolicyRow
|
|
:label="t('admin.dashboard.singleFileLimit')"
|
|
:value="dashboardData.uploadSizeLimitText"
|
|
/>
|
|
<PolicyRow
|
|
:label="t('admin.dashboard.guestUpload')"
|
|
:value="dashboardData.openUpload ? t('common.enabled') : t('common.disabled')"
|
|
/>
|
|
<PolicyRow :label="t('admin.dashboard.maxSaveTime')" :value="maxSaveTimeText" />
|
|
</div>
|
|
|
|
<div class="mt-5">
|
|
<div class="mb-2 flex items-center justify-between text-sm">
|
|
<span :class="[mutedTextClass]">{{ t('admin.dashboard.todayCapacityReference') }}</span>
|
|
<span :class="[primaryTextClass]">{{ dashboardData.todaySizeRatio }}%</span>
|
|
</div>
|
|
<div
|
|
class="h-2 overflow-hidden rounded-full"
|
|
:class="[isDarkMode ? 'bg-gray-700' : 'bg-gray-100']"
|
|
>
|
|
<div
|
|
class="h-full rounded-full bg-[#6f98a6]"
|
|
:style="{ width: `${dashboardData.todaySizeRatio}%` }"
|
|
></div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="mt-6 grid grid-cols-1 gap-6 xl:grid-cols-2">
|
|
<section
|
|
class="theme-2026-card theme-2026-card-hover rounded-[24px] p-4 shadow-md transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg sm:rounded-[30px] sm:p-5"
|
|
:class="[panelClass, cardHoverClass]"
|
|
>
|
|
<div class="mb-5 flex flex-col gap-4">
|
|
<div class="flex min-w-0 flex-col gap-3 xl:flex-row xl:items-start xl:justify-between">
|
|
<div class="min-w-0">
|
|
<h3 class="text-lg font-semibold" :class="[primaryTextClass]">{{ t('admin.dashboard.trend.title') }}</h3>
|
|
<p class="break-words text-sm leading-5" :class="[mutedTextClass]">
|
|
{{ analyticsSummaryText }}
|
|
</p>
|
|
<p class="mt-1 text-xs sm:hidden" :class="[mutedTextClass]">{{ t('admin.dashboard.trend.mobileHint') }}</p>
|
|
</div>
|
|
<div class="flex shrink-0 flex-wrap items-center justify-end gap-2 xl:flex-nowrap">
|
|
<div class="analytics-date-range flex min-w-0 items-center justify-center gap-1.5 sm:gap-2">
|
|
<NativeDateSelect
|
|
v-model="analyticsStart"
|
|
:field-class="fieldClass"
|
|
:aria-label="t('admin.dashboard.trend.startDate')"
|
|
@change="fetchAnalyticsData"
|
|
/>
|
|
<span
|
|
class="shrink-0 text-sm font-semibold"
|
|
:class="[isDarkMode ? 'text-[#aabdc2]' : 'text-[#789096]']"
|
|
>
|
|
-
|
|
</span>
|
|
<NativeDateSelect
|
|
v-model="analyticsEnd"
|
|
:field-class="fieldClass"
|
|
:aria-label="t('admin.dashboard.trend.endDate')"
|
|
@change="fetchAnalyticsData"
|
|
/>
|
|
</div>
|
|
<div class="hidden grid-cols-3 gap-2 sm:flex sm:justify-end">
|
|
<BaseButton
|
|
variant="outline"
|
|
size="sm"
|
|
class="h-9 min-w-16"
|
|
@click="trendCanvas?.zoom(0.75)"
|
|
>
|
|
{{ t('admin.dashboard.trend.zoomIn') }}
|
|
</BaseButton>
|
|
<BaseButton
|
|
variant="outline"
|
|
size="sm"
|
|
class="h-9 min-w-16"
|
|
@click="trendCanvas?.zoom(1.33)"
|
|
>
|
|
{{ t('admin.dashboard.trend.zoomOut') }}
|
|
</BaseButton>
|
|
<BaseButton
|
|
variant="outline"
|
|
size="sm"
|
|
class="h-9 min-w-16"
|
|
@click="trendCanvas?.resetWindow()"
|
|
>
|
|
{{ t('admin.dashboard.trend.reset') }}
|
|
</BaseButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div
|
|
v-if="analyticsError"
|
|
class="mb-4 rounded-[30px] border px-4 py-3 text-sm"
|
|
:class="[
|
|
isDarkMode
|
|
? 'border-red-900/50 bg-red-950/30 text-red-200'
|
|
: 'border-red-200 bg-red-50 text-red-700'
|
|
]"
|
|
>
|
|
{{ analyticsError }}
|
|
</div>
|
|
<SmoothTrendCanvas
|
|
ref="trendCanvas"
|
|
:rows="analyticsDailyRows"
|
|
:is-dark-mode="isDarkMode"
|
|
@window-change="analyticsWindowText = $event"
|
|
/>
|
|
</section>
|
|
|
|
<section
|
|
class="theme-2026-card theme-2026-card-hover rounded-[24px] p-4 shadow-md transition-all duration-200 hover:-translate-y-0.5 hover:shadow-lg sm:rounded-[30px] sm:p-5"
|
|
:class="[panelClass, cardHoverClass]"
|
|
>
|
|
<div class="mb-5 flex items-center justify-between">
|
|
<div>
|
|
<h3 class="text-lg font-semibold" :class="[primaryTextClass]">{{ t('admin.dashboard.topDownloads.title') }}</h3>
|
|
<p class="text-sm" :class="[mutedTextClass]">{{ t('admin.dashboard.topDownloads.description') }}</p>
|
|
</div>
|
|
<DownloadCloudIcon
|
|
class="h-5 w-5"
|
|
:class="[isDarkMode ? 'text-[#b8d4dc]' : 'text-[#5f8796]']"
|
|
/>
|
|
</div>
|
|
<div class="overflow-x-auto" tabindex="0" role="region" :aria-label="t('admin.dashboard.topDownloads.title')">
|
|
<table
|
|
class="min-w-full divide-y"
|
|
:class="[isDarkMode ? 'divide-gray-700' : 'divide-gray-200']"
|
|
>
|
|
<thead>
|
|
<tr>
|
|
<th
|
|
class="px-4 py-3 text-left text-xs font-semibold uppercase"
|
|
:class="[mutedTextClass]"
|
|
>
|
|
{{ t('admin.dashboard.topDownloads.file') }}
|
|
</th>
|
|
<th
|
|
class="px-4 py-3 text-left text-xs font-semibold uppercase"
|
|
:class="[mutedTextClass]"
|
|
>
|
|
{{ t('admin.dashboard.topDownloads.downloads') }}
|
|
</th>
|
|
<th
|
|
class="px-4 py-3 text-left text-xs font-semibold uppercase"
|
|
:class="[mutedTextClass]"
|
|
>
|
|
{{ t('admin.dashboard.topDownloads.traffic') }}
|
|
</th>
|
|
<th
|
|
class="px-4 py-3 text-left text-xs font-semibold uppercase"
|
|
:class="[mutedTextClass]"
|
|
>
|
|
{{ t('admin.dashboard.topDownloads.status') }}
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y" :class="[isDarkMode ? 'divide-gray-700' : 'divide-gray-100']">
|
|
<tr v-if="analyticsTopFiles.length === 0">
|
|
<td colspan="4" class="px-4 py-8 text-center text-sm" :class="[mutedTextClass]">
|
|
{{ t('admin.dashboard.topDownloads.empty') }}
|
|
</td>
|
|
</tr>
|
|
<tr
|
|
v-for="file in analyticsTopFiles"
|
|
:key="file.code"
|
|
:class="[isDarkMode ? 'hover:bg-gray-700/60' : 'hover:bg-gray-50']"
|
|
>
|
|
<td
|
|
class="max-w-xs truncate px-4 py-3 text-sm font-medium"
|
|
:class="[primaryTextClass]"
|
|
:title="file.name"
|
|
>
|
|
{{ file.name }}
|
|
</td>
|
|
<td class="px-4 py-3 text-sm" :class="[primaryTextClass]">
|
|
{{ file.download_count || 0 }}
|
|
</td>
|
|
<td class="px-4 py-3 text-sm" :class="[primaryTextClass]">
|
|
{{ formatBytes(file.download_traffic) }}
|
|
</td>
|
|
<td class="px-4 py-3 text-sm" :class="[mutedTextClass]">
|
|
{{ file.current ? t('admin.dashboard.topDownloads.current') : t('admin.dashboard.topDownloads.history') }}
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<footer
|
|
class="mt-6 flex flex-col gap-2 border-t pt-4 text-xs sm:flex-row sm:items-center sm:justify-between"
|
|
:class="[isDarkMode ? 'border-gray-800 text-gray-500' : 'border-gray-200 text-gray-500']"
|
|
>
|
|
<span>{{ t('admin.dashboard.footerProduct') }}</span>
|
|
<span class="inline-flex items-center gap-2">
|
|
<span>{{ t('admin.dashboard.runtimeVersion') }}</span>
|
|
<span
|
|
class="rounded-[30px] border px-2.5 py-0.5 font-medium shadow-sm"
|
|
:class="[
|
|
isDarkMode
|
|
? 'border-[#40545c] bg-[#263941]/80 text-[#d8e3e5]'
|
|
: 'border-[#c8d8dc] bg-[#edf4f5] text-[#415d66]'
|
|
]"
|
|
>
|
|
{{ versionText }}
|
|
</span>
|
|
</span>
|
|
</footer>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, defineComponent, h, onMounted, ref } from 'vue'
|
|
import type { Component, PropType } from 'vue'
|
|
import { storeToRefs } from 'pinia'
|
|
import { useRouter } from 'vue-router'
|
|
import {
|
|
ActivityIcon,
|
|
AlertTriangleIcon,
|
|
ArrowRightIcon,
|
|
CheckCircleIcon,
|
|
DownloadCloudIcon,
|
|
FilesIcon,
|
|
HardDriveIcon,
|
|
RefreshCwIcon,
|
|
ShieldCheckIcon,
|
|
UploadCloudIcon
|
|
} from 'lucide-vue-next'
|
|
import StatCard from '@/components/common/StatCard.vue'
|
|
import BaseButton from '@/components/common/BaseButton.vue'
|
|
import SmoothTrendCanvas from '@/components/common/SmoothTrendCanvas.vue'
|
|
import NativeDateSelect from '@/components/common/NativeDateSelect.vue'
|
|
import { useDashboardStats, useInjectedDarkMode, useTransferAnalytics } from '@/composables'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { ROUTES } from '@/constants'
|
|
import { useConfigStore } from '@/stores/configStore'
|
|
import { formatFileSize } from '@/utils/common'
|
|
import type { AnalyticsData, AnalyticsFileRow, DashboardHealthAction } from '@/types'
|
|
|
|
const isDarkMode = useInjectedDarkMode()
|
|
const { t } = useI18n()
|
|
const router = useRouter()
|
|
const configStore = useConfigStore()
|
|
const { appVersion } = storeToRefs(configStore)
|
|
const { dashboardData, errorMessage, fetchDashboardData, isLoading, lastUpdatedText } =
|
|
useDashboardStats({
|
|
loadFailedMessage: t('admin.dashboard.loadFailed')
|
|
})
|
|
const { fetchAnalytics } = useTransferAnalytics()
|
|
|
|
const primaryTextClass = computed(() => (isDarkMode.value ? 'text-white' : 'text-gray-900'))
|
|
const mutedTextClass = computed(() => (isDarkMode.value ? 'text-gray-400' : 'text-gray-500'))
|
|
const versionText = computed(() => appVersion.value || t('admin.dashboard.versionPending'))
|
|
const panelClass = computed(() =>
|
|
isDarkMode.value
|
|
? 'bg-[#202f36]/90 border border-[#40545c]'
|
|
: 'bg-[#f8fbfb] border border-[#d7e3e5]'
|
|
)
|
|
const fieldClass = computed(() =>
|
|
isDarkMode.value
|
|
? 'border-[#50666f] bg-[#253941] text-white'
|
|
: 'border-[#c8d8dc] bg-[#fbfdfd] text-[#263f48]'
|
|
)
|
|
const subtlePanelClass = computed(() =>
|
|
isDarkMode.value
|
|
? 'border-[#3d5159] bg-[#17252c]/50'
|
|
: 'border-[#d4e0e3] bg-[linear-gradient(135deg,#f7faf9,#eaf3f4)]'
|
|
)
|
|
const cardHoverClass = computed(() =>
|
|
isDarkMode.value
|
|
? 'hover:border-[#7199a8] hover:bg-[#263941] hover:shadow-black/25'
|
|
: 'hover:border-[#8fb2bf] hover:shadow-[#a9bdc2]/70'
|
|
)
|
|
const maxSaveTimeText = computed(() => {
|
|
if (!dashboardData.maxSaveSeconds) return t('admin.dashboard.noSaveLimit')
|
|
const days = Math.floor(dashboardData.maxSaveSeconds / 86400)
|
|
if (days >= 1) return `${days}${t('common.day')}`
|
|
const hours = Math.floor(dashboardData.maxSaveSeconds / 3600)
|
|
if (hours >= 1) return `${hours}${t('common.hour')}`
|
|
return `${Math.floor(dashboardData.maxSaveSeconds / 60)}${t('common.minute')}`
|
|
})
|
|
|
|
const today = () => new Date().toISOString().slice(0, 10)
|
|
const daysAgo = (days: number) => {
|
|
const date = new Date()
|
|
date.setDate(date.getDate() - days)
|
|
return date.toISOString().slice(0, 10)
|
|
}
|
|
const trendCanvas = ref<InstanceType<typeof SmoothTrendCanvas> | null>(null)
|
|
const analyticsStart = ref(daysAgo(120))
|
|
const analyticsEnd = ref(today())
|
|
const analyticsData = ref<AnalyticsData | null>(null)
|
|
const analyticsError = ref('')
|
|
const isAnalyticsLoading = ref(false)
|
|
const analyticsWindowText = ref(t('admin.dashboard.trend.noData'))
|
|
const analyticsDailyRows = computed(() => analyticsData.value?.daily || [])
|
|
const analyticsTopFiles = computed<AnalyticsFileRow[]>(() => analyticsData.value?.topFiles || [])
|
|
const analyticsUploadTrafficText = computed(() =>
|
|
formatBytes(analyticsData.value?.totals?.uploadTraffic || 0)
|
|
)
|
|
const analyticsDownloadTrafficText = computed(() =>
|
|
formatBytes(analyticsData.value?.totals?.downloadTraffic || 0)
|
|
)
|
|
const analyticsSummaryText = computed(() =>
|
|
t('admin.dashboard.trend.summary', {
|
|
window: analyticsWindowText.value,
|
|
downloads: analyticsData.value?.totals?.totalDownloads || 0,
|
|
downloadTraffic: analyticsDownloadTrafficText.value,
|
|
uploads: analyticsData.value?.totals?.totalUploads || 0,
|
|
uploadTraffic: analyticsUploadTrafficText.value
|
|
})
|
|
)
|
|
const formatBytes = (value: number | string | undefined) => formatFileSize(Number(value || 0), 1)
|
|
|
|
const fetchAnalyticsData = async () => {
|
|
analyticsError.value = ''
|
|
isAnalyticsLoading.value = true
|
|
try {
|
|
analyticsData.value = await fetchAnalytics(analyticsStart.value, analyticsEnd.value)
|
|
} catch (error) {
|
|
analyticsError.value = error instanceof Error ? error.message : t('admin.dashboard.trend.loadFailed')
|
|
} finally {
|
|
isAnalyticsLoading.value = false
|
|
}
|
|
}
|
|
const isDashboardRefreshing = computed(() => isLoading.value || isAnalyticsLoading.value)
|
|
const refreshDashboardPage = async () => {
|
|
await Promise.all([fetchDashboardData(), fetchAnalyticsData()])
|
|
}
|
|
|
|
const healthActions = computed<DashboardHealthAction[]>(() => [
|
|
{
|
|
key: 'attention',
|
|
label: t('admin.dashboard.healthActions.attention.title'),
|
|
description: t('admin.dashboard.healthActions.attention.description'),
|
|
count: dashboardData.healthAttentionCount,
|
|
health: 'attention',
|
|
tone: dashboardData.healthAttentionCount > 0 ? 'danger' : 'success'
|
|
},
|
|
{
|
|
key: 'storageIssue',
|
|
label: t('admin.dashboard.healthActions.storageIssue.title'),
|
|
description: t('admin.dashboard.healthActions.storageIssue.description'),
|
|
count: dashboardData.storageIssueCount,
|
|
health: 'storage_issue',
|
|
tone: dashboardData.storageIssueCount > 0 ? 'danger' : 'success'
|
|
},
|
|
{
|
|
key: 'expiringSoon',
|
|
label: t('admin.dashboard.healthActions.expiringSoon.title'),
|
|
description: t('admin.dashboard.healthActions.expiringSoon.description'),
|
|
count: dashboardData.expiringSoonCount,
|
|
health: 'expiring_soon',
|
|
tone: dashboardData.expiringSoonCount > 0 ? 'warning' : 'success'
|
|
},
|
|
{
|
|
key: 'neverRetrieved',
|
|
label: t('admin.dashboard.healthActions.neverRetrieved.title'),
|
|
description: t('admin.dashboard.healthActions.neverRetrieved.description'),
|
|
count: dashboardData.neverRetrievedCount,
|
|
health: 'never_retrieved',
|
|
tone: dashboardData.neverRetrievedCount > 0 ? 'neutral' : 'success'
|
|
},
|
|
{
|
|
key: 'permanent',
|
|
label: t('admin.dashboard.healthActions.permanent.title'),
|
|
description: t('admin.dashboard.healthActions.permanent.description'),
|
|
count: dashboardData.permanentCount,
|
|
health: 'permanent',
|
|
tone: 'success'
|
|
}
|
|
])
|
|
|
|
const healthActionIconMap: Record<DashboardHealthAction['tone'], Component> = {
|
|
danger: AlertTriangleIcon,
|
|
warning: AlertTriangleIcon,
|
|
success: CheckCircleIcon,
|
|
neutral: ShieldCheckIcon
|
|
}
|
|
|
|
const getHealthActionIcon = (tone: DashboardHealthAction['tone']) => healthActionIconMap[tone]
|
|
|
|
const getHealthActionClass = (tone: DashboardHealthAction['tone']) => {
|
|
const darkClasses: Record<DashboardHealthAction['tone'], string> = {
|
|
danger: 'border-[#7c5f64]/40 bg-[#5f383f]/24 text-[#f0d8dc] hover:border-[#b1878f]',
|
|
warning: 'border-[#8b7a57]/40 bg-[#665733]/24 text-[#efe3c6] hover:border-[#b8a775]',
|
|
success: 'border-[#58766d]/40 bg-[#31564f]/24 text-[#d2e7df] hover:border-[#7fa69a]',
|
|
neutral: 'border-[#40545c] bg-[#17252c]/50 text-[#d8e3e5] hover:border-[#7199a8]'
|
|
}
|
|
const lightClasses: Record<DashboardHealthAction['tone'], string> = {
|
|
danger: 'border-[#ead8dc] bg-[#f7ecee] text-[#8b5962] hover:border-[#d8b8bf]',
|
|
warning: 'border-[#e8dfc9] bg-[#f4efdf] text-[#806f44] hover:border-[#d4c28e]',
|
|
success: 'border-[#d6e5de] bg-[#edf5f1] text-[#4f746a] hover:border-[#aecfc3]',
|
|
neutral: 'border-[#d4e0e3] bg-[#f5faf9] text-[#496670] hover:border-[#9fbdc6]'
|
|
}
|
|
|
|
return isDarkMode.value ? darkClasses[tone] : lightClasses[tone]
|
|
}
|
|
|
|
const openHealthQueue = (health: DashboardHealthAction['health']) => {
|
|
void router.push({
|
|
path: ROUTES.FILE_MANAGE,
|
|
query: { health }
|
|
})
|
|
}
|
|
|
|
const MetricProgress = defineComponent({
|
|
name: 'MetricProgress',
|
|
props: {
|
|
label: { type: String, required: true },
|
|
value: { type: Number, required: true },
|
|
detail: { type: String, required: true },
|
|
tone: {
|
|
type: String as PropType<'green' | 'indigo' | 'purple'>,
|
|
required: true
|
|
}
|
|
},
|
|
setup(props) {
|
|
const toneClass = computed(() => {
|
|
const classes = {
|
|
green: 'bg-[#6f9688]',
|
|
indigo: 'bg-[#5f8796]',
|
|
purple: 'bg-[#8c8294]'
|
|
}
|
|
return classes[props.tone]
|
|
})
|
|
|
|
return () =>
|
|
h(
|
|
'div',
|
|
{
|
|
class:
|
|
'theme-2026-card-hover rounded-[18px] border border-[#d4e0e3] bg-[#f6faf9] p-2.5 shadow-sm transition-all duration-200 hover:-translate-y-0.5 hover:border-[#8fb2bf] hover:shadow-md sm:rounded-[30px] sm:p-4 sm:shadow-md dark:border-[#40545c] dark:bg-[#17252c]/50 dark:hover:border-[#7199a8] dark:hover:bg-[#263941] dark:hover:shadow-black/25'
|
|
},
|
|
[
|
|
h('div', { class: 'mb-2 flex flex-col gap-0.5 text-xs sm:flex-row sm:items-center sm:justify-between sm:text-sm' }, [
|
|
h('span', { class: 'line-clamp-1 text-gray-500 dark:text-gray-400' }, props.label),
|
|
h('span', { class: 'font-medium tabular-nums text-gray-900 dark:text-white' }, `${props.value}%`)
|
|
]),
|
|
h('div', {
|
|
class: 'h-2 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700',
|
|
role: 'progressbar',
|
|
'aria-label': props.label,
|
|
'aria-valuemin': 0,
|
|
'aria-valuemax': 100,
|
|
'aria-valuenow': props.value
|
|
}, [
|
|
h('div', {
|
|
class: ['h-full rounded-full', toneClass.value],
|
|
style: { width: `${Math.max(0, Math.min(100, props.value))}%` }
|
|
})
|
|
]),
|
|
h('p', { class: 'mt-2 hidden text-sm text-gray-500 sm:block dark:text-gray-400' }, props.detail)
|
|
]
|
|
)
|
|
}
|
|
})
|
|
|
|
const PolicyRow = defineComponent({
|
|
name: 'PolicyRow',
|
|
props: {
|
|
label: { type: String, required: true },
|
|
value: { type: String, required: true }
|
|
},
|
|
setup(props) {
|
|
return () =>
|
|
h(
|
|
'div',
|
|
{
|
|
class:
|
|
'flex items-center justify-between gap-4 border-b border-gray-200/60 pb-3 last:border-b-0 dark:border-gray-700'
|
|
},
|
|
[
|
|
h('span', { class: 'text-sm text-gray-500 dark:text-gray-400' }, props.label),
|
|
h('span', { class: 'min-w-0 break-words text-right text-sm font-medium text-gray-900 dark:text-white' }, props.value)
|
|
]
|
|
)
|
|
}
|
|
})
|
|
|
|
onMounted(() => {
|
|
void refreshDashboardPage()
|
|
})
|
|
</script>
|