feat: 统一 Admin 后台设计语言
用中性灰底 + 单一强调色重做后台视觉,并集中到一套令牌: - 新增 apps/admin/src/lib/theme.ts,通过 ConfigProvider 注入主题令牌 - 新增 apps/admin/src/styles/admin.css 与 AdminSection、MetricCard、StatusTag 组件 - 侧栏改白底浅色并补图标,顶栏改 56px 白底,内容区最大宽 1200px - 全部页面接入状态标签,antd 原生彩色 Tag 与内联色值清零 - 登录与改密页、加载态骨架屏、错误提示条统一 - brand 页两个 Tab 统一为白卡片容器,消除双标题与宽度不一致 设计规范见 apps/admin/design.md。
This commit is contained in:
1 parent
bb94d80e13
commit
2f26828f09
34 files changed
+2159
-922
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { Button, Card, Form, Input, Modal, Select, Space, Table, Tag, Typography } from "antd";
|
||||
import { Button, Card, Form, Input, Modal, Select, Space, Table, Typography } from "antd";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { ApiClientError } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
import { supportsIndustry, type IndustryTarget } from "./workspace-templates.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { MutationError } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
|
||||
export const inquiryFieldTypes = [
|
||||
{ value: "text", label: "简短文字" },
|
||||
@@ -146,12 +147,12 @@ export function WorkspacePage() {
|
||||
}
|
||||
const { fields, installations } = query.data;
|
||||
return (
|
||||
<Space direction="vertical" size="large" style={{ width: "100%" }}>
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<AdminPageHeader
|
||||
title="模板与表单设置"
|
||||
description="日常小程序内容请从页面配置、业务展示和信任证明进入;这里主要管理模板、咨询入口和负责人设置。"
|
||||
/>
|
||||
<Card title="先完成日常配置" style={{ marginBottom: 24 }}>
|
||||
<Card title="先完成日常配置">
|
||||
<Typography.Paragraph type="secondary">
|
||||
下面这些入口面向日常经营,不需要理解模板或技术设置。完成后回到“配置与发布”统一检查并上线。
|
||||
</Typography.Paragraph>
|
||||
@@ -166,38 +167,45 @@ export function WorkspacePage() {
|
||||
</Card>
|
||||
<Card title="小程序当前状态" loading={runtimeQuery.isLoading}>
|
||||
{runtimeQuery.isError ? (
|
||||
<Typography.Text type="danger">公开运行时工作空间暂时无法加载。</Typography.Text>
|
||||
<StatusTag tone="error" label="公开运行时工作空间暂时无法加载" />
|
||||
) : (
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<div className="admin-stack">
|
||||
<Space wrap>
|
||||
<Tag color="green">小程序数据已同步</Tag>
|
||||
<Tag>公开业务 {runtimeQuery.data?.offerings?.length ?? 0} 项</Tag>
|
||||
<Tag>已启用能力 {runtimeQuery.data?.capabilities?.length ?? 0} 项</Tag>
|
||||
<StatusTag tone="success" label="小程序数据已同步" />
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`公开业务 ${runtimeQuery.data?.offerings?.length ?? 0} 项`}
|
||||
/>
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`已启用能力 ${runtimeQuery.data?.capabilities?.length ?? 0} 项`}
|
||||
/>
|
||||
</Space>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 0 }}>
|
||||
<p className="admin-section-description admin-flush-top">
|
||||
小程序和后台预览会使用同一份已发布内容。这里的能力由当前模板自动提供,通常不需要手动调整。
|
||||
</Typography.Paragraph>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text strong>已启用的服务能力</Typography.Text>
|
||||
</p>
|
||||
<div className="admin-stack">
|
||||
<h3 className="admin-section-title">已启用的服务能力</h3>
|
||||
{(runtimeQuery.data?.plugins ?? []).map((plugin) => (
|
||||
<Card key={plugin.key} size="small">
|
||||
<Space wrap>
|
||||
<Typography.Text strong>{plugin.displayName}</Typography.Text>
|
||||
<Tag color={plugin.status === "enabled" ? "green" : "orange"}>
|
||||
{plugin.status}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Typography.Paragraph type="secondary" style={{ margin: "8px 0 0" }}>
|
||||
<div className="admin-row-line">
|
||||
<span className="admin-row-title">{plugin.displayName}</span>
|
||||
<StatusTag
|
||||
tone={plugin.status === "enabled" ? "success" : "warning"}
|
||||
label={plugin.status === "enabled" ? "已启用" : "未启用"}
|
||||
/>
|
||||
</div>
|
||||
<p className="admin-section-description admin-flush">
|
||||
这项能力已接入当前小程序流程,无需单独配置技术参数。
|
||||
</Typography.Paragraph>
|
||||
</p>
|
||||
</Card>
|
||||
))}
|
||||
{!runtimeQuery.data?.plugins?.length && (
|
||||
<Typography.Text type="secondary">当前模板未启用能力插件。</Typography.Text>
|
||||
<p className="admin-empty-inline">当前模板未启用能力插件。</p>
|
||||
)}
|
||||
</Space>
|
||||
</div>
|
||||
<Space wrap>
|
||||
<Typography.Text strong>视觉模板</Typography.Text>
|
||||
<span className="admin-field-label admin-flush">视觉模板</span>
|
||||
<Select
|
||||
value={runtimeQuery.data?.visualTemplate?.key}
|
||||
loading={visualTemplate.isPending}
|
||||
@@ -207,28 +215,33 @@ export function WorkspacePage() {
|
||||
]}
|
||||
/>
|
||||
{runtimeQuery.data?.visualTemplate && (
|
||||
<Tag>
|
||||
v{runtimeQuery.data.visualTemplate.version} ·{" "}
|
||||
{Object.values(runtimeQuery.data.visualTemplate.variants).join(" / ")}
|
||||
</Tag>
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`v${runtimeQuery.data.visualTemplate.version} · ${Object.values(
|
||||
runtimeQuery.data.visualTemplate.variants,
|
||||
).join(" / ")}`}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={visualTemplate.error} />
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text strong>视觉模板切换历史</Typography.Text>
|
||||
<div className="admin-stack">
|
||||
<h3 className="admin-section-title">视觉模板切换历史</h3>
|
||||
{visualHistory.data?.history.length ? (
|
||||
visualHistory.data.history.map((item) => (
|
||||
<Tag key={`${item.visualTemplateKey}-${item.savedAt}`}>
|
||||
{item.visualTemplateKey} · {item.savedAt}
|
||||
</Tag>
|
||||
))
|
||||
<div className="admin-row-line">
|
||||
{visualHistory.data.history.map((item) => (
|
||||
<StatusTag
|
||||
key={`${item.visualTemplateKey}-${item.savedAt}`}
|
||||
tone="neutral"
|
||||
label={`${item.visualTemplateKey} · ${item.savedAt}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Typography.Text type="secondary">暂无历史版本</Typography.Text>
|
||||
<p className="admin-empty-inline">暂无历史版本</p>
|
||||
)}
|
||||
{visualHistory.data?.history.length ? (
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
onClick={() => rollbackVisual.mutate()}
|
||||
loading={rollbackVisual.isPending}
|
||||
>
|
||||
@@ -236,33 +249,33 @@ export function WorkspacePage() {
|
||||
</Button>
|
||||
) : null}
|
||||
<MutationError error={rollbackVisual.error} />
|
||||
</Space>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Typography.Text strong>可用视觉模板</Typography.Text>
|
||||
</div>
|
||||
<div className="admin-stack">
|
||||
<h3 className="admin-section-title">可用视觉模板</h3>
|
||||
<Space wrap>
|
||||
{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 }}>
|
||||
{visual.description}
|
||||
</Typography.Paragraph>
|
||||
<Space wrap>
|
||||
<Card key={visual.key} size="small" className="admin-visual-card">
|
||||
<span className="admin-row-title">{visual.name}</span>
|
||||
<p className="admin-row-summary">{visual.description}</p>
|
||||
<div className="admin-row-line">
|
||||
{Object.entries(visual.theme.colors).map(([name, color]) => (
|
||||
<Tag key={name} color={color.startsWith("#") ? "default" : "blue"}>
|
||||
<span
|
||||
key={name}
|
||||
className="admin-swatch"
|
||||
title={`${name} ${color}`}
|
||||
style={{ "--swatch-color": color } as React.CSSProperties}
|
||||
>
|
||||
{name}
|
||||
</Tag>
|
||||
</span>
|
||||
))}
|
||||
</Space>
|
||||
<Typography.Paragraph
|
||||
type="secondary"
|
||||
style={{ marginTop: 12, marginBottom: 0 }}
|
||||
>
|
||||
</div>
|
||||
<p className="admin-row-meta admin-flush">
|
||||
{Object.values(visual.variants).join(" / ")}
|
||||
</Typography.Paragraph>
|
||||
</p>
|
||||
</Card>
|
||||
))}
|
||||
</Space>
|
||||
</Space>
|
||||
</div>
|
||||
<Modal
|
||||
title="确认切换视觉模板"
|
||||
open={visualTarget !== null}
|
||||
@@ -281,7 +294,7 @@ export function WorkspacePage() {
|
||||
只会替换视觉主题和模块变体,不会覆盖品牌内容、业务提供项或咨询记录。
|
||||
</Typography.Paragraph>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
<Card
|
||||
@@ -303,17 +316,20 @@ export function WorkspacePage() {
|
||||
<Typography.Paragraph type="secondary">
|
||||
模板只提供行业表达样例,不会替代你的品牌定位、经历、作品和合作方式。
|
||||
</Typography.Paragraph>
|
||||
<Tag>{installations.length ? `已安装 ${installations.length} 个模板` : "尚未安装模板"}</Tag>
|
||||
<StatusTag
|
||||
tone={installations.length ? "info" : "neutral"}
|
||||
label={installations.length ? `已安装 ${installations.length} 个模板` : "尚未安装模板"}
|
||||
/>
|
||||
{installations.length > 0 && (
|
||||
<Card size="small" style={{ marginTop: 16 }} title="模板版本">
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Card size="small" className="admin-offset-top" title="模板版本">
|
||||
<div className="admin-stack">
|
||||
<Typography.Text>
|
||||
当前版本:{templatePreview.data?.currentVersion ?? "加载中"},最新版本:
|
||||
{templatePreview.data?.latestVersion ?? "加载中"}
|
||||
</Typography.Text>
|
||||
{templatePreview.data?.canUpgrade ? (
|
||||
<>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 0 }}>
|
||||
<Typography.Paragraph type="secondary" className="admin-flush">
|
||||
可升级内容:新增 {templatePreview.data.missingModules.length} 个模块,新增{" "}
|
||||
{templatePreview.data.missingFields.length} 个字段。已有内容不会被覆盖。
|
||||
</Typography.Paragraph>
|
||||
@@ -326,7 +342,9 @@ export function WorkspacePage() {
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<Tag color="green">已是最新版本</Tag>
|
||||
<div>
|
||||
<StatusTag tone="success" label="已是最新版本" />
|
||||
</div>
|
||||
)}
|
||||
{templatePreview.data?.canRollback && (
|
||||
<Button danger onClick={() => rollback.mutate()} loading={rollback.isPending}>
|
||||
@@ -336,7 +354,7 @@ export function WorkspacePage() {
|
||||
<MutationError error={templatePreview.error} />
|
||||
<MutationError error={upgrade.error} />
|
||||
<MutationError error={rollback.error} />
|
||||
</Space>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
<MutationError error={install.error} />
|
||||
@@ -360,7 +378,6 @@ export function WorkspacePage() {
|
||||
</Modal>
|
||||
<Card
|
||||
title="模板组合预览"
|
||||
style={{ marginBottom: 24 }}
|
||||
extra={<Typography.Text type="secondary">高级预览</Typography.Text>}
|
||||
>
|
||||
<Typography.Paragraph type="secondary">
|
||||
@@ -384,19 +401,18 @@ export function WorkspacePage() {
|
||||
/>
|
||||
</Space>
|
||||
{combinationPreview.isLoading ? (
|
||||
<Card loading style={{ marginTop: 16 }} />
|
||||
<Card loading className="admin-offset-top" />
|
||||
) : combinationPreview.data ? (
|
||||
<Space direction="vertical" style={{ width: "100%", marginTop: 16 }}>
|
||||
<div className="admin-stack admin-offset-top">
|
||||
<Typography.Text strong>
|
||||
{combinationPreview.data.industry.name} × {combinationPreview.data.visual.name}
|
||||
</Typography.Text>
|
||||
<Space wrap></Space>
|
||||
<Typography.Text type="secondary">
|
||||
能力:
|
||||
{combinationPreview.data.runtime.capabilities.map((item) => item.key).join("、") ||
|
||||
"无"}
|
||||
</Typography.Text>
|
||||
</Space>
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
<Card
|
||||
@@ -414,18 +430,29 @@ export function WorkspacePage() {
|
||||
locale={{ emptyText: "还没有咨询入口,点击右上角即可从默认表单开始。" }}
|
||||
columns={[
|
||||
{ title: "名称", dataIndex: "name" },
|
||||
{ title: "版本", dataIndex: "version", render: (value) => <Tag>v{value}</Tag> },
|
||||
{
|
||||
title: "版本",
|
||||
dataIndex: "version",
|
||||
render: (value) => <StatusTag tone="neutral" label={`v${value}`} />,
|
||||
},
|
||||
{
|
||||
title: "字段数",
|
||||
dataIndex: "fieldsSnapshot",
|
||||
render: (value: unknown[]) => value?.length ?? 0,
|
||||
},
|
||||
{ title: "状态", dataIndex: "isEnabled", render: (value) => (value ? "启用" : "停用") },
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: "isEnabled",
|
||||
render: (value: boolean) => (
|
||||
<StatusTag tone={value ? "success" : "neutral"} label={value ? "启用" : "停用"} />
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
render: (_: unknown, item: InquiryForm) => (
|
||||
<Space>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
setEditingForm(item);
|
||||
@@ -637,7 +664,7 @@ export function WorkspacePage() {
|
||||
>
|
||||
<Input placeholder="例如:预约上门测量、家庭聚餐预订" />
|
||||
</Form.Item>
|
||||
<Space style={{ display: "flex" }} align="start">
|
||||
<div className="admin-form-row">
|
||||
<Form.Item
|
||||
name="purpose"
|
||||
label="客户要做什么"
|
||||
@@ -645,7 +672,7 @@ export function WorkspacePage() {
|
||||
initialValue="inquiry"
|
||||
>
|
||||
<Select
|
||||
style={{ width: 160 }}
|
||||
className="admin-field-w-lg"
|
||||
options={[
|
||||
{ value: "inquiry", label: "需求咨询" },
|
||||
{ value: "quote-request", label: "获取报价" },
|
||||
@@ -656,7 +683,7 @@ export function WorkspacePage() {
|
||||
<Form.Item name="offeringId" label="关联哪项业务" help="不选择表示这是品牌通用入口。">
|
||||
<Select
|
||||
allowClear
|
||||
style={{ width: 220 }}
|
||||
className="admin-field-w-xl"
|
||||
placeholder="品牌级表单"
|
||||
options={(runtimeQuery.data?.offerings ?? []).map((item) => ({
|
||||
value: item.id,
|
||||
@@ -664,7 +691,7 @@ export function WorkspacePage() {
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Space>
|
||||
</div>
|
||||
<Form.List name="fieldsSnapshot">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
@@ -685,36 +712,36 @@ export function WorkspacePage() {
|
||||
</Button>
|
||||
</Form.Item>
|
||||
{fields.map(({ key, name, ...restField }) => (
|
||||
<Card key={key} size="small" style={{ marginBottom: 12 }}>
|
||||
<Card key={key} size="small" className="admin-offset-bottom-sm">
|
||||
<Form.Item {...restField} name={[name, "key"]} hidden>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Space align="start" style={{ display: "flex" }}>
|
||||
<div className="admin-form-row">
|
||||
<Form.Item
|
||||
{...restField}
|
||||
name={[name, "label"]}
|
||||
label="要询问客户什么"
|
||||
rules={[{ required: true, message: "请填写字段名称" }]}
|
||||
style={{ flex: 1 }}
|
||||
className="admin-flex-1"
|
||||
>
|
||||
<Input placeholder="例如:联系电话、预计预算、项目地址" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "type"]} label="回答方式">
|
||||
<Select style={{ width: 150 }} options={inquiryFieldTypes} />
|
||||
<Select className="admin-field-w-md" options={inquiryFieldTypes} />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "required"]} label="必填">
|
||||
<Select
|
||||
style={{ width: 90 }}
|
||||
className="admin-field-w-sm"
|
||||
options={[
|
||||
{ value: true, label: "必填" },
|
||||
{ value: false, label: "选填" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)} style={{ marginTop: 30 }}>
|
||||
<Button danger onClick={() => remove(name)} className="admin-field-offset">
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) =>
|
||||
["select", "radio", "multi-select"].includes(
|
||||
@@ -735,32 +762,28 @@ export function WorkspacePage() {
|
||||
{(optionFields, { add, remove }, { errors }) => (
|
||||
<>
|
||||
{optionFields.map((optionField) => (
|
||||
<Space
|
||||
key={optionField.key}
|
||||
align="center"
|
||||
style={{ display: "flex" }}
|
||||
>
|
||||
<div key={optionField.key} className="admin-form-row-center">
|
||||
<Form.Item
|
||||
{...optionField}
|
||||
name={[optionField.name, "label"]}
|
||||
initialValue=""
|
||||
rules={[{ required: true, message: "请填写选项内容" }]}
|
||||
style={{ flex: 1, minWidth: 240, marginBottom: 8 }}
|
||||
className="admin-flex-1 admin-offset-bottom-xs"
|
||||
>
|
||||
<Input placeholder="例如:预算内" />
|
||||
</Form.Item>
|
||||
<Button
|
||||
danger
|
||||
onClick={() => remove(optionField.name)}
|
||||
style={{ marginBottom: 8 }}
|
||||
className="admin-offset-bottom-xs"
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
))}
|
||||
<Button
|
||||
onClick={() => add({ label: "", value: "" })}
|
||||
style={{ marginBottom: 8 }}
|
||||
className="admin-offset-bottom-xs"
|
||||
>
|
||||
新增选项
|
||||
</Button>
|
||||
@@ -778,6 +801,6 @@ export function WorkspacePage() {
|
||||
</Form.List>
|
||||
</Form>
|
||||
</Modal>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user