diff --git a/apps/admin/design.md b/apps/admin/design.md
index 54844f4..d27f912 100644
--- a/apps/admin/design.md
+++ b/apps/admin/design.md
@@ -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 列表 + 右详情的主从布局 |
+| 咨询表单与字段 | 咨询表单表(名称 / 版本 / 字段数 / 状态 / 操作)+ 新增与编辑弹窗(含选项编辑);高级自定义字段表 + 新增弹窗 |
+| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
+| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
diff --git a/apps/admin/src/features/capabilities/CapabilitiesPage.tsx b/apps/admin/src/features/capabilities/CapabilitiesPage.tsx
index c4d222c..412dc56 100644
--- a/apps/admin/src/features/capabilities/CapabilitiesPage.tsx
+++ b/apps/admin/src/features/capabilities/CapabilitiesPage.tsx
@@ -30,10 +30,8 @@ export function CapabilitiesPage() {
}
title="当前模板没有可配置能力"
- description="安装行业模板后,这里会列出可开关的能力插件。"
- action={
-
- }
+ description="能力的开关由品牌当前使用的行业模板决定;更换行业模板不在本版本范围内。"
+ action={}
/>
)}
diff --git a/apps/admin/src/features/publication/PublicationPage.tsx b/apps/admin/src/features/publication/PublicationPage.tsx
index 16fc30d..89daa4c 100644
--- a/apps/admin/src/features/publication/PublicationPage.tsx
+++ b/apps/admin/src/features/publication/PublicationPage.tsx
@@ -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 && (
-
- )}
- {workspace.data?.installations.length ? (
-
- 当前品牌已安装主模板。模板版本与升级在高级设置中管理。
-
+ {industryKey ? (
+
+
+
+
+ {templatePreview.data?.canUpgrade ? (
+
+ ) : (
+
+ )}
+ {templatePreview.data?.canRollback ? (
+
+ ) : null}
+
+
+ 行业模板随品牌身份固定,只能升级版本、不能更换行业;升级只补充字段与模块,不覆盖已有内容。视觉模板只替换排版风格。
+
+
+
) : null}
@@ -517,7 +572,9 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
label={check.passed ? "已完成" : "待完善"}
/>
{check.label}
- {check.help ? {check.help} : null}
+ {!check.passed && check.help ? (
+ {check.help}
+ ) : null}
{!check.passed ? (
diff --git a/apps/admin/src/features/workspace/WorkspacePage.tsx b/apps/admin/src/features/workspace/WorkspacePage.tsx
index 5f9112a..c127f9f 100644
--- a/apps/admin/src/features/workspace/WorkspacePage.tsx
+++ b/apps/admin/src/features/workspace/WorkspacePage.tsx
@@ -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(null);
- const [visualTarget, setVisualTarget] = useState(null);
- const [industryTarget, setIndustryTarget] = useState(null);
- const [previewIndustry, setPreviewIndustry] = useState(null);
- const [previewVisual, setPreviewVisual] = useState(null);
- const [form] = Form.useForm>();
+ const [fieldForm] = Form.useForm>();
const [inquiryForm] = Form.useForm>();
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 ;
- 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 (
- window.dispatchEvent(new Event("admin-auth-expired"))}
- >
- 重新登录
-
- ) : (
-
- )
- }
- >
- {expired
- ? "请重新登录后再访问工作空间。"
- : query.error instanceof Error
- ? query.error.message
- : "请检查 API 服务后刷新重试。"}
-
- );
- }
- const { fields, installations } = query.data;
+
return (
-
+
void Promise.all([workspace.refetch(), forms.refetch()])}
+ >
-
-
- 下面这些入口面向日常经营,不需要理解模板或技术设置。完成后回到“配置与发布”统一检查并上线。
-
-
-
-
-
-
-
-
-
- {runtimeQuery.isError ? (
-
- ) : (
-
-
-
-
-
-
-
- 小程序和后台预览会使用同一份已发布内容。这里的能力由当前模板自动提供,通常不需要手动调整。
-
-
-
已启用的服务能力
- {(runtimeQuery.data?.plugins ?? []).map((plugin) => (
-
-
- {plugin.displayName}
-
-
-
- 这项能力已接入当前小程序流程,无需单独配置技术参数。
-
-
- ))}
- {!runtimeQuery.data?.plugins?.length && (
-
- )}
-
-
- 视觉模板
-
-
-
-
视觉模板切换历史
- {visualHistory.data?.history.length ? (
-
- {visualHistory.data.history.map((item) => (
-
- ))}
-
- ) : (
-
- )}
- {visualHistory.data?.history.length ? (
-
- ) : null}
-
-
-
-
可用视觉模板
-
- {compatibleVisuals.map((visual) => (
-
- {visual.name}
- {visual.description}
-
- {Object.entries(visual.theme.colors).map(([name, color]) => (
-
- {name}
-
- ))}
-
-
- {Object.values(visual.variants).join(" / ")}
-
-
- ))}
-
-
-
setVisualTarget(null)}
- onOk={() => {
- if (visualTarget) visualTemplate.mutate(visualTarget);
- setVisualTarget(null);
- }}
- confirmLoading={visualTemplate.isPending}
- >
-
- 当前模板:{runtimeQuery.data?.visualTemplate?.name ?? "林境建筑画册"}
-
- 目标模板:林境建筑画册
-
- 只会替换视觉主题和模块变体,不会覆盖品牌内容、业务提供项或咨询记录。
-
-
-
- )}
-
-
- {(templateCatalog.data?.industries ?? []).map((item) => (
-
- ))}
-
- }
- >
-
- 模板只提供行业表达样例,不会替代你的品牌定位、经历、作品和合作方式。
-
-
- {installations.length > 0 && (
-
-
-
- 当前版本:{templatePreview.data?.currentVersion ?? "加载中"},最新版本:
- {templatePreview.data?.latestVersion ?? "加载中"}
-
- {templatePreview.data?.canUpgrade ? (
- <>
-
- 可升级内容:新增 {templatePreview.data.missingModules.length} 个模块,新增{" "}
- {templatePreview.data.missingFields.length} 个字段。已有内容不会被覆盖。
-
-
- >
- ) : (
-
-
-
- )}
- {templatePreview.data?.canRollback && (
-
- )}
-
-
-
-
-
- )}
-
-
- setIndustryTarget(null)}
- onOk={() => {
- if (industryTarget) install.mutate(industryTarget.key);
- setIndustryTarget(null);
- }}
- confirmLoading={install.isPending}
- >
- {industryTarget?.name}
- {industryTarget?.description}
-
- 模板会初始化模块、字段和默认业务表达,不会覆盖已有品牌内容。依赖能力:
- {industryTarget?.capabilities.join("、") || "无"}。
-
-
- 高级预览}
- >
-
- 用于负责人确认行业表达和视觉风格是否匹配,日常内容配置通常不需要使用这里。
-
-
-
- {combinationPreview.isLoading ? (
-
- ) : combinationPreview.data ? (
-
-
- {combinationPreview.data.industry.name} × {combinationPreview.data.visual.name}
-
-
- 能力:
- {combinationPreview.data.runtime.capabilities.map((item) => item.key).join("、") ||
- "无"}
-
-
- ) : null}
-
-
新增表单
@@ -431,17 +109,27 @@ export function WorkspacePage() {
),
}}
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) => (
-
+
),
},
{
@@ -486,17 +177,6 @@ export function WorkspacePage() {
>
编辑
-
- updateForm.mutate({ id: item.id, body: { isEnabled } })
- }
- />
),
},
@@ -505,46 +185,29 @@ export function WorkspacePage() {
)}
-
-
+
- 负责人设置
-
-
- }
+ description="仅在某个字段需要跨业务复用时才在这里添加;日常问题直接写在表单里即可。"
+ extra={}
>
item.source === "custom")}
+ dataSource={(workspace.data?.fields ?? []).filter((item) => item.source === "custom")}
+ pagination={false}
locale={{
emptyText: (
),
}}
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() {
/>
-
+
{
setFieldOpen(false);
- form.resetFields();
+ fieldForm.resetFields();
}}
- onOk={() => form.submit()}
+ onOk={() => fieldForm.submit()}
confirmLoading={createField.isPending}
>
{
setFormOpen(false);
setEditingForm(null);
@@ -637,7 +279,7 @@ export function WorkspacePage() {
width={760}
>
- 先确定客户要提交的事情,再设置你希望客户填写的问题。保存后还需要在“配置与发布”中检查并发布,才会在小程序生效。
+ 先确定客户要提交的事情,再设置希望客户填写的问题。保存后需在“配置与发布”发布,才会在小程序生效。
-
+
({
+ options={(workspace.data?.offerings ?? []).map((item) => ({
value: item.id,
- label: item.name,
+ label: item.isEnabled ? item.name : `${item.name}(已停用)`,
}))}
/>
@@ -781,7 +428,11 @@ export function WorkspacePage() {
},
]}
>
- {(optionFields, { add, remove }, { errors }) => (
+ {(
+ optionFields,
+ { add: addOption, remove: removeOption },
+ { errors },
+ ) => (
<>
{optionFields.map((optionField) => (
@@ -796,7 +447,7 @@ export function WorkspacePage() {
))}
-
+
);
}
diff --git a/apps/admin/src/features/workspace/workspace-mutations.ts b/apps/admin/src/features/workspace/workspace-mutations.ts
index a192de6..2703595 100644
--- a/apps/admin/src/features/workspace/workspace-mutations.ts
+++ b/apps/admin/src/features/workspace/workspace-mutations.ts
@@ -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;
- runtimeConfig: Record | undefined;
- queryClient: {
- invalidateQueries: (options: { queryKey: readonly unknown[] }) => Promise;
- };
-}
-
-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;
form: FormInstance>;
@@ -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 }) =>
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 }),
}),
diff --git a/apps/admin/src/features/workspace/workspace-queries.ts b/apps/admin/src/features/workspace/workspace-queries.ts
new file mode 100644
index 0000000..32a0cfd
--- /dev/null
+++ b/apps/admin/src/features/workspace/workspace-queries.ts
@@ -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(),
+ }),
+ };
+}
diff --git a/apps/admin/src/features/workspace/workspace-templates.ts b/apps/admin/src/features/workspace/workspace-templates.ts
deleted file mode 100644
index 1d5e0d8..0000000
--- a/apps/admin/src/features/workspace/workspace-templates.ts
+++ /dev/null
@@ -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)
- );
-}
diff --git a/apps/admin/src/main.tsx b/apps/admin/src/main.tsx
index 7dc8c32..0b556b2 100644
--- a/apps/admin/src/main.tsx
+++ b/apps/admin/src/main.tsx
@@ -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: },
{ key: "services", label: "业务提供项", icon: },
{ key: "inquiries", label: "咨询记录", icon: },
+ { key: "workspace", label: "咨询表单与字段", icon: },
],
},
...(role === "editor"
@@ -227,7 +228,6 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
type: "group" as const,
label: "系统管理",
children: [
- { key: "workspace", label: "模板与表单设置", icon: },
{ key: "capabilities", label: "能力插件", icon: },
{ key: "members", label: "团队成员", icon: },
],
@@ -285,9 +285,7 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
element={}
/>
} />
- {role === "editor" ? null : (
- } />
- )}
+ } />
{role === "editor" ? null : (
} />
)}
diff --git a/packages/api-client/src/resources/template.ts b/packages/api-client/src/resources/template.ts
index 1a793b5..7480117 100644
--- a/packages/api-client/src/resources/template.ts
+++ b/packages/api-client/src/resources/template.ts
@@ -75,11 +75,11 @@ export interface TemplateMethods {
}>;
importAdminSampleContent(): Promise<{ imported: boolean; counts: Record }>;
getAdminTemplateUpgradePreview(): Promise<{
+ templateKey: BrandTemplateKey;
currentVersion: string;
latestVersion: string;
canUpgrade: boolean;
canRollback: boolean;
- missingModules: unknown[];
missingFields: unknown[];
}>;
upgradeAdminTemplate(): Promise;