bugfix: 一些bug修复

This commit is contained in:
2026-05-22 17:45:58 +08:00
parent c286db68b1
commit b02f15f735
12 changed files with 115 additions and 304 deletions
+2 -5
View File
@@ -41,7 +41,7 @@ const pageCount = computed(() => Math.ceil(props.total / props.pageSize));
@update:page="(val: number) => emits('update:page', val)"
>
<PaginationContent v-slot="{ items }">
<PaginationPrevious class="w-5.5 h-5.5 text-primary!">
<PaginationPrevious class="w-5.5 h-5.5">
<ChevronLeftIcon class="size-4" />
</PaginationPrevious>
<template v-for="(item, index) in items" :key="index">
@@ -50,9 +50,6 @@ const pageCount = computed(() => Math.ceil(props.total / props.pageSize));
:value="item.value"
:is-active="item.value === page"
class="w-fit min-w-5.5 h-5.5 text-xs px-1 text-muted-foreground"
:class="{
'text-primary! border-primary!': item.value === page
}"
>
{{ item.value }}
</PaginationItem>
@@ -69,7 +66,7 @@ const pageCount = computed(() => Math.ceil(props.total / props.pageSize));
</Button>
</PaginationEllipsis>
</template>
<PaginationNext class="w-5.5 h-5.5 text-primary!">
<PaginationNext class="w-5.5 h-5.5">
<ChevronRightIcon class="size-4" />
</PaginationNext>
</PaginationContent>
-132
View File
@@ -1,132 +0,0 @@
<!-- app/components/docs/ApiDocsContent.vue - 前端文档页内容覆盖旧 Flask /docs 页面 -->
<script lang="ts" setup>
import { Badge } from "@/components/ui/badge";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle
} from "@/components/ui/card";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow
} from "@/components/ui/table";
/** 文档示例保持本地接口字段名,避免把真实 token 或 key 写进前端 */
const searchExample = `GET /api/search?title=中国的首都是哪个城市?&type=single&options=A. 北京\\nB. 上海`;
const successExample = `{
"code": 1,
"question": "中国的首都是哪个城市?",
"answer": "A"
}`;
const endpoints = [
{
method: "GET/POST",
path: "/api/search",
auth: "可选",
description: "OCS AnswererWrapper 查询入口"
},
{
method: "GET",
path: "/api/health",
auth: "否",
description: "服务健康检查"
},
{
method: "GET",
path: "/api/stats",
auth: "可选",
description: "运行统计和缓存数量"
},
{
method: "GET",
path: "/api/records",
auth: "可选",
description: "最近问答记录"
},
{
method: "POST",
path: "/api/cache/clear",
auth: "可选",
description: "清空当前进程内缓存"
}
];
</script>
<template>
<article class="grid gap-5">
<Card>
<CardHeader>
<CardTitle class="text-xl">API 文档</CardTitle>
<CardDescription class="leading-6">
响应保持 OCS AnswererWrapper 兼容成功返回
<Badge variant="secondary">code: 1</Badge>
失败返回
<Badge variant="secondary">code: 0</Badge>
</CardDescription>
</CardHeader>
</Card>
<Card>
<CardHeader>
<CardTitle>接口列表</CardTitle>
</CardHeader>
<CardContent>
<div class="overflow-auto">
<Table class="min-w-[720px]">
<TableHeader>
<TableRow>
<TableHead>方法</TableHead>
<TableHead>路径</TableHead>
<TableHead>Token</TableHead>
<TableHead>说明</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-for="item in endpoints" :key="item.path">
<TableCell>{{ item.method }}</TableCell>
<TableCell class="font-mono text-xs text-foreground">
{{ item.path }}
</TableCell>
<TableCell>{{ item.auth }}</TableCell>
<TableCell>{{ item.description }}</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
</CardContent>
</Card>
<section class="grid gap-4 lg:grid-cols-2">
<Card>
<CardHeader>
<CardTitle>请求示例</CardTitle>
</CardHeader>
<CardContent>
<pre
class="overflow-auto rounded-2xl bg-muted p-4 text-xs leading-5 text-muted-foreground"
><code>{{ searchExample }}</code></pre>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>成功响应</CardTitle>
</CardHeader>
<CardContent>
<pre
class="overflow-auto rounded-2xl bg-muted p-4 text-xs leading-5 text-muted-foreground"
><code>{{ successExample }}</code></pre>
</CardContent>
</Card>
</section>
</article>
</template>
+20 -11
View File
@@ -1,14 +1,17 @@
<!-- app/components/layout/AppHeader.vue - 顶部导航和页面切换入口 -->
<script lang="ts" setup>
import {
Activity,
BookOpenText,
LayoutDashboard,
Search
} from "lucide-vue-next";
import { Activity, LayoutDashboard, Moon, Search, Sun } from "lucide-vue-next";
import { Button } from "@/components/ui/button";
/** 使用 VueUse 的 useColorMode 切换 dark/lightclass 会挂到 <html> 上 */
const colorMode = useColorMode();
const isDark = computed(() => colorMode.value === "dark");
function toggleColorMode() {
colorMode.value = isDark.value ? "light" : "dark";
}
/** 顶部导航项,icon 使用 lucide,和项目里 shadcn 的图标体系保持一致 */
const navItems = [
{
@@ -20,11 +23,6 @@ const navItems = [
label: "Dashboard",
to: "/dashboard",
icon: LayoutDashboard
},
{
label: "文档",
to: "/docs",
icon: BookOpenText
}
];
@@ -73,6 +71,17 @@ const isActive = (to: string) => {
<span>{{ item.label }}</span>
</NuxtLink>
</Button>
<!-- 深色/浅色主题切换按钮 -->
<Button
variant="ghost"
size="icon"
aria-label="切换主题"
@click="toggleColorMode"
>
<Sun v-if="isDark" class="size-4" />
<Moon v-else class="size-4" />
</Button>
</nav>
</div>
</header>