transproof-dsh-plugin 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/index.html +4 -1
- package/app/js/01-core.js +1 -1
- package/app/js/04-settings-data.js +1 -1
- package/app/js/05-files-docx.js +3 -1
- package/app/js/08-render-audit.js +5 -3
- package/app/js/09-gloss.js +2 -1
- package/app/js/13-pipeline.js +28 -2
- package/app/js/14-noun-verify.js +7 -0
- package/app/js/15-delivery-report.js +5 -0
- package/app/js/23-asklist.js +5 -0
- package/app/js/26-waiver.js +64 -0
- package/package.json +1 -1
package/app/index.html
CHANGED
|
@@ -1059,7 +1059,7 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1059
1059
|
<h3><span class="step-num">1</span>原文输入 <span class="hint" id="ts-srcStat">未输入</span></h3>
|
|
1060
1060
|
<div class="body">
|
|
1061
1061
|
<div id="ts-srcFileBar" class="file-bar" style="display:none"></div>
|
|
1062
|
-
<input type="file" id="ts-srcFile" accept=".docx,.pdf,.png,.jpg,.jpeg,.webp,.bmp,.tiff,.txt,.md" hidden>
|
|
1062
|
+
<input type="file" id="ts-srcFile" accept=".docx,.pdf,.epub,.png,.jpg,.jpeg,.webp,.bmp,.tiff,.txt,.md" hidden>
|
|
1063
1063
|
<div style="display:flex;gap:8px;margin-bottom:8px;flex-wrap:wrap;align-items:center">
|
|
1064
1064
|
<button class="btn sm" id="ts-srcUpload">📂 上传原文</button>
|
|
1065
1065
|
<button class="btn gray sm" id="ts-srcClear">✕ 清除</button>
|
|
@@ -1723,6 +1723,7 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1723
1723
|
<tr><td><b>🎯 逐句评分(v4.50 新)</b></td><td>整篇修订译文逐句打分(红 1-2 / 黄 3 / 绿 4-5 徽章)+ 短评,点「应用重写」单句精修并写回(手动触发,不自动烧 token)</td></tr>
|
|
1724
1724
|
<tr><td><b>⚖️ 双模型分工(v4.51 新)</b></td><td>设置页可指定「初稿模型」与「审校模型」:便宜模型翻初稿,强模型做批评/精修/校对,省 token(留空 = 不分工,行为不变)</td></tr>
|
|
1725
1725
|
<tr><td><b>🎲 抽样质检(v4.51 新)</b></td><td>长文不全文复查:按 10% 抽样(5~30 句、少于 50 句全查),一次调用核查漏译/误译/术语不一致,给出错误率 + 交付建议(手动触发,不自动烧 token)</td></tr>
|
|
1726
|
+
<tr><td><b>📝 豁免登记(v4.52 新)</b></td><td>术语/专名/批注三处可登记「有意不一致」+ 理由,体检不再报;疑问清单与交付报告里可看到豁免清单</td></tr>
|
|
1726
1727
|
</tbody>
|
|
1727
1728
|
</table>
|
|
1728
1729
|
<div class="alert i" style="margin-top:12px">
|
|
@@ -1877,6 +1878,7 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1877
1878
|
<tr><td><b>近期</b></td><td><b>逐句评分</b>:逐句打分徽章 + 单句重写指令</td><td>✅ 已上线(v4.50.0)</td></tr>
|
|
1878
1879
|
<tr><td><b>近期</b></td><td><b>双模型分工</b>:初稿/审校分开选模型,省着用</td><td>✅ 已上线(v4.51.0)</td></tr>
|
|
1879
1880
|
<tr><td><b>近期</b></td><td><b>抽样质检</b>:长文抽样 10% 核查,给出错误率与交付建议</td><td>✅ 已上线(v4.51.0)</td></tr>
|
|
1881
|
+
<tr><td><b>近期</b></td><td><b>豁免登记</b>:有意不一致写理由,体检跳过,导出可见</td><td>✅ 已上线(v4.52.0)</td></tr>
|
|
1880
1882
|
<tr><td><b>云端版</b></td><td><b>改动留痕、可回溯</b>:每次重要校对留下不可篡改的备份点,谁改了什么、当时发生了什么都能查,不再靠猜</td><td>规划中</td></tr>
|
|
1881
1883
|
</tbody>
|
|
1882
1884
|
</table>
|
|
@@ -1932,5 +1934,6 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1932
1934
|
<script src="js/23-asklist.js"></script>
|
|
1933
1935
|
<script src="js/24-sentence-score.js"></script>
|
|
1934
1936
|
<script src="js/25-sample-qa.js"></script>
|
|
1937
|
+
<script src="js/26-waiver.js"></script>
|
|
1935
1938
|
</body>
|
|
1936
1939
|
</html>
|
package/app/js/01-core.js
CHANGED
|
@@ -340,7 +340,7 @@ function dl(name, content, type){
|
|
|
340
340
|
setTimeout(() => { if(a.parentNode) a.parentNode.removeChild(a); URL.revokeObjectURL(a.href); }, 3000);
|
|
341
341
|
}
|
|
342
342
|
// 全部持久化 key(v2 备份/恢复/清除/统计的单一来源)
|
|
343
|
-
const ALL_KEYS = ['tp.cfg','tp.terms','tp.prefs','tp.history','tp.memory','tp.project','tp.prompts','tp.gloss','tp.task','tp.stage','tp.theme','tp.accent','tp.splash','tp.fb.log','tp.snapshot'];
|
|
343
|
+
const ALL_KEYS = ['tp.cfg','tp.terms','tp.prefs','tp.history','tp.memory','tp.project','tp.prompts','tp.gloss','tp.task','tp.stage','tp.theme','tp.accent','tp.splash','tp.fb.log','tp.snapshot','tp.waiver'];
|
|
344
344
|
$('#btn-backup').onclick = () => {
|
|
345
345
|
// v2:完整备份所有本地数据(12 个 key),用于原封不动迁移到其他设备/平台
|
|
346
346
|
const data = {};
|
package/app/js/05-files-docx.js
CHANGED
|
@@ -784,9 +784,10 @@ function saveTask(){
|
|
|
784
784
|
work: { src:$('#src').value, dst:$('#dst').value, extra:$('#extra').value, out:LAST_OUT, auditFix: (typeof AUDIT_FIX === 'object' && AUDIT_FIX && Object.keys(AUDIT_FIX).length) ? AUDIT_FIX : null },
|
|
785
785
|
trans: { src:$('#ts-src').value, out:TS_LAST_OUT },
|
|
786
786
|
files: { src:fileSnap(__TP_FILES.src), dst:fileSnap(__TP_FILES.dst), tsSrc:fileSnap(TS_FILES.src) },
|
|
787
|
+
pipe: (typeof PL !== "undefined" && PL && PL.stage > 0) ? { stage: PL.stage, draft: PL.draft || "", critique: PL.critique || "", final: PL.final || "" } : null,
|
|
787
788
|
t: Date.now()
|
|
788
789
|
};
|
|
789
|
-
const has = snap.work.src || snap.work.dst || snap.work.extra || snap.trans.src || snap.work.out || snap.files.src || snap.files.dst || snap.files.tsSrc;
|
|
790
|
+
const has = snap.work.src || snap.work.dst || snap.work.extra || snap.trans.src || snap.work.out || snap.files.src || snap.files.dst || snap.files.tsSrc || snap.pipe;
|
|
790
791
|
if(has) localStorage.setItem(LS_TASK, JSON.stringify(snap));
|
|
791
792
|
else localStorage.removeItem(LS_TASK);
|
|
792
793
|
}catch(e){ /* localStorage 满或隐私模式:静默失败 */ }
|
|
@@ -810,6 +811,7 @@ function restoreTask(s){
|
|
|
810
811
|
if(s.trans.src) $('#ts-src').value = s.trans.src;
|
|
811
812
|
if(s.trans.out){ TS_LAST_OUT = s.trans.out; $('#ts-out').innerHTML = md(s.trans.out); $('#ts-outHint').textContent = '已恢复上次译文'; }
|
|
812
813
|
}
|
|
814
|
+
if(s.pipe && typeof PL !== "undefined" && PL){ PL.stage = s.pipe.stage || 0; PL.draft = s.pipe.draft || ""; PL.critique = s.pipe.critique || ""; PL.final = s.pipe.final || ""; }
|
|
813
815
|
renderFileBar('src'); renderFileBar('dst');
|
|
814
816
|
tsRenderSrcBar();
|
|
815
817
|
if(s.files && s.files.tsSrc) $('#ts-srcStat').textContent = '已恢复:' + s.files.tsSrc.chapters.length + ' 章节';
|
|
@@ -542,7 +542,7 @@ function termAudit(text, srcText){
|
|
|
542
542
|
if(!dst) return;
|
|
543
543
|
if(t.indexOf(dst) >= 0){ used.push(term); return; } // 已按术语库统一
|
|
544
544
|
const inSrc = src && s && s.indexOf(src.toLowerCase()) >= 0;
|
|
545
|
-
if(inSrc) conflict.push(term);
|
|
545
|
+
if(inSrc){ if(typeof waiverHas === 'function' && waiverHas('term', src)) return; conflict.push(term); } // 原文用了、定稿没用术语库译法
|
|
546
546
|
});
|
|
547
547
|
// 一词多译:抓「中文(外文)」与「外文(中文)」对照
|
|
548
548
|
const zh = '[\\u4e00-\\u9fff][\\u4e00-\\u9fff·]{0,11}';
|
|
@@ -559,7 +559,7 @@ function termAudit(text, srcText){
|
|
|
559
559
|
};
|
|
560
560
|
collect(new RegExp('(' + zh + ')[((]\\s*(' + en + ')\\s*[))]', 'g'), 2, 1);
|
|
561
561
|
collect(new RegExp('(' + en + ')[((]\\s*(' + zh + ')\\s*[))]', 'g'), 1, 2);
|
|
562
|
-
Object.values(map).forEach(v => { if(v.cn.size >= 2) multi.push({ word: v.word, cn: [...v.cn] }); });
|
|
562
|
+
Object.values(map).forEach(v => { if(v.cn.size >= 2){ if(typeof waiverHas === 'function' && waiverHas('term', v.word)) return; multi.push({ word: v.word, cn: [...v.cn] }); } });
|
|
563
563
|
return { used, conflict, multi, termTotal: TERMS.length };
|
|
564
564
|
}
|
|
565
565
|
|
|
@@ -1592,6 +1592,7 @@ function renderAuditControls(){
|
|
|
1592
1592
|
if(typeof efPromoteTerm === 'function') mkPromo('ef-term', '📌术语', '把这个译法存进词库并批准(锁定一致)', efPromoteTerm);
|
|
1593
1593
|
if(typeof efPromoteBan === 'function') mkPromo('ef-ban', '🚫禁用', '禁止再使用这个译法(下次请求生效)', efPromoteBan);
|
|
1594
1594
|
if(typeof efPromoteStyle === 'function') mkPromo('ef-style', '✍文风', '把理由存进文风偏好(下次请求自动附带)', efPromoteStyle);
|
|
1595
|
+
if(typeof waiverPrompt === 'function') mkPromo('ef-waive', '📝豁免', '登记豁免:这条我故意不改,体检别报', (a) => waiverPrompt('audit', a.frag || a.fix || a.fp, () => {}));
|
|
1595
1596
|
});
|
|
1596
1597
|
updateFixProgress();
|
|
1597
1598
|
}
|
|
@@ -1745,6 +1746,7 @@ function proNounAudit(outText, srcText){
|
|
|
1745
1746
|
Object.keys(bind).forEach(k => {
|
|
1746
1747
|
const s = bind[k];
|
|
1747
1748
|
if(s.size > 1){
|
|
1749
|
+
if(typeof waiverHas === 'function' && waiverHas('noun', k)) return;
|
|
1748
1750
|
const v = [...s];
|
|
1749
1751
|
F.push({ t: '同名异译', ev: v.join(' / '), d: '同一原文名「' + k + '」在译文里对应 ' + s.size + ' 种不同译法', sugg: v, fixable: true });
|
|
1750
1752
|
}
|
|
@@ -1760,7 +1762,7 @@ function proNounAudit(outText, srcText){
|
|
|
1760
1762
|
bare[mm[1]] = (bare[mm[1]] || 0) + 1;
|
|
1761
1763
|
}
|
|
1762
1764
|
Object.keys(bare).forEach(k => {
|
|
1763
|
-
if(srcL.has(nz(k))) F.push({ t: '疑似未译', ev: k, d: '原文明有这个词,译文里还是原文(出现 ' + bare[k] + ' 次),可能漏译或没附中文译名', fixable: false });
|
|
1765
|
+
if(srcL.has(nz(k))){ if(typeof waiverHas === 'function' && waiverHas('noun', k)) return; F.push({ t: '疑似未译', ev: k, d: '原文明有这个词,译文里还是原文(出现 ' + bare[k] + ' 次),可能漏译或没附中文译名', fixable: false }); }
|
|
1764
1766
|
});
|
|
1765
1767
|
// ③ 数字对不上:原文里 ≥3 位的数字(年份/数据)在译文里找不到(中文邻接也算边界)
|
|
1766
1768
|
const numSet = s => new Set((s.match(/(?<![\d,.])\d[\d,.]{0,12}(?![\d,.])/g) || []).filter(n => n.replace(/[,.]/g, '').length >= 3));
|
package/app/js/09-gloss.js
CHANGED
|
@@ -321,7 +321,7 @@ function renderGlossTable(){
|
|
|
321
321
|
(t.status !== 'rejected' ? '<button class="btn gray sm" data-toreject title="拒绝此条,不再注入提示词">✗ 拒绝</button>' : '') +
|
|
322
322
|
'</div></td>' +
|
|
323
323
|
'<td class="g-rec">' + recLabel + '</td>' +
|
|
324
|
-
'<td style="white-space:nowrap">' + (t.url ? '<a class="btn gray sm" href="' + esc(t.url) + '" target="_blank" rel="noopener" title="查看依据 URL">🔗</a> ' : '<button class="btn gray sm" data-gv-url2 title="回填依据 URL">🔗</button> ') + '<button class="btn gray sm" data-lookup title="联网查证通行译法">🔎</button> <button class="btn gray sm" data-verify title="AI 核查该条收录是否正确(v4.26.0)">🤖 核查</button> <button class="btn gray sm" data-edit>编辑</button> <button class="btn gray sm" data-merge1 title="把另一条合并进此条">⇄</button> <button class="btn gray sm" data-del title="删除此条">🗑</button></td>' +
|
|
324
|
+
'<td style="white-space:nowrap">' + (t.url ? '<a class="btn gray sm" href="' + esc(t.url) + '" target="_blank" rel="noopener" title="查看依据 URL">🔗</a> ' : '<button class="btn gray sm" data-gv-url2 title="回填依据 URL">🔗</button> ') + '<button class="btn gray sm" data-lookup title="联网查证通行译法">🔎</button> <button class="btn gray sm" data-verify title="AI 核查该条收录是否正确(v4.26.0)">🤖 核查</button> <button class="btn gray sm" data-edit>编辑</button> <button class="btn gray sm" data-merge1 title="把另一条合并进此条">⇄</button> <button class="btn gray sm" data-del title="删除此条">🗑</button> <button class="btn gray sm" data-waive title="登记豁免:有意这么译,体检别报">📝</button></td>' +
|
|
325
325
|
'</tr>';
|
|
326
326
|
}).join('');
|
|
327
327
|
// 行事件
|
|
@@ -357,6 +357,7 @@ function renderGlossTable(){
|
|
|
357
357
|
});
|
|
358
358
|
};
|
|
359
359
|
tr.querySelector('[data-edit]').onclick = () => glossEdit(id);
|
|
360
|
+
tr.querySelector('[data-waive]').onclick = () => { if(typeof waiverPrompt === 'function') waiverPrompt('term', t.foreign, () => renderGlossTable()); };
|
|
360
361
|
tr.querySelector('[data-merge1]').onclick = () => glossMergeInto(id);
|
|
361
362
|
tr.querySelector('[data-del]').onclick = () => glossDelete(id);
|
|
362
363
|
});
|
package/app/js/13-pipeline.js
CHANGED
|
@@ -76,6 +76,7 @@ function plHtml(){
|
|
|
76
76
|
' <span class="ef-chip" data-pls="3">③ 精修译文</span>',
|
|
77
77
|
'</div>',
|
|
78
78
|
'<div id="pl-status" style="font-size:12px;color:var(--tx3);margin-bottom:8px">准备就绪:点「开始第 1 段」出初稿。</div>',
|
|
79
|
+
'<div id="pl-contract" style="font-size:12px;color:var(--tx2);margin-bottom:6px;line-height:1.8;background:var(--bg2);padding:6px 10px;border-radius:4px"></div>',
|
|
79
80
|
'<div id="pl-box" style="min-height:120px;max-height:46vh;overflow:auto;padding:12px;background:var(--bg2);border:1px solid var(--bd);border-radius:6px;font-size:14px;line-height:1.8;white-space:pre-wrap"></div>',
|
|
80
81
|
'<div style="display:flex;gap:8px;margin-top:12px;flex-wrap:wrap">',
|
|
81
82
|
' <button class="btn pri sm" id="pl-next">▶ 开始第 1 段(翻译初稿)</button>',
|
|
@@ -101,6 +102,16 @@ function plCur(){
|
|
|
101
102
|
}
|
|
102
103
|
function plSetBox(t){ $('#pl-box').textContent = t; }
|
|
103
104
|
function plStatus(t){ $('#pl-status').textContent = t; }
|
|
105
|
+
function plContract(n){ /* v4.52.0:契约可见化——每段产物盒三行说明 */
|
|
106
|
+
const box = $('#pl-contract'); if(!box) return;
|
|
107
|
+
const R = [
|
|
108
|
+
['输入:外文原文', '产物:翻译初稿', '停止条件:初稿生成完停下,等你过目'],
|
|
109
|
+
['输入:原文 + 初稿 + 术语表(白名单,不带翻译自辩)', '产物:批评清单(只挑毛病、不改译文)', '停止条件:清单生成完停下,等你过目'],
|
|
110
|
+
['输入:原文 + 初稿 + 批评清单 + 术语表', '产物:精修译文', '停止条件:精修完停下,由你拍板采纳']
|
|
111
|
+
];
|
|
112
|
+
const r = R[n] || R[0];
|
|
113
|
+
box.innerHTML = '<div style="color:var(--tx2)">' + r.map((x,i) => '<div>' + ['①②③'[i]] + ' ' + x + '</div>').join('') + '</div>';
|
|
114
|
+
}
|
|
104
115
|
|
|
105
116
|
/* ── 主流程:跑第 n 段(n=1,2,3) ── */
|
|
106
117
|
async function plRun(n){
|
|
@@ -119,6 +130,7 @@ async function plRun(n){
|
|
|
119
130
|
plStatus('⏳ 第 ' + n + ' 段「' + label + '」生成中…(可随时中断)');
|
|
120
131
|
plSetBox('');
|
|
121
132
|
plStep(n);
|
|
133
|
+
plContract(n);
|
|
122
134
|
|
|
123
135
|
let sys, user, maxTok;
|
|
124
136
|
if(n === 1){ sys = plSysDraft(); user = '【外文原文】\n' + src.slice(0, (CFG.maxInChars||80000)); maxTok = 8000; }
|
|
@@ -137,6 +149,7 @@ async function plRun(n){
|
|
|
137
149
|
else if(n === 2) PL.critique = t;
|
|
138
150
|
else PL.final = t;
|
|
139
151
|
PL.stage = n; /* v4.34.0:只有真正跑完才推进段号——失败/中断永远重跑同一段 */
|
|
152
|
+
if(typeof saveTask === "function") saveTask(); /* v4.52.0:流水线进度随任务持久化,刷新后能续跑 */
|
|
140
153
|
|
|
141
154
|
plSetBox(t);
|
|
142
155
|
plStatus('✓ 第 ' + n + ' 段「' + label + '」完成 · ' + new Date().toLocaleTimeString('zh-CN'));
|
|
@@ -168,9 +181,22 @@ function plOpen(){
|
|
|
168
181
|
/* v4.34.0:重开弹窗先掐掉上次残留的调用并清 running,否则整块功能卡死 */
|
|
169
182
|
if(PL.ctrl){ PL.cancel = true; try{ PL.ctrl.abort(); }catch(_){} }
|
|
170
183
|
PL.running = false; PL.ctrl = null; PL.cancel = false;
|
|
171
|
-
PL.stage
|
|
184
|
+
const resumed = (PL.stage > 0) && (PL.draft || PL.critique || PL.final); /* v4.52.0:有已完成段就续跑,不重置 */
|
|
185
|
+
if(!resumed){ PL.stage = 0; PL.draft = ''; PL.critique = ''; PL.final = ''; }
|
|
172
186
|
modal('⚙ 三段流水线 · 翻译 → 批评 → 精修', plHtml());
|
|
173
|
-
plStep(
|
|
187
|
+
plStep(PL.stage);
|
|
188
|
+
if(resumed){
|
|
189
|
+
plSetBox(plCur());
|
|
190
|
+
plStatus('上次停在第 ' + PL.stage + ' 段,点下方按钮从中断处续跑。');
|
|
191
|
+
$('#pl-copy').disabled = false;
|
|
192
|
+
const _nx = $('#pl-next');
|
|
193
|
+
if(PL.stage === 1){ _nx.textContent = '▶ 下一段:第 2 段(批评挑毛病)'; }
|
|
194
|
+
else if(PL.stage === 2){ _nx.textContent = '▶ 下一段:第 3 段(按批评精修)'; }
|
|
195
|
+
else { _nx.textContent = '✓ 三段全部完成'; _nx.disabled = true; $('#pl-send').disabled = false; }
|
|
196
|
+
plContract(PL.stage);
|
|
197
|
+
} else {
|
|
198
|
+
plContract(0);
|
|
199
|
+
}
|
|
174
200
|
$('#pl-next').onclick = () => {
|
|
175
201
|
if(PL.running) return;
|
|
176
202
|
/* v4.34.0:段号由「已完成的内容」推导——失败/中断后重试永远重跑同一段,绝不会越位卡死;
|
package/app/js/14-noun-verify.js
CHANGED
|
@@ -121,6 +121,7 @@ function renderGvPanel(){
|
|
|
121
121
|
urlBtn +
|
|
122
122
|
'<button class="btn sm" data-gv-approve="' + t.id + '">✓ 批准</button>' +
|
|
123
123
|
'<button class="btn gray sm" data-gv-reject="' + t.id + '">✕ 拒绝</button>' +
|
|
124
|
+
'<button class="btn gray sm" data-gv-waive="' + t.id + '" title="登记豁免:有意这么译,体检别报">📝</button>' +
|
|
124
125
|
'</div>' +
|
|
125
126
|
'</div>';
|
|
126
127
|
}).join('') + (list.length > MAXN ? '<div class="muted sm" style="margin-top:8px">还有 ' + (list.length - MAXN) + ' 条待核验,请到「词条管理」按状态筛「待审核」。</div>' : '');
|
|
@@ -166,6 +167,12 @@ function renderGvPanel(){
|
|
|
166
167
|
if(t) gvSetUrl(t);
|
|
167
168
|
};
|
|
168
169
|
});
|
|
170
|
+
box.querySelectorAll('[data-gv-waive]').forEach(b => {
|
|
171
|
+
b.onclick = () => {
|
|
172
|
+
const t = GLOSS.terms.find(x => String(x.id) === String(b.dataset.gvWaive));
|
|
173
|
+
if(t && typeof waiverPrompt === 'function') waiverPrompt('noun', t.foreign, () => renderGvPanel());
|
|
174
|
+
};
|
|
175
|
+
});
|
|
169
176
|
box.querySelectorAll('[data-gv-approve]').forEach(b => {
|
|
170
177
|
b.onclick = () => {
|
|
171
178
|
const t = GLOSS.terms.find(x => String(x.id) === String(b.dataset.gvApprove));
|
|
@@ -111,6 +111,11 @@ function reportMarkdown(d){
|
|
|
111
111
|
L.push('- 术语一致(专名体检)· 段落对齐 · 数字格式 · 标点对账 · 翻译腔 · 风格简报 · 错误分类 · 已修/未修流转');
|
|
112
112
|
L.push('- 质量评分 = 忠实度 60 + 流畅度 40,本地计算,不花 token');
|
|
113
113
|
L.push('');
|
|
114
|
+
var _wv = (typeof waiverAll === 'function') ? waiverAll() : [];
|
|
115
|
+
L.push('## 豁免登记');
|
|
116
|
+
L.push('');
|
|
117
|
+
if(_wv.length){ _wv.forEach(function(w, i){ L.push('- [' + w.type + '] ' + w.key + ':' + w.reason + '(' + new Date(w.ts).toISOString().slice(0,10) + ')'); }); }else{ L.push('- 无'); }
|
|
118
|
+
L.push('');
|
|
114
119
|
L.push('---');
|
|
115
120
|
L.push('');
|
|
116
121
|
L.push('本报告由 TransProof 生成 · https://transproof.pages.dev · v' + APP_VERSION);
|
package/app/js/23-asklist.js
CHANGED
|
@@ -62,6 +62,11 @@
|
|
|
62
62
|
L.push((i+1) + '. ' + t.foreign + ' → ' + (t.zh || '(未定)') + (t.type ? '(' + t.type + ')' : '') + (t.note ? ' · ' + t.note : ''));
|
|
63
63
|
});
|
|
64
64
|
L.push('');
|
|
65
|
+
var wv = (typeof waiverAll === 'function') ? waiverAll() : [];
|
|
66
|
+
L.push('## 五、豁免登记(' + wv.length + ' 条)');
|
|
67
|
+
if(!wv.length){ L.push('(无)'); }
|
|
68
|
+
wv.forEach(function(w, i){ L.push((i+1) + '. [' + w.type + '] ' + w.key + ' — ' + w.reason + '(' + new Date(w.ts).toISOString().slice(0,10) + ')'); });
|
|
69
|
+
L.push('');
|
|
65
70
|
return L.join(NL);
|
|
66
71
|
}
|
|
67
72
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* ═══════════ 豁免登记(T-026)· v4.52.0 ═══════════
|
|
2
|
+
· 译者有意不一致时留一条「豁免」记录(词条/专名/批注 + 理由),体检别再报。
|
|
3
|
+
· 结构 {type:'term'|'noun'|'audit', key, reason, ts};key 归一化后去空格小写匹配。 */
|
|
4
|
+
(function(){
|
|
5
|
+
'use strict';
|
|
6
|
+
const LS = 'tp.waiver';
|
|
7
|
+
function wAll(){ try{ const a = JSON.parse(localStorage.getItem(LS) || '[]'); return Array.isArray(a) ? a : []; }catch(e){ return []; } }
|
|
8
|
+
function wSave(a){ try{ localStorage.setItem(LS, JSON.stringify(a)); }catch(e){} }
|
|
9
|
+
function wNorm(s){ return String(s || '').replace(/\s+/g, '').toLowerCase(); }
|
|
10
|
+
function waiverCount(){ return wAll().length; }
|
|
11
|
+
function waiverAll(){ return wAll(); }
|
|
12
|
+
function waiverHas(type, key){
|
|
13
|
+
const k = wNorm(key); if(!k) return false;
|
|
14
|
+
return wAll().some(w => w.type === type && wNorm(w.key) === k);
|
|
15
|
+
}
|
|
16
|
+
function waiverAdd(type, key, reason){
|
|
17
|
+
reason = String(reason || '').trim();
|
|
18
|
+
if(!reason) return false; /* 空理由禁止保存 */
|
|
19
|
+
const a = wAll();
|
|
20
|
+
a.push({ type: type, key: String(key || ''), reason: reason, ts: Date.now() });
|
|
21
|
+
wSave(a);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
function waiverDel(idx){
|
|
25
|
+
const a = wAll(); if(idx < 0 || idx >= a.length) return;
|
|
26
|
+
a.splice(idx, 1); wSave(a);
|
|
27
|
+
}
|
|
28
|
+
function waiverPrompt(type, key, done){ /* 弹理由输入,保存后回调 */
|
|
29
|
+
const label = { term:'术语', noun:'专名', audit:'批注' }[type] || '该项';
|
|
30
|
+
const html = '<div style="font-size:13px;color:var(--tx2);line-height:1.9">登记「<b>' + esc(key) + '</b>」为有意豁免(' + label + '),体检将不再报它。<br>请写一句理由(为什么故意这么译):</div>' +
|
|
31
|
+
'<textarea id="wv-reason" rows="2" style="width:100%;margin-top:10px;font-size:14px" placeholder="例如:客户指定沿用旧译名"></textarea>' +
|
|
32
|
+
'<div style="display:flex;gap:8px;margin-top:12px"><button class="btn pri" id="wv-save">保存豁免</button><button class="btn gray" id="wv-cancel">取消</button></div>';
|
|
33
|
+
modal('📝 登记豁免', html);
|
|
34
|
+
$('#wv-cancel').onclick = () => { closeModal(); };
|
|
35
|
+
$('#wv-save').onclick = () => {
|
|
36
|
+
const r = $('#wv-reason').value.trim();
|
|
37
|
+
if(!r){ toast('请先写理由,空理由不能保存', 'e'); return; }
|
|
38
|
+
if(!waiverAdd(type, key, r)){ toast('保存失败', 'e'); return; }
|
|
39
|
+
closeModal(); toast('已登记豁免,体检将跳过它');
|
|
40
|
+
if(typeof done === 'function') done();
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function waiverOpen(){ /* 查看/删除豁免列表 */
|
|
44
|
+
const a = wAll();
|
|
45
|
+
if(!a.length){ modal('📝 豁免登记', '<div class="alert i">还没有豁免记录。在术语库 / 专名核验 / 批注卡点「📝 豁免」即可登记。</div>'); return; }
|
|
46
|
+
const TL = { term:'术语', noun:'专名', audit:'批注' };
|
|
47
|
+
let html = '<div class="alert i" style="margin-bottom:10px">已豁免 <b>' + a.length + '</b> 条,体检将跳过这些项。</div>';
|
|
48
|
+
a.forEach((w, i) => {
|
|
49
|
+
html += '<div style="display:flex;gap:8px;align-items:center;justify-content:space-between;border:1px solid var(--bd);border-radius:var(--r);padding:8px 12px;margin-bottom:6px">' +
|
|
50
|
+
'<div style="font-size:13px;line-height:1.6"><b>' + esc(TL[w.type] || w.type) + '</b> · ' + esc(w.key) + '<br><span style="color:var(--tx2)">理由:' + esc(w.reason) + ' · ' + new Date(w.ts).toLocaleString('zh-CN') + '</span></div>' +
|
|
51
|
+
'<button class="btn gray sm" data-wv-del="' + i + '">删除</button></div>';
|
|
52
|
+
});
|
|
53
|
+
modal('📝 豁免登记', html);
|
|
54
|
+
document.querySelectorAll('[data-wv-del]').forEach(b => {
|
|
55
|
+
b.onclick = () => { waiverDel(+b.dataset.wvDel); waiverOpen(); };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
window.waiverCount = waiverCount;
|
|
59
|
+
window.waiverAll = waiverAll;
|
|
60
|
+
window.waiverHas = waiverHas;
|
|
61
|
+
window.waiverAdd = waiverAdd;
|
|
62
|
+
window.waiverPrompt = waiverPrompt;
|
|
63
|
+
window.waiverOpen = waiverOpen;
|
|
64
|
+
})();
|
package/package.json
CHANGED