From 83c0d6d0c694c93d35261589cfab8c3f3ede944c Mon Sep 17 00:00:00 2001 From: LaoWang <257199637@qq.com> Date: Tue, 2 Jun 2026 13:56:17 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=91=E6=96=87iframe=E5=86=85?= =?UTF-8?q?=E5=B5=8C=20+=20=E6=97=A0=E8=AF=91=E6=96=87=E6=97=B6=E5=BC=B9?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/app.js | 12 ++++++++++-- static/index.html | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/static/app.js b/static/app.js index 3478829..6b5d573 100644 --- a/static/app.js +++ b/static/app.js @@ -157,8 +157,7 @@ function renderPaper(p) { // Show translation button for ALL papers with arxiv or pdf const paperId = p.arxiv || (p.pdf ? p.pdf.split('/').pop().replace('.pdf','') : null); if (paperId) { - const transUrl = `/papers/translated/${paperId}.pdf`; - links.push(``); + links.push(''); } return `
${p.year||'—'}
${p.title}
@@ -175,6 +174,15 @@ function getPdfLink(p) { function openPdfBtn(btn) { openPdf(btn.dataset.pdf, btn.dataset.title); } +async function openTrans(btn) { + const url = btn.dataset.pdf; + try { + const resp = await fetch(url, { method: 'HEAD' }); + if (resp.ok) { openPdf(url, btn.dataset.title); return; } + } catch(e) {} + alert('该论文译文尚未生成,请稍后再试'); +} + // ═══════════════ PDF VIEWER (状态条驱动) ═══════════════ function getLocalPdfUrl(extUrl) { const am = extUrl.match(/arxiv\.org\/pdf\/(\d+\.\d+)/); diff --git a/static/index.html b/static/index.html index da257ae..0e6a2e4 100644 --- a/static/index.html +++ b/static/index.html @@ -190,8 +190,7 @@ function renderPaper(p) { // Show translation button for ALL papers with arxiv or pdf const paperId = p.arxiv || (p.pdf ? p.pdf.split('/').pop().replace('.pdf','') : null); if (paperId) { - const transUrl = `/papers/translated/${paperId}.pdf`; - links.push(``); + links.push(''); } return `
${p.year||'—'}
${p.title}
@@ -208,6 +207,15 @@ function getPdfLink(p) { function openPdfBtn(btn) { openPdf(btn.dataset.pdf, btn.dataset.title); } +async function openTrans(btn) { + const url = btn.dataset.pdf; + try { + const resp = await fetch(url, { method: 'HEAD' }); + if (resp.ok) { openPdf(url, btn.dataset.title); return; } + } catch(e) {} + alert('该论文译文尚未生成,请稍后再试'); +} + // ═══════════════ PDF VIEWER (状态条驱动) ═══════════════ function getLocalPdfUrl(extUrl) { const am = extUrl.match(/arxiv\.org\/pdf\/(\d+\.\d+)/);