feat(diag): 可保留调试日志+版本可追溯机制(阶段0.5止血增强)
解决 EQD-6838 排查时硬编码版本号 v20260729a 散落3处、无法按需开关、
看不到实际加载缓存戳的问题。
层1 运行时开关(核心):
- HtmlUtil.cs 新增 GitCommit(读 AssemblyInformationalVersion,零新依赖)
- _MainLayout.cshtml 注入 window.ylotc.__diag(jsVersion+git+built)
- main.js 顶部新增 otcDebug 工具(banner+log),debug 默认 false 生产零输出
- swapTradeEdit.js / fastVue.base.js 硬编码标记改为 otcDebug.banner
- 开启方式:URL ?otcdebug=1(会话)或 localStorage.setItem('otcdebug','1')(持久)
层2 构建守卫:
- pre-commit 新增第三块 bundle 版本一致性检查(rebuild-bundles.py --verify)
- 修复 Windows python3 Store stub 不可用问题(优先用 python)
- 注:bundle 头部不注入 git sha(会随 commit 变化导致 verify 永久失败),
版本可追溯完全由运行时 __diag(后端注入)覆盖
层3 单测预防:
- 新增 diag.test.js(213测试之一),用 console spy 守卫开关行为
- 断言不再含硬编码 v20260729a + 防止第二套调试开关回归
验证:11 suites/213 tests 全绿,--verify 通过,C# 编译0错误
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
//依赖类库:lodash.js + jquery + jquery.validate + bootstrap.emodal.js
|
||||
|
||||
// 统一调试日志工具:仅在 otcdebug 开启时输出,默认静默(生产零噪音)。
|
||||
// 开启方式:URL 加 ?otcdebug=1,或控制台 localStorage.setItem('otcdebug','1')。
|
||||
// 业务脚本逐步改用 otcDebug.banner / otcDebug.log 替代裸 console.log,
|
||||
// 既能在排查时一键全开,又能避免版本标记散落硬编码(见 swapTradeEdit.js / fastVue.base.js 用法)。
|
||||
var __otcDiag = (window.ylotc && window.ylotc.__diag) || { debug: false };
|
||||
window.otcDebug = {
|
||||
// 模块加载横幅:F12 一眼看到模块名+bundle版本+git sha,用于排查"是不是加载了旧代码/旧缓存"
|
||||
banner: function (name, ver) {
|
||||
if (!__otcDiag.debug || !window.console) return;
|
||||
var git = (__otcDiag.git || '').slice(0, 7);
|
||||
console.log('%c[' + name + '] v' + ver + ' (bundle=' + __otcDiag.jsVersion + ', git=' + git + ', built=' + __otcDiag.built + ')',
|
||||
'color:#06c;font-weight:bold');
|
||||
},
|
||||
// 普通调试日志:透传参数,仅 debug 开启时输出
|
||||
log: function () {
|
||||
if (!__otcDiag.debug || !window.console) return;
|
||||
console.log.apply(console, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
var main = window.main || { version: "1.0" };
|
||||
|
||||
main.extend = $.extend;
|
||||
|
||||
Reference in New Issue
Block a user