This commit is contained in:
2026-04-22 14:09:33 +08:00
parent 7b0d387af1
commit 99a75c52f5
4 changed files with 329 additions and 3 deletions

171
getUrl.html Normal file
View File

@@ -0,0 +1,171 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>TMR 文章处理工具</title>
<style>
body { font-family: sans-serif; padding: 20px; line-height: 1.6; }
#tmrUrl {
width: 80%;
height: 35px;
font-size: 16px;
padding: 0 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
.search-btn {
height: 37px;
background-color: #20558a;
color: #fff;
border: none;
padding: 0 20px;
cursor: pointer;
border-radius: 4px;
vertical-align: top;
}
.search-btn:hover { background-color: #163d63; }
/* 结果展示区 */
#resultArea {
margin-top: 30px;
padding: 20px;
border-top: 1px dashed #ccc;
display: none; /* 初始隐藏 */
}
.btn-group { display: flex; gap: 15px; margin-top: 15px; }
.action-btn {
flex: 1;
padding: 15px;
font-size: 16px;
font-weight: bold;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
text-align: center;
transition: transform 0.1s;
}
.action-btn:active { transform: scale(0.98); }
/* 两个按钮的不同颜色 */
.btn-produce { background-color: #28a745; } /* 绿色 - 生产 */
.btn-typeset { background-color: #007bff; } /* 蓝色 - 排版 */
.tip { color: #666; font-size: 14px; margin-bottom: 10px; }
</style>
</head>
<body>
<h3>期刊文章快速跳转工具</h3>
<p>请输入期刊官网文章链接:</p>
<input type="text" id="tmrUrl" placeholder="https://www.tmrjournals.com/article.html?J_num=2&a_id=3578">
<button class="search-btn" onclick="getHtmlInfo()">查询状态</button>
<div id="resultArea">
<p class="tip">检测到自动化排版文章,请选择跳转目标:</p>
<div class="btn-group">
<button id="btnProduce" class="action-btn btn-produce">1. 跳转 Produce (生产)</button>
<button id="btnTypeset" class="action-btn btn-typeset">2. 跳转排版 (GenerateCharts)</button>
</div>
</div>
</body>
<script src="./js/jquery.min.js"></script>
<script>
var apiUrl = "/";
// 提取 URL 参数
function extractParamFromUrl(url, paramName) {
try {
const urlObj = new URL(url);
return urlObj.searchParams.get(paramName);
} catch (e) {
return null;
}
}
function getHtmlInfo() {
const url = $('#tmrUrl').val().trim();
const $resultArea = $('#resultArea');
if (!url) {
alert('请输入文章链接');
return;
}
const a_ID = extractParamFromUrl(url, 'a_id');
if (!a_ID) {
alert('链接中缺少 a_id 参数');
return;
}
// 每次查询前先隐藏结果区
$resultArea.hide();
// 1. 获取文章详情判断类型
$.ajax({
type: 'post',
url: apiUrl + 'api/Article/getArticleDetail',
data: { "article_id": a_ID },
success: function (result) {
if (result.code == 0) {
// 判断是否为新文章 (html_type == 2)
if (result.data.articleInfo.html_type == 2) {
$.ajax({
type: 'post',
url: apiUrl + 'api/Article/getArticleDetailHtmlFor2',
data: { "article_id": a_ID },
success: function (res) {
if (res.code != 0) {
// 显示操作区域
alert('无法获取该文章投稿系统 ID');
}
$resultArea.fadeIn();
// --- 按钮 1: 跳转 Produce ---
$('#btnProduce').off('click').on('click', function() {
// 这里假设 Produce 的链接是这个,如果不对请微调
if(res.data.refers&&res.data.refers.length>0){
var refer_id = res.data.refers[0].p_article_id;
window.open(`https://submission.tmrjournals.com/articleListEditor_B1?id=${refer_id}`, '_blank');
}else{
alert('暂无文章数据');
}
});
// --- 按钮 2: 跳转排版 (需二次查询) ---
$('#btnTypeset').off('click').on('click', function() {
if (res.data.mains && res.data.mains.length > 0) {
var inner_id = res.data.mains[0].article_id;
window.open(`https://submission.tmrjournals.com/GenerateCharts?id=${inner_id}`, '_blank');
} else{
alert('暂无排版数据');
}
});
}
});
} else {
alert('该文章不是自动化排版文章html_type 不等于 2');
}
} else {
alert('获取详情失败:' + (result.msg || '未知错误'));
}
},
error: function() {
alert('网络请求失败,请检查 API 接口');
}
});
}
</script>
</html>

View File

@@ -9,6 +9,9 @@ wmath[data-wrap="inline"] {
width: auto !important;
}
mycite{
color:rgb(0, 130, 170) !important;
}
.outiline-item-h1,.outiline-item-h1 *{
font-weight: bold;
}
@@ -7691,8 +7694,6 @@ function article_con() {
// initArticleNavList(a_ID)
console.log('result at line 7575:', result)
$('.wenzhang .wen_rong .left').css({
'background-color': '#f4fafd',
@@ -8969,7 +8970,154 @@ text-align:left;color:#333;" >${item.table.note ? item.table.note : ''
$('.wen_rong .content-box .conthtmn').append('<div id="ArticleRef" style="margin-left:300px;" class="ArticleRef"><p id="References" class="Ptitle "><b>References</b></p>' + refs + '</div>');
}
initArticleHtml(arr, result.data.refers, html_type)
// 2. 渲染完成后立即重新计算并纠正顺序
updateCitationDisplayWithMyTable('.wen_rong .content-box .conthtmn', result.data.refers, {
writeInnerHTML: true,
hideEmptyCite: true
});
}
/**
* 根据容器内 mycite/autocite 的文档顺序,按 data-id 首次出现编号并写回角标。
*/
function updateCitationDisplayWithMyTable(root, refers, opt) {
opt = opt || {};
var el = typeof root === 'string' ? document.querySelector(root) : root;
if (!el) return { idToNum: {}, order: [] };
// 1) 合法参考文献集合
var validRef = Object.create(null);
(refers || []).forEach(function (r) {
if (r && r.p_refer_id != null) validRef[String(r.p_refer_id)] = true;
});
function parseIds(raw) {
return String(raw || '')
.split(',')
.map(function (s) { return s.trim(); })
.filter(Boolean);
}
function formatNums(nums) {
var a = nums.filter(function (n, i, arr) { return arr.indexOf(n) === i; })
.sort(function (x, y) { return x - y; });
var out = [], i = 0;
while (i < a.length) {
var j = i;
while (j < a.length - 1 && a[j + 1] === a[j] + 1) j++;
if (j - i >= 2) out.push(a[i] + '' + a[j]);
else for (var k = i; k <= j; k++) out.push(String(a[k]));
i = j + 1;
}
return out.join(', ');
}
// 2) 建一个“表格索引”tableId -> 真实表格节点
// 这里把常见承载节点都尝试一遍,你可按官网实际 class 再加
var tableMap = Object.create(null);
var tableCandidates = el.querySelectorAll(
'table, .myeditabledivTable, .wordTableHtml, [data-table-id], [data-amt-id], [main-id]'
);
tableCandidates.forEach(function (node) {
var ids = [
node.getAttribute('data-table-id'),
node.getAttribute('data-amt-id'),
node.getAttribute('data-id'),
node.getAttribute('main-id')
].filter(Boolean).map(String);
ids.forEach(function (id) {
if (!tableMap[id]) tableMap[id] = node;
});
});
// 3) 全局编号状态
var idToNum = Object.create(null);
var order = [];
var nextNum = 1;
function assignId(id) {
id = String(id);
if (!validRef[id]) return null; // 不存在就不显示
if (idToNum[id] == null) {
idToNum[id] = nextNum++;
order.push(id);
}
return idToNum[id];
}
function paintCiteNode(node, ids) {
var nums = [];
ids.forEach(function (id) {
var n = assignId(id);
if (n != null) nums.push(n);
});
nums = nums.filter(function (v, i, a) { return a.indexOf(v) === i; })
.sort(function (a, b) { return a - b; });
if (!nums.length) {
node.removeAttribute('data-cite-label');
if (opt.writeInnerHTML) node.innerHTML = '';
if (opt.hideEmptyCite !== false) node.style.display = 'none';
return;
}
var label = formatNums(nums);
node.setAttribute('data-cite-label', label);
if (opt.writeInnerHTML) node.innerHTML = '[' + label + ']';
}
// 4) 扫描一个子树内 mycite/autocite
function scanCitesInSubtree(node) {
node.querySelectorAll('mycite, autocite').forEach(function (cite) {
paintCiteNode(cite, parseIds(cite.getAttribute('data-id')));
});
}
// 5) 主遍历:遇到 mytable 时“提前注入”对应表格引用
var consumedTableNode = new WeakSet();
function walk(node) {
if (!node || node.nodeType !== 1) return;
var tag = node.tagName.toLowerCase();
// 5.1 引用标签
if (tag === 'mycite' || tag === 'autocite') {
paintCiteNode(node, parseIds(node.getAttribute('data-id')));
return;
}
// 5.2 mytable 占位:在这里扫描对应表格
if (tag === 'mytable') {
var tid = String(node.getAttribute('data-id') || '').trim();
var tableNode = tid ? tableMap[tid] : null;
if (!tableNode) {
// 兜底:按属性再找一次
tableNode = el.querySelector(
'[data-table-id="' + tid + '"], [data-amt-id="' + tid + '"], [data-id="' + tid + '"], [main-id="' + tid + '"]'
);
}
if (tableNode && !consumedTableNode.has(tableNode)) {
scanCitesInSubtree(tableNode); // 在 mytable 位置提前计入
consumedTableNode.add(tableNode); // 后续真实表格处不再重复
}
return;
}
// 5.3 若走到真实表格节点,且已在 mytable 处消费过,则跳过
if (consumedTableNode.has(node)) return;
// 5.4 正常递归
for (var ch = node.firstElementChild; ch; ch = ch.nextElementSibling) {
walk(ch);
}
}
walk(el);
return { idToNum: idToNum, order: order };
}
function initArticleHtml(htmlData, refs, type) {
document.querySelectorAll('wmath').forEach(el => {
const latex = el.getAttribute('data-latex');

View File

@@ -226,7 +226,7 @@ justify-content: space-between;
}
.zuo_zhe_info.show {
max-height: 300px; /* 根据实际内容调整 */
max-height: 1000px; /* 根据实际内容调整 */
opacity: 1;
margin-top:10px;

View File

@@ -95,6 +95,12 @@ margin-left: calc((100% - 190px - 65px)/2) !important;
.thumbnailTableBox {
overflow-x: auto;
}
.zuo_zhe_info.show {
max-height: 1000px; /* 根据实际内容调整 */
opacity: 1;
margin-top:10px;
}
`
document.head.appendChild(style);
@@ -1864,6 +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 initRelatedArticles(ArticleData.a_ID)
await initTopics(ArticleData.a_ID)