From ad70eef8eb9ffd515cae00262bb0862d27f9ee90 Mon Sep 17 00:00:00 2001 From: que01 Date: Sat, 19 Sep 2026 17:50:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8E=A5=E5=85=A5=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E4=BF=A1=E4=BB=BB=E5=86=85=E5=AE=B9=E7=AE=A1=E7=90=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/src/main.tsx | 15 ++++++++++++--- packages/api-client/src/index.ts | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/admin/src/main.tsx b/apps/admin/src/main.tsx index eb990f1..935dca3 100644 --- a/apps/admin/src/main.tsx +++ b/apps/admin/src/main.tsx @@ -1,9 +1,9 @@ import React, { useState } from "react"; import { createRoot } from "react-dom/client"; import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { App, Button, Card, Form, Input, Layout, Menu, Select, Space, Typography, message } from "antd"; +import { App, Button, Card, Form, Input, Layout, Menu, Select, Space, Typography, message, Table, Tag, Popconfirm, Modal } from "antd"; import { ApiClient } from "@personal-brand/api-client"; -import type { BrandProfile } from "@personal-brand/api-client"; +import type { BrandProfile, TrustContent, TrustContentInput } from "@personal-brand/api-client"; import "antd/dist/reset.css"; const apiBaseUrl = "http://localhost:3001"; @@ -26,7 +26,16 @@ function BrandPage() { return
save.mutate(values)}>
; } -function Dashboard() { const [page, setPage] = useState("brand"); return 个人品牌 setPage(key)} items={[{ key: "brand", label: "品牌信任" }, { key: "trust", label: "信任内容" }, { key: "services", label: "服务与合作" }, { key: "inquiries", label: "咨询记录" }]} />品牌管理后台{page === "brand" ? : 该模块正在接入通用配置接口。}; } +function TrustContentPage() { + const client = api(); const queryClientHook = useQueryClient(); const [editing, setEditing] = useState(null); const [modalOpen, setModalOpen] = useState(false); const [form] = Form.useForm(); + const query = useQuery({ queryKey: ["trust-content"], queryFn: () => client.listAdminTrustContent() }); + const save = useMutation({ mutationFn: (values: TrustContentInput) => editing ? client.updateAdminTrustContent(editing.id, values) : client.createAdminTrustContent(values), onSuccess: () => { message.success("信任内容已保存"); setEditing(null); form.resetFields(); void queryClientHook.invalidateQueries({ queryKey: ["trust-content"] }); } }); + const remove = useMutation({ mutationFn: (id: string) => client.deleteAdminTrustContent(id), onSuccess: () => { message.success("内容已删除"); void queryClientHook.invalidateQueries({ queryKey: ["trust-content"] }); } }); + function open(item?: TrustContent) { setEditing(item ?? null); setModalOpen(true); form.setFieldsValue(item ? { type: item.type, title: item.title, summary: item.summary ?? undefined, content: item.content, sortOrder: item.sortOrder, isPublished: item.isPublished } : { type: "profile", isPublished: true }); } + return open()}>新增内容}>{value} }, { title: "标题", dataIndex: "title" }, { title: "状态", dataIndex: "isPublished", render: (value) => value ? "已发布" : "草稿" }, { title: "操作", render: (_: unknown, item: TrustContent) => remove.mutate(item.id)}> }]} /> { setModalOpen(false); setEditing(null); form.resetFields(); }} onOk={() => form.submit()} confirmLoading={save.isPending}>
{ save.mutate(values); setModalOpen(false); }}>