Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d923b8cea9 | ||
|
|
a1b29cedee | ||
|
|
34504c0b44 |
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||||
"generatedAt": "2026-10-23T04:57:19.065Z",
|
"generatedAt": "2026-10-23T06:35:59.337Z",
|
||||||
"templates": {
|
"templates": {
|
||||||
"acheng-campus-food": {
|
"acheng-campus-food": {
|
||||||
"real-manifest-interaction": {
|
"real-manifest-interaction": {
|
||||||
@@ -256,5 +256,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sourceTreeHash": "59a9701ea852e1b9240b22b85b67ef37b5bd4830f69436a94bf83066806af59d"
|
"sourceTreeHash": "f39e31a1959e24c07bf60776a0d3c5f28e5745962ca004301ff304daa1430041"
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,9 @@ export function InquiryPreviewEditor({
|
|||||||
const record = query.data?.find((item) => item.id === runtime.key);
|
const record = query.data?.find((item) => item.id === runtime.key);
|
||||||
const field = runtime.fields.find((item) => item.key === fieldKey);
|
const field = runtime.fields.find((item) => item.key === fieldKey);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (field) form.setFieldsValue({ ...field });
|
if (!record || !field) return;
|
||||||
}, [fieldKey, runtime.key, form]);
|
form.setFieldsValue({ ...field });
|
||||||
|
}, [field, fieldKey, form, record, runtime.key]);
|
||||||
const update = (values: Record<string, unknown>) =>
|
const update = (values: Record<string, unknown>) =>
|
||||||
runtime.fields.map((item) => (item.key === fieldKey ? { ...item, ...values } : item));
|
runtime.fields.map((item) => (item.key === fieldKey ? { ...item, ...values } : item));
|
||||||
const save = useMutation({
|
const save = useMutation({
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export function PresentationEditorInspector({
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<PresentationFormPanel
|
<PresentationFormPanel
|
||||||
|
key={`${selectedPage}:${selectedTarget.key}`}
|
||||||
form={form}
|
form={form}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
editableSections={editableSections}
|
editableSections={editableSections}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ export function TemplatePreview({
|
|||||||
<>
|
<>
|
||||||
{!ready && !error ? (
|
{!ready && !error ? (
|
||||||
<div className="template-preview__loading">
|
<div className="template-preview__loading">
|
||||||
<Spin tip="正在加载页面预览" />
|
<Spin description="正在加载页面预览" />
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{error ? (
|
{error ? (
|
||||||
|
|||||||
@@ -348,14 +348,13 @@ export function usePresentationEditorController({
|
|||||||
(page: string) => {
|
(page: string) => {
|
||||||
guardDraft(() => {
|
guardDraft(() => {
|
||||||
setBrandDirty(false);
|
setBrandDirty(false);
|
||||||
form.setFieldsValue(initialValues);
|
|
||||||
resetPreview();
|
resetPreview();
|
||||||
setRecordDraft(undefined);
|
setRecordDraft(undefined);
|
||||||
setInquiryDraft(undefined);
|
setInquiryDraft(undefined);
|
||||||
setActivePage(page);
|
setActivePage(page);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[guardDraft, form, initialValues, resetPreview],
|
[guardDraft, resetPreview],
|
||||||
);
|
);
|
||||||
const selectDetailOffering = useCallback((id: string) => {
|
const selectDetailOffering = useCallback((id: string) => {
|
||||||
setDetailOfferingId(id);
|
setDetailOfferingId(id);
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ export function useBrandPresentationForm({
|
|||||||
return values;
|
return values;
|
||||||
}, [brand, config, sections]);
|
}, [brand, config, sections]);
|
||||||
|
|
||||||
useEffect(() => form.setFieldsValue(initialValues), [form, initialValues]);
|
|
||||||
return { form, initialValues };
|
return { form, initialValues };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,21 @@ const element = (tag) =>
|
|||||||
|
|
||||||
export const View = element("div");
|
export const View = element("div");
|
||||||
export const Text = element("span");
|
export const Text = element("span");
|
||||||
export const Button = element("button");
|
export const Button = React.forwardRef(
|
||||||
|
({ children, className, style, onClick, loading, ...props }, ref) =>
|
||||||
|
React.createElement(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
...props,
|
||||||
|
ref,
|
||||||
|
className,
|
||||||
|
style,
|
||||||
|
onClick,
|
||||||
|
...(loading ? { "aria-busy": "true" } : {}),
|
||||||
|
},
|
||||||
|
children,
|
||||||
|
),
|
||||||
|
);
|
||||||
export const Input = React.forwardRef(({ onInput, ...props }, ref) =>
|
export const Input = React.forwardRef(({ onInput, ...props }, ref) =>
|
||||||
React.createElement("input", {
|
React.createElement("input", {
|
||||||
...props,
|
...props,
|
||||||
@@ -101,16 +115,18 @@ export const Label = element("label");
|
|||||||
export const Image = React.forwardRef(({ mode, src, style, ...props }, ref) => {
|
export const Image = React.forwardRef(({ mode, src, style, ...props }, ref) => {
|
||||||
const key = React.useContext(TemplateAssetContext);
|
const key = React.useContext(TemplateAssetContext);
|
||||||
const assets = React.useContext(TemplatePreviewAssetsContext);
|
const assets = React.useContext(TemplatePreviewAssetsContext);
|
||||||
|
const normalizedSrc = typeof src === "string" ? src.trim() : "";
|
||||||
|
if (!normalizedSrc) return null;
|
||||||
return React.createElement("img", {
|
return React.createElement("img", {
|
||||||
...props,
|
...props,
|
||||||
ref,
|
ref,
|
||||||
src:
|
src:
|
||||||
assets && typeof src === "string" && src.startsWith("/assets/")
|
assets && normalizedSrc.startsWith("/assets/")
|
||||||
? // 导入包资源以 /assets 开头;本地多模板预览的 renderer 可能额外携带包 key 前缀。
|
? // 导入包资源以 /assets 开头;本地多模板预览的 renderer 可能额外携带包 key 前缀。
|
||||||
(assets[src]?.dataUrl ??
|
(assets[normalizedSrc]?.dataUrl ??
|
||||||
assets[src.replace(`/assets/${key}/`, "/assets/")]?.dataUrl ??
|
assets[normalizedSrc.replace(`/assets/${key}/`, "/assets/")]?.dataUrl ??
|
||||||
src)
|
normalizedSrc)
|
||||||
: resolveImageSource(src, key),
|
: resolveImageSource(normalizedSrc, key),
|
||||||
style: { objectFit: mode === "aspectFit" ? "contain" : "cover", ...style },
|
style: { objectFit: mode === "aspectFit" ? "contain" : "cover", ...style },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -24,19 +24,16 @@ export class MemoryClientErrorThrottleStore implements ClientErrorThrottleStore
|
|||||||
private readonly recentErrorIds = new Map<string, number>();
|
private readonly recentErrorIds = new Map<string, number>();
|
||||||
private readonly windows = new Map<string, number[]>();
|
private readonly windows = new Map<string, number[]>();
|
||||||
|
|
||||||
async record(
|
record(report: ClientErrorThrottleReport, now = Date.now()): Promise<ClientErrorThrottleResult> {
|
||||||
report: ClientErrorThrottleReport,
|
|
||||||
now = Date.now(),
|
|
||||||
): Promise<ClientErrorThrottleResult> {
|
|
||||||
this.prune(now);
|
this.prune(now);
|
||||||
|
|
||||||
const dedupeKey = `${report.subject}:${report.errorId}`;
|
const dedupeKey = `${report.subject}:${report.errorId}`;
|
||||||
if (this.recentErrorIds.has(dedupeKey)) return { duplicate: true };
|
if (this.recentErrorIds.has(dedupeKey)) return Promise.resolve({ duplicate: true });
|
||||||
|
|
||||||
this.assertWithinRate(report.subject, now);
|
this.assertWithinRate(report.subject, now);
|
||||||
this.recentErrorIds.set(dedupeKey, now);
|
this.recentErrorIds.set(dedupeKey, now);
|
||||||
this.trimDedupe();
|
this.trimDedupe();
|
||||||
return { duplicate: false };
|
return Promise.resolve({ duplicate: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
private assertWithinRate(subject: string, now: number): void {
|
private assertWithinRate(subject: string, now: number): void {
|
||||||
|
|||||||
@@ -88,6 +88,27 @@ async function verifyCanvasTargets(page: Page, manifest: any, pageKey: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
|
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
|
||||||
|
const consoleWarnings = new WeakMap<Page, string[]>();
|
||||||
|
|
||||||
|
test.beforeEach(({ page }) => {
|
||||||
|
const warnings: string[] = [];
|
||||||
|
consoleWarnings.set(page, warnings);
|
||||||
|
page.on("console", (message) => {
|
||||||
|
const text = message.text();
|
||||||
|
const isWarning =
|
||||||
|
message.type() === "warning" ||
|
||||||
|
(message.type() === "error" &&
|
||||||
|
(text.startsWith("Warning:") ||
|
||||||
|
text.includes("non-boolean attribute") ||
|
||||||
|
text.includes("empty string")));
|
||||||
|
if (isWarning) warnings.push(text);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterEach(({ page }) => {
|
||||||
|
expect(consoleWarnings.get(page) ?? []).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
const brand = {
|
const brand = {
|
||||||
id: "brand-fixture",
|
id: "brand-fixture",
|
||||||
slug: "preview-fixture",
|
slug: "preview-fixture",
|
||||||
|
|||||||
@@ -1,7 +1,28 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { test, expect } from "@playwright/test";
|
import { test, expect, type Page } from "@playwright/test";
|
||||||
|
|
||||||
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
|
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
|
||||||
|
const consoleWarnings = new WeakMap<Page, string[]>();
|
||||||
|
|
||||||
|
test.beforeEach(({ page }) => {
|
||||||
|
const warnings: string[] = [];
|
||||||
|
consoleWarnings.set(page, warnings);
|
||||||
|
page.on("console", (message) => {
|
||||||
|
const text = message.text();
|
||||||
|
const isWarning =
|
||||||
|
message.type() === "warning" ||
|
||||||
|
(message.type() === "error" &&
|
||||||
|
(text.startsWith("Warning:") ||
|
||||||
|
text.includes("non-boolean attribute") ||
|
||||||
|
text.includes("empty string")));
|
||||||
|
if (isWarning) warnings.push(text);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterEach(({ page }) => {
|
||||||
|
expect(consoleWarnings.get(page) ?? []).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
const templateContent = JSON.parse(
|
const templateContent = JSON.parse(
|
||||||
fs.readFileSync("../../packages/template-acheng-campus-food/template.json", "utf8"),
|
fs.readFileSync("../../packages/template-acheng-campus-food/template.json", "utf8"),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user