Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d923b8cea9 | ||
|
|
a1b29cedee | ||
|
|
34504c0b44 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"scope": "模板完成证据登记,保留命令、日志与产物哈希",
|
||||
"generatedAt": "2026-10-23T04:57:19.065Z",
|
||||
"generatedAt": "2026-10-23T06:35:59.337Z",
|
||||
"templates": {
|
||||
"acheng-campus-food": {
|
||||
"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 field = runtime.fields.find((item) => item.key === fieldKey);
|
||||
useEffect(() => {
|
||||
if (field) form.setFieldsValue({ ...field });
|
||||
}, [fieldKey, runtime.key, form]);
|
||||
if (!record || !field) return;
|
||||
form.setFieldsValue({ ...field });
|
||||
}, [field, fieldKey, form, record, runtime.key]);
|
||||
const update = (values: Record<string, unknown>) =>
|
||||
runtime.fields.map((item) => (item.key === fieldKey ? { ...item, ...values } : item));
|
||||
const save = useMutation({
|
||||
|
||||
@@ -173,6 +173,7 @@ export function PresentationEditorInspector({
|
||||
</div>
|
||||
) : (
|
||||
<PresentationFormPanel
|
||||
key={`${selectedPage}:${selectedTarget.key}`}
|
||||
form={form}
|
||||
initialValues={initialValues}
|
||||
editableSections={editableSections}
|
||||
|
||||
@@ -146,7 +146,7 @@ export function TemplatePreview({
|
||||
<>
|
||||
{!ready && !error ? (
|
||||
<div className="template-preview__loading">
|
||||
<Spin tip="正在加载页面预览" />
|
||||
<Spin description="正在加载页面预览" />
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
|
||||
@@ -348,14 +348,13 @@ export function usePresentationEditorController({
|
||||
(page: string) => {
|
||||
guardDraft(() => {
|
||||
setBrandDirty(false);
|
||||
form.setFieldsValue(initialValues);
|
||||
resetPreview();
|
||||
setRecordDraft(undefined);
|
||||
setInquiryDraft(undefined);
|
||||
setActivePage(page);
|
||||
});
|
||||
},
|
||||
[guardDraft, form, initialValues, resetPreview],
|
||||
[guardDraft, resetPreview],
|
||||
);
|
||||
const selectDetailOffering = useCallback((id: string) => {
|
||||
setDetailOfferingId(id);
|
||||
|
||||
@@ -89,7 +89,6 @@ export function useBrandPresentationForm({
|
||||
return values;
|
||||
}, [brand, config, sections]);
|
||||
|
||||
useEffect(() => form.setFieldsValue(initialValues), [form, initialValues]);
|
||||
return { form, initialValues };
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,21 @@ const element = (tag) =>
|
||||
|
||||
export const View = element("div");
|
||||
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) =>
|
||||
React.createElement("input", {
|
||||
...props,
|
||||
@@ -101,16 +115,18 @@ export const Label = element("label");
|
||||
export const Image = React.forwardRef(({ mode, src, style, ...props }, ref) => {
|
||||
const key = React.useContext(TemplateAssetContext);
|
||||
const assets = React.useContext(TemplatePreviewAssetsContext);
|
||||
const normalizedSrc = typeof src === "string" ? src.trim() : "";
|
||||
if (!normalizedSrc) return null;
|
||||
return React.createElement("img", {
|
||||
...props,
|
||||
ref,
|
||||
src:
|
||||
assets && typeof src === "string" && src.startsWith("/assets/")
|
||||
assets && normalizedSrc.startsWith("/assets/")
|
||||
? // 导入包资源以 /assets 开头;本地多模板预览的 renderer 可能额外携带包 key 前缀。
|
||||
(assets[src]?.dataUrl ??
|
||||
assets[src.replace(`/assets/${key}/`, "/assets/")]?.dataUrl ??
|
||||
src)
|
||||
: resolveImageSource(src, key),
|
||||
(assets[normalizedSrc]?.dataUrl ??
|
||||
assets[normalizedSrc.replace(`/assets/${key}/`, "/assets/")]?.dataUrl ??
|
||||
normalizedSrc)
|
||||
: resolveImageSource(normalizedSrc, key),
|
||||
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 windows = new Map<string, number[]>();
|
||||
|
||||
async record(
|
||||
report: ClientErrorThrottleReport,
|
||||
now = Date.now(),
|
||||
): Promise<ClientErrorThrottleResult> {
|
||||
record(report: ClientErrorThrottleReport, now = Date.now()): Promise<ClientErrorThrottleResult> {
|
||||
this.prune(now);
|
||||
|
||||
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.recentErrorIds.set(dedupeKey, now);
|
||||
this.trimDedupe();
|
||||
return { duplicate: false };
|
||||
return Promise.resolve({ duplicate: false });
|
||||
}
|
||||
|
||||
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 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 = {
|
||||
id: "brand-fixture",
|
||||
slug: "preview-fixture",
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
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 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(
|
||||
fs.readFileSync("../../packages/template-acheng-campus-food/template.json", "utf8"),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user