Update App.jsx via upload script - 2026-11-09 15:53:54
This commit is contained in:
parent
2007f2e601
commit
e8d862b644
18
App.jsx
18
App.jsx
|
|
@ -4914,7 +4914,7 @@ function MainApp({ username, onLogout }) {
|
|||
</div>
|
||||
{aiImportPreciseInfo && (aiImportPreciseInfo.doc ? (
|
||||
<div className="disclaimer" style={{ background: '#E8F5EF', marginTop: -6 }}>
|
||||
✓ 原版彩页已生成({aiImportPreciseInfo.doc.pages} 页),导入后在产品详情的"原版彩页"里查看、翻译和下载。
|
||||
✓ 原版彩页已生成({aiImportPreciseInfo.doc.pages} 页),正在后台自动翻译成英语、俄语、西班牙语(每种约 1 分钟)。导入后在产品详情的"原版彩页"里切换语言查看、下载。
|
||||
</div>
|
||||
) : (
|
||||
<div className="disclaimer" style={{ background: '#FDECEC', color: 'var(--led-red)', marginTop: -6 }}>
|
||||
|
|
@ -9225,10 +9225,20 @@ function PreciseDocPanel({ docId, productName }) {
|
|||
getPreciseDoc(docId).then(d => { if (alive) { setInfo(d); setLang(d.srcLang); } }).catch(e => alive && setErr(e.message));
|
||||
return () => { alive = false; };
|
||||
}, [docId]);
|
||||
// 导入后正在后台自动翻译(英 / 俄 / 西):每 8 秒刷新一次,翻完一种就能看一种
|
||||
const pendingKey = info && info.pending ? info.pending.join(',') : '';
|
||||
useEffect(() => {
|
||||
if (!pendingKey) return;
|
||||
const t = setInterval(() => {
|
||||
getPreciseDoc(docId).then(d => setInfo(d)).catch(() => {});
|
||||
}, 8000);
|
||||
return () => clearInterval(t);
|
||||
}, [docId, pendingKey]);
|
||||
if (err) return <div className="panel section-gap"><div className="panel-body" style={{ padding: 18, color: 'var(--led-red)', fontSize: 12.5 }}>原版彩页读取失败:{err}</div></div>;
|
||||
if (!info) return null;
|
||||
const isSrc = lang === info.srcLang;
|
||||
const done = isSrc || !!(info.langs && info.langs[lang] > 0);
|
||||
const pending = (info.pending || []).includes(lang);
|
||||
const url = (extra = '') => `/api/precise/${encodeURIComponent(docId)}/html?lang=${lang}${extra}&v=${ver}`;
|
||||
async function doTranslate() {
|
||||
setBusy(true);
|
||||
|
|
@ -9249,12 +9259,12 @@ function PreciseDocPanel({ docId, productName }) {
|
|||
<select className="select" style={{ width: 'auto' }} value={lang} onChange={e => setLang(e.target.value)}>
|
||||
{[{ code: 'zh', label: '中文' }, ...EXPORT_LANGUAGES.filter(l => l.code !== 'zh')].map(l => (
|
||||
<option key={l.code} value={l.code}>
|
||||
{l.label}{l.code === info.srcLang ? '(原文)' : info.langs && info.langs[l.code] ? '(已翻译)' : ''}
|
||||
{l.label}{l.code === info.srcLang ? '(原文)' : info.langs && info.langs[l.code] ? '(已翻译)' : (info.pending || []).includes(l.code) ? '(自动翻译中…)' : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{!isSrc && (
|
||||
<button className={`btn btn-sm${done ? '' : ' btn-primary'}`} disabled={busy} onClick={doTranslate}>
|
||||
<button className={`btn btn-sm${done ? '' : ' btn-primary'}`} disabled={busy || pending} onClick={doTranslate}>
|
||||
<Sparkles size={12} />{busy ? 'AI 翻译中…' : done ? '重新翻译' : `AI 翻译成${langLabel}`}
|
||||
</button>
|
||||
)}
|
||||
|
|
@ -9265,7 +9275,7 @@ function PreciseDocPanel({ docId, productName }) {
|
|||
{done ? (
|
||||
<iframe title="原版彩页" src={url()} className="precise-frame" />
|
||||
) : (
|
||||
<div className="empty-state" style={{ padding: 30 }}>{busy ? 'AI 正在翻译,版式不变,只替换文字…' : `还没有${langLabel}版,点上面的按钮翻译(正文和图表里的文字都会翻译,版式不变)。`}</div>
|
||||
<div className="empty-state" style={{ padding: 30 }}>{busy || pending ? `AI 正在翻译${langLabel}版,版式不变,只替换文字…(导入后会自动翻译英语、俄语、西班牙语)` : info.failed && info.failed[lang] ? `${langLabel}版自动翻译失败(${info.failed[lang]}),点上面的按钮重试。` : `还没有${langLabel}版,点上面的按钮翻译(正文和图表里的文字都会翻译,版式不变)。`}</div>
|
||||
)}
|
||||
<div style={{ fontSize: 12, color: 'var(--ink-soft)', marginTop: 8 }}>
|
||||
打印时在打印窗口里选"另存为 PDF",页面大小和原文件一致;产品照片上印的文字属于照片本身,不会翻译。
|
||||
|
|
|
|||
Loading…
Reference in New Issue