fix: 清理后台开发态 React 警告
This commit is contained in:
1 parent
3af5611da5
commit
34504c0b44
8 files changed
+42
-9
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:26:00.678Z",
|
||||||
"templates": {
|
"templates": {
|
||||||
"acheng-campus-food": {
|
"acheng-campus-food": {
|
||||||
"real-manifest-interaction": {
|
"real-manifest-interaction": {
|
||||||
@@ -256,5 +256,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sourceTreeHash": "59a9701ea852e1b9240b22b85b67ef37b5bd4830f69436a94bf83066806af59d"
|
"sourceTreeHash": "e9ba4ece3d4b8d81e7afb2f0b62fb9c02468cf9a7da08ef80486c707f2667242"
|
||||||
}
|
}
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -88,6 +88,25 @@ 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")));
|
||||||
|
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",
|
||||||
|
|||||||
Reference in new issue
Block a user