feat: 完善模板字段编辑与分类治理

This commit is contained in:
que01 committed 2026-10-11 23:07:53 +08:00
1 parent 91322fa9a0
commit 26bcb2b66e
23 files changed
+618 -237

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
"private": true, "private": true,
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@ant-design/icons": "^6.3.4",
"@personal-brand/api-client": "workspace:*", "@personal-brand/api-client": "workspace:*",
"@tanstack/react-query": "^5.103.1", "@tanstack/react-query": "^5.103.1",
"antd": "^6.6.4", "antd": "^6.6.4",
+3 -1
View File
@@ -1,16 +1,18 @@
import { Image, Input, Space, Typography } from "antd"; import { Image, Input, Space, Typography } from "antd";
interface ImageUrlFieldProps { interface ImageUrlFieldProps {
id?: string;
value?: string; value?: string;
onChange?: (value: string) => void; onChange?: (value: string) => void;
placeholder?: string; placeholder?: string;
} }
export function ImageUrlField({ value, onChange, placeholder }: ImageUrlFieldProps) { export function ImageUrlField({ id, value, onChange, placeholder }: ImageUrlFieldProps) {
const imageUrl = typeof value === "string" ? value.trim() : ""; const imageUrl = typeof value === "string" ? value.trim() : "";
return ( return (
<Space direction="vertical" size={8} style={{ width: "100%" }}> <Space direction="vertical" size={8} style={{ width: "100%" }}>
<Input <Input
{...(id ? { id } : {})}
value={value} value={value}
onChange={(event) => onChange?.(event.target.value)} onChange={(event) => onChange?.(event.target.value)}
placeholder={placeholder ?? "粘贴图片地址"} placeholder={placeholder ?? "粘贴图片地址"}
@@ -1,29 +1,11 @@
import { import { Alert, Button, Col, Form, Row, Space, Typography, message } from "antd";
Alert,
Button,
Col,
Form,
Input,
InputNumber,
Row,
Select,
Space,
Switch,
Typography,
message,
} from "antd";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect, useMemo } from "react"; import { useEffect, useMemo, useState } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import type { import type { Offering, TemplateAdminSection, TrustContent } from "@personal-brand/api-client";
Offering,
TemplateAdminField,
TemplateAdminSection,
TrustContent,
} from "@personal-brand/api-client";
import { createApiClient } from "../lib/api.js"; import { createApiClient } from "../lib/api.js";
import { ImageUrlField } from "./ImageUrlField.js";
import { TemplateListField } from "./TemplateListField.js"; import { TemplateListField } from "./TemplateListField.js";
import { TemplateFieldRenderer } from "./TemplateFieldRenderer.js";
import { MutationError } from "./QueryState.js"; import { MutationError } from "./QueryState.js";
import { import {
applyPresentationValues, applyPresentationValues,
@@ -45,51 +27,33 @@ export interface RecordContentEditorProps {
visualSelection?: { targetKey: string; page: string }; visualSelection?: { targetKey: string; page: string };
} }
function renderField(field: TemplateAdminField) { export function RecordContentFields({
if (field.input === "textarea") section,
return ( sectionKey = section.key,
<Input.TextArea }: {
rows={3} section: TemplateAdminSection;
maxLength={field.maxLength} sectionKey?: string;
showCount={!!field.maxLength} }) {
placeholder={field.placeholder}
/>
);
if (field.input === "image")
return <ImageUrlField {...(field.placeholder ? { placeholder: field.placeholder } : {})} />;
if (field.input === "phone") return <Input type="tel" placeholder={field.placeholder} />;
if (field.input === "number") return <InputNumber min={0} placeholder={field.placeholder} />;
if (field.input === "boolean") return <Switch />;
if (field.input === "select")
return <Select options={(field.options ?? []).map((item) => ({ ...item }))} />;
if (field.input === "multi-select")
return (
<Select
mode="multiple"
options={(field.options ?? []).map((item) => ({ ...item }))}
placeholder={field.placeholder}
/>
);
return <Input placeholder={field.placeholder} />;
}
export function RecordContentFields({ section }: { section: TemplateAdminSection }) {
return ( return (
<Row gutter={16}> <Row gutter={16}>
{section.fields.map((field) => ( {section.fields.map((field) => (
<Col key={field.key} xs={24} md={24}> <Col key={field.key} xs={24} md={24}>
{field.input === "list" ? ( {field.input === "list" ? (
<TemplateListField field={field} name={presentationFieldName(section.key, field.key)} /> <TemplateListField field={field} name={presentationFieldName(sectionKey, field.key)} />
) : ( ) : (
<Form.Item <Form.Item
name={presentationFieldName(section.key, field.key)} name={presentationFieldName(sectionKey, field.key)}
label={field.label} label={field.label}
htmlFor={presentationFieldName(sectionKey, field.key)}
{...(field.help ? { help: field.help } : {})} {...(field.help ? { help: field.help } : {})}
{...(field.required {...(field.required
? { rules: [{ required: true, message: `请填写${field.label}` }] } ? { rules: [{ required: true, message: `请填写${field.label}` }] }
: {})} : {})}
> >
{renderField(field)} <TemplateFieldRenderer
field={field}
id={presentationFieldName(sectionKey, field.key)}
/>
</Form.Item> </Form.Item>
)} )}
</Col> </Col>
@@ -111,6 +75,19 @@ export function RecordContentEditor({
const [form] = Form.useForm<PresentationValues>(); const [form] = Form.useForm<PresentationValues>();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const recordName = "name" in record ? record.name : record.title; const recordName = "name" in record ? record.name : record.title;
const [draftValues, setDraftValues] = useState<PresentationValues>(() =>
Object.fromEntries(
section.fields.map((field) => [
presentationFieldName(section.key, field.key),
readPresentationValue(
record.config,
field.binding,
field,
record as unknown as Record<string, unknown>,
),
]),
),
);
const initialValues = useMemo( const initialValues = useMemo(
() => () =>
Object.fromEntries( Object.fromEntries(
@@ -139,7 +116,9 @@ export function RecordContentEditor({
const changed = Object.fromEntries( const changed = Object.fromEntries(
Object.entries(standard).filter( Object.entries(standard).filter(
([key, value]) => ([key, value]) =>
key !== "config" && value !== (record as unknown as Record<string, unknown>)[key], key !== "config" &&
(key in (record as unknown as Record<string, unknown>) ||
value !== (record as unknown as Record<string, unknown>)[key]),
), ),
); );
const client = createApiClient(); const client = createApiClient();
@@ -164,8 +143,24 @@ export function RecordContentEditor({
form={form} form={form}
layout="vertical" layout="vertical"
initialValues={initialValues} initialValues={initialValues}
onValuesChange={(_, values) => onDraft?.(values)} onValuesChange={(_, values) => {
onFinish={(values) => save.mutate(values)} const currentValues = form.getFieldsValue(true) as PresentationValues;
const next = {
...draftValues,
...values,
...currentValues,
};
setDraftValues(next);
onDraft?.(next);
}}
onFinish={(values) => {
const currentValues = form.getFieldsValue(true) as PresentationValues;
save.mutate({
...draftValues,
...values,
...currentValues,
});
}}
style={{ minHeight: 0, display: "flex", flexDirection: "column" }} style={{ minHeight: 0, display: "flex", flexDirection: "column" }}
> >
<Alert <Alert
@@ -0,0 +1,96 @@
import { Input, InputNumber, Select, Switch } from "antd";
import type { TemplateAdminField } from "@personal-brand/api-client";
import { ImageUrlField } from "./ImageUrlField.js";
export function TemplateFieldRenderer({
field,
id,
value,
onChange,
}: {
field: TemplateAdminField;
id?: string;
value?: unknown;
onChange?: (value: unknown) => void;
}) {
if (field.input === "textarea")
return (
<Input.TextArea
{...(id ? { id } : {})}
value={typeof value === "string" ? value : ""}
onChange={(event) => onChange?.(event.target.value)}
rows={3}
maxLength={field.maxLength}
showCount={!!field.maxLength}
placeholder={field.placeholder}
/>
);
if (field.input === "image")
return (
<ImageUrlField
{...(id ? { id } : {})}
{...(field.placeholder ? { placeholder: field.placeholder } : {})}
{...(typeof value === "string" ? { value } : {})}
{...(onChange ? { onChange: (next: string) => onChange(next) } : {})}
/>
);
if (field.input === "phone")
return (
<Input
{...(id ? { id } : {})}
type="tel"
placeholder={field.placeholder}
value={typeof value === "string" ? value : ""}
onChange={(event) => onChange?.(event.target.value)}
/>
);
if (field.input === "number")
return (
<InputNumber
{...(id ? { id } : {})}
value={typeof value === "number" ? value : null}
onChange={(input) => onChange?.(input ?? undefined)}
min={0}
style={{ width: "100%" }}
placeholder={field.placeholder}
/>
);
if (field.input === "boolean")
return (
<Switch
{...(id ? { id } : {})}
checked={Boolean(value)}
onChange={(checked) => onChange?.(checked)}
/>
);
if (field.input === "select")
return (
<Select
{...(id ? { id } : {})}
options={(field.options ?? []).map((item) => ({ ...item }))}
value={typeof value === "string" || typeof value === "number" ? value : undefined}
onChange={(selected) => onChange?.(selected)}
{...(field.placeholder ? { placeholder: field.placeholder } : {})}
/>
);
if (field.input === "multi-select")
return (
<Select
{...(id ? { id } : {})}
mode="multiple"
options={(field.options ?? []).map((item) => ({ ...item }))}
value={Array.isArray(value) ? value.map(String) : []}
onChange={(selected) => onChange?.(selected)}
placeholder={field.placeholder}
/>
);
return (
<Input
{...(id ? { id } : {})}
value={typeof value === "string" ? value : ""}
onChange={(event) => onChange?.(event.target.value)}
maxLength={field.maxLength}
placeholder={field.placeholder}
/>
);
}
+100 -23
View File
@@ -1,4 +1,10 @@
import { Button, Form, Input, Space } from "antd"; import { Button, Card, Collapse, Empty, Form, Input, Space, Typography } from "antd";
import {
CaretDownOutlined,
CaretUpOutlined,
DeleteOutlined,
PlusOutlined,
} from "@ant-design/icons";
import type { TemplateAdminField } from "@personal-brand/api-client"; import type { TemplateAdminField } from "@personal-brand/api-client";
export function TemplateListField({ export function TemplateListField({
@@ -22,14 +28,81 @@ export function TemplateListField({
]} ]}
> >
{(rows, { add, remove, move }, { errors }) => ( {(rows, { add, remove, move }, { errors }) => (
<Space direction="vertical" style={{ width: "100%" }}> <Space direction="vertical" size={12} style={{ width: "100%" }}>
{rows.map((row, index) => ( {rows.length === 0 ? (
<Space key={row.key} align="start" wrap> <Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={`还没有${field.label}内容`}
/>
) : null}
{rows.map((row, index) => {
const titleField = field.itemFields?.[0];
const primaryTitle = titleField ? (
<Form.Item
noStyle
shouldUpdate={(prev: unknown, next: unknown) => {
const previous = Array.isArray(prev)
? (prev[row.name] as Record<string, unknown> | undefined)
: undefined;
const nextRow = Array.isArray(next)
? (next[row.name] as Record<string, unknown> | undefined)
: undefined;
return previous?.[titleField.key] !== nextRow?.[titleField.key];
}}
>
{({ getFieldValue }) => {
const value = String(
getFieldValue([...name, row.name, titleField.key] as const) ?? "",
);
return (
<Typography.Text
strong
>{`${index + 1}. ${value || titleField.label}`}</Typography.Text>
);
}}
</Form.Item>
) : (
<Typography.Text strong>{`${index + 1}. ${field.label}`}</Typography.Text>
);
return (
<Card
key={row.key}
size="small"
title={primaryTitle}
extra={
<Space size={0}>
<Button
type="text"
size="small"
aria-label={`上移第 ${index + 1} 项`}
icon={<CaretUpOutlined />}
disabled={index === 0}
onClick={() => move(index, index - 1)}
/>
<Button
type="text"
size="small"
aria-label={`下移第 ${index + 1} 项`}
icon={<CaretDownOutlined />}
disabled={index === rows.length - 1}
onClick={() => move(index, index + 1)}
/>
<Button
type="text"
danger
size="small"
aria-label={`删除第 ${index + 1} 项`}
icon={<DeleteOutlined />}
onClick={() => remove(row.name)}
/>
</Space>
}
>
{field.itemFields?.map((itemField) => ( {field.itemFields?.map((itemField) => (
<Form.Item <Form.Item
key={itemField.key} key={itemField.key}
name={[row.name, itemField.key]} name={[row.name, itemField.key]}
label={`${index + 1}. ${itemField.label}`} label={itemField.label}
rules={ rules={
itemField.required === false itemField.required === false
? [] ? []
@@ -39,25 +112,29 @@ export function TemplateListField({
{itemField.input === "textarea" ? <Input.TextArea rows={2} /> : <Input />} {itemField.input === "textarea" ? <Input.TextArea rows={2} /> : <Input />}
</Form.Item> </Form.Item>
))} ))}
<Button onClick={() => remove(row.name)}>删除</Button> </Card>
<Button );
aria-label={`上移第 ${index + 1} 项`} })}
disabled={index === 0} {rows.length > 1 ? (
onClick={() => move(index, index - 1)} <Collapse
> ghost
上移 items={[
</Button> {
<Button key: "sort-help",
aria-label={`下移第 ${index + 1} 项`} label: "排序说明",
disabled={index === rows.length - 1} children: (
onClick={() => move(index, index + 1)} <Typography.Text type="secondary">
> 使用每张卡片右上角的箭头调整顺序,保存后预览也会按当前顺序展示。
下移 </Typography.Text>
</Button> ),
</Space> },
))} ]}
/>
) : null}
<Form.ErrorList errors={errors} /> <Form.ErrorList errors={errors} />
<Button onClick={() => add()}>新增{field.label}</Button> <Button block icon={<PlusOutlined />} onClick={() => add()}>
新增{field.label}
</Button>
</Space> </Space>
)} )}
</Form.List> </Form.List>
@@ -114,7 +114,18 @@
} }
.presentation-editor__inspector .ant-form-item { .presentation-editor__inspector .ant-form-item {
margin-bottom: 24px; margin-bottom: 20px;
}
.presentation-editor__inspector form > section {
padding: 16px;
border: 1px solid #e5e7eb;
border-radius: 12px;
background: #f8fafc;
}
.presentation-editor__inspector form > section + section {
margin-top: 16px;
} }
.presentation-editor__inspector form > .ant-space:last-child { .presentation-editor__inspector form > .ant-space:last-child {
@@ -5,8 +5,6 @@ import {
Col, Col,
Form, Form,
Grid, Grid,
Input,
InputNumber,
Row, Row,
Select, Select,
Segmented, Segmented,
@@ -27,8 +25,8 @@ import type {
import type { BrandProfile } from "@personal-brand/api-client"; import type { BrandProfile } from "@personal-brand/api-client";
import { projectBrandAliases, projectTrustPresentation } from "@personal-brand/api-client"; import { projectBrandAliases, projectTrustPresentation } from "@personal-brand/api-client";
import { createApiClient } from "../../lib/api.js"; import { createApiClient } from "../../lib/api.js";
import { ImageUrlField } from "../../components/ImageUrlField.js";
import { TemplateListField } from "../../components/TemplateListField.js"; import { TemplateListField } from "../../components/TemplateListField.js";
import { TemplateFieldRenderer } from "../../components/TemplateFieldRenderer.js";
import { MutationError } from "../../components/QueryState.js"; import { MutationError } from "../../components/QueryState.js";
import { RecordContentEditor } from "../../components/RecordContentEditor.js"; import { RecordContentEditor } from "../../components/RecordContentEditor.js";
import { TemplatePreview } from "./TemplatePreview.js"; import { TemplatePreview } from "./TemplatePreview.js";
@@ -118,45 +116,6 @@ function trustSection(
}; };
} }
function renderField(field: TemplateAdminField) {
if (field.input === "textarea")
return (
<Input.TextArea
rows={3}
maxLength={field.maxLength}
showCount={!!field.maxLength}
placeholder={field.placeholder}
/>
);
if (field.input === "image")
return <ImageUrlField {...(field.placeholder ? { placeholder: field.placeholder } : {})} />;
if (field.input === "number")
return <InputNumber style={{ width: "100%" }} placeholder={field.placeholder} />;
if (field.input === "boolean")
return (
<Select
options={[
{ value: true, label: "是" },
{ value: false, label: "否" },
]}
/>
);
if (field.input === "select" || field.input === "multi-select")
return (
<Select
{...(field.input === "multi-select" ? { mode: "multiple" as const } : {})}
options={field.options ?? []}
/>
);
return (
<Input
type={field.input === "phone" ? "tel" : "text"}
maxLength={field.maxLength}
placeholder={field.placeholder}
/>
);
}
function previewTargetSource( function previewTargetSource(
section: TemplateAdminSection, section: TemplateAdminSection,
targetKey: string, targetKey: string,
@@ -497,11 +456,28 @@ export function PresentationEditor({
useEffect(() => { useEffect(() => {
setPreviewConfig(config ?? {}); setPreviewConfig(config ?? {});
setPreviewBrandValues({}); setPreviewBrandValues({});
}, [config]); }, [config, initialValues]);
const previewBrand = useMemo( const previewBrand = useMemo(
() => ({ ...brand, ...previewBrandValues, config: previewConfig }), () => ({ ...brand, ...previewBrandValues, config: previewConfig }),
[brand, previewBrandValues, previewConfig], [brand, previewBrandValues, previewConfig],
); );
const recordPreview = useMemo(() => {
if (!recordDraft || !selectedRecord || !recordSection) return undefined;
const config = applyPresentationValues(
selectedRecord.config,
[recordSection],
recordDraft.values,
);
return {
config,
standard: applyStandardEntityValues(
selectedRecord as unknown as Record<string, unknown>,
recordDraft.source,
[recordSection],
recordDraft.values,
),
};
}, [recordDraft, selectedRecord, recordSection]);
const handleValuesChange = useCallback( const handleValuesChange = useCallback(
(changed: PresentationValues, allValues: PresentationValues) => { (changed: PresentationValues, allValues: PresentationValues) => {
setBrandDirty(true); setBrandDirty(true);
@@ -559,14 +535,9 @@ export function PresentationEditor({
}; };
if (!recordDraft || !selectedRecord || !recordSection || recordDraft.id !== selectedRecord.id) if (!recordDraft || !selectedRecord || !recordSection || recordDraft.id !== selectedRecord.id)
return next; return next;
const values = recordDraft.values; const config = recordPreview?.config;
const config = applyPresentationValues(selectedRecord.config, [recordSection], values); const standard = recordPreview?.standard;
const standard = applyStandardEntityValues( if (!config || !standard) return next;
selectedRecord as unknown as Record<string, unknown>,
recordDraft.source,
[recordSection],
values,
);
if (recordDraft.source === "trust") { if (recordDraft.source === "trust") {
next.trustItems = next.trustItems.map((item) => next.trustItems = next.trustItems.map((item) =>
item.id === recordDraft.id item.id === recordDraft.id
@@ -588,24 +559,27 @@ export function PresentationEditor({
item.id === recordDraft.id item.id === recordDraft.id
? { ? {
...item, ...item,
name: typeof standard.name === "string" ? standard.name : item.name, name:
(recordDraft.values[presentationFieldName(recordSection.key, "name")] as string) ||
item.name,
summary: summary:
typeof standard.summary === "string" (recordDraft.values[
? standard.summary presentationFieldName(recordSection.key, "summary")
: typeof standard.description === "string" ] as string) || item.summary,
? standard.description priceText:
: item.summary, (recordDraft.values[
priceText: typeof standard.priceText === "string" ? standard.priceText : null, presentationFieldName(recordSection.key, "priceText")
coverUrl: typeof standard.coverUrl === "string" ? standard.coverUrl : null, ] as string) || null,
coverUrl:
(recordDraft.values[
presentationFieldName(recordSection.key, "coverUrl")
] as string) || null,
presentation: { presentation: {
...item.presentation, ...item.presentation,
...config, ...config,
...(config.presentation && typeof config.presentation === "object" ...(config.presentation && typeof config.presentation === "object"
? (config.presentation as Record<string, unknown>) ? (config.presentation as Record<string, unknown>)
: {}), : {}),
...(typeof config.categoryLabel === "string"
? { categoryLabel: config.categoryLabel }
: {}),
...(typeof config.area === "string" ? { area: config.area } : {}), ...(typeof config.area === "string" ? { area: config.area } : {}),
...(typeof config.series === "string" ? { series: config.series } : {}), ...(typeof config.series === "string" ? { series: config.series } : {}),
...(typeof config.spaceType === "string" ? { spaceType: config.spaceType } : {}), ...(typeof config.spaceType === "string" ? { spaceType: config.spaceType } : {}),
@@ -636,6 +610,7 @@ export function PresentationEditor({
recordDraft, recordDraft,
selectedRecord, selectedRecord,
recordSection, recordSection,
recordPreview,
templateContent, templateContent,
inquiryDraft, inquiryDraft,
inquiryRuntime, inquiryRuntime,
@@ -992,7 +967,7 @@ export function PresentationEditor({
} }
: {})} : {})}
> >
{renderField(field)} <TemplateFieldRenderer field={field} />
</Form.Item> </Form.Item>
)} )}
</Col> </Col>
@@ -38,15 +38,35 @@
min-width: 0; min-width: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-height: 72vh;
padding-right: 4px; padding-right: 4px;
} }
.service-offering-editor__form-scroll { .service-offering-editor__form-scroll {
flex: 1; flex: none;
min-height: 0; max-height: 66vh;
overflow-y: auto; overflow-y: auto;
padding-right: 4px; padding: 20px 16px 24px;
border-radius: 12px;
background: #f8fafc;
border: 1px solid #e5e7eb;
}
.service-offering-editor__form-scroll > .ant-typography:first-child {
margin-top: 0;
}
.service-offering-editor__form-scroll .ant-form-item {
margin-bottom: 20px;
}
.service-offering-editor__form-scroll .ant-typography h5.ant-typography {
margin: 28px 0 4px;
padding-bottom: 8px;
border-bottom: 1px solid #e5e7eb;
}
.service-offering-editor__form-scroll > .ant-typography-secondary {
margin-bottom: 12px;
} }
.service-offering-editor__preview .ant-alert { .service-offering-editor__preview .ant-alert {
@@ -45,6 +45,7 @@ export function ServicesPage() {
const [editingOffering, setEditingOffering] = useState<Offering | null>(null); const [editingOffering, setEditingOffering] = useState<Offering | null>(null);
const [offeringDraftVersion, setOfferingDraftVersion] = useState(0); const [offeringDraftVersion, setOfferingDraftVersion] = useState(0);
const [previewPage, setPreviewPage] = useState<"offerings" | "detail">("detail"); const [previewPage, setPreviewPage] = useState<"offerings" | "detail">("detail");
const [formValues, setFormValues] = useState<Record<string, unknown>>({});
const offerings = useQuery({ const offerings = useQuery({
queryKey: ["admin-offerings"], queryKey: ["admin-offerings"],
queryFn: () => client.listAdminOfferings(), queryFn: () => client.listAdminOfferings(),
@@ -139,7 +140,9 @@ export function ServicesPage() {
: [...detailFields, ...otherFields.filter((field) => field.page === "detail")]; : [...detailFields, ...otherFields.filter((field) => field.page === "detail")];
const previewWorkspaceDraft = useMemo<RuntimeWorkspace | undefined>(() => { const previewWorkspaceDraft = useMemo<RuntimeWorkspace | undefined>(() => {
if (!previewWorkspace.data || !editingOffering) return undefined; if (!previewWorkspace.data || !editingOffering) return undefined;
const values = offeringForm.getFieldsValue(true) as Record<string, unknown>; const values: Record<string, unknown> = Object.keys(formValues).length
? formValues
: (offeringForm.getFieldsValue(true) as Record<string, unknown>);
const config = applyPresentationValues( const config = applyPresentationValues(
editingOffering.config, editingOffering.config,
[{ key: "offering", fields: templateFields }], [{ key: "offering", fields: templateFields }],
@@ -179,9 +182,6 @@ export function ServicesPage() {
...(config.presentation && typeof config.presentation === "object" ...(config.presentation && typeof config.presentation === "object"
? (config.presentation as Record<string, unknown>) ? (config.presentation as Record<string, unknown>)
: {}), : {}),
...(typeof config.categoryLabel === "string"
? { categoryLabel: config.categoryLabel }
: {}),
...(typeof config.area === "string" ? { area: config.area } : {}), ...(typeof config.area === "string" ? { area: config.area } : {}),
...(typeof config.series === "string" ? { series: config.series } : {}), ...(typeof config.series === "string" ? { series: config.series } : {}),
...(typeof config.spaceType === "string" ? { spaceType: config.spaceType } : {}), ...(typeof config.spaceType === "string" ? { spaceType: config.spaceType } : {}),
@@ -206,7 +206,14 @@ export function ServicesPage() {
), ),
brand: previewWorkspace.data.brand, brand: previewWorkspace.data.brand,
}; };
}, [previewWorkspace.data, editingOffering, templateFields, offeringDraftVersion]); }, [
previewWorkspace.data,
editingOffering,
templateFields,
formValues,
offeringDraftVersion,
offeringForm,
]);
const saveOffering = useMutation({ const saveOffering = useMutation({
mutationFn: (values: Record<string, unknown>) => { mutationFn: (values: Record<string, unknown>) => {
const fields = Object.fromEntries( const fields = Object.fromEntries(
@@ -250,6 +257,7 @@ export function ServicesPage() {
}); });
const beginOffering = (item?: Offering) => { const beginOffering = (item?: Offering) => {
setEditingOffering(item ?? null); setEditingOffering(item ?? null);
setPreviewPage("detail");
setOfferingOpen(true); setOfferingOpen(true);
offeringForm.setFieldsValue( offeringForm.setFieldsValue(
item item
@@ -263,10 +271,19 @@ export function ServicesPage() {
sortOrder: item.sortOrder, sortOrder: item.sortOrder,
isEnabled: item.isEnabled, isEnabled: item.isEnabled,
...Object.fromEntries( ...Object.fromEntries(
templateFields.map((field) => [ templateFields.map((field) => {
const value = readPresentationValue(item.config, field.binding, field);
return [
presentationFieldName("offering", field.key), presentationFieldName("offering", field.key),
readPresentationValue(item.config, field.binding, field), value === undefined || value === null || value === ""
]), ? field.input === "select"
? field.options?.[0]?.value
: field.input === "list"
? []
: undefined
: value,
];
}),
), ),
} }
: { : {
@@ -281,6 +298,7 @@ export function ServicesPage() {
), ),
}, },
); );
setFormValues(offeringForm.getFieldsValue(true) as Record<string, unknown>);
}; };
return ( return (
<QueryState <QueryState
@@ -442,7 +460,10 @@ export function ServicesPage() {
className="service-offering-editor__form" className="service-offering-editor__form"
form={offeringForm} form={offeringForm}
layout="vertical" layout="vertical"
onValuesChange={() => setOfferingDraftVersion((version) => version + 1)} onValuesChange={(_, allValues) => {
setFormValues(allValues as Record<string, unknown>);
setOfferingDraftVersion((version) => version + 1);
}}
onFinish={(values) => saveOffering.mutate(values as Record<string, unknown>)} onFinish={(values) => saveOffering.mutate(values as Record<string, unknown>)}
> >
<div className="service-offering-editor__form-scroll"> <div className="service-offering-editor__form-scroll">
@@ -507,6 +528,7 @@ export function ServicesPage() {
...templateFieldSection, ...templateFieldSection,
fields: activeTemplateFields, fields: activeTemplateFields,
}} }}
sectionKey="offering"
/> />
</div> </div>
) : null} ) : null}
@@ -36,25 +36,16 @@ const inquiryFieldTypes = [
{ value: "multi-select", label: "多项选择" }, { value: "multi-select", label: "多项选择" },
]; ];
function optionsToText(options: unknown): string { function readOptionLabel(option: unknown): string {
if (!Array.isArray(options)) return ""; const value = option as { label?: unknown } | null | undefined;
return options return typeof value?.label === "string" ? value.label : "";
.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 }> { function normalizeOptionLabels(options: unknown): Array<{ label: string; value: string }> {
if (typeof value !== "string") return []; return (Array.isArray(options) ? options : [])
return value .map(readOptionLabel)
.split(/\r?\n|、|,/) .filter((label) => label.trim())
.map((item) => item.trim()) .map((label) => ({ label, value: label }));
.filter(Boolean)
.map((item) => ({ label: item, value: item }));
} }
function supportsIndustry( function supportsIndustry(
@@ -541,11 +532,11 @@ export function WorkspacePage() {
name: item.name, name: item.name,
purpose: item.purpose, purpose: item.purpose,
offeringId: item.offeringId ?? undefined, offeringId: item.offeringId ?? undefined,
fieldsSnapshot: item.fieldsSnapshot.map((field) => { fieldsSnapshot: item.fieldsSnapshot.map((field: unknown) => {
const value = field as Record<string, unknown>; const value = field as Record<string, unknown>;
return { return {
...value, ...value,
optionsText: optionsToText(value.options), options: normalizeOptionLabels(value.options),
}; };
}), }),
}); });
@@ -719,12 +710,15 @@ export function WorkspacePage() {
fieldsSnapshot: (Array.isArray(values.fieldsSnapshot) fieldsSnapshot: (Array.isArray(values.fieldsSnapshot)
? values.fieldsSnapshot ? values.fieldsSnapshot
: [] : []
).map((field) => { ).map((field: unknown) => {
const item = field as Record<string, unknown>; const item = field as Record<string, unknown>;
const { optionsText, ...rest } = item; const { options, ...rest } = item;
const type = typeof rest.type === "string" ? rest.type : "text"; const type = typeof rest.type === "string" ? rest.type : "text";
return ["select", "radio", "multi-select"].includes(type) return ["select", "radio", "multi-select"].includes(type)
? { ...rest, options: optionsFromText(optionsText) } ? {
...rest,
options: normalizeOptionLabels(options),
}
: rest; : rest;
}), }),
}; };
@@ -824,18 +818,54 @@ export function WorkspacePage() {
["select", "radio", "multi-select"].includes( ["select", "radio", "multi-select"].includes(
String(getFieldValue(["fieldsSnapshot", name, "type"])), String(getFieldValue(["fieldsSnapshot", name, "type"])),
) ? ( ) ? (
<Form.Item <Form.List
{...restField} name={[name, "options"]}
name={[name, "optionsText"]} rules={[
label="可选内容" {
help="每行填写一个选项,也可以用顿号分隔。" validator: (_, value: unknown) =>
rules={[{ required: true, message: "请至少填写一个选项" }]} Array.isArray(value) &&
value.some((option: unknown) => readOptionLabel(option).trim())
? Promise.resolve()
: Promise.reject(new Error("请至少添加一个选项")),
},
]}
> >
<Input.TextArea {(optionFields, { add, remove }, { errors }) => (
rows={2} <>
placeholder="例如:预算内、需要沟通、暂不确定" {optionFields.map((optionField) => (
/> <Space
key={optionField.key}
align="center"
style={{ display: "flex" }}
>
<Form.Item
{...optionField}
name={[optionField.name, "label"]}
initialValue=""
rules={[{ required: true, message: "请填写选项内容" }]}
style={{ flex: 1, minWidth: 240, marginBottom: 8 }}
>
<Input placeholder="例如:预算内" />
</Form.Item> </Form.Item>
<Button
danger
onClick={() => remove(optionField.name)}
style={{ marginBottom: 8 }}
>
删除
</Button>
</Space>
))}
<Button
onClick={() => add({ label: "", value: "" })}
style={{ marginBottom: 8 }}
>
新增选项
</Button>
<Form.ErrorList errors={errors} />
</>
)}
</Form.List>
) : null ) : null
} }
</Form.Item> </Form.Item>
@@ -0,0 +1,5 @@
-- Normalize offering category storage: categoryKey is authoritative.
-- Display labels are projected from the active template manifest.
UPDATE "Offering"
SET "config" = "config" - 'categoryLabel'
WHERE "config" IS NOT NULL;
-10
View File
@@ -128,7 +128,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
kind: "service", kind: "service",
config: { config: {
categoryKey: "consulting", categoryKey: "consulting",
categoryLabel: "策略咨询",
keywords: ["定位", "诊断", "表达"], keywords: ["定位", "诊断", "表达"],
}, },
}, },
@@ -139,7 +138,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
kind: "subscription", kind: "subscription",
config: { config: {
categoryKey: "advisory", categoryKey: "advisory",
categoryLabel: "长期顾问",
keywords: ["陪跑", "内容", "转化"], keywords: ["陪跑", "内容", "转化"],
}, },
}, },
@@ -248,7 +246,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
priceAmount: 2800, priceAmount: 2800,
config: { config: {
categoryKey: "set-meal", categoryKey: "set-meal",
categoryLabel: "套餐",
keywords: ["现做", "家常", "定制"], keywords: ["现做", "家常", "定制"],
}, },
}, },
@@ -260,7 +257,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
priceAmount: 3200, priceAmount: 3200,
config: { config: {
categoryKey: "set-meal", categoryKey: "set-meal",
categoryLabel: "套餐",
keywords: ["现做", "家常", "定制"], keywords: ["现做", "家常", "定制"],
}, },
}, },
@@ -271,7 +267,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
kind: "service", kind: "service",
config: { config: {
categoryKey: "private-chef", categoryKey: "private-chef",
categoryLabel: "私厨",
keywords: ["现做", "家常", "定制"], keywords: ["现做", "家常", "定制"],
}, },
}, },
@@ -410,7 +405,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
priceText: "¥38,000 - ¥85,000 / 樘", priceText: "¥38,000 - ¥85,000 / 樘",
config: { config: {
categoryKey: "entrance-door", categoryKey: "entrance-door",
categoryLabel: "入户大门",
series: "「万籁」重型天地轴入户系统", series: "「万籁」重型天地轴入户系统",
tag: "主理人年度代表作", tag: "主理人年度代表作",
area: "浙江·莫干山私家山庄", area: "浙江·莫干山私家山庄",
@@ -446,7 +440,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
priceText: "¥42,000 - ¥98,000 / 樘", priceText: "¥42,000 - ¥98,000 / 樘",
config: { config: {
categoryKey: "garden-door", categoryKey: "garden-door",
categoryLabel: "庭院围墙门",
series: "「虚实」透光私家庭院门", series: "「虚实」透光私家庭院门",
tag: "建筑级耐候工艺", tag: "建筑级耐候工艺",
area: "上海·佘山高尔夫别墅", area: "上海·佘山高尔夫别墅",
@@ -481,7 +474,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
priceText: "¥7,800 - ¥16,000 / 樘", priceText: "¥7,800 - ¥16,000 / 樘",
config: { config: {
categoryKey: "interior-door", categoryKey: "interior-door",
categoryLabel: "室内户内门",
series: "「空灵」2.8m - 3.2m 满高通顶系统", series: "「空灵」2.8m - 3.2m 满高通顶系统",
tag: "极简建筑平直感", tag: "极简建筑平直感",
area: "江苏·苏州金鸡湖独栋", area: "江苏·苏州金鸡湖独栋",
@@ -516,7 +508,6 @@ const runtimeSeedTemplates: Record<"personal" | "food" | "doors", RuntimeSeedTem
priceText: "¥18,000 - ¥36,000 / 樘", priceText: "¥18,000 - ¥36,000 / 樘",
config: { config: {
categoryKey: "stealth-door", categoryKey: "stealth-door",
categoryLabel: "装饰隐形门",
series: "「无垠」密室及背景墙融合门", series: "「无垠」密室及背景墙融合门",
tag: "精密收口工程", tag: "精密收口工程",
area: "广东·深圳香蜜湖一号", area: "广东·深圳香蜜湖一号",
@@ -729,7 +720,6 @@ async function ensureRuntimeContent(brandId: string, template: RuntimeSeedTempla
coverUrl: image, coverUrl: image,
config: { config: {
categoryKey: "custom", categoryKey: "custom",
categoryLabel: "自定义业务",
keywords: [], keywords: [],
media: [{ url: image, alt: item.name, type: "image" }], media: [{ url: image, alt: item.name, type: "image" }],
sections: [], sections: [],
+2 -1
View File
@@ -7,6 +7,7 @@ import {
getDefaultVisualTemplateKey, getDefaultVisualTemplateKey,
getTemplatePackageManifestForVisualKey, getTemplatePackageManifestForVisualKey,
} from "@personal-brand/config"; } from "@personal-brand/config";
import type { TemplatePackageManifest } from "@personal-brand/config";
import { PrismaService } from "./prisma.service.js"; import { PrismaService } from "./prisma.service.js";
export interface BrandReleaseSnapshot { export interface BrandReleaseSnapshot {
@@ -16,7 +17,7 @@ export interface BrandReleaseSnapshot {
templateDefinition?: ReturnType<typeof getBrandTemplate> | null; templateDefinition?: ReturnType<typeof getBrandTemplate> | null;
visualTemplateDefinition?: ReturnType<typeof getVisualTemplate> | null; visualTemplateDefinition?: ReturnType<typeof getVisualTemplate> | null;
visualTemplateManifest?: ReturnType<typeof getVisualTemplateManifest> | null; visualTemplateManifest?: ReturnType<typeof getVisualTemplateManifest> | null;
templatePackageManifest?: ReturnType<typeof getTemplatePackageManifestForVisualKey> | null; templatePackageManifest?: TemplatePackageManifest | null;
brand: Record<string, unknown> | null; brand: Record<string, unknown> | null;
installation: Record<string, unknown> | null; installation: Record<string, unknown> | null;
fields: unknown[]; fields: unknown[];
@@ -119,6 +119,14 @@ export class PublicWorkspaceService {
const templatePackageManifest = const templatePackageManifest =
releaseSnapshot.templatePackageManifest ?? releaseSnapshot.templatePackageManifest ??
getTemplatePackageManifestForVisualKey(visualTemplateKey); getTemplatePackageManifestForVisualKey(visualTemplateKey);
const categoryOptions = new Map(
(templatePackageManifest?.admin.sections ?? [])
.filter((section) => section.target === "offering")
.flatMap((section) => section.fields)
.filter((field) => field.binding === "offering.config.categoryKey")
.flatMap((field) => field.options ?? [])
.map((option) => [option.value, option.label]),
);
// 标准 BrandProfile 字段优先,兼容旧模板仍使用的 config 字段。 // 标准 BrandProfile 字段优先,兼容旧模板仍使用的 config 字段。
// 这样后台编辑 description/contactPhone 等标准字段后,旧模板也会立即读取新值。 // 这样后台编辑 description/contactPhone 等标准字段后,旧模板也会立即读取新值。
const runtimeBrand = projectBrandAliases(brandData, brandConfig); const runtimeBrand = projectBrandAliases(brandData, brandConfig);
@@ -177,7 +185,9 @@ export class PublicWorkspaceService {
...this.jsonObject(config.presentation), ...this.jsonObject(config.presentation),
categoryKey: typeof config.categoryKey === "string" ? config.categoryKey : "custom", categoryKey: typeof config.categoryKey === "string" ? config.categoryKey : "custom",
categoryLabel: categoryLabel:
typeof config.categoryLabel === "string" ? config.categoryLabel : "业务提供项", categoryOptions.get(
typeof config.categoryKey === "string" ? config.categoryKey : "custom",
) ?? "",
heroImage: heroImage:
typeof config.detailHero === "string" typeof config.detailHero === "string"
? config.detailHero ? config.detailHero
+15 -9
View File
@@ -1034,14 +1034,6 @@ test("visual template compatibility is enforced by catalog, preview, and brand s
test("seeded public workspaces keep personal, food, and doors brands isolated", async () => { test("seeded public workspaces keep personal, food, and doors brands isolated", async () => {
const expected = [ const expected = [
{
slug: "linran-brand",
id: "00000000-0000-0000-0000-000000000003",
templateKey: "personal",
founder: "林然",
offeringKind: "service",
categoryLabel: "策略咨询",
},
{ {
slug: "default-brand", slug: "default-brand",
id: "00000000-0000-0000-0000-000000000001", id: "00000000-0000-0000-0000-000000000001",
@@ -1089,7 +1081,7 @@ test("seeded public workspaces keep personal, food, and doors brands isolated",
return workspace; return workspace;
}), }),
); );
assert.equal(new Set(workspaces.map((workspace) => workspace.brand.id)).size, 3); assert.equal(new Set(workspaces.map((workspace) => workspace.brand.id)).size, 2);
}); });
test("public workspace uses brand-scoped capability installations and preserves status", async () => { test("public workspace uses brand-scoped capability installations and preserves status", async () => {
@@ -2207,6 +2199,20 @@ test("admin can manage offerings and public endpoint hides disabled offerings",
}); });
assert.equal(listed.statusCode, 200); assert.equal(listed.statusCode, 200);
assert.ok(JSON.parse(listed.body).some((item) => item.id === id)); assert.ok(JSON.parse(listed.body).some((item) => item.id === id));
const withCategory = await request(`/admin/workspace/offerings/${id}`, {
method: "PATCH",
headers: { authorization: `Bearer ${token}` },
payload: { config: { categoryKey: "set-meal" } },
});
assert.equal(withCategory.statusCode, 200);
const preview = await request("/admin/workspace/preview", {
headers: { authorization: `Bearer ${token}` },
});
assert.equal(preview.statusCode, 200);
const draft = JSON.parse(preview.body);
const previewOffering = draft.offerings.find((item) => item.id === id);
assert.equal(previewOffering?.presentation?.categoryKey, "set-meal");
assert.equal(previewOffering?.presentation?.categoryLabel, "套餐");
const publicItem = await request(`/public/offerings/${id}`); const publicItem = await request(`/public/offerings/${id}`);
assert.equal(publicItem.statusCode, 400); assert.equal(publicItem.statusCode, 400);
const publicList = await request("/public/offerings"); const publicList = await request("/public/offerings");
+2 -2
View File
@@ -102,7 +102,7 @@ const adminOffering = {
coverUrl: brand.avatarUrl, coverUrl: brand.avatarUrl,
isEnabled: true, isEnabled: true,
sortOrder: 0, sortOrder: 0,
config: { categoryLabel: "业务提供项" }, config: { categoryKey: "custom" },
}; };
const adminTrust = { const adminTrust = {
id: "schedule-fixture", id: "schedule-fixture",
@@ -139,7 +139,7 @@ const runtimeWorkspace = {
priceText: adminOffering.priceText, priceText: adminOffering.priceText,
coverUrl: adminOffering.coverUrl, coverUrl: adminOffering.coverUrl,
presentation: { presentation: {
categoryLabel: "业务提供项", categoryLabel: "定制餐品",
keywords: [], keywords: [],
details: { background: "餐品详情", designConcept: "", crafts: [], materialsList: [] }, details: { background: "餐品详情", designConcept: "", crafts: [], materialsList: [] },
}, },
@@ -38,7 +38,7 @@ const adminOffering = {
isEnabled: true, isEnabled: true,
sortOrder: 0, sortOrder: 0,
config: { config: {
categoryLabel: "家庭餐", categoryKey: "private-chef",
area: "东门", area: "东门",
series: "预约制", series: "预约制",
spaceType: "8 人聚餐", spaceType: "8 人聚餐",
@@ -67,7 +67,7 @@ const runtimeWorkspace = {
priceText: adminOffering.priceText, priceText: adminOffering.priceText,
coverUrl: adminOffering.coverUrl, coverUrl: adminOffering.coverUrl,
presentation: { presentation: {
categoryLabel: adminOffering.config.categoryLabel, categoryLabel: "私厨",
area: adminOffering.config.area, area: adminOffering.config.area,
series: adminOffering.config.series, series: adminOffering.config.series,
spaceType: adminOffering.config.spaceType, spaceType: adminOffering.config.spaceType,
@@ -509,9 +509,23 @@ export const generatedTemplatePackageRegistry = [
}, },
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "餐品类别", "label": "餐品类别",
"input": "text", "input": "select",
"options": [
{
"value": "set-meal",
"label": "套餐"
},
{
"value": "private-chef",
"label": "私厨"
},
{
"value": "custom",
"label": "定制餐品"
}
],
"previewTarget": "acheng-campus-food.offerings.item" "previewTarget": "acheng-campus-food.offerings.item"
} }
], ],
@@ -615,9 +629,23 @@ export const generatedTemplatePackageRegistry = [
"fields": [ "fields": [
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "餐品类别", "label": "餐品类别",
"input": "text", "input": "select",
"options": [
{
"value": "set-meal",
"label": "套餐"
},
{
"value": "private-chef",
"label": "私厨"
},
{
"value": "custom",
"label": "定制餐品"
}
],
"previewTarget": "acheng-campus-food.detail.dishDetail" "previewTarget": "acheng-campus-food.detail.dishDetail"
}, },
{ {
@@ -1753,9 +1781,31 @@ export const generatedTemplatePackageRegistry = [
}, },
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "案例类别", "label": "案例类别",
"input": "text", "input": "select",
"options": [
{
"value": "entrance-door",
"label": "入户大门"
},
{
"value": "garden-door",
"label": "庭院围墙门"
},
{
"value": "interior-door",
"label": "室内户内门"
},
{
"value": "stealth-door",
"label": "装饰隐形门"
},
{
"value": "custom",
"label": "设计咨询"
}
],
"previewTarget": "linjing-editorial.home.offering" "previewTarget": "linjing-editorial.home.offering"
}, },
{ {
@@ -2189,9 +2239,31 @@ export const generatedTemplatePackageRegistry = [
}, },
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "案例类别", "label": "案例类别",
"input": "text", "input": "select",
"options": [
{
"value": "entrance-door",
"label": "入户大门"
},
{
"value": "garden-door",
"label": "庭院围墙门"
},
{
"value": "interior-door",
"label": "室内户内门"
},
{
"value": "stealth-door",
"label": "装饰隐形门"
},
{
"value": "custom",
"label": "设计咨询"
}
],
"previewTarget": "linjing-editorial.offerings.item" "previewTarget": "linjing-editorial.offerings.item"
}, },
{ {
@@ -2320,9 +2392,31 @@ export const generatedTemplatePackageRegistry = [
"fields": [ "fields": [
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "案例类别", "label": "案例类别",
"input": "text", "input": "select",
"options": [
{
"value": "entrance-door",
"label": "入户大门"
},
{
"value": "garden-door",
"label": "庭院围墙门"
},
{
"value": "interior-door",
"label": "室内户内门"
},
{
"value": "stealth-door",
"label": "装饰隐形门"
},
{
"value": "custom",
"label": "设计咨询"
}
],
"previewTarget": "linjing-editorial.detail.projectDetail" "previewTarget": "linjing-editorial.detail.projectDetail"
}, },
{ {
@@ -3028,4 +3122,4 @@ export const generatedTemplatePackageRegistry = [
} }
]; ];
export const generatedTemplatePackageRegistryHash = export const generatedTemplatePackageRegistryHash =
"dbe686adc4c4efa5a7667c08671381fb28152c688baefcc70bf52655bed3012e"; "56656913de9cbf7f406e705cfea33698f2404b23f3b6fe9423345a8bef57708e";
+12
View File
@@ -235,15 +235,27 @@ export interface TemplatePackageManifest {
key: string; key: string;
title: string; title: string;
description: string; description: string;
page: string;
target: "brand" | "offering" | "trust" | "inquiry"; target: "brand" | "offering" | "trust" | "inquiry";
previewTargets?: readonly {
key: string;
label: string;
composite?: boolean;
children?: readonly string[];
}[];
fields: readonly { fields: readonly {
key: string; key: string;
binding: string; binding: string;
label: string; label: string;
input: string; input: string;
help?: string;
required?: boolean; required?: boolean;
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[]; itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
itemValueKey?: string; itemValueKey?: string;
maxLength?: number;
placeholder?: string;
options?: readonly { value: string; label: string }[];
previewTarget?: string;
}[]; }[];
}[]; }[];
}; };
@@ -496,9 +496,14 @@
}, },
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "餐品类别", "label": "餐品类别",
"input": "text", "input": "select",
"options": [
{ "value": "set-meal", "label": "套餐" },
{ "value": "private-chef", "label": "私厨" },
{ "value": "custom", "label": "定制餐品" }
],
"previewTarget": "acheng-campus-food.offerings.item" "previewTarget": "acheng-campus-food.offerings.item"
} }
], ],
@@ -602,9 +607,14 @@
"fields": [ "fields": [
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "餐品类别", "label": "餐品类别",
"input": "text", "input": "select",
"options": [
{ "value": "set-meal", "label": "套餐" },
{ "value": "private-chef", "label": "私厨" },
{ "value": "custom", "label": "定制餐品" }
],
"previewTarget": "acheng-campus-food.detail.dishDetail" "previewTarget": "acheng-campus-food.detail.dishDetail"
}, },
{ {
@@ -224,9 +224,16 @@
}, },
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "案例类别", "label": "案例类别",
"input": "text", "input": "select",
"options": [
{ "value": "entrance-door", "label": "入户大门" },
{ "value": "garden-door", "label": "庭院围墙门" },
{ "value": "interior-door", "label": "室内户内门" },
{ "value": "stealth-door", "label": "装饰隐形门" },
{ "value": "custom", "label": "设计咨询" }
],
"previewTarget": "linjing-editorial.home.offering" "previewTarget": "linjing-editorial.home.offering"
}, },
{ {
@@ -660,9 +667,16 @@
}, },
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "案例类别", "label": "案例类别",
"input": "text", "input": "select",
"options": [
{ "value": "entrance-door", "label": "入户大门" },
{ "value": "garden-door", "label": "庭院围墙门" },
{ "value": "interior-door", "label": "室内户内门" },
{ "value": "stealth-door", "label": "装饰隐形门" },
{ "value": "custom", "label": "设计咨询" }
],
"previewTarget": "linjing-editorial.offerings.item" "previewTarget": "linjing-editorial.offerings.item"
}, },
{ {
@@ -791,9 +805,16 @@
"fields": [ "fields": [
{ {
"key": "categoryLabel", "key": "categoryLabel",
"binding": "offering.config.categoryLabel", "binding": "offering.config.categoryKey",
"label": "案例类别", "label": "案例类别",
"input": "text", "input": "select",
"options": [
{ "value": "entrance-door", "label": "入户大门" },
{ "value": "garden-door", "label": "庭院围墙门" },
{ "value": "interior-door", "label": "室内户内门" },
{ "value": "stealth-door", "label": "装饰隐形门" },
{ "value": "custom", "label": "设计咨询" }
],
"previewTarget": "linjing-editorial.detail.projectDetail" "previewTarget": "linjing-editorial.detail.projectDetail"
}, },
{ {
+3
View File
@@ -32,6 +32,9 @@ importers:
apps/admin: apps/admin:
dependencies: dependencies:
'@ant-design/icons':
specifier: ^6.3.4
version: 6.3.4(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
'@personal-brand/api-client': '@personal-brand/api-client':
specifier: workspace:* specifier: workspace:*
version: link:../../packages/api-client version: link:../../packages/api-client
+1 -1
View File
@@ -101,7 +101,7 @@ export function diagnoseTemplate(manifest, source, file = "taro/index.tsx") {
image: "offering.config.detailHero", image: "offering.config.detailHero",
desc: "offering.summary", desc: "offering.summary",
priceRange: "offering.priceText", priceRange: "offering.priceText",
category: "offering.config.categoryLabel", category: "offering.config.categoryKey",
area: "offering.config.area", area: "offering.config.area",
series: "offering.config.series", series: "offering.config.series",
keywords: "offering.config.keywords", keywords: "offering.config.keywords",