fix: 译文直接打开iframe,不再预检HEAD
This commit is contained in:
@@ -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 (状态条驱动) ═══════════════
|
||||||
|
|||||||
@@ -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 (状态条驱动) ═══════════════
|
||||||
|
|||||||
Reference in New Issue
Block a user