fix: 译文直接打开iframe,不再预检HEAD

This commit is contained in:
2026-06-02 13:59:27 +00:00
parent 83c0d6d0c6
commit 3f62fe903f
2 changed files with 8 additions and 12 deletions

View File

@@ -174,13 +174,11 @@ function getPdfLink(p) {
function openPdfBtn(btn) { openPdf(btn.dataset.pdf, btn.dataset.title); } function openPdfBtn(btn) { openPdf(btn.dataset.pdf, btn.dataset.title); }
async function openTrans(btn) { function openTrans(btn) {
const url = btn.dataset.pdf; const url = btn.dataset.pdf;
try { const title = btn.dataset.title;
const resp = await fetch(url, { method: 'HEAD' }); openPdf(url, title);
if (resp.ok) { openPdf(url, btn.dataset.title); return; } // If translation doesn't exist, the iframe will show error - user can see it
} catch(e) {}
alert('该论文译文尚未生成,请稍后再试');
} }
// ═══════════════ PDF VIEWER (状态条驱动) ═══════════════ // ═══════════════ PDF VIEWER (状态条驱动) ═══════════════

View File

@@ -207,13 +207,11 @@ function getPdfLink(p) {
function openPdfBtn(btn) { openPdf(btn.dataset.pdf, btn.dataset.title); } function openPdfBtn(btn) { openPdf(btn.dataset.pdf, btn.dataset.title); }
async function openTrans(btn) { function openTrans(btn) {
const url = btn.dataset.pdf; const url = btn.dataset.pdf;
try { const title = btn.dataset.title;
const resp = await fetch(url, { method: 'HEAD' }); openPdf(url, title);
if (resp.ok) { openPdf(url, btn.dataset.title); return; } // If translation doesn't exist, the iframe will show error - user can see it
} catch(e) {}
alert('该论文译文尚未生成,请稍后再试');
} }
// ═══════════════ PDF VIEWER (状态条驱动) ═══════════════ // ═══════════════ PDF VIEWER (状态条驱动) ═══════════════