refactor: 模板注册与默认模板收敛到目录驱动
This commit is contained in:
1 parent
f87b26b201
commit
89fdfd7d83
25 files changed
+122
-96
No files matched your search
@@ -51,8 +51,8 @@ export function WorkspacePage() {
|
||||
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>("personal");
|
||||
const [previewVisual, setPreviewVisual] = useState("linjing-editorial");
|
||||
const [previewIndustry, setPreviewIndustry] = useState<BrandTemplateKey | null>(null);
|
||||
const [previewVisual, setPreviewVisual] = useState<string | null>(null);
|
||||
const [form] = Form.useForm<Record<string, unknown>>();
|
||||
const [inquiryForm] = Form.useForm<Record<string, unknown>>();
|
||||
const openNewInquiryForm = () => {
|
||||
@@ -69,14 +69,28 @@ export function WorkspacePage() {
|
||||
setFormOpen(true);
|
||||
};
|
||||
const { query, runtimeQuery, templateCatalog, forms, templatePreview } = useWorkspaceQueries();
|
||||
const previewIndustryKey =
|
||||
previewIndustry ??
|
||||
query.data?.installations[0]?.templateKey ??
|
||||
query.data?.brand.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", previewIndustry, previewVisual],
|
||||
queryKey: ["template-combination-preview", previewIndustryKey, previewVisualKey],
|
||||
queryFn: () =>
|
||||
createApiClient().previewPublicTemplateCombination(previewIndustry, previewVisual),
|
||||
enabled: Boolean(templateCatalog.data),
|
||||
createApiClient().previewPublicTemplateCombination(
|
||||
previewIndustryKey ?? "",
|
||||
previewVisualKey ?? "",
|
||||
),
|
||||
enabled: Boolean(templateCatalog.data && previewIndustryKey && previewVisualKey),
|
||||
});
|
||||
const compatibleVisuals = (templateCatalog.data?.visuals ?? []).filter((visual) =>
|
||||
supportsIndustry(visual, query.data?.brand?.templateKey ?? "personal"),
|
||||
supportsIndustry(visual, query.data?.brand?.templateKey ?? ""),
|
||||
);
|
||||
const { visualTemplate, rollbackVisual, install, upgrade, rollback } = useTemplateMutations({
|
||||
runtimeConfig: runtimeQuery.data?.brand?.config ?? undefined,
|
||||
@@ -185,9 +199,9 @@ export function WorkspacePage() {
|
||||
<Space wrap>
|
||||
<Typography.Text strong>视觉模板</Typography.Text>
|
||||
<Select
|
||||
value={runtimeQuery.data?.visualTemplate?.key ?? "linjing-editorial"}
|
||||
value={runtimeQuery.data?.visualTemplate?.key}
|
||||
loading={visualTemplate.isPending}
|
||||
onChange={(key) => setVisualTarget(key)}
|
||||
onChange={(key) => setVisualTarget(key ?? null)}
|
||||
options={[
|
||||
...compatibleVisuals.map((visual) => ({ value: visual.key, label: visual.name })),
|
||||
]}
|
||||
@@ -354,18 +368,18 @@ export function WorkspacePage() {
|
||||
</Typography.Paragraph>
|
||||
<Space wrap>
|
||||
<Select
|
||||
value={previewIndustry}
|
||||
onChange={setPreviewIndustry}
|
||||
value={previewIndustryKey ?? null}
|
||||
onChange={(key) => setPreviewIndustry(key)}
|
||||
options={(templateCatalog.data?.industries ?? []).map((item) => ({
|
||||
value: item.key,
|
||||
label: item.name,
|
||||
}))}
|
||||
/>
|
||||
<Select
|
||||
value={previewVisual}
|
||||
onChange={setPreviewVisual}
|
||||
value={previewVisualKey ?? null}
|
||||
onChange={(key) => setPreviewVisual(key)}
|
||||
options={(templateCatalog.data?.visuals ?? [])
|
||||
.filter((item) => supportsIndustry(item, previewIndustry))
|
||||
.filter((item) => supportsIndustry(item, previewIndustryKey ?? ""))
|
||||
.map((item) => ({ value: item.key, label: item.name }))}
|
||||
/>
|
||||
</Space>
|
||||
|
||||
Reference in new issue
Block a user