import { Alert, App, Button, Card, Col, Row, Space } from "antd"; import { PlusOutlined } from "@ant-design/icons"; import { useQuery } from "@tanstack/react-query"; import { useNavigate } from "react-router-dom"; import { createApiClient } from "../../lib/api.js"; import { AdminPageHeader } from "../../components/AdminPageHeader.js"; import { EmptyState } from "../../components/EmptyState.js"; import { QueryState } from "../../components/QueryState.js"; import { StatusTag } from "../../components/StatusTag.js"; const client = createApiClient(); export function BrandsPage({ canCreate }: { canCreate: boolean }) { const { message } = App.useApp(); const navigate = useNavigate(); const brands = useQuery({ queryKey: ["admin-brand-memberships"], queryFn: () => client.listAdminBrands(), }); const current = useQuery({ queryKey: ["admin-shell-brand"], queryFn: () => client.getAdminBrand(), }); const switchBrand = async (brandId: string) => { try { await client.switchAdminBrand(brandId); window.location.assign("/admin/overview"); } catch (error) { message.error(error instanceof Error ? error.message : "品牌切换失败,请重试"); } }; return ( { void brands.refetch(); void current.refetch(); }} > } onClick={() => navigate("/admin/brands/new")} > 创建品牌 ) : null } /> {brands.data?.length ? ( {brands.data.map((membership) => { const isCurrent = membership.brand.id === current.data?.id; return ( } actions={[ , ]} > 小程序地址标识:{membership.brand.slug} {membership.role === "owner" ? ( 你可以在该品牌中管理页面方案、成员和发布。 ) : ( 你在该品牌中的角色是内容编辑,不能管理页面方案或成员。 )} ); })} ) : ( navigate("/admin/brands/new")}> 创建品牌 ) : undefined } /> )} ); }