diff --git a/src/components/question/QuestionForm.tsx b/src/components/question/QuestionForm.tsx index b7e0f4c..c8d4370 100644 --- a/src/components/question/QuestionForm.tsx +++ b/src/components/question/QuestionForm.tsx @@ -83,7 +83,7 @@ export function QuestionForm({ question }: QuestionFormProps) { }) useEffect(() => { - fetchCategories({ limit: 100 }).then((res) => setCategories(res.data)) + fetchCategories({}).then((res) => setCategories(res.data)) }, []) async function onSubmit(data: FormValues) { diff --git a/src/lib/api-client.ts b/src/lib/api-client.ts index 69b8344..55e74bb 100644 --- a/src/lib/api-client.ts +++ b/src/lib/api-client.ts @@ -4,7 +4,7 @@ import { getStoredToken, removeStoredToken } from "./auth" export const apiClient = ky.create({ baseUrl: API_BASE_URL, - prefix: "/admin", + prefix: "/v1/admin", hooks: { beforeRequest: [ ({ request }) => { diff --git a/src/lib/api/category-api.ts b/src/lib/api/category-api.ts index 94acd06..b3c0ce6 100644 --- a/src/lib/api/category-api.ts +++ b/src/lib/api/category-api.ts @@ -1,12 +1,10 @@ import { apiClient } from "@/lib/api-client" -import type { PaginatedResponse, ApiResponse } from "@/types/api" -import type { Category, CategoryFormData, CategoryStatus } from "@/types/category" +import type { ApiResponse, PaginatedResponse } from "@/types/api" +import type { Category, CategoryFormData } from "@/types/category" export interface FetchCategoriesParams { page?: number limit?: number - search?: string - status?: CategoryStatus } export async function fetchCategories( @@ -15,8 +13,6 @@ export async function fetchCategories( const searchParams = new URLSearchParams() if (params.page) searchParams.set("page", String(params.page)) if (params.limit) searchParams.set("limit", String(params.limit)) - if (params.search) searchParams.set("search", params.search) - if (params.status) searchParams.set("status", params.status) return apiClient .get("categories", { searchParams }) diff --git a/src/lib/api/knowledge-card-api.ts b/src/lib/api/knowledge-card-api.ts index 47f30d4..17e202f 100644 --- a/src/lib/api/knowledge-card-api.ts +++ b/src/lib/api/knowledge-card-api.ts @@ -6,8 +6,8 @@ export interface KnowledgeCardItem { questionId: string questionStem: string categoryId: string - basic: string - deep?: string + summary: string + deepDive?: string sourceRef?: string updatedAt: string } @@ -34,8 +34,8 @@ export async function fetchKnowledgeCards( } export interface UpdateKnowledgeCardData { - basic: string - deep?: string + summary: string + deepDive?: string sourceRef?: string } diff --git a/src/routes/categories/index.tsx b/src/routes/categories/index.tsx index 5edb158..cafbfdd 100644 --- a/src/routes/categories/index.tsx +++ b/src/routes/categories/index.tsx @@ -4,16 +4,8 @@ import { getCoreRowModel, flexRender, } from "@tanstack/react-table" -import { Plus, Search } from "lucide-react" +import { Plus } from "lucide-react" import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select" import { Table, TableBody, @@ -31,8 +23,7 @@ import { updateCategory, deleteCategory, } from "@/lib/api/category-api" -import { CATEGORY_STATUS_LABELS } from "@/lib/constants" -import type { Category, CategoryFormData, CategoryStatus } from "@/types/category" +import type { Category, CategoryFormData } from "@/types/category" const PAGE_SIZE = 20 @@ -41,8 +32,6 @@ export default function CategoriesPage() { const [loading, setLoading] = useState(true) const [total, setTotal] = useState(0) const [page, setPage] = useState(1) - const [search, setSearch] = useState("") - const [statusFilter, setStatusFilter] = useState("all") // 对话框状态 const [formOpen, setFormOpen] = useState(false) @@ -58,17 +47,16 @@ export default function CategoriesPage() { const res = await fetchCategories({ page, limit: PAGE_SIZE, - search: search || undefined, - status: statusFilter !== "all" ? statusFilter : undefined, }) setCategories(res.data) setTotal(res.pagination.total) } catch { setCategories([]) + setTotal(0) } finally { setLoading(false) } - }, [page, search, statusFilter]) + }, [page]) useEffect(() => { loadCategories() @@ -133,41 +121,6 @@ export default function CategoriesPage() { - {/* 筛选栏 */} -
-
- - { - setSearch(e.target.value) - setPage(1) - }} - /> -
- -
- {/* 表格 */}
diff --git a/src/routes/knowledge-cards/index.tsx b/src/routes/knowledge-cards/index.tsx index eef18c8..dd59d8c 100644 --- a/src/routes/knowledge-cards/index.tsx +++ b/src/routes/knowledge-cards/index.tsx @@ -45,7 +45,7 @@ const DEEP_MAX = 300 type CardStatus = "all" | "complete" | "incomplete" function getCardStatus(item: KnowledgeCardItem): "complete" | "incomplete" { - return item.basic && item.basic.trim().length > 0 ? "complete" : "incomplete" + return item.summary && item.summary.trim().length > 0 ? "complete" : "incomplete" } export default function KnowledgeCardsPage() { @@ -58,7 +58,7 @@ export default function KnowledgeCardsPage() { // 编辑对话框 const [editOpen, setEditOpen] = useState(false) const [editingCard, setEditingCard] = useState(null) - const [editForm, setEditForm] = useState({ basic: "", deep: "", sourceRef: "" }) + const [editForm, setEditForm] = useState({ summary: "", deepDive: "", sourceRef: "" }) const [submitting, setSubmitting] = useState(false) // 详情对话框 @@ -66,7 +66,7 @@ export default function KnowledgeCardsPage() { const [detailCard, setDetailCard] = useState(null) useEffect(() => { - fetchCategories({ limit: 100 }).then((res) => setCategories(res.data)) + fetchCategories({}).then((res) => setCategories(res.data)) }, []) const loadCards = useCallback(async () => { @@ -95,8 +95,8 @@ export default function KnowledgeCardsPage() { function openEdit(card: KnowledgeCardItem) { setEditingCard(card) setEditForm({ - basic: card.basic, - deep: card.deep || "", + summary: card.summary, + deepDive: card.deepDive || "", sourceRef: card.sourceRef || "", }) setEditOpen(true) @@ -145,10 +145,10 @@ export default function KnowledgeCardsPage() { id: "basicStatus", header: "基础卡", cell: ({ row }) => { - const hasBasic = row.original.basic?.trim().length > 0 + const hasBasic = row.original.summary?.trim().length > 0 return ( - {hasBasic ? `${row.original.basic.length} 字` : "未填写"} + {hasBasic ? `${row.original.summary.length} 字` : "未填写"} ) }, @@ -157,10 +157,10 @@ export default function KnowledgeCardsPage() { id: "deepStatus", header: "深度卡", cell: ({ row }) => { - const hasDeep = (row.original.deep?.trim().length ?? 0) > 0 + const hasDeep = (row.original.deepDive?.trim().length ?? 0) > 0 return ( - {hasDeep ? `${row.original.deep!.length} 字` : "未填写"} + {hasDeep ? `${row.original.deepDive!.length} 字` : "未填写"} ) }, @@ -312,17 +312,17 @@ export default function KnowledgeCardsPage() { 所有用户

- {detailCard.basic || 未填写} + {detailCard.summary || 未填写}

- {detailCard.deep && ( + {detailCard.deepDive && (
Pro 用户

- {detailCard.deep} + {detailCard.deepDive}

)} @@ -364,14 +364,14 @@ export default function KnowledgeCardsPage() {
- BASIC_MAX ? "text-destructive font-medium" : "text-muted-foreground"}`}> - {editForm.basic.length}/{BASIC_MAX} + BASIC_MAX ? "text-destructive font-medium" : "text-muted-foreground"}`}> + {editForm.summary.length}/{BASIC_MAX}