feat: 收口多品牌与模板构建基础

This commit is contained in:
que01 committed 2026-09-25 02:55:46 +08:00
1 parent 0425a1c672
commit 77224ea51f
317 files changed
+11290 -1158

No files matched your search

@@ -0,0 +1,33 @@
import { Image, Input, Space, Typography } from "antd";
interface ImageUrlFieldProps {
value?: string;
onChange?: (value: string) => void;
placeholder?: string;
}
export function ImageUrlField({ value, onChange, placeholder }: ImageUrlFieldProps) {
const imageUrl = typeof value === "string" ? value.trim() : "";
return (
<Space direction="vertical" size={8} style={{ width: "100%" }}>
<Input
value={value}
onChange={(event) => onChange?.(event.target.value)}
placeholder={placeholder ?? "粘贴图片地址"}
/>
{imageUrl ? (
<Space align="start">
<Image
src={imageUrl}
width={96}
height={64}
preview
fallback="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="
style={{ objectFit: "cover", borderRadius: 8, background: "#f5f5f5" }}
/>
<Typography.Text type="secondary">预览图</Typography.Text>
</Space>
) : null}
</Space>
);
}
+57 -4
View File
@@ -3,7 +3,13 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { BrandProfile } from "@personal-brand/api-client";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { ImageUrlField } from "../../components/ImageUrlField.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
import { PresentationEditor } from "./PresentationEditor.js";
function textValue(value: unknown): string {
return typeof value === "string" ? value : "";
}
export function BrandPage() {
const client = createApiClient();
@@ -15,6 +21,10 @@ export function BrandPage() {
queryFn: () => client.getPublicTemplate(brand.data!.templateKey),
enabled: Boolean(brand.data?.templateKey),
});
const runtime = useQuery({
queryKey: ["public-runtime-workspace"],
queryFn: () => client.getPublicWorkspace(),
});
const save = useMutation({
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
onSuccess: () => {
@@ -115,13 +125,17 @@ export function BrandPage() {
</Form.Item>
<Row gutter={16}>
<Col xs={24} md={12}>
<Form.Item name="avatarUrl" label="头像 URL">
<Input />
<Form.Item
name="avatarUrl"
label="头像图片地址"
help="粘贴一张可公开访问的图片地址。"
>
<ImageUrlField />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name="coverUrl" label="品牌封面 URL">
<Input />
<Form.Item name="coverUrl" label="品牌封面图片地址" help="建议使用横向图片。">
<ImageUrlField />
</Form.Item>
</Col>
</Row>
@@ -133,6 +147,45 @@ export function BrandPage() {
</Button>
</Space>
</Form>
<PresentationEditor
initialValue={{
identity: {
founder: textValue(brand.data.config?.founder),
title: textValue(brand.data.config?.title),
slogan: textValue(brand.data.config?.slogan),
phone: textValue(brand.data.config?.phone),
wechat: textValue(brand.data.config?.wechat),
studioAddress: textValue(brand.data.config?.studioAddress),
},
...((brand.data.config?.visualPresentation as {
home?: Record<string, string>;
offerings?: Record<string, string>;
detail?: Record<string, string>;
profile?: Record<string, string>;
inquiry?: Record<string, string>;
success?: Record<string, string>;
records?: Record<string, string>;
}) ?? {}),
}}
runtimeValue={
runtime.data?.brand
? {
identity: {
founder: textValue(runtime.data.brand.config?.founder),
title: textValue(runtime.data.brand.config?.title),
slogan: textValue(runtime.data.brand.config?.slogan),
},
...((runtime.data.brand.config?.visualPresentation as {
home?: Record<string, string>;
inquiry?: Record<string, string>;
profile?: Record<string, string>;
}) ?? {}),
}
: undefined
}
runtimeLoading={runtime.isLoading}
runtimeError={runtime.error}
/>
</Col>
<Col xs={24} xl={9}>
<Card title="公开表达预览" style={{ position: "sticky", top: 24 }}>
@@ -0,0 +1,189 @@
import { Alert, Button, Card, Col, Form, Input, Row, Space, Typography, message } from "antd";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect } from "react";
import { createApiClient } from "../../lib/api.js";
import { MutationError } from "../../components/QueryState.js";
interface PresentationEditorProps {
initialValue: PresentationFormValues;
runtimeValue?: PresentationFormValues | undefined;
runtimeLoading?: boolean | undefined;
runtimeError?: unknown;
}
type PresentationFormValues = {
identity?: Record<string, string>;
home?: Record<string, string>;
offerings?: Record<string, string>;
detail?: Record<string, string>;
profile?: Record<string, string>;
inquiry?: Record<string, string>;
success?: Record<string, string>;
records?: Record<string, string>;
};
export function PresentationEditor({
initialValue,
runtimeValue,
runtimeLoading,
runtimeError,
}: PresentationEditorProps) {
const [form] = Form.useForm<PresentationFormValues>();
const queryClient = useQueryClient();
const save = useMutation({
mutationFn: (values: PresentationFormValues) =>
createApiClient().updateAdminBrandPresentation(values),
onSuccess: () => {
message.success("页面表达已保存,小程序将使用最新内容");
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
void queryClient.invalidateQueries({ queryKey: ["public-runtime-workspace"] });
},
});
useEffect(() => {
form.setFieldsValue(initialValue);
}, [form, initialValue]);
return (
<Card
title="小程序页面表达"
style={{ marginTop: 24 }}
extra={<Typography.Text type="secondary">普通用户配置</Typography.Text>}
>
<Typography.Paragraph type="secondary">
这里的内容会显示在小程序中。只填写你希望访客看到的话,不需要理解模板或技术配置。
</Typography.Paragraph>
{runtimeLoading ? <Alert type="info" showIcon message="正在读取小程序当前内容" /> : null}
{runtimeError ? (
<Alert type="warning" showIcon message="小程序当前内容暂时无法读取,保存后可重新加载。" />
) : runtimeValue ? (
<Card size="small" title="小程序当前已生效内容" style={{ marginBottom: 16 }}>
<Typography.Text strong>
{runtimeValue.identity?.founder || "尚未设置主理人 / 老板姓名"}
</Typography.Text>
{runtimeValue.identity?.title ? (
<Typography.Text type="secondary"> · {runtimeValue.identity.title}</Typography.Text>
) : null}
<Typography.Paragraph strong>
{runtimeValue.home?.proofTitle || "尚未设置信任介绍标题"}
</Typography.Paragraph>
<Typography.Paragraph type="secondary">
{runtimeValue.inquiry?.subtitle || "尚未设置咨询说明"}
</Typography.Paragraph>
<Typography.Text type="secondary">
咨询按钮:{runtimeValue.inquiry?.submitLabel || "未设置"} · 记录入口:
{runtimeValue.profile?.recordsTitle || "未设置"}
</Typography.Text>
</Card>
) : null}
<Form
form={form}
layout="vertical"
initialValues={initialValue}
onFinish={(values) => save.mutate(values)}
>
<Card size="small" title="主理人信息" style={{ marginBottom: 16 }}>
<Typography.Paragraph type="secondary">
访客需要先知道是谁在提供服务。这里填写主理人或老板的公开信息。
</Typography.Paragraph>
<Row gutter={16}>
<Col xs={24} md={12}>
<Form.Item name={["identity", "founder"]} label="主理人 / 老板姓名">
<Input placeholder="例如:林然" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["identity", "title"]} label="身份或职位">
<Input placeholder="例如:品牌顾问 / 工作室主理人" />
</Form.Item>
</Col>
<Col xs={24}>
<Form.Item name={["identity", "slogan"]} label="主理人希望传达的一句话">
<Input placeholder="例如:认真做好每一次定制" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["identity", "phone"]} label="公开联系电话">
<Input placeholder="选填" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["identity", "wechat"]} label="公开微信号">
<Input placeholder="选填" />
</Form.Item>
</Col>
<Col xs={24}>
<Form.Item name={["identity", "studioAddress"]} label="工作地点或服务范围">
<Input placeholder="例如:杭州及周边地区 / 某某工作室" />
</Form.Item>
</Col>
</Row>
</Card>
<Card size="small" title="首页" style={{ marginBottom: 16 }}>
<Row gutter={16}>
<Col xs={24} md={12}>
<Form.Item name={["home", "founderBadge"]} label="主理人标签">
<Input placeholder="例如:亲自主理 / 10 年经验" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["home", "proofTitle"]} label="信任介绍标题">
<Input placeholder="例如:用经历和作品建立信任" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["home", "worksTitle"]} label="作品区域标题">
<Input placeholder="例如:精选作品" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["home", "flowTitle"]} label="合作流程标题">
<Input placeholder="例如:从沟通到交付" />
</Form.Item>
</Col>
</Row>
</Card>
<Card size="small" title="咨询页面" style={{ marginBottom: 16 }}>
<Form.Item name={["inquiry", "title"]} label="页面标题">
<Input placeholder="例如:告诉我你的需求" />
</Form.Item>
<Form.Item name={["inquiry", "subtitle"]} label="说明文字">
<Input.TextArea
rows={2}
showCount
maxLength={120}
placeholder="告诉访客提交后会发生什么。"
/>
</Form.Item>
<Form.Item name={["inquiry", "submitLabel"]} label="提交按钮文字">
<Input placeholder="例如:提交咨询" />
</Form.Item>
</Card>
<Card size="small" title="主理人与我" style={{ marginBottom: 16 }}>
<Row gutter={16}>
<Col xs={24} md={12}>
<Form.Item name={["profile", "recordsTitle"]} label="咨询记录入口标题">
<Input placeholder="例如:我的咨询记录" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["profile", "coverageTitle"]} label="服务范围标题">
<Input placeholder="例如:服务范围与合作方式" />
</Form.Item>
</Col>
<Col xs={24} md={12}>
<Form.Item name={["profile", "warrantyTitle"]} label="承诺标题">
<Input placeholder="例如:我的服务承诺" />
</Form.Item>
</Col>
</Row>
</Card>
<Space direction="vertical" style={{ width: "100%" }}>
<MutationError error={save.error} />
<Button type="primary" htmlType="submit" loading={save.isPending}>
保存页面表达
</Button>
</Space>
</Form>
</Card>
);
}
@@ -0,0 +1,382 @@
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
Alert,
Button,
Divider,
Empty,
Input,
Modal,
Select,
Space,
Spin,
Tag,
Typography,
message,
} from "antd";
import type { BrandTemplateKey } from "@personal-brand/api-client";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
const client = createApiClient();
const destinations: Record<string, string> = {
brand: "/admin/brand",
positioning: "/admin/brand",
template: "/admin/publication",
visual: "/admin/publication",
offerings: "/admin/services",
forms: "/admin/workspace",
trust: "/admin/trust",
};
export function PublicationPage({ canManageTemplate }: { canManageTemplate: boolean }) {
const navigate = useNavigate();
const queryClient = useQueryClient();
const [industryTarget, setIndustryTarget] = useState<BrandTemplateKey | null>(null);
const [confirmAction, setConfirmAction] = useState<"publish" | "revoke" | null>(null);
const [rollbackVersion, setRollbackVersion] = useState<number | null>(null);
const [note, setNote] = useState("");
const brand = useQuery({
queryKey: ["publication-brand"],
queryFn: () => client.getAdminBrand(),
});
const workspace = useQuery({
queryKey: ["publication-workspace"],
queryFn: () => client.getAdminWorkspace(),
});
const catalog = useQuery({
queryKey: ["publication-catalog"],
queryFn: () => client.listPublicTemplates(),
});
const sample = useQuery({
queryKey: ["publication-sample"],
queryFn: () => client.previewAdminSampleContent(),
enabled: Boolean(workspace.data),
});
const readiness = useQuery({
queryKey: ["publication-readiness"],
queryFn: () => client.getAdminReleaseReadiness(),
});
const releases = useQuery({
queryKey: ["publication-releases"],
queryFn: () => client.listAdminReleases(),
});
const refresh = () => {
for (const key of [
"publication-brand",
"publication-workspace",
"publication-sample",
"publication-readiness",
"publication-releases",
"admin-shell-brand",
"admin-workspace",
"public-runtime-workspace",
]) {
void queryClient.invalidateQueries({ queryKey: [key] });
}
};
const install = useMutation({
mutationFn: (key: BrandTemplateKey) => client.installAdminTemplate(key),
onSuccess: () => {
setIndustryTarget(null);
message.success("行业模板已安装");
refresh();
},
});
const selectVisual = useMutation({
mutationFn: (key: string) =>
client.updateAdminBrand({
config: { ...(brand.data?.config ?? {}), visualTemplateKey: key },
}),
onSuccess: () => {
message.success("视觉模板已保存到草稿");
refresh();
},
});
const importSample = useMutation({
mutationFn: () => client.importAdminSampleContent(),
onSuccess: () => {
message.success("示例内容已导入草稿");
refresh();
},
});
const publish = useMutation({
mutationFn: () => client.publishAdminRelease(note.trim() || undefined),
onSuccess: () => {
setConfirmAction(null);
setNote("");
message.success("品牌已发布");
refresh();
},
});
const revoke = useMutation({
mutationFn: () => client.revokeAdminRelease(),
onSuccess: () => {
setConfirmAction(null);
message.success("品牌已撤回,小程序将显示未发布状态");
refresh();
},
});
const rollback = useMutation({
mutationFn: (version: number) => client.rollbackAdminRelease(version),
onSuccess: () => {
setRollbackVersion(null);
message.success("历史版本已重新发布");
refresh();
},
});
const loading = [brand, workspace, catalog, readiness, releases].some((query) => query.isLoading);
const error = [brand, workspace, catalog, readiness, releases].find(
(query) => query.isError,
)?.error;
const retry = () => {
void brand.refetch();
void workspace.refetch();
void catalog.refetch();
void readiness.refetch();
void releases.refetch();
};
const industryKey =
workspace.data?.installations[0]?.templateKey ??
workspace.data?.brand?.templateKey ??
brand.data?.templateKey ??
"personal";
const visuals = (catalog.data?.visuals ?? []).filter((item) =>
item.supportedIndustryTemplates.includes(industryKey),
);
const visualKey =
typeof brand.data?.config?.visualTemplateKey === "string"
? brand.data.config.visualTemplateKey
: "linjing-editorial";
const currentRelease = releases.data?.find((item) => item.status === "published");
const publishedHistory = (releases.data ?? []).filter(
(item) => item.status === "published" || item.status === "superseded",
);
const draftOfferings = workspace.data?.offerings.filter((item) => item.isEnabled) ?? [];
const draftForms = (workspace.data?.forms ?? []) as Array<{
id: string;
name: string;
isEnabled: boolean;
}>;
return (
<QueryState loading={loading} error={error} onRetry={retry}>
<AdminPageHeader
title="配置与发布"
description="编辑内容不会立即影响小程序;确认后统一发布当前品牌。"
/>
<Space direction="vertical" size={24} style={{ width: "100%" }}>
<section>
<Typography.Title level={4}>1. 选择表达方式</Typography.Title>
<Space wrap>
<Select
aria-label="行业模板"
style={{ width: 220 }}
value={industryKey}
disabled={!canManageTemplate || Boolean(workspace.data?.installations.length)}
options={(catalog.data?.industries ?? []).map((item) => ({
value: item.key,
label: item.name,
}))}
onChange={(key: BrandTemplateKey) => setIndustryTarget(key)}
/>
<Select
aria-label="视觉模板"
style={{ width: 220 }}
value={visualKey}
disabled={!canManageTemplate}
loading={selectVisual.isPending}
options={visuals.map((item) => ({ value: item.key, label: item.name }))}
onChange={(key) => selectVisual.mutate(key)}
/>
{canManageTemplate && (
<Button onClick={() => navigate("/admin/workspace")}>高级模板设置</Button>
)}
</Space>
{workspace.data?.installations.length ? (
<Typography.Paragraph type="secondary" style={{ marginTop: 8 }}>
当前品牌已安装主模板。模板版本与升级在高级设置中管理。
</Typography.Paragraph>
) : null}
<MutationError error={install.error || selectVisual.error} />
<Divider />
<Space wrap>
<Typography.Text>示例内容</Typography.Text>
{sample.isLoading && <Spin size="small" />}
{sample.data && (
<Tag color={sample.data.alreadyImported ? "green" : "blue"}>
{sample.data.alreadyImported ? "已导入" : "可导入"}
</Tag>
)}
<Button
disabled={!canManageTemplate || !sample.data || sample.data.alreadyImported}
loading={importSample.isPending}
onClick={() => importSample.mutate()}
>
导入示例内容
</Button>
{sample.isError && <Button onClick={() => void sample.refetch()}>重试</Button>}
</Space>
{sample.isError && (
<Alert
type="error"
message={sample.error instanceof Error ? sample.error.message : "示例内容加载失败"}
showIcon
style={{ marginTop: 8 }}
/>
)}
{sample.data && !sample.data.alreadyImported && (
<Typography.Paragraph type="secondary" style={{ marginTop: 8 }}>
将向草稿添加{" "}
{Object.entries(sample.data.counts)
.map(([key, count]) => `${key} ${count} 项`)
.join("、")}
;发布前请替换示例文案和图片。
</Typography.Paragraph>
)}
<MutationError error={importSample.error} />
</section>
<section>
<Typography.Title level={4}>2. 核对草稿内容</Typography.Title>
<Typography.Paragraph type="secondary">
此处核对的是待发布内容,不是小程序视觉预览。
</Typography.Paragraph>
<Space direction="vertical" style={{ width: "100%" }}>
<Typography.Text strong>{brand.data?.name || "未命名品牌"}</Typography.Text>
<Typography.Text>{brand.data?.tagline || "尚未填写品牌定位"}</Typography.Text>
<Typography.Text>
已启用业务项:{draftOfferings.map((item) => item.name).join("、") || "无"}
</Typography.Text>
<Typography.Text>
已启用咨询表单:
{draftForms
.filter((item) => item.isEnabled)
.map((item) => item.name)
.join("、") || "无"}
</Typography.Text>
<Space wrap>
<Button onClick={() => navigate("/admin/brand")}>编辑品牌</Button>
<Button onClick={() => navigate("/admin/services")}>编辑业务项</Button>
<Button onClick={() => navigate("/admin/trust")}>编辑信任内容</Button>
</Space>
</Space>
</section>
<section>
<Typography.Title level={4}>3. 检查并发布</Typography.Title>
<Space wrap style={{ marginBottom: 12 }}>
<Tag color={currentRelease ? "green" : "default"}>
{currentRelease ? `已发布 v${currentRelease.version}` : "尚未发布"}
</Tag>
<Button onClick={() => void readiness.refetch()}>重新检查</Button>
</Space>
<Space direction="vertical" style={{ width: "100%" }}>
{(readiness.data?.checks ?? []).map((check) => (
<Space key={check.key}>
<Tag color={check.passed ? "success" : "warning"}>
{check.passed ? "已完成" : "待完善"}
</Tag>
<Typography.Text>{check.label}</Typography.Text>
{!check.passed && (
<Button
type="link"
onClick={() => navigate(destinations[check.key] ?? "/admin/overview")}
>
去处理
</Button>
)}
</Space>
))}
</Space>
<Space wrap style={{ marginTop: 16 }}>
<Button
type="primary"
disabled={!readiness.data?.ready}
onClick={() => setConfirmAction("publish")}
>
发布当前草稿
</Button>
{currentRelease && (
<Button danger onClick={() => setConfirmAction("revoke")}>
撤回当前版本
</Button>
)}
</Space>
<MutationError error={publish.error || revoke.error} />
<Divider />
<Typography.Title level={5}>发布记录</Typography.Title>
{releases.data?.length ? (
<Space direction="vertical" style={{ width: "100%" }}>
{releases.data.map((item) => (
<Space key={item.id} wrap>
<Typography.Text>v{item.version}</Typography.Text>
<Tag color={item.status === "published" ? "green" : "default"}>{item.status}</Tag>
<Typography.Text type="secondary">
{new Date(item.createdAt).toLocaleString("zh-CN")}
</Typography.Text>
{item.note && <Typography.Text>{item.note}</Typography.Text>}
{item.status === "superseded" && publishedHistory.length > 1 && (
<Button size="small" onClick={() => setRollbackVersion(item.version)}>
恢复此版本
</Button>
)}
</Space>
))}
</Space>
) : (
<Empty description="暂无发布记录" />
)}
<MutationError error={rollback.error} />
</section>
</Space>
<Modal
title={confirmAction === "revoke" ? "确认撤回品牌" : "确认发布品牌"}
open={confirmAction !== null}
onCancel={() => setConfirmAction(null)}
onOk={() => (confirmAction === "revoke" ? revoke.mutate() : publish.mutate())}
confirmLoading={publish.isPending || revoke.isPending}
okText={confirmAction === "revoke" ? "确认撤回" : "确认发布"}
okButtonProps={{ danger: confirmAction === "revoke" }}
>
{confirmAction === "revoke" ? (
<Alert
type="warning"
message="撤回后,小程序将显示品牌尚未发布,新的咨询和预约会停止受理。"
/>
) : (
<Space direction="vertical" style={{ width: "100%" }}>
<Typography.Text>当前草稿将成为品牌新的公开版本。</Typography.Text>
<Input
value={note}
onChange={(event) => setNote(event.target.value)}
placeholder="发布备注(可选)"
maxLength={200}
/>
</Space>
)}
</Modal>
<Modal
title="确认恢复历史版本"
open={rollbackVersion !== null}
onCancel={() => setRollbackVersion(null)}
onOk={() => rollbackVersion !== null && rollback.mutate(rollbackVersion)}
confirmLoading={rollback.isPending}
>
将 v{rollbackVersion} 重新发布为新版本;当前草稿不会被覆盖。
</Modal>
<Modal
title="确认安装行业模板"
open={industryTarget !== null}
onCancel={() => setIndustryTarget(null)}
onOk={() => industryTarget && install.mutate(industryTarget)}
confirmLoading={install.isPending}
>
模板会更新当前品牌的草稿结构,不会立即改变已发布的小程序。请安装后核对业务内容与视觉模板。
</Modal>
</QueryState>
);
}
@@ -4,6 +4,7 @@ import {
Form,
Input,
Modal,
Popconfirm,
Select,
Space,
Table,
@@ -16,6 +17,7 @@ import type { Offering } from "@personal-brand/api-client";
import { useState } from "react";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { ImageUrlField } from "../../components/ImageUrlField.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
export function ServicesPage() {
@@ -56,16 +58,19 @@ export function ServicesPage() {
const beginOffering = (item?: Offering) => {
setEditingOffering(item ?? null);
setOfferingOpen(true);
const config = item?.config ?? {};
offeringForm.setFieldsValue(
item
? {
...item,
sections: config.sections ?? [],
media: config.media ?? [],
cta: config.cta ?? {},
kind: item.kind,
name: item.name,
summary: item.summary ?? "",
description: item.description ?? "",
priceText: item.priceText ?? "",
coverUrl: item.coverUrl ?? "",
sortOrder: item.sortOrder,
isEnabled: item.isEnabled,
}
: { kind: "service", isEnabled: true, sortOrder: 0, sections: [], media: [], cta: {} },
: { kind: "service", isEnabled: true, sortOrder: 0 },
);
};
return (
@@ -129,9 +134,17 @@ export function ServicesPage() {
>
{item.isEnabled ? "禁用" : "启用"}
</Button>
<Button danger size="small" onClick={() => deleteOffering.mutate(item.id)}>
删除
</Button>
<Popconfirm
title="确认删除这项业务提供项?"
description="如果它已经关联咨询表单,系统会阻止删除。"
onConfirm={() => deleteOffering.mutate(item.id)}
okText="删除"
cancelText="取消"
>
<Button danger size="small" loading={deleteOffering.isPending}>
删除
</Button>
</Popconfirm>
</Space>
),
},
@@ -180,85 +193,22 @@ export function ServicesPage() {
<Input.TextArea rows={5} />
</Form.Item>
<Form.Item name="priceText" label="价格展示">
<Input />
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
</Form.Item>
<Form.Item name="coverUrl" label="封面图片 URL">
<Input />
<Form.Item
name="coverUrl"
label="封面图片地址"
help="填写图片地址;图片上传能力将在后续媒体管理中提供。"
>
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" />
</Form.Item>
<Form.List name="sections">
{(fields, { add, remove }) => (
<>
<Form.Item label="内容分区">
<Button onClick={() => add({ type: "text" })}>新增分区</Button>
</Form.Item>
{fields.map(({ key, name, ...restField }) => (
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
<Form.Item {...restField} name={[name, "type"]}>
<Select
style={{ width: 120 }}
options={[
{ value: "text", label: "文本" },
{ value: "image-list", label: "图片列表" },
{ value: "timeline", label: "时间线" },
{ value: "faq", label: "常见问题" },
]}
/>
</Form.Item>
<Form.Item {...restField} name={[name, "title"]}>
<Input placeholder="分区标题" />
</Form.Item>
<Form.Item {...restField} name={[name, "content"]}>
<Input placeholder="分区内容" />
</Form.Item>
<Button danger onClick={() => remove(name)}>
删除
</Button>
</Space>
))}
</>
)}
</Form.List>
<Form.List name="media">
{(fields, { add, remove }) => (
<>
<Form.Item label="媒体列表">
<Button onClick={() => add({ type: "image" })}>新增媒体</Button>
</Form.Item>
{fields.map(({ key, name, ...restField }) => (
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
<Form.Item {...restField} name={[name, "url"]}>
<Input placeholder="图片 URL" />
</Form.Item>
<Form.Item {...restField} name={[name, "alt"]}>
<Input placeholder="替代文本" />
</Form.Item>
<Button danger onClick={() => remove(name)}>
删除
</Button>
</Space>
))}
</>
)}
</Form.List>
<Form.Item label="行动按钮">
<Space>
<Form.Item name={["cta", "type"]} noStyle>
<Select
style={{ width: 150 }}
allowClear
placeholder="按钮行为"
options={[
{ value: "inquiry", label: "提交咨询" },
{ value: "booking", label: "预约服务" },
{ value: "contact", label: "联系品牌" },
{ value: "external-link", label: "外部链接" },
]}
/>
</Form.Item>
<Form.Item name={["cta", "label"]} noStyle>
<Input placeholder="按钮文案" />
</Form.Item>
</Space>
<Form.Item
name="sortOrder"
label="展示顺序"
help="数字越小越靠前,不确定时填写 0。"
rules={[{ type: "number", min: 0, max: 9999 }]}
>
<Input type="number" min={0} max={9999} />
</Form.Item>
<Form.Item name="isEnabled" label="公开状态">
<Select
@@ -0,0 +1,201 @@
import {
Alert,
Button,
Card,
Form,
Input,
Modal,
Select,
Space,
Table,
Tag,
Typography,
message,
} from "antd";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { AdminBrandMember } from "@personal-brand/api-client";
import { useState } from "react";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
const roleLabels: Record<string, string> = {
owner: "负责人",
editor: "内容编辑",
admin: "管理员",
"platform-admin": "平台管理员",
};
export function MembersPage() {
const client = createApiClient();
const queryClient = useQueryClient();
const [addOpen, setAddOpen] = useState(false);
const [addForm] = Form.useForm();
const members = useQuery({
queryKey: ["admin-members"],
queryFn: () => client.listAdminMembers(),
});
const update = useMutation({
mutationFn: ({
id,
body,
}: {
id: string;
body: Partial<Pick<AdminBrandMember, "role" | "isEnabled">>;
}) => client.updateAdminMember(id, body),
onSuccess: () => {
message.success("成员权限已更新");
void queryClient.invalidateQueries({ queryKey: ["admin-members"] });
},
});
const create = useMutation({
mutationFn: (values: {
username: string;
displayName: string;
password: string;
role: "owner" | "editor";
}) => client.createAdminMember(values),
onSuccess: () => {
message.success("成员已添加");
setAddOpen(false);
addForm.resetFields();
void queryClient.invalidateQueries({ queryKey: ["admin-members"] });
},
});
return (
<QueryState
loading={members.isLoading}
error={members.error}
onRetry={() => void members.refetch()}
>
<AdminPageHeader
title="团队成员"
description="管理谁可以维护当前品牌。负责人可以调整系统设置,内容编辑只能维护日常经营内容。"
extra={
<Button type="primary" onClick={() => setAddOpen(true)}>
手动添加成员
</Button>
}
/>
<Card>
<Alert
type="info"
showIcon
message="请将初始账号和密码安全地交给成员"
description="当前采用负责人手动添加方式;系统不会再次显示成员初始密码。"
style={{ marginBottom: 16 }}
/>
<Table
rowKey="id"
loading={members.isLoading}
dataSource={members.data ?? []}
columns={[
{
title: "成员",
render: (_: unknown, item: AdminBrandMember) => item.adminUser.displayName,
},
{ title: "账号", dataIndex: ["adminUser", "username"] },
{
title: "角色",
dataIndex: "role",
render: (value: string, item: AdminBrandMember) => (
<Select
value={value}
options={["owner", "editor"].map((role) => ({
value: role,
label: roleLabels[role],
}))}
onChange={(role) => update.mutate({ id: item.id, body: { role } })}
/>
),
},
{
title: "状态",
dataIndex: "isEnabled",
render: (value: boolean, item: AdminBrandMember) => (
<Select
value={value}
options={[
{ value: true, label: "已启用" },
{ value: false, label: "已停用" },
]}
onChange={(isEnabled) => update.mutate({ id: item.id, body: { isEnabled } })}
/>
),
},
{
title: "说明",
render: (_: unknown, item: AdminBrandMember) => (
<Space>
<Tag>{roleLabels[item.role] ?? item.role}</Tag>
{!item.adminUser.isEnabled ? (
<Typography.Text type="danger">账号已停用</Typography.Text>
) : null}
</Space>
),
},
]}
/>
<MutationError error={update.error} />
<MutationError error={create.error} />
</Card>
<Modal
open={addOpen}
title="手动添加成员"
onCancel={() => {
setAddOpen(false);
addForm.resetFields();
}}
onOk={() => addForm.submit()}
confirmLoading={create.isPending}
destroyOnClose
>
<Form
form={addForm}
layout="vertical"
onFinish={(values) =>
create.mutate(
values as {
username: string;
displayName: string;
password: string;
role: "owner" | "editor";
},
)
}
>
<Form.Item
name="username"
label="登录账号"
rules={[{ required: true, message: "请输入登录账号" }]}
>
<Input placeholder="例如:linran" />
</Form.Item>
<Form.Item
name="displayName"
label="成员姓名"
rules={[{ required: true, message: "请输入成员姓名" }]}
>
<Input placeholder="例如:林然" />
</Form.Item>
<Form.Item
name="password"
label="初始密码"
rules={[{ required: true, min: 8, message: "请输入至少 8 位初始密码" }]}
extra="添加成功后不会再次显示,请提前告知成员。"
>
<Input.Password />
</Form.Item>
<Form.Item name="role" label="角色" initialValue="editor" rules={[{ required: true }]}>
<Select
options={[
{ value: "editor", label: "内容编辑:维护日常经营内容" },
{ value: "owner", label: "负责人:可调整系统设置" },
]}
/>
</Form.Item>
</Form>
</Modal>
</QueryState>
);
}
@@ -16,6 +16,7 @@ import type { TrustContent, TrustContentInput } from "@personal-brand/api-client
import { useState } from "react";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { ImageUrlField } from "../../components/ImageUrlField.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
const types = [
@@ -157,8 +158,12 @@ export function TrustContentPage() {
<Form.Item name="content" label="详细内容" rules={[{ required: true }]}>
<Input.TextArea rows={8} showCount maxLength={2000} />
</Form.Item>
<Form.Item name="coverUrl" label="封面图片 URL">
<Input />
<Form.Item
name="coverUrl"
label="配图地址"
help="粘贴一张可公开访问的图片地址,保存前会显示预览。"
>
<ImageUrlField placeholder="粘贴案例或经历配图地址" />
</Form.Item>
<Form.Item name="isPublished" label="公开状态">
<Select
@@ -14,11 +14,59 @@ import {
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { createApiClient } from "../../lib/api.js";
import { ApiClientError } from "@personal-brand/api-client";
import type { BrandFieldDefinition, BrandModule, InquiryForm } from "@personal-brand/api-client";
import type {
BrandFieldDefinition,
BrandModule,
BrandTemplateKey,
InquiryForm,
} from "@personal-brand/api-client";
import { useState } from "react";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { MutationError } from "../../components/QueryState.js";
const inquiryFieldTypes = [
{ value: "text", label: "简短文字" },
{ value: "textarea", label: "详细说明" },
{ value: "phone", label: "联系电话" },
{ value: "number", label: "数字" },
{ value: "date", label: "日期" },
{ value: "image", label: "图片" },
{ value: "url", label: "链接" },
{ value: "select", label: "单项选择" },
{ value: "multi-select", label: "多项选择" },
];
function optionsToText(options: unknown): string {
if (!Array.isArray(options)) return "";
return options
.map((option) => {
if (!option || typeof option !== "object") return "";
const label = (option as { label?: unknown }).label;
return typeof label === "string" ? label : "";
})
.filter(Boolean)
.join("\n");
}
function optionsFromText(value: unknown): Array<{ label: string; value: string }> {
if (typeof value !== "string") return [];
return value
.split(/\r?\n|、|,/)
.map((item) => item.trim())
.filter(Boolean)
.map((item) => ({ label: item, value: item }));
}
function supportsIndustry(
visual: { supportedIndustryTemplates?: unknown },
industry: string,
): boolean {
return (
Array.isArray(visual.supportedIndustryTemplates) &&
visual.supportedIndustryTemplates.includes(industry)
);
}
export function WorkspacePage() {
const client = createApiClient();
const queryClient = useQueryClient();
@@ -32,7 +80,7 @@ export function WorkspacePage() {
description: string;
capabilities: string[];
} | null>(null);
const [previewIndustry, setPreviewIndustry] = useState("personal");
const [previewIndustry, setPreviewIndustry] = useState<BrandTemplateKey>("personal");
const [previewVisual, setPreviewVisual] = useState("linjing-editorial");
const [form] = Form.useForm<Record<string, unknown>>();
const [inquiryForm] = Form.useForm<Record<string, unknown>>();
@@ -53,6 +101,9 @@ export function WorkspacePage() {
queryFn: () => client.previewPublicTemplateCombination(previewIndustry, previewVisual),
enabled: Boolean(templateCatalog.data),
});
const compatibleVisuals = (templateCatalog.data?.visuals ?? []).filter((visual) =>
supportsIndustry(visual, query.data?.brand?.templateKey ?? "personal"),
);
const visualTemplate = useMutation({
mutationFn: (key: string) =>
client.updateAdminBrand({
@@ -247,8 +298,7 @@ export function WorkspacePage() {
loading={visualTemplate.isPending}
onChange={(key) => setVisualTarget(key)}
options={[
{ value: "linjing-editorial", label: "林境建筑画册" },
{ value: "minimal-neutral", label: "极简留白" },
...compatibleVisuals.map((visual) => ({ value: visual.key, label: visual.name })),
]}
/>
{runtimeQuery.data?.visualTemplate && (
@@ -285,7 +335,7 @@ export function WorkspacePage() {
<Space direction="vertical" style={{ width: "100%" }}>
<Typography.Text strong>可用视觉模板</Typography.Text>
<Space wrap>
{(templateCatalog.data?.visuals ?? []).map((visual) => (
{compatibleVisuals.map((visual) => (
<Card key={visual.key} size="small" style={{ width: 260 }}>
<Typography.Text strong>{visual.name}</Typography.Text>
<Typography.Paragraph type="secondary" ellipsis={{ rows: 2 }}>
@@ -321,9 +371,7 @@ export function WorkspacePage() {
<Typography.Paragraph>
当前模板:{runtimeQuery.data?.visualTemplate?.name ?? "林境建筑画册"}
</Typography.Paragraph>
<Typography.Paragraph>
目标模板:{visualTarget === "minimal-neutral" ? "极简留白" : "林境建筑画册"}
</Typography.Paragraph>
<Typography.Paragraph>目标模板:林境建筑画册</Typography.Paragraph>
<Typography.Paragraph type="secondary">
只会替换视觉主题和模块变体,不会覆盖品牌内容、业务提供项或咨询记录。
</Typography.Paragraph>
@@ -418,10 +466,9 @@ export function WorkspacePage() {
<Select
value={previewVisual}
onChange={setPreviewVisual}
options={(templateCatalog.data?.visuals ?? []).map((item) => ({
value: item.key,
label: item.name,
}))}
options={(templateCatalog.data?.visuals ?? [])
.filter((item) => supportsIndustry(item, previewIndustry))
.map((item) => ({ value: item.key, label: item.name }))}
/>
</Space>
{combinationPreview.isLoading ? (
@@ -490,9 +537,7 @@ export function WorkspacePage() {
const value = field as Record<string, unknown>;
return {
...value,
...(Array.isArray(value.options)
? { optionsText: JSON.stringify(value.options) }
: {}),
optionsText: optionsToText(value.options),
};
}),
});
@@ -692,15 +737,11 @@ export function WorkspacePage() {
: []
).map((field) => {
const item = field as Record<string, unknown>;
if (typeof item.optionsText !== "string") return item;
try {
const options = JSON.parse(item.optionsText) as unknown;
const { optionsText, ...rest } = item;
void optionsText;
return { ...rest, options };
} catch {
return item;
}
const { optionsText, ...rest } = item;
const type = typeof rest.type === "string" ? rest.type : "text";
return ["select", "radio", "multi-select"].includes(type)
? { ...rest, options: optionsFromText(optionsText) }
: rest;
}),
};
if (editingForm) updateForm.mutate({ id: editingForm.id, body });
@@ -738,47 +779,70 @@ export function WorkspacePage() {
{(fields, { add, remove }) => (
<>
<Form.Item label="表单字段">
<Button onClick={() => add({ type: "text", required: false })}>新增字段</Button>
<Button
onClick={() =>
add({
key: `field_${Date.now()}`,
type: "text",
required: false,
})
}
>
新增字段
</Button>
</Form.Item>
{fields.map(({ key, name, ...restField }) => (
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
<Form.Item {...restField} name={[name, "key"]} rules={[{ required: true }]}>
<Input placeholder="Key" />
</Form.Item>
<Form.Item {...restField} name={[name, "label"]} rules={[{ required: true }]}>
<Input placeholder="字段名称" />
</Form.Item>
<Form.Item {...restField} name={[name, "type"]}>
<Select
style={{ width: 120 }}
options={[
"text",
"textarea",
"number",
"date",
"select",
"multi-select",
"image",
"url",
"phone",
].map((value) => ({ value, label: value }))}
/>
<Card key={key} size="small" style={{ marginBottom: 12 }}>
<Form.Item {...restField} name={[name, "key"]} hidden>
<Input />
</Form.Item>
<Space align="start" style={{ display: "flex" }}>
<Form.Item
{...restField}
name={[name, "label"]}
label="要询问客户什么"
rules={[{ required: true, message: "请填写字段名称" }]}
style={{ flex: 1 }}
>
<Input placeholder="例如:联系电话、预计预算、项目地址" />
</Form.Item>
<Form.Item {...restField} name={[name, "type"]} label="回答方式">
<Select style={{ width: 130 }} options={inquiryFieldTypes} />
</Form.Item>
<Form.Item {...restField} name={[name, "required"]} label="必填">
<Select
style={{ width: 90 }}
options={[
{ value: true, label: "必填" },
{ value: false, label: "选填" },
]}
/>
</Form.Item>
<Button danger onClick={() => remove(name)} style={{ marginTop: 30 }}>
删除
</Button>
</Space>
<Form.Item noStyle shouldUpdate>
{({ getFieldValue }) =>
["select", "radio"].includes(
["select", "radio", "multi-select"].includes(
String(getFieldValue(["fieldsSnapshot", name, "type"])),
) ? (
<Form.Item {...restField} name={[name, "optionsText"]}>
<Input placeholder="选项 JSON" />
<Form.Item
{...restField}
name={[name, "optionsText"]}
label="可选内容"
help="每行填写一个选项,也可以用顿号分隔。"
rules={[{ required: true, message: "请至少填写一个选项" }]}
>
<Input.TextArea
rows={2}
placeholder="例如:预算内、需要沟通、暂不确定"
/>
</Form.Item>
) : null
}
</Form.Item>
<Button danger onClick={() => remove(name)}>
删除
</Button>
</Space>
</Card>
))}
</>
)}
+128 -13
View File
@@ -49,13 +49,27 @@ const FeatureCapabilitiesPage = React.lazy(() =>
default: module.CapabilitiesPage,
})),
);
const FeatureMembersPage = React.lazy(() =>
import("./features/team/MembersPage.js").then((module) => ({
default: module.MembersPage,
})),
);
const FeaturePublicationPage = React.lazy(() =>
import("./features/publication/PublicationPage.js").then((module) => ({
default: module.PublicationPage,
})),
);
import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom";
import "antd/dist/reset.css";
const queryClient = new QueryClient();
const api = createApiClient;
function Login({ onLogin }: { onLogin: () => void }) {
function Login({
onLogin,
}: {
onLogin: (session: { role: string; mustChangePassword: boolean }) => void;
}) {
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
async function submit(values: { username: string; password: string }) {
@@ -63,7 +77,9 @@ function Login({ onLogin }: { onLogin: () => void }) {
try {
const result = await api().loginAdmin(values.username, values.password);
localStorage.setItem("adminToken", result.token);
onLogin();
localStorage.setItem("adminRole", result.role);
localStorage.setItem("adminMustChangePassword", String(result.mustChangePassword));
onLogin(result);
} catch (error) {
message.error(error instanceof Error ? error.message : "登录失败");
} finally {
@@ -87,7 +103,60 @@ function Login({ onLogin }: { onLogin: () => void }) {
);
}
function Dashboard({ onLogout }: { onLogout: () => void }) {
function ChangePassword({ onComplete }: { onComplete: () => void }) {
const [form] = Form.useForm<{
currentPassword: string;
newPassword: string;
confirmPassword: string;
}>();
const [loading, setLoading] = useState(false);
async function submit(values: {
currentPassword: string;
newPassword: string;
confirmPassword: string;
}) {
if (values.newPassword !== values.confirmPassword) {
message.error("两次输入的新密码不一致");
return;
}
setLoading(true);
try {
await api().changeAdminPassword(values.currentPassword, values.newPassword);
localStorage.setItem("adminMustChangePassword", "false");
message.success("密码已更新");
onComplete();
} catch (error) {
message.error(error instanceof Error ? error.message : "密码更新失败");
} finally {
setLoading(false);
}
}
return (
<Card title="首次登录需要修改密码" style={{ maxWidth: 420, margin: "120px auto" }}>
<Typography.Paragraph type="secondary">请先设置只有你本人知道的新密码。</Typography.Paragraph>
<Form form={form} layout="vertical" onFinish={submit}>
<Form.Item name="currentPassword" label="初始密码" rules={[{ required: true }]}>
<Input.Password />
</Form.Item>
<Form.Item
name="newPassword"
label="新密码"
rules={[{ required: true, min: 8, message: "请输入至少 8 位新密码" }]}
>
<Input.Password />
</Form.Item>
<Form.Item name="confirmPassword" label="确认新密码" rules={[{ required: true }]}>
<Input.Password />
</Form.Item>
<Button type="primary" htmlType="submit" loading={loading} block>
保存新密码
</Button>
</Form>
</Card>
);
}
function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
const navigate = useNavigate();
const location = useLocation();
const brand = useQuery({
@@ -109,13 +178,31 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
};
const page = location.pathname.split("/")[2] || "overview";
const items = [
{ key: "overview", label: "当前品牌概览" },
{ key: "brand", label: "当前品牌表达" },
{ key: "trust", label: "信任内容" },
{ key: "services", label: "业务提供项" },
{ key: "workspace", label: "模板与设置" },
{ key: "capabilities", label: "能力插件" },
{ key: "inquiries", label: "咨询记录" },
{
type: "group" as const,
label: "日常经营",
children: [
{ key: "overview", label: "当前品牌概览" },
{ key: "publication", label: "配置与发布" },
{ key: "brand", label: "品牌表达" },
{ key: "trust", label: "信任内容" },
{ key: "services", label: "业务提供项" },
{ key: "inquiries", label: "咨询记录" },
],
},
...(role === "editor"
? []
: [
{
type: "group" as const,
label: "系统管理",
children: [
{ key: "workspace", label: "模板与设置" },
{ key: "capabilities", label: "能力插件" },
{ key: "members", label: "团队成员" },
],
},
]),
];
return (
<Layout style={{ minHeight: "100vh" }}>
@@ -163,9 +250,20 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
<Suspense fallback={<Card loading />}>
<Routes>
<Route path="/admin/overview" element={<FeatureOverviewPage />} />
<Route
path="/admin/publication"
element={<FeaturePublicationPage canManageTemplate={role !== "editor"} />}
/>
<Route path="/admin/brand" element={<FeatureBrandPage />} />
<Route path="/admin/workspace" element={<FeatureWorkspacePage />} />
<Route path="/admin/capabilities" element={<FeatureCapabilitiesPage />} />
{role === "editor" ? null : (
<Route path="/admin/workspace" element={<FeatureWorkspacePage />} />
)}
{role === "editor" ? null : (
<Route path="/admin/capabilities" element={<FeatureCapabilitiesPage />} />
)}
{role === "editor" ? null : (
<Route path="/admin/members" element={<FeatureMembersPage />} />
)}
<Route path="/admin/trust" element={<FeatureTrustContentPage />} />
<Route path="/admin/services" element={<FeatureServicesPage />} />
<Route path="/admin/inquiries" element={<FeatureInquiriesPage />} />
@@ -180,6 +278,10 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
function Root() {
const [loggedIn, setLoggedIn] = useState(Boolean(localStorage.getItem("adminToken")));
const [role, setRole] = useState(localStorage.getItem("adminRole") || "owner");
const [mustChangePassword, setMustChangePassword] = useState(
localStorage.getItem("adminMustChangePassword") === "true",
);
React.useEffect(() => {
const expire = () => {
message.warning("登录状态已失效,请重新登录");
@@ -190,9 +292,22 @@ function Root() {
}, []);
const logout = () => {
localStorage.removeItem("adminToken");
localStorage.removeItem("adminRole");
localStorage.removeItem("adminMustChangePassword");
setLoggedIn(false);
};
return loggedIn ? <Dashboard onLogout={logout} /> : <Login onLogin={() => setLoggedIn(true)} />;
if (!loggedIn)
return (
<Login
onLogin={(session) => {
setRole(session.role);
setMustChangePassword(session.mustChangePassword);
setLoggedIn(true);
}}
/>
);
if (mustChangePassword) return <ChangePassword onComplete={() => setMustChangePassword(false)} />;
return <Dashboard onLogout={logout} role={role} />;
}
createRoot(document.getElementById("app")!).render(
<React.StrictMode>