From cce6d8d29d1fc1dd8baaff4db380f9bf99bf0c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= Date: Fri, 29 May 2026 16:45:07 +0800 Subject: [PATCH] =?UTF-8?q?md=E6=96=87=E6=9C=AC=E5=9B=BE=E7=89=87=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E4=B8=8D=E5=87=BA=E6=9D=A5=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?ai-=E4=BB=A3=E7=A0=81=E5=BA=93=E4=B8=8D=E6=98=BE=E7=A4=BAAI-RES?= =?UTF-8?q?OURCE=E5=88=9B=E5=BB=BA=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ai/list/index.jsx | 2 +- src/components/render-html.jsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ai/list/index.jsx b/src/ai/list/index.jsx index 562347161..a61c8b20b 100644 --- a/src/ai/list/index.jsx +++ b/src/ai/list/index.jsx @@ -66,7 +66,7 @@ function List(props) { const { projectProperties, id } = row; return { id: id, - name: projectProperties.name, + name: projectProperties.fromOwner === "AI-RESOURCE" ? projectProperties.name.split("/").pop() : projectProperties.name, image: projectProperties.authorImageUrl, isNew: false, url: projectProperties.fullName, diff --git a/src/components/render-html.jsx b/src/components/render-html.jsx index 8ef280932..3d9baaccc 100644 --- a/src/components/render-html.jsx +++ b/src/components/render-html.jsx @@ -135,6 +135,14 @@ export default ({ } } + // 图片加载失败处理 - 使用事件委托统一监听 + const handleImageError = (e) => { + const img = e.target; + // 避免循环调用:如果当前已经是裂图,不再替换 + if (img.src === imgError) return; + img.src = imgError; + }; + useEffect(() => { if (el.current && html) { if (html.match(preRegex)) { @@ -143,8 +151,11 @@ export default ({ } if (el.current) { el.current.addEventListener('click', onAncherHandler) + // 使用事件委托,在父容器上统一监听图片错误事件 + el.current.addEventListener('error', handleImageError, true); return () => { - el.current.removeEventListener('click', onAncherHandler) + el.current.removeEventListener('click', onAncherHandler); + el.current.removeEventListener('error', handleImageError, true); resetMathExpressions() cleanToc() }