From f0836ec0566485d360ed8e291b54b3af395a4529 Mon Sep 17 00:00:00 2001 From: que01 Date: Sat, 19 Sep 2026 18:34:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8E=A5=E5=85=A5=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E9=A1=B5=E9=9D=A2=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/src/main.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/admin/src/main.tsx b/apps/admin/src/main.tsx index 7dbc36e..b029670 100644 --- a/apps/admin/src/main.tsx +++ b/apps/admin/src/main.tsx @@ -3,6 +3,7 @@ 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, Table, Tag, Popconfirm, Modal, Badge } from "antd"; import { ApiClient } from "@personal-brand/api-client"; +import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom"; import type { BrandProfile, PublicService, TrustContent, TrustContentInput } from "@personal-brand/api-client"; import "antd/dist/reset.css"; @@ -64,7 +65,7 @@ function InquiriesPage() { return update.mutate({ id: item.id, nextStatus: nextStatus as never })} options={bookingStatusOptions.map((value) => ({ value, label: bookingStatusLabels[value] }))} /> }]} />; } -function Dashboard({ onLogout }: { onLogout: () => void }) { const [page, setPage] = useState("brand"); return 个人品牌 setPage(key)} items={[{ key: "brand", label: "品牌信任" }, { key: "trust", label: "信任内容" }, { key: "services", label: "服务与合作" }, { key: "inquiries", label: "咨询记录" }]} />品牌管理后台{page === "brand" ? : page === "trust" ? : page === "services" ? : }; } +function Dashboard({ onLogout }: { onLogout: () => void }) { const navigate = useNavigate(); const location = useLocation(); const page = location.pathname.split("/")[2] || "brand"; const items = [{ key: "brand", label: "品牌信任" }, { key: "trust", label: "信任内容" }, { key: "services", label: "服务与合作" }, { key: "inquiries", label: "咨询记录" }]; return 个人品牌 navigate(`/admin/${key}`)} items={items} />品牌管理后台} />} />} />} />} />; } function Root() { const [loggedIn, setLoggedIn] = useState(Boolean(localStorage.getItem("adminToken"))); React.useEffect(() => { const expire = () => { message.warning("登录状态已失效,请重新登录"); setLoggedIn(false); }; window.addEventListener("admin-auth-expired", expire); return () => window.removeEventListener("admin-auth-expired", expire); }, []); const logout = () => { localStorage.removeItem("adminToken"); setLoggedIn(false); }; return loggedIn ? : setLoggedIn(true)} />; } -createRoot(document.getElementById("app")!).render(); +createRoot(document.getElementById("app")!).render();