feat: 添加分页功能和缓存管理,优化问答记录展示
This commit is contained in:
@@ -14,8 +14,19 @@ import {
|
||||
CardHeader,
|
||||
CardTitle
|
||||
} from "@/components/ui/card";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue
|
||||
} from "@/components/ui/select";
|
||||
import type { IQaRecord } from "@/interfaces";
|
||||
import { QUESTION_TYPE_LABELS, useAnswerStore } from "@/stores/answer";
|
||||
import {
|
||||
DASHBOARD_PAGE_SIZE_OPTIONS,
|
||||
QUESTION_TYPE_LABELS,
|
||||
useAnswerStore
|
||||
} from "@/stores/answer";
|
||||
|
||||
const answerStore = useAnswerStore();
|
||||
const {
|
||||
@@ -78,8 +89,29 @@ const displayOptions = (record: IQaRecord) => {
|
||||
<template>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>最近问答记录</CardTitle>
|
||||
<CardDescription>当前进程最多保留最近 100 条。</CardDescription>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<CardTitle>最近问答记录</CardTitle>
|
||||
<CardDescription>分页展示,按创建时间倒序</CardDescription>
|
||||
</div>
|
||||
<Select
|
||||
:model-value="String(recordsPageSize)"
|
||||
@update:model-value="(v) => answerStore.setRecordsPageSize(Number(v))"
|
||||
>
|
||||
<SelectTrigger class="w-28">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem
|
||||
v-for="size in DASHBOARD_PAGE_SIZE_OPTIONS"
|
||||
:key="size"
|
||||
:value="String(size)"
|
||||
>
|
||||
{{ size }} 条/页
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent>
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
import { RefreshCw, Trash2 } from "lucide-vue-next";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
||||
import {
|
||||
Alert,
|
||||
AlertDescription
|
||||
} from "@/components/ui/alert";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
@@ -39,13 +36,7 @@ const overviewItems = computed(() => [
|
||||
{
|
||||
label: "模型",
|
||||
value: stats.value?.model || health.value?.model || "-",
|
||||
detail: stats.value?.cache_enabled ? "缓存已启用" : "缓存未启用",
|
||||
loading: statsLoading.value && !stats.value
|
||||
},
|
||||
{
|
||||
label: "缓存数量",
|
||||
value: stats.value?.cache_size?.toString() ?? "0",
|
||||
detail: "当前进程",
|
||||
detail: "AI 模型",
|
||||
loading: statsLoading.value && !stats.value
|
||||
},
|
||||
{
|
||||
@@ -59,7 +50,9 @@ const overviewItems = computed(() => [
|
||||
|
||||
<template>
|
||||
<section class="grid gap-4">
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||
<div
|
||||
class="flex flex-col gap-3 md:flex-row md:items-center md:justify-between"
|
||||
>
|
||||
<div>
|
||||
<h1 class="text-xl font-semibold text-foreground">Dashboard</h1>
|
||||
<p class="mt-1 text-sm text-muted-foreground">
|
||||
|
||||
Reference in New Issue
Block a user