上标离子不变色

This commit is contained in:
2026-04-27 14:18:34 +08:00
parent d83e8659ba
commit b19445a771

View File

@@ -1530,12 +1530,12 @@ ${header
// 1. 判断是否是 Base64 图片 (用于点击预览逻辑) // 1. 判断是否是 Base64 图片 (用于点击预览逻辑)
const isBase64Image = /^<img\s+[^>]*src=["']data:image\//i.test(content); const isBase64Image = /^<img\s+[^>]*src=["']data:image\//i.test(content);
// 2. 判断是否是服务器特定的图片路径 (用于拼接域名) // 2. 判断是否是服务器特定的图片路径 (用于拼接域名)
const isServerPathImage = /src=["']\/public\/articleTableImage/i.test(content); const isServerPathImage = /src=["']\/public\/articleTableImage/i.test(content);
let finalContent = content; let finalContent = content;
if (isBase64Image) { if (isBase64Image) {
// 处理 Base64注入点击预览 picPreview // 处理 Base64注入点击预览 picPreview
finalContent = content.replace( finalContent = content.replace(
@@ -1583,7 +1583,7 @@ text-align:left;color:#333;" >${item.table.note ? item.table.note : ''
'pMain', 'pMain',
item.is_h1 ? 'Ptitle' : null, item.is_h1 ? 'Ptitle' : null,
item.is_h2 ? 'Subtitle' : null item.is_h2 ? 'Subtitle' : null
].filter(Boolean).join(' ')}" style="font-family: 'Charis SIL';min-height:12px;" main-state="${item.state}" contenteditable="false" data-id="${item.am_id}" main-id="${item.am_id}" id="${sectionId}">${item.content}</p>`; ].filter(Boolean).join(' ')}" style="font-family: 'Charis SIL';min-height:12px;" main-state="${item.state}" contenteditable="false" data-id="${item.am_id}" main-id="${item.am_id}" id="${sectionId}">${item.content}</p>`;
} }
@@ -1688,7 +1688,7 @@ async function initContentHtml(content, arr, refers, html_type, ArticleData) {
'<div>Supplementary Material for doi: ' + j_artc.doi + '<a class="download" target="_blank" href="' + apiUrl + 'public/articleSUBTAB/' + j_artc.file_sub_table + '"><i class="fa fa-download"></i>Download</a></div></li>'; '<div>Supplementary Material for doi: ' + j_artc.doi + '<a class="download" target="_blank" href="' + apiUrl + 'public/articleSUBTAB/' + j_artc.file_sub_table + '"><i class="fa fa-download"></i>Download</a></div></li>';
} }
if (pdf_list != '') { if (pdf_list != '') {
pdfStr = `<div id="ArticlePdfBox" style="" class="ArticlePdfBox"><p id="ArticlePdf" class="Ptitle " style="margin-bottom:22px;"><b>Supplementary Material</b></p>${pdf_list}</div>` pdfStr = `<div id="ArticlePdfBox" style="" class="ArticlePdfBox"><p id="ArticlePdf" class="Ptitle " style="margin-bottom:22px;"><b>Supplementary Material</b></p>${pdf_list}</div>`
} }
@@ -1870,7 +1870,7 @@ async function initContentHtml(content, arr, refers, html_type, ArticleData) {
await initArticleHtml(arr, refers, html_type, { OriginalDataStr: OriginalDataStr, pdfStr: pdfStr, trackStr: trackStr, mhooStr: mhooStr }) await initArticleHtml(arr, refers, html_type, { OriginalDataStr: OriginalDataStr, pdfStr: pdfStr, trackStr: trackStr, mhooStr: mhooStr })
await initRelatedArticles(ArticleData.a_ID) await initRelatedArticles(ArticleData.a_ID)
await initTopics(ArticleData.a_ID) await initTopics(ArticleData.a_ID)
@@ -1965,12 +1965,29 @@ function initArticleHtml(htmlData, refs, type, otherList) {
nextParagraph.style.color = commonSupColor; nextParagraph.style.color = commonSupColor;
} }
$('.wen_rong .content-box .conthtmn sup').each(function () { $('.wen_rong .content-box .conthtmn sup').each(function () {
var $this = $(this);
var textContent = $(this).text().trim(); // 获取并清理文本内容 var textContent = $(this).text().trim(); // 获取并清理文本内容
// 如果包含 + 或 - (离子的特征),直接跳过,不执行后面的标蓝逻辑 // 如果包含 + 或 - (离子的特征),直接跳过,不执行后面的标蓝逻辑
if (/[+\-]/.test(textContent)) { // if (/[+\-]/.test(textContent)) {
return; // 结束当前循环,进入下一个 sup // return; // 结束当前循环,进入下一个 sup
} // }
var isSign = /[+\--—]/.test(textContent);
if (isSign) {
return; // 只要是这类符号,直接跳过不染色
}
// 2. 检查邻居(防止离子里的数字被误伤)
// 同时也检查邻居是否有这些全角/半角的正负号
var prevText = $this.prev('sup').text().trim();
var nextText = $this.next('sup').text().trim();
var hasSignNeighbor = /[+\--—]/.test(prevText) || /[+\--—]/.test(nextText);
if (hasSignNeighbor && /^\d+$/.test(textContent)) {
return; // 邻居是正负号,判定为离子价态,放行
}
// 判断文本是否是纯数字 // 判断文本是否是纯数字
if (/^\d+$/.test(textContent)) { if (/^\d+$/.test(textContent)) {
this.style.setProperty('color', commonSupColor, 'important'); this.style.setProperty('color', commonSupColor, 'important');
@@ -2382,31 +2399,31 @@ function initArticleHtml(htmlData, refs, type, otherList) {
triggerElements.forEach(el => { triggerElements.forEach(el => {
// 1. 获取当前触发元素的 data-id (对应 nav-data-id) // 1. 获取当前触发元素的 data-id (对应 nav-data-id)
const dataIndex = el.getAttribute('data-id'); const dataIndex = el.getAttribute('data-id');
if (dataIndex) { if (dataIndex) {
// 2. 查找中间导航元素 // 2. 查找中间导航元素
const navElement = document.querySelector(`[nav-data-id="${dataIndex}"]`); const navElement = document.querySelector(`[nav-data-id="${dataIndex}"]`);
if (navElement) { if (navElement) {
// 3. 从导航元素中提取目标 section 的 ID // 3. 从导航元素中提取目标 section 的 ID
const targetSectionId = navElement.getAttribute('data-section'); const targetSectionId = navElement.getAttribute('data-section');
// 4. 绑定点击事件 // 4. 绑定点击事件
el.addEventListener('click', (e) => { el.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
if (targetSectionId) { if (targetSectionId) {
// 5. 查找最终跳转的目标段落 (假设 data-section 的值就是元素的 ID) // 5. 查找最终跳转的目标段落 (假设 data-section 的值就是元素的 ID)
const finalTarget = document.getElementById(targetSectionId); const finalTarget = document.getElementById(targetSectionId);
if (finalTarget) { if (finalTarget) {
console.log(`正在跳转至: #${targetSectionId}`); console.log(`正在跳转至: #${targetSectionId}`);
finalTarget.scrollIntoView({ finalTarget.scrollIntoView({
behavior: 'smooth', behavior: 'smooth',
block: 'start' block: 'start'
}); });
// 可选:添加临时高亮提示用户 // 可选:添加临时高亮提示用户
// highlightElement(finalTarget); // highlightElement(finalTarget);
} else { } else {
@@ -2421,7 +2438,7 @@ function initArticleHtml(htmlData, refs, type, otherList) {
}); });
}); });
} }
@@ -2484,7 +2501,7 @@ function showComments(num) {
, btnAlign: 'c' , btnAlign: 'c'
, moveType: 1 //拖拽模式0或者1 , moveType: 1 //拖拽模式0或者1
, content: shenCode[num], , content: shenCode[num],
success: function(layero, index) { success: function (layero, index) {
// success 会在弹窗 DOM 准备就绪后立即触发 // success 会在弹窗 DOM 准备就绪后立即触发
const wmathElements = layero[0].querySelectorAll('wmath'); const wmathElements = layero[0].querySelectorAll('wmath');
wmathElements.forEach(el => { wmathElements.forEach(el => {
@@ -2500,7 +2517,7 @@ function showComments(num) {
} }
} }
}); });
} }
function getCiteList(a_ID) { function getCiteList(a_ID) {
$('.cite_box .export_cite').html('<div class="loader-01"></div>'); $('.cite_box .export_cite').html('<div class="loader-01"></div>');