md文本图片加载不出来处理,ai-代码库不显示AI-RESOURCE创建者
This commit is contained in:
parent
2f43e7dfe0
commit
cce6d8d29d
|
|
@ -66,7 +66,7 @@ function List(props) {
|
||||||
const { projectProperties, id } = row;
|
const { projectProperties, id } = row;
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
name: projectProperties.name,
|
name: projectProperties.fromOwner === "AI-RESOURCE" ? projectProperties.name.split("/").pop() : projectProperties.name,
|
||||||
image: projectProperties.authorImageUrl,
|
image: projectProperties.authorImageUrl,
|
||||||
isNew: false,
|
isNew: false,
|
||||||
url: projectProperties.fullName,
|
url: projectProperties.fullName,
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,14 @@ export default ({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 图片加载失败处理 - 使用事件委托统一监听
|
||||||
|
const handleImageError = (e) => {
|
||||||
|
const img = e.target;
|
||||||
|
// 避免循环调用:如果当前已经是裂图,不再替换
|
||||||
|
if (img.src === imgError) return;
|
||||||
|
img.src = imgError;
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (el.current && html) {
|
if (el.current && html) {
|
||||||
if (html.match(preRegex)) {
|
if (html.match(preRegex)) {
|
||||||
|
|
@ -143,8 +151,11 @@ export default ({
|
||||||
}
|
}
|
||||||
if (el.current) {
|
if (el.current) {
|
||||||
el.current.addEventListener('click', onAncherHandler)
|
el.current.addEventListener('click', onAncherHandler)
|
||||||
|
// 使用事件委托,在父容器上统一监听图片错误事件
|
||||||
|
el.current.addEventListener('error', handleImageError, true);
|
||||||
return () => {
|
return () => {
|
||||||
el.current.removeEventListener('click', onAncherHandler)
|
el.current.removeEventListener('click', onAncherHandler);
|
||||||
|
el.current.removeEventListener('error', handleImageError, true);
|
||||||
resetMathExpressions()
|
resetMathExpressions()
|
||||||
cleanToc()
|
cleanToc()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue