feat: 大量优化和bug修复

This commit is contained in:
2026-05-23 22:23:29 +08:00
parent 92b063c4c4
commit fc71e924e7
39 changed files with 1381 additions and 302 deletions
+8 -63
View File
@@ -5,47 +5,11 @@ import { storeToRefs } from "pinia";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle
} from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import { useAnswerStore } from "@/stores/answer";
const answerStore = useAnswerStore();
const {
health,
stats,
uptimeText,
dashboardErrorMessage,
statsLoading,
cacheClearing
} = storeToRefs(answerStore);
/** 顶部指标由 store 中的健康状态和统计信息组合而来 */
const overviewItems = computed(() => [
{
label: "服务状态",
value: health.value?.status === "ok" ? "运行中" : "-",
detail: health.value?.version ? `v${health.value.version}` : "-",
loading: statsLoading.value && !health.value
},
{
label: "模型",
value: stats.value?.model || health.value?.model || "-",
detail: "AI 模型",
loading: statsLoading.value && !stats.value
},
{
label: "问答记录",
value: stats.value?.qa_records_count?.toString() ?? "0",
detail: uptimeText.value,
loading: statsLoading.value && !stats.value
}
]);
const { dashboardErrorMessage, recordsLoading, cacheClearing } =
storeToRefs(answerStore);
</script>
<template>
@@ -65,10 +29,13 @@ const overviewItems = computed(() => [
type="button"
variant="outline"
size="sm"
:disabled="statsLoading"
:disabled="recordsLoading"
@click="answerStore.loadDashboard"
>
<RefreshCw class="size-4" :class="{ 'animate-spin': statsLoading }" />
<RefreshCw
class="size-4"
:class="{ 'animate-spin': recordsLoading }"
/>
<span>刷新</span>
</Button>
<Button
@@ -87,27 +54,5 @@ const overviewItems = computed(() => [
<Alert v-if="dashboardErrorMessage" variant="destructive">
<AlertDescription>{{ dashboardErrorMessage }}</AlertDescription>
</Alert>
<div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-4">
<Card v-for="item in overviewItems" :key="item.label" size="sm">
<CardHeader>
<CardDescription>{{ item.label }}</CardDescription>
</CardHeader>
<CardContent>
<template v-if="item.loading">
<Skeleton class="mb-2 h-8 w-24" />
<Skeleton class="h-4 w-32" />
</template>
<template v-else>
<CardTitle class="truncate text-2xl font-semibold">
{{ item.value }}
</CardTitle>
<div class="mt-1 truncate text-xs text-muted-foreground">
{{ item.detail }}
</div>
</template>
</CardContent>
</Card>
</div>
</section>
</template>
</template>