fix: 债券三字段调试日志改为 otcdebug gated,出问题时一键可定位

用户指出:上一笔直接删了 onBondPriceKeydown 的逐键 console.log 又没补 gated 版,
等于平时没噪音了、真出问题也看不见——这正是反复改几十遍都满足不了需求时才需要日志兜底的场景。

修复:
- onBondPriceKeydown 逐键 before/after(driver/rev) trace 改为 otcDebug.log(?otcdebug=1 才输出)
- onBondPriceEdit(失焦/粘贴) 补同款 gated trace
- calcBondForItem 补 enter/success/calc-error/post-fail 四条 gated trace
  → 三字段整条链路(逐键→回车→计算器→源/AUTO或失败)开开关即得完整现场
- main.js 第226/669行 catch 内 error console.log 保留(错误日志本就应在生产可见,利于定位)
- otcDebug 机制本身已存在且唯一:?otcdebug=1 或 localStorage.otcdebug=1 开启,
  _MainLayout 注入 jsVersion/git/built,加载时打带版本 banner,平时零噪音

测试:
- diag.test.js 新增源码守卫:swapTradeEdit.js 三字段埋点必须 otcDebug.log、不得退回裸 console.log
- diag 18 例 / bondCalc 81 例全过
This commit is contained in:
hjhan
2026-07-30 10:15:00 +08:00
parent ead2c01f0d
commit 72b2a4cbf6
2 changed files with 25 additions and 0 deletions
+12
View File
@@ -135,6 +135,18 @@ describe('diag: 源码守卫(防回归——不许再硬编码易过期版本
expect(src).toMatch(/otcDebug\.banner|window\.ylotc\.__diag/);
});
test('swapTradeEdit.js 三字段调试埋点必须 gated(otcDebug.log),不得裸 console.log 退回', () => {
// 防回归:历史多次"改了不生效"靠日志兜底,曾出现①把 console.log 直接删了(出问题时看不见)
// ②或解除了开关控制(生产噪音)。正确做法是 otcDebug.log?otcdebug=1 才输出)。
const src = fs.readFileSync(path.join(SCRIPTS, 'app/swaptrade/swapTradeEdit.js'), 'utf8');
// 存在 gated 埋点
expect(src).toMatch(/otcDebug\.log\(/);
// 关键路径不得出现裸 console.log 调试行
expect(src).not.toMatch(/console\.log\('\[onBondPriceKeydown\]/);
expect(src).not.toMatch(/console\.log\('\[calcBondForItem\]/);
expect(src).not.toMatch(/console\.log\('\[onBondPriceEdit\]/);
});
test('fastVue.base.js 顶部 banner 不再硬编码 v20260729a', () => {
const src = fs.readFileSync(path.join(SCRIPTS, 'fast/fastVue.base.js'), 'utf8');
expect(src).not.toContain('v20260729a');