From a1b29cedee8ffa322339d55a99fd5cf6f03dcf75 Mon Sep 17 00:00:00 2001 From: que01 Date: Fri, 23 Oct 2026 14:32:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=BD=E7=95=A5=E7=A9=BA=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=B9=B6=E6=94=B6=E7=B4=A7=E9=A2=84=E8=A7=88=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../raw/completion-evidence.json | 4 ++-- .../features/brand/taro-web-components.jsx | 12 ++++++---- apps/taro/test/browser/admin-editor.spec.ts | 4 +++- .../taro/test/browser/services-editor.spec.ts | 23 ++++++++++++++++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/.codex-tasks/template-audit-execution/raw/completion-evidence.json b/.codex-tasks/template-audit-execution/raw/completion-evidence.json index d69a055..90d8dff 100644 --- a/.codex-tasks/template-audit-execution/raw/completion-evidence.json +++ b/.codex-tasks/template-audit-execution/raw/completion-evidence.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "scope": "模板完成证据登记,保留命令、日志与产物哈希", - "generatedAt": "2026-10-23T06:26:00.678Z", + "generatedAt": "2026-10-23T06:32:05.523Z", "templates": { "acheng-campus-food": { "real-manifest-interaction": { @@ -256,5 +256,5 @@ } } }, - "sourceTreeHash": "e9ba4ece3d4b8d81e7afb2f0b62fb9c02468cf9a7da08ef80486c707f2667242" + "sourceTreeHash": "1e2a205c5faf17468eddc4526c462f9d7d749447d7e43c4087fb6b08f8244223" } diff --git a/apps/admin/src/features/brand/taro-web-components.jsx b/apps/admin/src/features/brand/taro-web-components.jsx index f77ef8e..04f8127 100644 --- a/apps/admin/src/features/brand/taro-web-components.jsx +++ b/apps/admin/src/features/brand/taro-web-components.jsx @@ -115,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 }, }); }); diff --git a/apps/taro/test/browser/admin-editor.spec.ts b/apps/taro/test/browser/admin-editor.spec.ts index 130d8dd..4ccc4ea 100644 --- a/apps/taro/test/browser/admin-editor.spec.ts +++ b/apps/taro/test/browser/admin-editor.spec.ts @@ -98,7 +98,9 @@ test.beforeEach(({ page }) => { const isWarning = message.type() === "warning" || (message.type() === "error" && - (text.startsWith("Warning:") || text.includes("non-boolean attribute"))); + (text.startsWith("Warning:") || + text.includes("non-boolean attribute") || + text.includes("empty string"))); if (isWarning) warnings.push(text); }); }); diff --git a/apps/taro/test/browser/services-editor.spec.ts b/apps/taro/test/browser/services-editor.spec.ts index f8030f6..f4f157c 100644 --- a/apps/taro/test/browser/services-editor.spec.ts +++ b/apps/taro/test/browser/services-editor.spec.ts @@ -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(); + +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"), );