@next-core/brick-kit 2.207.0 → 2.208.0
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/dist/index.bundle.js +178 -0
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +178 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/types/internal/bindListeners.d.ts.map +1 -1
- package/dist/types/internal/debugManager.d.ts +17 -0
- package/dist/types/internal/debugManager.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.bundle.js
CHANGED
|
@@ -6330,6 +6330,177 @@
|
|
|
6330
6330
|
}
|
|
6331
6331
|
}
|
|
6332
6332
|
|
|
6333
|
+
class DebugManager {
|
|
6334
|
+
static getInstance() {
|
|
6335
|
+
if (!DebugManager.instance) {
|
|
6336
|
+
DebugManager.instance = new DebugManager();
|
|
6337
|
+
}
|
|
6338
|
+
return DebugManager.instance;
|
|
6339
|
+
}
|
|
6340
|
+
constructor() {
|
|
6341
|
+
_defineProperty__default["default"](this, "debugMode", false);
|
|
6342
|
+
_defineProperty__default["default"](this, "debugType", "none");
|
|
6343
|
+
this.initDebugMode();
|
|
6344
|
+
this.setupWindowAPI();
|
|
6345
|
+
}
|
|
6346
|
+
initDebugMode() {
|
|
6347
|
+
// 1. 首先检查URL参数
|
|
6348
|
+
var urlParams = new URLSearchParams(window.location.search);
|
|
6349
|
+
var debugFromUrl = urlParams.get("debugConsole");
|
|
6350
|
+
if (debugFromUrl === "true") {
|
|
6351
|
+
this.activateSessionDebug();
|
|
6352
|
+
return;
|
|
6353
|
+
}
|
|
6354
|
+
|
|
6355
|
+
// 2. 检查localStorage(内部人员长期调试)
|
|
6356
|
+
var persistentDebug = localStorage.getItem("debugConsole");
|
|
6357
|
+
if (persistentDebug === "true") {
|
|
6358
|
+
this.debugMode = true;
|
|
6359
|
+
this.debugType = "persistent";
|
|
6360
|
+
// eslint-disable-next-line no-console
|
|
6361
|
+
console.log("🔧 调试模式已开启(持久模式 - 内部调试)");
|
|
6362
|
+
return;
|
|
6363
|
+
}
|
|
6364
|
+
|
|
6365
|
+
// 3. 检查sessionStorage(客户临时调试)
|
|
6366
|
+
var sessionDebug = sessionStorage.getItem("debugConsole");
|
|
6367
|
+
if (sessionDebug === "true") {
|
|
6368
|
+
this.debugMode = true;
|
|
6369
|
+
this.debugType = "session";
|
|
6370
|
+
// eslint-disable-next-line no-console
|
|
6371
|
+
console.log("🔧 调试模式已开启(会话模式 - 关闭标签页后失效)");
|
|
6372
|
+
return;
|
|
6373
|
+
}
|
|
6374
|
+
|
|
6375
|
+
// 4. 检查日志级别设置
|
|
6376
|
+
}
|
|
6377
|
+
|
|
6378
|
+
activateSessionDebug() {
|
|
6379
|
+
this.debugMode = true;
|
|
6380
|
+
this.debugType = "session";
|
|
6381
|
+
sessionStorage.setItem("debugConsole", "true");
|
|
6382
|
+
// eslint-disable-next-line no-console
|
|
6383
|
+
console.log("🔧 调试模式已通过URL参数激活(会话模式)");
|
|
6384
|
+
}
|
|
6385
|
+
setupWindowAPI() {
|
|
6386
|
+
window.debugConsole = {
|
|
6387
|
+
// 开启会话调试模式(客户现场使用)
|
|
6388
|
+
enable: () => {
|
|
6389
|
+
this.debugMode = true;
|
|
6390
|
+
this.debugType = "session";
|
|
6391
|
+
sessionStorage.setItem("debugConsole", "true");
|
|
6392
|
+
// eslint-disable-next-line no-console
|
|
6393
|
+
console.log("🔧 调试模式已开启(会话模式 - 关闭标签页后失效)");
|
|
6394
|
+
return this.debugMode;
|
|
6395
|
+
},
|
|
6396
|
+
// 开启持久调试模式(内部人员使用)
|
|
6397
|
+
enablePersistent: () => {
|
|
6398
|
+
this.debugMode = true;
|
|
6399
|
+
this.debugType = "persistent";
|
|
6400
|
+
localStorage.setItem("debugConsole", "true");
|
|
6401
|
+
// eslint-disable-next-line no-console
|
|
6402
|
+
console.log("🔧 调试模式已开启(持久模式 - 内部调试)");
|
|
6403
|
+
return this.debugMode;
|
|
6404
|
+
},
|
|
6405
|
+
// 关闭调试模式
|
|
6406
|
+
disable: () => {
|
|
6407
|
+
this.debugMode = false;
|
|
6408
|
+
this.debugType = "none";
|
|
6409
|
+
sessionStorage.removeItem("debugConsole");
|
|
6410
|
+
localStorage.removeItem("debugConsole");
|
|
6411
|
+
// eslint-disable-next-line no-console
|
|
6412
|
+
console.log("🔧 调试模式已关闭");
|
|
6413
|
+
return this.debugMode;
|
|
6414
|
+
},
|
|
6415
|
+
// 切换调试模式
|
|
6416
|
+
toggle: () => {
|
|
6417
|
+
if (this.debugMode) {
|
|
6418
|
+
this.debugMode = false;
|
|
6419
|
+
this.debugType = "none";
|
|
6420
|
+
sessionStorage.removeItem("debugConsole");
|
|
6421
|
+
localStorage.removeItem("debugConsole");
|
|
6422
|
+
// eslint-disable-next-line no-console
|
|
6423
|
+
console.log("🔧 调试模式已关闭");
|
|
6424
|
+
} else {
|
|
6425
|
+
this.debugMode = true;
|
|
6426
|
+
this.debugType = "session";
|
|
6427
|
+
sessionStorage.setItem("debugConsole", "true");
|
|
6428
|
+
// eslint-disable-next-line no-console
|
|
6429
|
+
console.log("🔧 调试模式已开启(会话模式 - 关闭标签页后失效)");
|
|
6430
|
+
}
|
|
6431
|
+
return this.debugMode;
|
|
6432
|
+
},
|
|
6433
|
+
// 切换持久调试模式
|
|
6434
|
+
togglePersistent: () => {
|
|
6435
|
+
if (this.debugMode && this.debugType === "persistent") {
|
|
6436
|
+
this.debugMode = false;
|
|
6437
|
+
this.debugType = "none";
|
|
6438
|
+
sessionStorage.removeItem("debugConsole");
|
|
6439
|
+
localStorage.removeItem("debugConsole");
|
|
6440
|
+
// eslint-disable-next-line no-console
|
|
6441
|
+
console.log("🔧 调试模式已关闭");
|
|
6442
|
+
} else {
|
|
6443
|
+
this.debugMode = true;
|
|
6444
|
+
this.debugType = "persistent";
|
|
6445
|
+
localStorage.setItem("debugConsole", "true");
|
|
6446
|
+
// eslint-disable-next-line no-console
|
|
6447
|
+
console.log("🔧 调试模式已开启(持久模式 - 内部调试)");
|
|
6448
|
+
}
|
|
6449
|
+
return this.debugMode;
|
|
6450
|
+
},
|
|
6451
|
+
// 获取当前状态
|
|
6452
|
+
status: () => {
|
|
6453
|
+
var status = {
|
|
6454
|
+
debugMode: this.debugMode,
|
|
6455
|
+
debugType: this.debugType,
|
|
6456
|
+
description: this.getStatusDescription()
|
|
6457
|
+
};
|
|
6458
|
+
// eslint-disable-next-line no-console
|
|
6459
|
+
console.log("🔧 调试状态:", status);
|
|
6460
|
+
return status;
|
|
6461
|
+
},
|
|
6462
|
+
// 帮助信息
|
|
6463
|
+
help: () => {
|
|
6464
|
+
// eslint-disable-next-line no-console
|
|
6465
|
+
console.log("\n\uD83D\uDD27 \u6DF7\u5408\u8C03\u8BD5\u63A7\u5236\u53F0\u4F7F\u7528\u8BF4\u660E\uFF1A\n\n\uD83D\uDC65 \u751F\u4EA7\u73AF\u5883\u4F7F\u7528\uFF08\u4E34\u65F6\u8C03\u8BD5\uFF09\uFF1A\n window.debugConsole.enable() - \u5F00\u542F\u4F1A\u8BDD\u8C03\u8BD5\uFF08\u5173\u95ED\u6807\u7B7E\u9875\u540E\u5931\u6548\uFF09\n window.debugConsole.disable() - \u5173\u95ED\u8C03\u8BD5\u6A21\u5F0F\n window.debugConsole.toggle() - \u5207\u6362\u4F1A\u8BDD\u8C03\u8BD5\u6A21\u5F0F\n\n\uD83D\uDC68\u200D\uD83D\uDCBB \u5F00\u53D1\u4EBA\u5458\u4F7F\u7528\uFF08\u957F\u671F\u8C03\u8BD5\uFF09\uFF1A\n window.debugConsole.enablePersistent() - \u5F00\u542F\u6301\u4E45\u8C03\u8BD5\uFF08\u957F\u671F\u6709\u6548\uFF09\n window.debugConsole.togglePersistent() - \u5207\u6362\u6301\u4E45\u8C03\u8BD5\u6A21\u5F0F\n window.debugConsole.disable() - \u5173\u95ED\u8C03\u8BD5\u6A21\u5F0F\n\n\uD83D\uDD0D \u5176\u4ED6\u529F\u80FD\uFF1A\n window.debugConsole.status() - \u67E5\u770B\u5F53\u524D\u72B6\u6001\n window.debugConsole.help() - \u663E\u793A\u6B64\u5E2E\u52A9\u4FE1\u606F\n\n\uD83C\uDF10 URL\u53C2\u6570\uFF1A\n ?debugConsole=true - \u901A\u8FC7URL\u6FC0\u6D3B\u4F1A\u8BDD\u8C03\u8BD5\u6A21\u5F0F\n\n\uD83D\uDCDD \u8BF4\u660E\uFF1A\n - \u4F1A\u8BDD\u6A21\u5F0F\uFF1A\u5237\u65B0\u9875\u9762\u540E\u4ECD\u7136\u6709\u6548\uFF0C\u5173\u95ED\u6807\u7B7E\u9875\u540E\u5931\u6548\n - \u6301\u4E45\u6A21\u5F0F\uFF1A\u957F\u671F\u6709\u6548\uFF0C\u9664\u975E\u624B\u52A8\u5173\u95ED\n ");
|
|
6466
|
+
}
|
|
6467
|
+
};
|
|
6468
|
+
|
|
6469
|
+
// 显示初始状态
|
|
6470
|
+
if (this.debugMode) {
|
|
6471
|
+
// eslint-disable-next-line no-console
|
|
6472
|
+
console.log("\uD83D\uDD27 \u8C03\u8BD5\u6A21\u5F0F\u5DF2\u5F00\u542F\uFF08".concat(this.debugType === "persistent" ? "持久模式" : "会话模式", "\uFF09"));
|
|
6473
|
+
} else {
|
|
6474
|
+
// eslint-disable-next-line no-console
|
|
6475
|
+
console.log("💡 提示:使用 window.debugConsole.help() 查看使用说明");
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
getStatusDescription() {
|
|
6479
|
+
if (!this.debugMode) {
|
|
6480
|
+
return "调试模式已关闭";
|
|
6481
|
+
}
|
|
6482
|
+
switch (this.debugType) {
|
|
6483
|
+
case "persistent":
|
|
6484
|
+
return "持久模式 - 内部调试(长期有效)";
|
|
6485
|
+
case "session":
|
|
6486
|
+
return "会话模式 - 临时调试(关闭标签页后失效)";
|
|
6487
|
+
default:
|
|
6488
|
+
return "未知模式";
|
|
6489
|
+
}
|
|
6490
|
+
}
|
|
6491
|
+
isDebugMode() {
|
|
6492
|
+
return this.debugMode;
|
|
6493
|
+
}
|
|
6494
|
+
getDebugType() {
|
|
6495
|
+
return this.debugType;
|
|
6496
|
+
}
|
|
6497
|
+
shouldLog(method) {
|
|
6498
|
+
return method === "error" ? true : this.debugMode;
|
|
6499
|
+
}
|
|
6500
|
+
}
|
|
6501
|
+
_defineProperty__default["default"](DebugManager, "instance", void 0);
|
|
6502
|
+
var debugManager = DebugManager.getInstance();
|
|
6503
|
+
|
|
6333
6504
|
function bindListeners(brick, eventsMap, context) {
|
|
6334
6505
|
Object.entries(eventsMap).forEach(_ref => {
|
|
6335
6506
|
var [eventType, handlers] = _ref;
|
|
@@ -6995,6 +7166,13 @@
|
|
|
6995
7166
|
}), runtimeBrick)) {
|
|
6996
7167
|
return;
|
|
6997
7168
|
}
|
|
7169
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
7170
|
+
|
|
7171
|
+
// 生产环境下,只有调试模式开启且符合日志级别才输出
|
|
7172
|
+
if (isProduction && !debugManager.shouldLog(method)) {
|
|
7173
|
+
return;
|
|
7174
|
+
}
|
|
7175
|
+
|
|
6998
7176
|
// eslint-disable-next-line no-console
|
|
6999
7177
|
console[method](...argsFactory(args, context, event, {
|
|
7000
7178
|
useEventAsDefault: true
|