feat: 重做管理后台的导航、表单和登录页

This commit is contained in:
Nixevol
2026-10-19 16:47:19 +08:00
parent 8beacfb931
commit 9c33ba1431
29 changed files with 794 additions and 321 deletions
+42 -24
View File
@@ -1,17 +1,20 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { NDescriptions, NDescriptionsItem, NSpin } from "naive-ui";
import { computed, onMounted, ref } from "vue";
import { NCard, NGrid, NGridItem, NSpin, NStatistic } from "naive-ui";
import PageHeader from "@/components/PageHeader.vue";
import HelpTip from "@/components/HelpTip.vue";
import LoadFailed from "@/components/LoadFailed.vue";
import DailyChart from "@/components/DailyChart.vue";
import { fetchOverview, type Overview } from "@/api/admin";
import { formatLocalMs } from "@/utils/time";
import { formatUptime } from "@/utils/labels";
import { useAppTheme } from "@/theme";
const { isDark } = useAppTheme();
const loading = ref(true);
const loadError = ref("");
const data = ref<Overview | null>(null);
const daily = computed(() => data.value?.messages_daily ?? []);
async function load() {
loading.value = true;
loadError.value = "";
@@ -31,27 +34,39 @@ onMounted(() => {
<template>
<div class="page">
<PageHeader title="概览" help="汇总当前实例的端、群与未完成投递数量,不含正文与编号明细。" />
<div class="page-body">
<PageHeader title="概览" />
<div class="page-body overview-body">
<n-spin :show="loading">
<LoadFailed v-if="loadError && !data" :description="loadError" @retry="load" />
<n-descriptions v-else-if="data" label-placement="left" :column="2" bordered size="small">
<n-descriptions-item label="版本">{{ data.version }}</n-descriptions-item>
<n-descriptions-item>
<template #label>
运行时长
<HelpTip>自进程启动起的毫秒数,按本地时区换算展示起点附近时间差。</HelpTip>
</template>
{{ formatUptime(data.uptime_ms) }}(约 {{ formatLocalMs(Date.now() - data.uptime_ms) }} 起)
</n-descriptions-item>
<n-descriptions-item label="端总数">{{ data.endpoints_total }}</n-descriptions-item>
<n-descriptions-item label="其中自助注册">{{ data.endpoints_self }}</n-descriptions-item>
<n-descriptions-item label="在线端">{{ data.endpoints_online }}</n-descriptions-item>
<n-descriptions-item label="已停用">{{ data.endpoints_disabled }}</n-descriptions-item>
<n-descriptions-item label="群数量">{{ data.groups_total }}</n-descriptions-item>
<n-descriptions-item label="待完成投递">{{ data.messages_pending }}</n-descriptions-item>
<n-descriptions-item label="定时中">{{ data.messages_scheduled }}</n-descriptions-item>
</n-descriptions>
<template v-else-if="data">
<n-grid :cols="4" :x-gap="12" :y-gap="12" responsive="screen" item-responsive>
<n-grid-item span="4 m:2 l:1">
<n-card size="small">
<n-statistic label="在线设备" :value="data.endpoints_online">
<template #suffix>/ {{ data.endpoints_total }}</template>
</n-statistic>
</n-card>
</n-grid-item>
<n-grid-item span="4 m:2 l:1">
<n-card size="small">
<n-statistic label="群组" :value="data.groups_total" />
</n-card>
</n-grid-item>
<n-grid-item span="4 m:2 l:1">
<n-card size="small">
<n-statistic label="待送达" :value="data.messages_pending" />
</n-card>
</n-grid-item>
<n-grid-item span="4 m:2 l:1">
<n-card size="small">
<n-statistic label="已运行" :value="formatUptime(data.uptime_ms)" />
</n-card>
</n-grid-item>
</n-grid>
<n-card title="近两周消息量" size="small" class="chart-card">
<DailyChart :points="daily" :dark="isDark" />
</n-card>
</template>
</n-spin>
</div>
</div>
@@ -64,9 +79,12 @@ onMounted(() => {
height: 100%;
min-height: 0;
}
.page-body {
.overview-body {
flex: 1;
overflow: auto;
padding: 16px;
}
.chart-card {
margin-top: 12px;
}
</style>