refactor: 拆分模板治理与咨询表单页面
- /admin/workspace 收敛为「咨询表单与字段」,只做咨询入口表单与高级自定义字段 - 行业模板版本升级/回滚迁入「配置与发布 → 内容发布 → 选择表达方式」 - 移除行业模板安装入口、视觉模板历史与模板组合预览等不可达 UI - 表单下拉的业务选项改用本品牌后台数据,避免公开接口回退默认品牌导致跨品牌串数据 - 侧栏导航与设计文档同步
This commit is contained in:
1 parent
7b1e9eee47
commit
896f3240f9
9 files changed
+206
-583
No files matched your search
+14
-13
@@ -262,6 +262,7 @@
|
||||
- 空状态统一用 `EmptyState`(`components/EmptyState.tsx`);表格内用 `compact` 变体,整块区域用默认变体。禁止再使用 antd 默认 `Empty` 插画。
|
||||
- 列表 / 表格加载统一用 `TableSkeleton`、`ListSkeleton`(`components/TableSkeleton.tsx`)替换内容区,不使用 antd `Table` 的转圈遮罩;卡片级加载用 `LoadingStack`。
|
||||
- 卡片内的写操作只在「有未保存修改」时使用主按钮,其余状态用次要按钮并禁用,同时用 `StatusTag` 标明修改状态。
|
||||
- 发布准备度、内容检查这类清单,条目文案只描述「检查什么」(中性名词),是否达标由「已完成 / 待完善」标签表达;帮助文案只在待完善时展示。禁止出现「已完成 · 请先完善…」这类自相矛盾的措辞。
|
||||
|
||||
---
|
||||
|
||||
@@ -269,19 +270,19 @@
|
||||
|
||||
以下为各页面的视觉结构约定,业务逻辑不变。
|
||||
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
| 页面 | 结构要点 |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
|
||||
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
|
||||
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
|
||||
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);内容发布含「选择表达方式」(行业模板 + 视觉模板 + 版本升级/回滚)+ 发布状态卡 + 草稿卡 + 历史版本表 |
|
||||
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
|
||||
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
|
||||
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
|
||||
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
|
||||
| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
|
||||
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
|
||||
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
|
||||
|
||||
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
|
||||
|
||||
|
||||
@@ -30,10 +30,8 @@ export function CapabilitiesPage() {
|
||||
<EmptyState
|
||||
icon={<AppstoreOutlined />}
|
||||
title="当前模板没有可配置能力"
|
||||
description="安装行业模板后,这里会列出可开关的能力插件。"
|
||||
action={
|
||||
<Button onClick={() => navigate("/admin/workspace")}>前往模板与表单设置</Button>
|
||||
}
|
||||
description="能力的开关由品牌当前使用的行业模板决定;更换行业模板不在本版本范围内。"
|
||||
action={<Button onClick={() => navigate("/admin/publication")}>查看模板与发布</Button>}
|
||||
/>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
@@ -83,6 +83,10 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
queryKey: ["publication-miniapp-settings"],
|
||||
queryFn: () => client.getAdminMiniAppSettings(),
|
||||
});
|
||||
const templatePreview = useQuery({
|
||||
queryKey: ["publication-template-preview"],
|
||||
queryFn: () => client.getAdminTemplateUpgradePreview(),
|
||||
});
|
||||
useEffect(() => {
|
||||
if (!miniAppSettings.data) return;
|
||||
miniAppSettingsForm.setFieldsValue({
|
||||
@@ -108,6 +112,7 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
"publication-workspace",
|
||||
"publication-sample",
|
||||
"publication-readiness",
|
||||
"publication-template-preview",
|
||||
"publication-releases",
|
||||
"publication-miniapp-releases",
|
||||
"admin-shell-brand",
|
||||
@@ -125,6 +130,20 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const upgradeTemplate = useMutation({
|
||||
mutationFn: () => client.upgradeAdminTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("行业模板已升级,现有内容未被覆盖");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const rollbackTemplate = useMutation({
|
||||
mutationFn: () => client.rollbackAdminTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("行业模板配置基线已回滚");
|
||||
refresh();
|
||||
},
|
||||
});
|
||||
const selectVisual = useMutation({
|
||||
mutationFn: (key: string) =>
|
||||
client.updateAdminBrand({
|
||||
@@ -405,14 +424,50 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
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 ? (
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
当前品牌已安装主模板。模板版本与升级在高级设置中管理。
|
||||
</p>
|
||||
{industryKey ? (
|
||||
<div className="admin-offset-top-sm">
|
||||
<Space wrap>
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`当前版本 ${templatePreview.data?.currentVersion ?? "加载中"}`}
|
||||
/>
|
||||
<StatusTag
|
||||
tone="info"
|
||||
label={`最新版本 ${templatePreview.data?.latestVersion ?? "加载中"}`}
|
||||
/>
|
||||
{templatePreview.data?.canUpgrade ? (
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={upgradeTemplate.isPending}
|
||||
onClick={() => upgradeTemplate.mutate()}
|
||||
>
|
||||
升级模板
|
||||
</Button>
|
||||
) : (
|
||||
<StatusTag tone="success" label="已是最新版本" />
|
||||
)}
|
||||
{templatePreview.data?.canRollback ? (
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
disabled={!canManageTemplate}
|
||||
loading={rollbackTemplate.isPending}
|
||||
onClick={() => rollbackTemplate.mutate()}
|
||||
>
|
||||
回滚到上一版
|
||||
</Button>
|
||||
) : null}
|
||||
</Space>
|
||||
<p className="admin-section-description admin-offset-top-sm">
|
||||
行业模板随品牌身份固定,只能升级版本、不能更换行业;升级只补充字段与模块,不覆盖已有内容。视觉模板只替换排版风格。
|
||||
</p>
|
||||
<MutationError
|
||||
error={templatePreview.error || upgradeTemplate.error || rollbackTemplate.error}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
<MutationError error={install.error || selectVisual.error} />
|
||||
<Divider className="admin-divider" />
|
||||
@@ -517,7 +572,9 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
|
||||
label={check.passed ? "已完成" : "待完善"}
|
||||
/>
|
||||
<span className="admin-row-title">{check.label}</span>
|
||||
{check.help ? <span className="admin-row-meta">{check.help}</span> : null}
|
||||
{!check.passed && check.help ? (
|
||||
<span className="admin-row-meta">{check.help}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{!check.passed ? (
|
||||
|
||||
@@ -1,26 +1,15 @@
|
||||
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";
|
||||
import type {
|
||||
BrandFieldDefinition,
|
||||
BrandTemplateKey,
|
||||
InquiryForm,
|
||||
} from "@personal-brand/api-client";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
useWorkspaceQueries,
|
||||
useTemplateMutations,
|
||||
useFieldMutations,
|
||||
useInquiryFormMutations,
|
||||
} from "./workspace-mutations.js";
|
||||
import { supportsIndustry, type IndustryTarget } from "./workspace-templates.js";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { Button, Card, Form, Input, Modal, Select, Space, Table } from "antd";
|
||||
import type { BrandFieldDefinition, InquiryForm } from "@personal-brand/api-client";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { EmptyState } from "../../components/EmptyState.js";
|
||||
import { MutationError } from "../../components/QueryState.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
import { ListSkeleton } from "../../components/TableSkeleton.js";
|
||||
import { useFieldMutations, useInquiryFormMutations } from "./workspace-mutations.js";
|
||||
import { useFormWorkspaceQueries } from "./workspace-queries.js";
|
||||
|
||||
export const inquiryFieldTypes = [
|
||||
{ value: "text", label: "简短文字" },
|
||||
@@ -34,6 +23,20 @@ export const inquiryFieldTypes = [
|
||||
{ value: "multi-select", label: "多项选择" },
|
||||
];
|
||||
|
||||
const fieldScopes = [
|
||||
{ value: "profile", label: "品牌资料" },
|
||||
{ value: "service", label: "业务提供项" },
|
||||
{ value: "inquiry", label: "咨询表单" },
|
||||
];
|
||||
|
||||
function fieldTypeLabel(type: unknown): string {
|
||||
return inquiryFieldTypes.find((item) => item.value === type)?.label ?? "自定义";
|
||||
}
|
||||
|
||||
function fieldScopeLabel(scope: unknown): string {
|
||||
return fieldScopes.find((item) => item.value === scope)?.label ?? "其他";
|
||||
}
|
||||
|
||||
export function readOptionLabel(option: unknown): string {
|
||||
const value = option as { label?: unknown } | null | undefined;
|
||||
return typeof value?.label === "string" ? value.label : "";
|
||||
@@ -47,16 +50,12 @@ export function normalizeOptionLabels(options: unknown): Array<{ label: string;
|
||||
}
|
||||
|
||||
export function WorkspacePage() {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const { workspace, forms } = useFormWorkspaceQueries();
|
||||
const [fieldOpen, setFieldOpen] = useState(false);
|
||||
const [formOpen, setFormOpen] = useState(false);
|
||||
const [editingForm, setEditingForm] = useState<InquiryForm | null>(null);
|
||||
const [visualTarget, setVisualTarget] = useState<string | null>(null);
|
||||
const [industryTarget, setIndustryTarget] = useState<IndustryTarget | null>(null);
|
||||
const [previewIndustry, setPreviewIndustry] = useState<BrandTemplateKey | null>(null);
|
||||
const [previewVisual, setPreviewVisual] = useState<string | null>(null);
|
||||
const [form] = Form.useForm<Record<string, unknown>>();
|
||||
const [fieldForm] = Form.useForm<Record<string, unknown>>();
|
||||
const [inquiryForm] = Form.useForm<Record<string, unknown>>();
|
||||
const openNewInquiryForm = () => {
|
||||
setEditingForm(null);
|
||||
@@ -71,40 +70,8 @@ export function WorkspacePage() {
|
||||
});
|
||||
setFormOpen(true);
|
||||
};
|
||||
const { query, runtimeQuery, templateCatalog, forms, templatePreview } = useWorkspaceQueries();
|
||||
const previewIndustryKey =
|
||||
previewIndustry ??
|
||||
query.data?.brand.templateKey ??
|
||||
query.data?.installations[0]?.templateKey ??
|
||||
templateCatalog.data?.industries[0]?.key;
|
||||
const previewVisualKey =
|
||||
previewVisual ??
|
||||
runtimeQuery.data?.visualTemplate?.key ??
|
||||
(templateCatalog.data?.visuals ?? []).find((visual) =>
|
||||
supportsIndustry(visual, previewIndustryKey ?? ""),
|
||||
)?.key;
|
||||
const combinationPreview = useQuery({
|
||||
queryKey: ["template-combination-preview", previewIndustryKey, previewVisualKey],
|
||||
queryFn: () =>
|
||||
createApiClient().previewPublicTemplateCombination(
|
||||
previewIndustryKey ?? "",
|
||||
previewVisualKey ?? "",
|
||||
),
|
||||
enabled: Boolean(templateCatalog.data && previewIndustryKey && previewVisualKey),
|
||||
});
|
||||
const compatibleVisuals = (templateCatalog.data?.visuals ?? []).filter((visual) =>
|
||||
supportsIndustry(visual, query.data?.brand?.templateKey ?? ""),
|
||||
);
|
||||
const { visualTemplate, rollbackVisual, install, upgrade, rollback } = useTemplateMutations({
|
||||
runtimeConfig: runtimeQuery.data?.brand?.config ?? undefined,
|
||||
queryClient,
|
||||
});
|
||||
const visualHistory = useQuery({
|
||||
queryKey: ["visual-template-history"],
|
||||
queryFn: () => createApiClient().getAdminVisualTemplateHistory(),
|
||||
});
|
||||
const { createField, removeField } = useFieldMutations({
|
||||
form,
|
||||
form: fieldForm,
|
||||
queryClient,
|
||||
onClose: () => setFieldOpen(false),
|
||||
});
|
||||
@@ -116,309 +83,20 @@ export function WorkspacePage() {
|
||||
setEditingForm(null);
|
||||
},
|
||||
});
|
||||
if (query.isLoading) return <Card loading />;
|
||||
if (query.isError || !query.data) {
|
||||
const errorStatus =
|
||||
query.error instanceof ApiClientError
|
||||
? query.error.status
|
||||
: (query.error as { status?: number } | null)?.status;
|
||||
const expired = errorStatus === 401;
|
||||
return (
|
||||
<Card
|
||||
title={expired ? "登录状态已失效" : "工作空间加载失败"}
|
||||
extra={
|
||||
expired ? (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => window.dispatchEvent(new Event("admin-auth-expired"))}
|
||||
>
|
||||
重新登录
|
||||
</Button>
|
||||
) : (
|
||||
<Button onClick={() => void query.refetch()}>重新请求</Button>
|
||||
)
|
||||
}
|
||||
>
|
||||
{expired
|
||||
? "请重新登录后再访问工作空间。"
|
||||
: query.error instanceof Error
|
||||
? query.error.message
|
||||
: "请检查 API 服务后刷新重试。"}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
const { fields, installations } = query.data;
|
||||
|
||||
return (
|
||||
<div className="admin-stack admin-stack-lg">
|
||||
<QueryState
|
||||
loading={workspace.isLoading || forms.isLoading}
|
||||
error={workspace.error || forms.error}
|
||||
onRetry={() => void Promise.all([workspace.refetch(), forms.refetch()])}
|
||||
>
|
||||
<AdminPageHeader
|
||||
title="模板与表单设置"
|
||||
description="日常小程序内容请从页面配置、业务展示和信任证明进入;这里主要管理模板、咨询入口和负责人设置。"
|
||||
title="咨询表单与字段"
|
||||
description="这里决定客户在小程序里能提交什么。保存后需在“配置与发布”发布,小程序才会更新。"
|
||||
/>
|
||||
<Card title="先完成日常配置">
|
||||
<p className="admin-section-description admin-offset-bottom">
|
||||
下面这些入口面向日常经营,不需要理解模板或技术设置。完成后回到“配置与发布”统一检查并上线。
|
||||
</p>
|
||||
<Space wrap>
|
||||
<Button onClick={() => navigate("/admin/brand")}>配置小程序页面</Button>
|
||||
<Button onClick={() => navigate("/admin/services")}>添加业务展示内容</Button>
|
||||
<Button onClick={() => navigate("/admin/trust")}>补充信任证明</Button>
|
||||
<Button type="primary" onClick={() => navigate("/admin/publication")}>
|
||||
检查并发布
|
||||
</Button>
|
||||
</Space>
|
||||
</Card>
|
||||
<Card title="小程序当前状态" loading={runtimeQuery.isLoading}>
|
||||
{runtimeQuery.isError ? (
|
||||
<StatusTag tone="error" label="公开运行时工作空间暂时无法加载" />
|
||||
) : (
|
||||
<div className="admin-stack">
|
||||
<Space wrap>
|
||||
<StatusTag tone="success" label="小程序数据已同步" />
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`公开业务 ${runtimeQuery.data?.offerings?.length ?? 0} 项`}
|
||||
/>
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`已启用能力 ${runtimeQuery.data?.capabilities?.length ?? 0} 项`}
|
||||
/>
|
||||
</Space>
|
||||
<p className="admin-section-description admin-flush-top">
|
||||
小程序和后台预览会使用同一份已发布内容。这里的能力由当前模板自动提供,通常不需要手动调整。
|
||||
</p>
|
||||
<div className="admin-stack">
|
||||
<h3 className="admin-section-title">已启用的服务能力</h3>
|
||||
{(runtimeQuery.data?.plugins ?? []).map((plugin) => (
|
||||
<Card key={plugin.key} size="small">
|
||||
<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">
|
||||
这项能力已接入当前小程序流程,无需单独配置技术参数。
|
||||
</p>
|
||||
</Card>
|
||||
))}
|
||||
{!runtimeQuery.data?.plugins?.length && (
|
||||
<EmptyState compact title="当前模板未启用能力插件" />
|
||||
)}
|
||||
</div>
|
||||
<Space wrap>
|
||||
<span className="admin-field-label admin-flush">视觉模板</span>
|
||||
<Select
|
||||
value={runtimeQuery.data?.visualTemplate?.key}
|
||||
loading={visualTemplate.isPending}
|
||||
onChange={(key) => setVisualTarget(key ?? null)}
|
||||
options={[
|
||||
...compatibleVisuals.map((visual) => ({ value: visual.key, label: visual.name })),
|
||||
]}
|
||||
/>
|
||||
{runtimeQuery.data?.visualTemplate && (
|
||||
<StatusTag
|
||||
tone="neutral"
|
||||
label={`v${runtimeQuery.data.visualTemplate.version} · ${Object.values(
|
||||
runtimeQuery.data.visualTemplate.variants,
|
||||
).join(" / ")}`}
|
||||
/>
|
||||
)}
|
||||
</Space>
|
||||
<MutationError error={visualTemplate.error} />
|
||||
<div className="admin-stack">
|
||||
<h3 className="admin-section-title">视觉模板切换历史</h3>
|
||||
{visualHistory.data?.history.length ? (
|
||||
<div className="admin-row-line">
|
||||
{visualHistory.data.history.map((item) => (
|
||||
<StatusTag
|
||||
key={`${item.visualTemplateKey}-${item.savedAt}`}
|
||||
tone="neutral"
|
||||
label={`${item.visualTemplateKey} · ${item.savedAt}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState compact title="暂无历史版本" />
|
||||
)}
|
||||
{visualHistory.data?.history.length ? (
|
||||
<Button
|
||||
danger
|
||||
onClick={() => rollbackVisual.mutate()}
|
||||
loading={rollbackVisual.isPending}
|
||||
>
|
||||
回滚上一版视觉模板
|
||||
</Button>
|
||||
) : null}
|
||||
<MutationError error={rollbackVisual.error} />
|
||||
</div>
|
||||
<div className="admin-stack">
|
||||
<h3 className="admin-section-title">可用视觉模板</h3>
|
||||
<Space wrap>
|
||||
{compatibleVisuals.map((visual) => (
|
||||
<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]) => (
|
||||
<span
|
||||
key={name}
|
||||
className="admin-swatch"
|
||||
title={`${name} ${color}`}
|
||||
style={{ "--swatch-color": color } as React.CSSProperties}
|
||||
>
|
||||
{name}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<p className="admin-row-meta admin-flush">
|
||||
{Object.values(visual.variants).join(" / ")}
|
||||
</p>
|
||||
</Card>
|
||||
))}
|
||||
</Space>
|
||||
</div>
|
||||
<Modal
|
||||
title="确认切换视觉模板"
|
||||
open={visualTarget !== null}
|
||||
onCancel={() => setVisualTarget(null)}
|
||||
onOk={() => {
|
||||
if (visualTarget) visualTemplate.mutate(visualTarget);
|
||||
setVisualTarget(null);
|
||||
}}
|
||||
confirmLoading={visualTemplate.isPending}
|
||||
>
|
||||
<Typography.Paragraph>
|
||||
当前模板:{runtimeQuery.data?.visualTemplate?.name ?? "林境建筑画册"}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph>目标模板:林境建筑画册</Typography.Paragraph>
|
||||
<p className="admin-section-description">
|
||||
只会替换视觉主题和模块变体,不会覆盖品牌内容、业务提供项或咨询记录。
|
||||
</p>
|
||||
</Modal>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
<Card
|
||||
title="行业模板"
|
||||
extra={
|
||||
<Space>
|
||||
{(templateCatalog.data?.industries ?? []).map((item) => (
|
||||
<Button
|
||||
key={item.key}
|
||||
onClick={() => setIndustryTarget(item)}
|
||||
loading={install.isPending}
|
||||
>
|
||||
安装{item.name}
|
||||
</Button>
|
||||
))}
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<p className="admin-section-description admin-offset-bottom">
|
||||
模板只提供行业表达样例,不会替代你的品牌定位、经历、作品和合作方式。
|
||||
</p>
|
||||
<StatusTag
|
||||
tone={installations.length ? "info" : "neutral"}
|
||||
label={installations.length ? `已安装 ${installations.length} 个模板` : "尚未安装模板"}
|
||||
/>
|
||||
{installations.length > 0 && (
|
||||
<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 ? (
|
||||
<>
|
||||
<p className="admin-section-description">
|
||||
可升级内容:新增 {templatePreview.data.missingModules.length} 个模块,新增{" "}
|
||||
{templatePreview.data.missingFields.length} 个字段。已有内容不会被覆盖。
|
||||
</p>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => upgrade.mutate()}
|
||||
loading={upgrade.isPending}
|
||||
>
|
||||
确认升级模板
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<div>
|
||||
<StatusTag tone="success" label="已是最新版本" />
|
||||
</div>
|
||||
)}
|
||||
{templatePreview.data?.canRollback && (
|
||||
<Button danger onClick={() => rollback.mutate()} loading={rollback.isPending}>
|
||||
恢复上一版配置基线
|
||||
</Button>
|
||||
)}
|
||||
<MutationError error={templatePreview.error} />
|
||||
<MutationError error={upgrade.error} />
|
||||
<MutationError error={rollback.error} />
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
<MutationError error={install.error} />
|
||||
</Card>
|
||||
<Modal
|
||||
title="确认安装行业模板"
|
||||
open={industryTarget !== null}
|
||||
onCancel={() => setIndustryTarget(null)}
|
||||
onOk={() => {
|
||||
if (industryTarget) install.mutate(industryTarget.key);
|
||||
setIndustryTarget(null);
|
||||
}}
|
||||
confirmLoading={install.isPending}
|
||||
>
|
||||
<h3 className="admin-subhead">{industryTarget?.name}</h3>
|
||||
<p className="admin-section-description">{industryTarget?.description}</p>
|
||||
<p className="admin-section-description">
|
||||
模板会初始化模块、字段和默认业务表达,不会覆盖已有品牌内容。依赖能力:
|
||||
{industryTarget?.capabilities.join("、") || "无"}。
|
||||
</p>
|
||||
</Modal>
|
||||
<Card
|
||||
title="模板组合预览"
|
||||
extra={<Typography.Text type="secondary">高级预览</Typography.Text>}
|
||||
>
|
||||
<p className="admin-section-description admin-offset-bottom">
|
||||
用于负责人确认行业表达和视觉风格是否匹配,日常内容配置通常不需要使用这里。
|
||||
</p>
|
||||
<Space wrap>
|
||||
<Select
|
||||
value={previewIndustryKey ?? null}
|
||||
onChange={(key) => setPreviewIndustry(key)}
|
||||
options={(templateCatalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
/>
|
||||
<Select
|
||||
value={previewVisualKey ?? null}
|
||||
onChange={(key) => setPreviewVisual(key)}
|
||||
options={(templateCatalog.data?.visuals ?? [])
|
||||
.filter((item) => supportsIndustry(item, previewIndustryKey ?? ""))
|
||||
.map((item) => ({ value: item.key, label: item.name }))}
|
||||
/>
|
||||
</Space>
|
||||
{combinationPreview.isLoading ? (
|
||||
<Card loading className="admin-offset-top" />
|
||||
) : combinationPreview.data ? (
|
||||
<div className="admin-stack admin-offset-top">
|
||||
<Typography.Text strong>
|
||||
{combinationPreview.data.industry.name} × {combinationPreview.data.visual.name}
|
||||
</Typography.Text>
|
||||
<Typography.Text type="secondary">
|
||||
能力:
|
||||
{combinationPreview.data.runtime.capabilities.map((item) => item.key).join("、") ||
|
||||
"无"}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
<Card
|
||||
title="动态咨询表单"
|
||||
<AdminSection
|
||||
title="咨询表单"
|
||||
description="每份表单对应小程序里的一个咨询入口;字段与选项由你在这里维护。"
|
||||
extra={
|
||||
<Button type="primary" onClick={openNewInquiryForm}>
|
||||
新增表单
|
||||
@@ -431,17 +109,27 @@ export function WorkspacePage() {
|
||||
<Table
|
||||
rowKey="id"
|
||||
dataSource={forms.data ?? []}
|
||||
pagination={false}
|
||||
locale={{
|
||||
emptyText: (
|
||||
<EmptyState
|
||||
compact
|
||||
title="还没有咨询入口"
|
||||
description="点击右上角「新增表单」,从默认表单开始配置。"
|
||||
description="先新增一份表单,再配置希望客户填写的问题。"
|
||||
/>
|
||||
),
|
||||
}}
|
||||
columns={[
|
||||
{ title: "名称", dataIndex: "name" },
|
||||
{
|
||||
title: "作用范围",
|
||||
render: (_: unknown, item: InquiryForm) => {
|
||||
const offeringName = (workspace.data?.offerings ?? []).find(
|
||||
(offering) => offering.id === item.offeringId,
|
||||
)?.name;
|
||||
return offeringName ? `仅「${offeringName}」` : "品牌通用";
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "版本",
|
||||
dataIndex: "version",
|
||||
@@ -456,7 +144,10 @@ export function WorkspacePage() {
|
||||
title: "状态",
|
||||
dataIndex: "isEnabled",
|
||||
render: (value: boolean) => (
|
||||
<StatusTag tone={value ? "success" : "neutral"} label={value ? "启用" : "停用"} />
|
||||
<StatusTag
|
||||
tone={value ? "success" : "warning"}
|
||||
label={value ? "已启用" : "已停用"}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -486,17 +177,6 @@ export function WorkspacePage() {
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Select
|
||||
size="small"
|
||||
value={item.isEnabled}
|
||||
options={[
|
||||
{ value: true, label: "启用" },
|
||||
{ value: false, label: "停用" },
|
||||
]}
|
||||
onChange={(isEnabled) =>
|
||||
updateForm.mutate({ id: item.id, body: { isEnabled } })
|
||||
}
|
||||
/>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -505,46 +185,29 @@ export function WorkspacePage() {
|
||||
)}
|
||||
<MutationError error={createForm.error} />
|
||||
<MutationError error={updateForm.error} />
|
||||
</Card>
|
||||
<Card
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title="高级自定义字段"
|
||||
extra={
|
||||
<Space>
|
||||
<Typography.Text type="secondary">负责人设置</Typography.Text>
|
||||
<Button type="primary" onClick={() => setFieldOpen(true)}>
|
||||
新增字段
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
description="仅在某个字段需要跨业务复用时才在这里添加;日常问题直接写在表单里即可。"
|
||||
extra={<Button onClick={() => setFieldOpen(true)}>新增字段</Button>}
|
||||
>
|
||||
<Table
|
||||
rowKey="id"
|
||||
dataSource={fields.filter((item) => item.source === "custom")}
|
||||
dataSource={(workspace.data?.fields ?? []).filter((item) => item.source === "custom")}
|
||||
pagination={false}
|
||||
locale={{
|
||||
emptyText: (
|
||||
<EmptyState
|
||||
compact
|
||||
title="还没有高级自定义字段"
|
||||
description="仅在需要跨业务复用的字段时才添加。"
|
||||
description="绝大多数业务不需要用到这一层。"
|
||||
/>
|
||||
),
|
||||
}}
|
||||
columns={[
|
||||
{ title: "字段", dataIndex: "label" },
|
||||
{
|
||||
title: "使用位置",
|
||||
dataIndex: "scope",
|
||||
render: (value) =>
|
||||
({ profile: "品牌资料", service: "业务提供项", inquiry: "咨询表单" })[
|
||||
String(value)
|
||||
] ?? "其他",
|
||||
},
|
||||
{
|
||||
title: "填写方式",
|
||||
dataIndex: "type",
|
||||
render: (value) =>
|
||||
inquiryFieldTypes.find((item) => item.value === value)?.label ?? "自定义",
|
||||
},
|
||||
{ title: "使用位置", dataIndex: "scope", render: fieldScopeLabel },
|
||||
{ title: "填写方式", dataIndex: "type", render: fieldTypeLabel },
|
||||
{
|
||||
title: "操作",
|
||||
render: (_: unknown, item: BrandFieldDefinition) => (
|
||||
@@ -557,19 +220,19 @@ export function WorkspacePage() {
|
||||
/>
|
||||
<MutationError error={createField.error} />
|
||||
<MutationError error={removeField.error} />
|
||||
</Card>
|
||||
</AdminSection>
|
||||
<Modal
|
||||
open={fieldOpen}
|
||||
title="新增自定义字段"
|
||||
onCancel={() => {
|
||||
setFieldOpen(false);
|
||||
form.resetFields();
|
||||
fieldForm.resetFields();
|
||||
}}
|
||||
onOk={() => form.submit()}
|
||||
onOk={() => fieldForm.submit()}
|
||||
confirmLoading={createField.isPending}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
form={fieldForm}
|
||||
layout="vertical"
|
||||
onFinish={(values) =>
|
||||
createField.mutate({
|
||||
@@ -584,41 +247,20 @@ export function WorkspacePage() {
|
||||
} as Omit<BrandFieldDefinition, "id" | "source">)
|
||||
}
|
||||
>
|
||||
<Form.Item name="scope" label="作用域" rules={[{ required: true }]}>
|
||||
<Select
|
||||
options={[
|
||||
{ value: "profile", label: "品牌资料" },
|
||||
{ value: "service", label: "服务" },
|
||||
{ value: "inquiry", label: "咨询表单" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="key" hidden rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="label" label="显示名称" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
<Input placeholder="例如:项目预算区间" />
|
||||
</Form.Item>
|
||||
<Form.Item name="type" label="字段类型" rules={[{ required: true }]}>
|
||||
<Form.Item name="scope" label="使用位置" rules={[{ required: true }]}>
|
||||
<Select options={fieldScopes} />
|
||||
</Form.Item>
|
||||
<Form.Item name="type" label="填写方式" rules={[{ required: true }]}>
|
||||
<Select options={inquiryFieldTypes} />
|
||||
</Form.Item>
|
||||
<Form.Item name="required" label="是否必填" initialValue={false}>
|
||||
<Select
|
||||
options={[
|
||||
"text",
|
||||
"textarea",
|
||||
"number",
|
||||
"date",
|
||||
"select",
|
||||
"multi-select",
|
||||
"image",
|
||||
"url",
|
||||
"phone",
|
||||
].map((value) => ({ value, label: value }))}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="required" label="是否必填">
|
||||
<Select
|
||||
options={[
|
||||
{ value: true, label: "是" },
|
||||
{ value: false, label: "否" },
|
||||
{ value: true, label: "必填" },
|
||||
{ value: false, label: "选填" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
@@ -626,7 +268,7 @@ export function WorkspacePage() {
|
||||
</Modal>
|
||||
<Modal
|
||||
open={formOpen}
|
||||
title={editingForm ? "编辑动态咨询表单" : "新增动态咨询表单"}
|
||||
title={editingForm ? "编辑咨询表单" : "新增咨询表单"}
|
||||
onCancel={() => {
|
||||
setFormOpen(false);
|
||||
setEditingForm(null);
|
||||
@@ -637,7 +279,7 @@ export function WorkspacePage() {
|
||||
width={760}
|
||||
>
|
||||
<p className="admin-section-description admin-offset-bottom">
|
||||
先确定客户要提交的事情,再设置你希望客户填写的问题。保存后还需要在“配置与发布”中检查并发布,才会在小程序生效。
|
||||
先确定客户要提交的事情,再设置希望客户填写的问题。保存后需在“配置与发布”发布,才会在小程序生效。
|
||||
</p>
|
||||
<Form
|
||||
form={inquiryForm}
|
||||
@@ -654,7 +296,11 @@ export function WorkspacePage() {
|
||||
purpose === "quote-request" ? "create-quote" : "create-inquiry";
|
||||
const body = {
|
||||
name: typeof values.name === "string" ? values.name : "",
|
||||
...(typeof values.offeringId === "string" ? { offeringId: values.offeringId } : {}),
|
||||
// 显式传 null 才能解除关联;省略字段会被后端当成「不改动」。
|
||||
offeringId:
|
||||
typeof values.offeringId === "string" && values.offeringId
|
||||
? values.offeringId
|
||||
: null,
|
||||
purpose,
|
||||
targetType,
|
||||
submissionAction,
|
||||
@@ -666,10 +312,7 @@ export function WorkspacePage() {
|
||||
const { options, ...rest } = item;
|
||||
const type = typeof rest.type === "string" ? rest.type : "text";
|
||||
return ["select", "radio", "multi-select"].includes(type)
|
||||
? {
|
||||
...rest,
|
||||
options: normalizeOptionLabels(options),
|
||||
}
|
||||
? { ...rest, options: normalizeOptionLabels(options) }
|
||||
: rest;
|
||||
}),
|
||||
};
|
||||
@@ -702,14 +345,18 @@ export function WorkspacePage() {
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="offeringId" label="关联哪项业务" help="不选择表示这是品牌通用入口。">
|
||||
<Form.Item
|
||||
name="offeringId"
|
||||
label="在哪儿出现"
|
||||
help="留空 = 品牌通用入口,任何页面都能进入;选择某项业务后,这份表单只在该业务的详情页使用。"
|
||||
>
|
||||
<Select
|
||||
allowClear
|
||||
className="admin-field-w-xl"
|
||||
placeholder="品牌级表单"
|
||||
options={(runtimeQuery.data?.offerings ?? []).map((item) => ({
|
||||
options={(workspace.data?.offerings ?? []).map((item) => ({
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
label: item.isEnabled ? item.name : `${item.name}(已停用)`,
|
||||
}))}
|
||||
/>
|
||||
</Form.Item>
|
||||
@@ -781,7 +428,11 @@ export function WorkspacePage() {
|
||||
},
|
||||
]}
|
||||
>
|
||||
{(optionFields, { add, remove }, { errors }) => (
|
||||
{(
|
||||
optionFields,
|
||||
{ add: addOption, remove: removeOption },
|
||||
{ errors },
|
||||
) => (
|
||||
<>
|
||||
{optionFields.map((optionField) => (
|
||||
<div key={optionField.key} className="admin-form-row-center">
|
||||
@@ -796,7 +447,7 @@ export function WorkspacePage() {
|
||||
</Form.Item>
|
||||
<Button
|
||||
danger
|
||||
onClick={() => remove(optionField.name)}
|
||||
onClick={() => removeOption(optionField.name)}
|
||||
className="admin-offset-bottom-xs"
|
||||
>
|
||||
删除
|
||||
@@ -804,7 +455,7 @@ export function WorkspacePage() {
|
||||
</div>
|
||||
))}
|
||||
<Button
|
||||
onClick={() => add({ label: "", value: "" })}
|
||||
onClick={() => addOption({ label: "", value: "" })}
|
||||
className="admin-offset-bottom-xs"
|
||||
>
|
||||
新增选项
|
||||
@@ -823,6 +474,6 @@ export function WorkspacePage() {
|
||||
</Form.List>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
@@ -1,94 +1,9 @@
|
||||
import { message } from "antd";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import type { FormInstance } from "antd";
|
||||
import type {
|
||||
BrandFieldDefinition,
|
||||
BrandTemplateKey,
|
||||
InquiryForm,
|
||||
} from "@personal-brand/api-client";
|
||||
import type { BrandFieldDefinition, InquiryForm } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
|
||||
export function useWorkspaceQueries(client = createApiClient()) {
|
||||
const query = useQuery({
|
||||
queryKey: ["admin-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const runtimeQuery = useQuery({
|
||||
queryKey: ["public-runtime-workspace"],
|
||||
queryFn: () => client.getPublicWorkspace(),
|
||||
});
|
||||
const templateCatalog = useQuery({
|
||||
queryKey: ["template-catalog"],
|
||||
queryFn: () => client.listPublicTemplates(),
|
||||
});
|
||||
const forms = useQuery({
|
||||
queryKey: ["admin-inquiry-forms"],
|
||||
queryFn: () => client.listAdminInquiryForms(),
|
||||
});
|
||||
const templatePreview = useQuery({
|
||||
queryKey: ["admin-template-preview"],
|
||||
queryFn: () => client.getAdminTemplateUpgradePreview(),
|
||||
enabled: Boolean(query.data?.installations?.length),
|
||||
});
|
||||
return { query, runtimeQuery, templateCatalog, forms, templatePreview };
|
||||
}
|
||||
|
||||
interface TemplateMutationOptions {
|
||||
client?: ReturnType<typeof createApiClient>;
|
||||
runtimeConfig: Record<string, unknown> | undefined;
|
||||
queryClient: {
|
||||
invalidateQueries: (options: { queryKey: readonly unknown[] }) => Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
export function useTemplateMutations({
|
||||
client = createApiClient(),
|
||||
runtimeConfig,
|
||||
queryClient,
|
||||
}: TemplateMutationOptions) {
|
||||
const visualTemplate = useMutation({
|
||||
mutationFn: (key: string) =>
|
||||
client.updateAdminBrand({ config: { ...(runtimeConfig ?? {}), visualTemplateKey: key } }),
|
||||
onSuccess: () => {
|
||||
message.success("视觉模板已切换");
|
||||
void queryClient.invalidateQueries({ queryKey: ["public-runtime-workspace"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
},
|
||||
});
|
||||
const rollbackVisual = useMutation({
|
||||
mutationFn: () => client.rollbackAdminVisualTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("视觉模板已回滚");
|
||||
void queryClient.invalidateQueries({ queryKey: ["public-runtime-workspace"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["visual-template-history"] });
|
||||
},
|
||||
});
|
||||
const install = useMutation({
|
||||
mutationFn: (key: BrandTemplateKey) => client.installAdminTemplate(key),
|
||||
onSuccess: () => {
|
||||
message.success("模板已安装");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
||||
},
|
||||
});
|
||||
const upgrade = useMutation({
|
||||
mutationFn: () => client.upgradeAdminTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("模板已升级,已有内容未被覆盖");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-template-preview"] });
|
||||
},
|
||||
});
|
||||
const rollback = useMutation({
|
||||
mutationFn: () => client.rollbackAdminTemplate(),
|
||||
onSuccess: () => {
|
||||
message.success("模板版本已回滚,现有内容未删除");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-template-preview"] });
|
||||
},
|
||||
});
|
||||
return { visualTemplate, rollbackVisual, install, upgrade, rollback };
|
||||
}
|
||||
|
||||
interface FieldMutationOptions {
|
||||
client?: ReturnType<typeof createApiClient>;
|
||||
form: FormInstance<Record<string, unknown>>;
|
||||
@@ -137,7 +52,7 @@ export function useInquiryFormMutations({
|
||||
const createForm = useMutation({
|
||||
mutationFn: (values: {
|
||||
name: string;
|
||||
offeringId?: string;
|
||||
offeringId?: string | null;
|
||||
purpose?: InquiryForm["purpose"];
|
||||
targetType?: InquiryForm["targetType"];
|
||||
submissionAction?: InquiryForm["submissionAction"];
|
||||
@@ -154,7 +69,7 @@ export function useInquiryFormMutations({
|
||||
mutationFn: ({ id, body }: { id: string; body: Partial<InquiryForm> }) =>
|
||||
client.updateAdminInquiryForm(id, {
|
||||
...(body.name === undefined ? {} : { name: body.name }),
|
||||
...(body.offeringId == null ? {} : { offeringId: body.offeringId }),
|
||||
...(body.offeringId === undefined ? {} : { offeringId: body.offeringId }),
|
||||
...(body.fieldsSnapshot === undefined ? {} : { fieldsSnapshot: body.fieldsSnapshot }),
|
||||
...(body.isEnabled === undefined ? {} : { isEnabled: body.isEnabled }),
|
||||
}),
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
|
||||
/**
|
||||
* 咨询表单与自定义字段只需要两份后台数据:品牌工作空间(含本品牌业务提供项)和表单列表。
|
||||
*
|
||||
* 注意:这里不能用 `getPublicWorkspace()` 取业务提供项。公开工作空间不带 brandSlug 时会回退到
|
||||
* 默认品牌,管理其它品牌时下拉框会列出别的品牌的业务(跨品牌串数据)。
|
||||
*/
|
||||
export function useFormWorkspaceQueries(client = createApiClient()) {
|
||||
return {
|
||||
workspace: useQuery({
|
||||
queryKey: ["admin-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
}),
|
||||
forms: useQuery({
|
||||
queryKey: ["admin-inquiry-forms"],
|
||||
queryFn: () => client.listAdminInquiryForms(),
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import type { BrandTemplateKey } from "@personal-brand/api-client";
|
||||
|
||||
export interface IndustryTarget {
|
||||
key: BrandTemplateKey;
|
||||
name: string;
|
||||
description: string;
|
||||
capabilities: string[];
|
||||
}
|
||||
|
||||
export function supportsIndustry(
|
||||
visual: { supportedIndustryTemplates?: unknown },
|
||||
industry: string,
|
||||
): boolean {
|
||||
return (
|
||||
Array.isArray(visual.supportedIndustryTemplates) &&
|
||||
visual.supportedIndustryTemplates.includes(industry)
|
||||
);
|
||||
}
|
||||
@@ -19,10 +19,10 @@ import {
|
||||
AppstoreOutlined,
|
||||
BarsOutlined,
|
||||
CloudUploadOutlined,
|
||||
FormOutlined,
|
||||
MessageOutlined,
|
||||
MobileOutlined,
|
||||
SafetyCertificateOutlined,
|
||||
SettingOutlined,
|
||||
TeamOutlined,
|
||||
ThunderboltOutlined,
|
||||
} from "@ant-design/icons";
|
||||
@@ -218,6 +218,7 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
{ key: "trust", label: "信任内容", icon: <SafetyCertificateOutlined /> },
|
||||
{ key: "services", label: "业务提供项", icon: <BarsOutlined /> },
|
||||
{ key: "inquiries", label: "咨询记录", icon: <MessageOutlined /> },
|
||||
{ key: "workspace", label: "咨询表单与字段", icon: <FormOutlined /> },
|
||||
],
|
||||
},
|
||||
...(role === "editor"
|
||||
@@ -227,7 +228,6 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
type: "group" as const,
|
||||
label: "系统管理",
|
||||
children: [
|
||||
{ key: "workspace", label: "模板与表单设置", icon: <SettingOutlined /> },
|
||||
{ key: "capabilities", label: "能力插件", icon: <ThunderboltOutlined /> },
|
||||
{ key: "members", label: "团队成员", icon: <TeamOutlined /> },
|
||||
],
|
||||
@@ -285,9 +285,7 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
element={<FeaturePublicationPage canManageTemplate={role !== "editor"} />}
|
||||
/>
|
||||
<Route path="/admin/brand" element={<FeatureBrandPage />} />
|
||||
{role === "editor" ? null : (
|
||||
<Route path="/admin/workspace" element={<FeatureWorkspacePage />} />
|
||||
)}
|
||||
<Route path="/admin/workspace" element={<FeatureWorkspacePage />} />
|
||||
{role === "editor" ? null : (
|
||||
<Route path="/admin/capabilities" element={<FeatureCapabilitiesPage />} />
|
||||
)}
|
||||
|
||||
@@ -75,11 +75,11 @@ export interface TemplateMethods {
|
||||
}>;
|
||||
importAdminSampleContent(): Promise<{ imported: boolean; counts: Record<string, number> }>;
|
||||
getAdminTemplateUpgradePreview(): Promise<{
|
||||
templateKey: BrandTemplateKey;
|
||||
currentVersion: string;
|
||||
latestVersion: string;
|
||||
canUpgrade: boolean;
|
||||
canRollback: boolean;
|
||||
missingModules: unknown[];
|
||||
missingFields: unknown[];
|
||||
}>;
|
||||
upgradeAdminTemplate(): Promise<unknown>;
|
||||
|
||||
Reference in new issue
Block a user