修改投稿系统预览文章显示页面

This commit is contained in:
2026-05-15 16:11:13 +08:00
parent 458e16339f
commit 4cc5910df3

View File

@@ -8880,17 +8880,35 @@ ${header
if (!cell || !cell.cellId) return '';
const content = cell.text || '';
// 1. 判断是否是 Base64 图片 (用于点击预览逻辑)
const isBase64Image = /^<img\s+[^>]*src=["']data:image\//i.test(content);
const finalContent = isBase64Image
? content.replace(
// 2. 判断是否是服务器特定的图片路径 (用于拼接域名)
const isServerPathImage = /src=["']\/public\/articleTableImage/i.test(content);
let finalContent = content;
if (isBase64Image) {
// 处理 Base64注入点击预览 picPreview
finalContent = content.replace(
/<img\s+([^>]*?)src=["'](data:image\/[^"']+)["']([^>]*)>/gi,
(match, preAttrs, src, postAttrs) => {
const safeSrc = src.replace(/'/g, "\\'");
return `<img ${preAttrs}src="${src}"${postAttrs} style="cursor:pointer;" onclick="picPreview('${safeSrc}')" />`;
return `<img ${preAttrs}src="${src}"${postAttrs} style="cursor:pointer; max-width:500px;" onclick="picPreview('${safeSrc}')" />`;
}
);
} else if (isServerPathImage) {
// 处理特定路径:拼接域名 https://submission.tmrjournals.com
finalContent = content.replace(
/<img\s+([^>]*?)src=["'](\/public\/articleTableImage[^"']+)["']([^>]*)>/gi,
(match, preAttrs, src, postAttrs) => {
const fullUrl = `https://submission.tmrjournals.com${src}`;
// 建议这里也加上 max-width 兼容性更好
return `<img ${preAttrs}src="${fullUrl}"${postAttrs} style="max-width:500px;" onclick="picPreview('${fullUrl}')" />`;
}
);
}
)
: content;
return `
@@ -9116,7 +9134,7 @@ function updateCitationDisplayWithMyTable(root, refers, opt) {
walk(el);
return { idToNum: idToNum, order: order };
}
}
function initArticleHtml(htmlData, refs, type) {
document.querySelectorAll('wmath').forEach(el => {