@pisell/pisellos 2.2.31 → 2.2.33
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/modules/Product/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +1 -1
- package/dist/server/index.d.ts +20 -0
- package/dist/server/index.js +508 -125
- package/dist/server/modules/menu/index.d.ts +19 -0
- package/dist/server/modules/menu/index.js +220 -70
- package/dist/server/modules/products/index.d.ts +19 -0
- package/dist/server/modules/products/index.js +347 -116
- package/dist/server/modules/schedule/index.d.ts +19 -0
- package/dist/server/modules/schedule/index.js +227 -66
- package/dist/server/utils/product.js +3 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +1 -1
- package/lib/server/index.d.ts +20 -0
- package/lib/server/index.js +288 -5
- package/lib/server/modules/menu/index.d.ts +19 -0
- package/lib/server/modules/menu/index.js +120 -1
- package/lib/server/modules/products/index.d.ts +19 -0
- package/lib/server/modules/products/index.js +203 -17
- package/lib/server/modules/schedule/index.d.ts +19 -0
- package/lib/server/modules/schedule/index.js +140 -11
- package/lib/server/utils/product.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export declare class MenuModule extends BaseModule implements Module {
|
|
|
11
11
|
private request;
|
|
12
12
|
private store;
|
|
13
13
|
private dbManager;
|
|
14
|
+
private logger;
|
|
14
15
|
constructor(name?: string, version?: string);
|
|
15
16
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
16
17
|
/**
|
|
@@ -60,4 +61,22 @@ export declare class MenuModule extends BaseModule implements Module {
|
|
|
60
61
|
* 返回该模块需要注册的 API 路由
|
|
61
62
|
*/
|
|
62
63
|
getRoutes(): RouteDefinition[];
|
|
64
|
+
/**
|
|
65
|
+
* 记录信息日志
|
|
66
|
+
* @param title 日志标题
|
|
67
|
+
* @param metadata 日志元数据
|
|
68
|
+
*/
|
|
69
|
+
private logInfo;
|
|
70
|
+
/**
|
|
71
|
+
* 记录警告日志
|
|
72
|
+
* @param title 日志标题
|
|
73
|
+
* @param metadata 日志元数据
|
|
74
|
+
*/
|
|
75
|
+
private logWarning;
|
|
76
|
+
/**
|
|
77
|
+
* 记录错误日志
|
|
78
|
+
* @param title 日志标题
|
|
79
|
+
* @param metadata 日志元数据
|
|
80
|
+
*/
|
|
81
|
+
private logError;
|
|
63
82
|
}
|
|
@@ -33,7 +33,7 @@ var INDEXDB_STORE_NAME = 'menu';
|
|
|
33
33
|
export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
34
34
|
_inherits(MenuModule, _BaseModule);
|
|
35
35
|
var _super = _createSuper(MenuModule);
|
|
36
|
-
//
|
|
36
|
+
// LoggerManager 实例
|
|
37
37
|
|
|
38
38
|
function MenuModule(name, version) {
|
|
39
39
|
var _this;
|
|
@@ -44,6 +44,8 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
44
44
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
45
45
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
46
46
|
_defineProperty(_assertThisInitialized(_this), "dbManager", void 0);
|
|
47
|
+
// IndexDBManager 实例
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
47
49
|
return _this;
|
|
48
50
|
}
|
|
49
51
|
_createClass(MenuModule, [{
|
|
@@ -81,13 +83,19 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
81
83
|
if (appPlugin) {
|
|
82
84
|
app = appPlugin.getApp();
|
|
83
85
|
this.dbManager = app.dbManager;
|
|
86
|
+
this.logger = app.logger;
|
|
84
87
|
if (this.dbManager) {
|
|
85
88
|
console.log('[Menu] IndexDB Manager 已初始化');
|
|
86
89
|
} else {
|
|
87
90
|
console.warn('[Menu] IndexDB Manager 未找到');
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
|
-
|
|
93
|
+
this.logInfo('模块初始化完成', {
|
|
94
|
+
hasDbManager: !!this.dbManager,
|
|
95
|
+
hasLogger: !!this.logger,
|
|
96
|
+
initialMenuCount: this.store.menuList.length
|
|
97
|
+
});
|
|
98
|
+
case 9:
|
|
91
99
|
case "end":
|
|
92
100
|
return _context.stop();
|
|
93
101
|
}
|
|
@@ -105,12 +113,14 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
105
113
|
key: "loadMenuList",
|
|
106
114
|
value: (function () {
|
|
107
115
|
var _loadMenuList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
108
|
-
var _response$data, response, menuList;
|
|
116
|
+
var startTime, _response$data, response, menuList, duration, _duration, errorMessage;
|
|
109
117
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
110
118
|
while (1) switch (_context2.prev = _context2.next) {
|
|
111
119
|
case 0:
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
this.logInfo('开始从服务器加载餐牌列表');
|
|
121
|
+
startTime = Date.now();
|
|
122
|
+
_context2.prev = 2;
|
|
123
|
+
_context2.next = 5;
|
|
114
124
|
return this.request.get("/form/data/v1", {
|
|
115
125
|
skip: 1,
|
|
116
126
|
num: 999,
|
|
@@ -118,26 +128,39 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
118
128
|
}, {
|
|
119
129
|
cache: undefined
|
|
120
130
|
});
|
|
121
|
-
case
|
|
131
|
+
case 5:
|
|
122
132
|
response = _context2.sent;
|
|
123
|
-
menuList = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || [];
|
|
124
|
-
|
|
133
|
+
menuList = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || [];
|
|
134
|
+
duration = Date.now() - startTime;
|
|
135
|
+
this.logInfo('从服务器加载餐牌列表成功', {
|
|
136
|
+
menuCount: menuList.length,
|
|
137
|
+
duration: "".concat(duration, "ms")
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// 保存到 IndexDB
|
|
141
|
+
_context2.next = 11;
|
|
125
142
|
return this.saveMenuToIndexDB(menuList);
|
|
126
|
-
case
|
|
127
|
-
_context2.next =
|
|
143
|
+
case 11:
|
|
144
|
+
_context2.next = 13;
|
|
128
145
|
return this.setMenuList(menuList);
|
|
129
|
-
case
|
|
146
|
+
case 13:
|
|
130
147
|
return _context2.abrupt("return", menuList);
|
|
131
|
-
case
|
|
132
|
-
_context2.prev =
|
|
133
|
-
_context2.t0 = _context2["catch"](
|
|
148
|
+
case 16:
|
|
149
|
+
_context2.prev = 16;
|
|
150
|
+
_context2.t0 = _context2["catch"](2);
|
|
151
|
+
_duration = Date.now() - startTime;
|
|
152
|
+
errorMessage = _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0);
|
|
134
153
|
console.error('[Menu] 加载餐牌数据失败:', _context2.t0);
|
|
154
|
+
this.logError('从服务器加载餐牌列表失败', {
|
|
155
|
+
duration: "".concat(_duration, "ms"),
|
|
156
|
+
error: errorMessage
|
|
157
|
+
});
|
|
135
158
|
return _context2.abrupt("return", []);
|
|
136
|
-
case
|
|
159
|
+
case 23:
|
|
137
160
|
case "end":
|
|
138
161
|
return _context2.stop();
|
|
139
162
|
}
|
|
140
|
-
}, _callee2, this, [[
|
|
163
|
+
}, _callee2, this, [[2, 16]]);
|
|
141
164
|
}));
|
|
142
165
|
function loadMenuList() {
|
|
143
166
|
return _loadMenuList.apply(this, arguments);
|
|
@@ -189,6 +212,9 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
189
212
|
key: "getMenuByIds",
|
|
190
213
|
value: function getMenuByIds(ids) {
|
|
191
214
|
if (!ids || ids.length === 0) {
|
|
215
|
+
this.logWarning('getMenuByIds: 未提供有效的 ids', {
|
|
216
|
+
idsCount: 0
|
|
217
|
+
});
|
|
192
218
|
return [];
|
|
193
219
|
}
|
|
194
220
|
var result = [];
|
|
@@ -207,6 +233,11 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
207
233
|
} finally {
|
|
208
234
|
_iterator.f();
|
|
209
235
|
}
|
|
236
|
+
this.logInfo('getMenuByIds: 查询完成', {
|
|
237
|
+
requestedCount: ids.length,
|
|
238
|
+
foundCount: result.length,
|
|
239
|
+
notFoundCount: ids.length - result.length
|
|
240
|
+
});
|
|
210
241
|
return result;
|
|
211
242
|
}
|
|
212
243
|
|
|
@@ -241,36 +272,46 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
272
|
key: "clear",
|
|
242
273
|
value: (function () {
|
|
243
274
|
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
275
|
+
var errorMessage;
|
|
244
276
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
245
277
|
while (1) switch (_context4.prev = _context4.next) {
|
|
246
278
|
case 0:
|
|
279
|
+
this.logInfo('开始清空缓存', {
|
|
280
|
+
currentMenuCount: this.store.menuList.length
|
|
281
|
+
});
|
|
247
282
|
this.store.menuList = [];
|
|
248
283
|
this.store.map.clear();
|
|
249
284
|
this.store.currentMenu = undefined;
|
|
250
285
|
|
|
251
286
|
// 同时清空 IndexDB 中的数据
|
|
252
287
|
if (!this.dbManager) {
|
|
253
|
-
_context4.next =
|
|
288
|
+
_context4.next = 17;
|
|
254
289
|
break;
|
|
255
290
|
}
|
|
256
|
-
_context4.prev =
|
|
257
|
-
_context4.next =
|
|
291
|
+
_context4.prev = 5;
|
|
292
|
+
_context4.next = 8;
|
|
258
293
|
return this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
259
|
-
case
|
|
294
|
+
case 8:
|
|
260
295
|
console.log('[Menu] IndexDB 缓存已清空');
|
|
261
|
-
|
|
296
|
+
this.logInfo('IndexDB 缓存已清空');
|
|
297
|
+
_context4.next = 17;
|
|
262
298
|
break;
|
|
263
|
-
case
|
|
264
|
-
_context4.prev =
|
|
265
|
-
_context4.t0 = _context4["catch"](
|
|
299
|
+
case 12:
|
|
300
|
+
_context4.prev = 12;
|
|
301
|
+
_context4.t0 = _context4["catch"](5);
|
|
302
|
+
errorMessage = _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0);
|
|
266
303
|
console.error('[Menu] 清空 IndexDB 缓存失败:', _context4.t0);
|
|
267
|
-
|
|
304
|
+
this.logError('清空 IndexDB 缓存失败', {
|
|
305
|
+
error: errorMessage
|
|
306
|
+
});
|
|
307
|
+
case 17:
|
|
268
308
|
console.log('[Menu] 缓存已清空');
|
|
269
|
-
|
|
309
|
+
this.logInfo('缓存清空完成');
|
|
310
|
+
case 19:
|
|
270
311
|
case "end":
|
|
271
312
|
return _context4.stop();
|
|
272
313
|
}
|
|
273
|
-
}, _callee4, this, [[
|
|
314
|
+
}, _callee4, this, [[5, 12]]);
|
|
274
315
|
}));
|
|
275
316
|
function clear() {
|
|
276
317
|
return _clear.apply(this, arguments);
|
|
@@ -286,32 +327,40 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
286
327
|
key: "loadMenuFromIndexDB",
|
|
287
328
|
value: (function () {
|
|
288
329
|
var _loadMenuFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
289
|
-
var menuList;
|
|
330
|
+
var _menuList$length, menuList, errorMessage;
|
|
290
331
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
291
332
|
while (1) switch (_context5.prev = _context5.next) {
|
|
292
333
|
case 0:
|
|
293
334
|
if (this.dbManager) {
|
|
294
|
-
_context5.next =
|
|
335
|
+
_context5.next = 3;
|
|
295
336
|
break;
|
|
296
337
|
}
|
|
338
|
+
this.logWarning('loadMenuFromIndexDB: dbManager 不可用');
|
|
297
339
|
return _context5.abrupt("return", []);
|
|
298
|
-
case
|
|
299
|
-
_context5.prev =
|
|
300
|
-
_context5.next =
|
|
340
|
+
case 3:
|
|
341
|
+
_context5.prev = 3;
|
|
342
|
+
_context5.next = 6;
|
|
301
343
|
return this.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
302
|
-
case
|
|
344
|
+
case 6:
|
|
303
345
|
menuList = _context5.sent;
|
|
346
|
+
this.logInfo('从 IndexDB 加载餐牌数据', {
|
|
347
|
+
menuCount: (_menuList$length = menuList === null || menuList === void 0 ? void 0 : menuList.length) !== null && _menuList$length !== void 0 ? _menuList$length : 0
|
|
348
|
+
});
|
|
304
349
|
return _context5.abrupt("return", menuList || []);
|
|
305
|
-
case
|
|
306
|
-
_context5.prev =
|
|
307
|
-
_context5.t0 = _context5["catch"](
|
|
350
|
+
case 11:
|
|
351
|
+
_context5.prev = 11;
|
|
352
|
+
_context5.t0 = _context5["catch"](3);
|
|
353
|
+
errorMessage = _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0);
|
|
308
354
|
console.error('[Menu] 从 IndexDB 读取数据失败:', _context5.t0);
|
|
355
|
+
this.logError('从 IndexDB 读取数据失败', {
|
|
356
|
+
error: errorMessage
|
|
357
|
+
});
|
|
309
358
|
return _context5.abrupt("return", []);
|
|
310
|
-
case
|
|
359
|
+
case 17:
|
|
311
360
|
case "end":
|
|
312
361
|
return _context5.stop();
|
|
313
362
|
}
|
|
314
|
-
}, _callee5, this, [[
|
|
363
|
+
}, _callee5, this, [[3, 11]]);
|
|
315
364
|
}));
|
|
316
365
|
function loadMenuFromIndexDB() {
|
|
317
366
|
return _loadMenuFromIndexDB.apply(this, arguments);
|
|
@@ -328,39 +377,51 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
377
|
value: (function () {
|
|
329
378
|
var _saveMenuToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(menuList) {
|
|
330
379
|
var _this2 = this;
|
|
331
|
-
var savePromises;
|
|
380
|
+
var savePromises, errorMessage;
|
|
332
381
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
333
382
|
while (1) switch (_context6.prev = _context6.next) {
|
|
334
383
|
case 0:
|
|
335
384
|
if (this.dbManager) {
|
|
336
|
-
_context6.next =
|
|
385
|
+
_context6.next = 3;
|
|
337
386
|
break;
|
|
338
387
|
}
|
|
388
|
+
this.logWarning('saveMenuToIndexDB: dbManager 不可用');
|
|
339
389
|
return _context6.abrupt("return");
|
|
340
|
-
case
|
|
341
|
-
|
|
342
|
-
|
|
390
|
+
case 3:
|
|
391
|
+
this.logInfo('开始保存餐牌数据到 IndexDB', {
|
|
392
|
+
menuCount: menuList.length
|
|
393
|
+
});
|
|
394
|
+
_context6.prev = 4;
|
|
395
|
+
_context6.next = 7;
|
|
343
396
|
return this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
344
|
-
case
|
|
397
|
+
case 7:
|
|
345
398
|
// 逐个保存餐牌(每个餐牌是独立的记录)
|
|
346
399
|
savePromises = menuList.map(function (menu) {
|
|
347
400
|
return _this2.dbManager.add(INDEXDB_STORE_NAME, menu);
|
|
348
401
|
});
|
|
349
|
-
_context6.next =
|
|
402
|
+
_context6.next = 10;
|
|
350
403
|
return Promise.all(savePromises);
|
|
351
|
-
case
|
|
404
|
+
case 10:
|
|
352
405
|
console.log("[Menu] \u5DF2\u5C06 ".concat(menuList.length, " \u6761\u9910\u724C\u6570\u636E\u4FDD\u5B58\u5230 IndexDB"));
|
|
353
|
-
|
|
406
|
+
this.logInfo('餐牌数据已保存到 IndexDB', {
|
|
407
|
+
menuCount: menuList.length
|
|
408
|
+
});
|
|
409
|
+
_context6.next = 19;
|
|
354
410
|
break;
|
|
355
|
-
case 11:
|
|
356
|
-
_context6.prev = 11;
|
|
357
|
-
_context6.t0 = _context6["catch"](2);
|
|
358
|
-
console.error('[Menu] 保存数据到 IndexDB 失败:', _context6.t0);
|
|
359
411
|
case 14:
|
|
412
|
+
_context6.prev = 14;
|
|
413
|
+
_context6.t0 = _context6["catch"](4);
|
|
414
|
+
errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
|
|
415
|
+
console.error('[Menu] 保存数据到 IndexDB 失败:', _context6.t0);
|
|
416
|
+
this.logError('保存数据到 IndexDB 失败', {
|
|
417
|
+
menuCount: menuList.length,
|
|
418
|
+
error: errorMessage
|
|
419
|
+
});
|
|
420
|
+
case 19:
|
|
360
421
|
case "end":
|
|
361
422
|
return _context6.stop();
|
|
362
423
|
}
|
|
363
|
-
}, _callee6, this, [[
|
|
424
|
+
}, _callee6, this, [[4, 14]]);
|
|
364
425
|
}));
|
|
365
426
|
function saveMenuToIndexDB(_x4) {
|
|
366
427
|
return _saveMenuToIndexDB.apply(this, arguments);
|
|
@@ -376,18 +437,20 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
376
437
|
key: "preload",
|
|
377
438
|
value: (function () {
|
|
378
439
|
var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
379
|
-
var cachedData, menuList;
|
|
440
|
+
var startTime, cachedData, duration, errorMessage, menuList, _duration2, _duration3;
|
|
380
441
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
381
442
|
while (1) switch (_context7.prev = _context7.next) {
|
|
382
443
|
case 0:
|
|
383
444
|
console.log('[Menu] 开始预加载数据...');
|
|
384
|
-
|
|
385
|
-
|
|
445
|
+
startTime = Date.now();
|
|
446
|
+
this.logInfo('开始预加载数据');
|
|
447
|
+
_context7.prev = 3;
|
|
448
|
+
_context7.next = 6;
|
|
386
449
|
return this.loadMenuFromIndexDB();
|
|
387
|
-
case
|
|
450
|
+
case 6:
|
|
388
451
|
cachedData = _context7.sent;
|
|
389
452
|
if (!(cachedData && cachedData.length > 0)) {
|
|
390
|
-
_context7.next =
|
|
453
|
+
_context7.next = 15;
|
|
391
454
|
break;
|
|
392
455
|
}
|
|
393
456
|
console.log("[Menu] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u6761\u9910\u724C\u6570\u636E"));
|
|
@@ -396,36 +459,60 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
459
|
// 同步更新 Map 缓存
|
|
397
460
|
this.syncMenuMap();
|
|
398
461
|
this.core.effects.emit(MenuHooks.onMenuChanged, this.store.menuList);
|
|
462
|
+
duration = Date.now() - startTime;
|
|
463
|
+
this.logInfo('预加载完成(从 IndexDB)', {
|
|
464
|
+
menuCount: cachedData.length,
|
|
465
|
+
duration: "".concat(duration, "ms"),
|
|
466
|
+
source: 'IndexDB'
|
|
467
|
+
});
|
|
399
468
|
return _context7.abrupt("return");
|
|
400
|
-
case
|
|
469
|
+
case 15:
|
|
401
470
|
console.log('[Menu] IndexDB 中没有缓存数据,从服务器加载...');
|
|
402
|
-
|
|
471
|
+
this.logInfo('IndexDB 中没有缓存数据,准备从服务器加载');
|
|
472
|
+
_context7.next = 24;
|
|
403
473
|
break;
|
|
404
|
-
case
|
|
405
|
-
_context7.prev =
|
|
406
|
-
_context7.t0 = _context7["catch"](
|
|
474
|
+
case 19:
|
|
475
|
+
_context7.prev = 19;
|
|
476
|
+
_context7.t0 = _context7["catch"](3);
|
|
477
|
+
errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
|
|
407
478
|
console.warn('[Menu] 从 IndexDB 加载数据失败:', _context7.t0);
|
|
408
|
-
|
|
409
|
-
|
|
479
|
+
this.logWarning('从 IndexDB 加载数据失败,准备从服务器加载', {
|
|
480
|
+
error: errorMessage
|
|
481
|
+
});
|
|
482
|
+
case 24:
|
|
483
|
+
_context7.next = 26;
|
|
410
484
|
return this.loadMenuList();
|
|
411
|
-
case
|
|
485
|
+
case 26:
|
|
412
486
|
menuList = _context7.sent;
|
|
413
487
|
if (!(menuList && menuList.length > 0)) {
|
|
414
|
-
_context7.next =
|
|
488
|
+
_context7.next = 37;
|
|
415
489
|
break;
|
|
416
490
|
}
|
|
417
|
-
_context7.next =
|
|
491
|
+
_context7.next = 30;
|
|
418
492
|
return this.saveMenuToIndexDB(menuList);
|
|
419
|
-
case
|
|
493
|
+
case 30:
|
|
420
494
|
this.store.menuList = cloneDeep(menuList);
|
|
421
495
|
// 同步更新 Map 缓存
|
|
422
496
|
this.syncMenuMap();
|
|
423
497
|
this.core.effects.emit(MenuHooks.onMenuChanged, this.store.menuList);
|
|
424
|
-
|
|
498
|
+
_duration2 = Date.now() - startTime;
|
|
499
|
+
this.logInfo('预加载完成(从服务器)', {
|
|
500
|
+
menuCount: menuList.length,
|
|
501
|
+
duration: "".concat(_duration2, "ms"),
|
|
502
|
+
source: 'Server'
|
|
503
|
+
});
|
|
504
|
+
_context7.next = 39;
|
|
505
|
+
break;
|
|
506
|
+
case 37:
|
|
507
|
+
_duration3 = Date.now() - startTime;
|
|
508
|
+
this.logWarning('预加载完成但未获取到数据', {
|
|
509
|
+
duration: "".concat(_duration3, "ms")
|
|
510
|
+
});
|
|
511
|
+
case 39:
|
|
425
512
|
case "end":
|
|
426
513
|
return _context7.stop();
|
|
427
514
|
}
|
|
428
|
-
}, _callee7, this, [[
|
|
515
|
+
}, _callee7, this, [[3, 19]]);
|
|
429
516
|
}));
|
|
430
517
|
function preload() {
|
|
431
518
|
return _preload.apply(this, arguments);
|
|
@@ -471,6 +558,69 @@ export var MenuModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
471
558
|
}()
|
|
472
559
|
}];
|
|
473
560
|
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* 记录信息日志
|
|
564
|
+
* @param title 日志标题
|
|
565
|
+
* @param metadata 日志元数据
|
|
566
|
+
*/
|
|
567
|
+
}, {
|
|
568
|
+
key: "logInfo",
|
|
569
|
+
value: function logInfo(title, metadata) {
|
|
570
|
+
try {
|
|
571
|
+
if (this.logger) {
|
|
572
|
+
this.logger.addLog({
|
|
573
|
+
type: 'info',
|
|
574
|
+
title: "[MenuModule] ".concat(title),
|
|
575
|
+
metadata: metadata || {}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
} catch (_unused) {
|
|
579
|
+
// 日志记录失败不影响主流程
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* 记录警告日志
|
|
585
|
+
* @param title 日志标题
|
|
586
|
+
* @param metadata 日志元数据
|
|
587
|
+
*/
|
|
588
|
+
}, {
|
|
589
|
+
key: "logWarning",
|
|
590
|
+
value: function logWarning(title, metadata) {
|
|
591
|
+
try {
|
|
592
|
+
if (this.logger) {
|
|
593
|
+
this.logger.addLog({
|
|
594
|
+
type: 'warning',
|
|
595
|
+
title: "[MenuModule] ".concat(title),
|
|
596
|
+
metadata: metadata || {}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
} catch (_unused2) {
|
|
600
|
+
// 日志记录失败不影响主流程
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* 记录错误日志
|
|
606
|
+
* @param title 日志标题
|
|
607
|
+
* @param metadata 日志元数据
|
|
608
|
+
*/
|
|
609
|
+
}, {
|
|
610
|
+
key: "logError",
|
|
611
|
+
value: function logError(title, metadata) {
|
|
612
|
+
try {
|
|
613
|
+
if (this.logger) {
|
|
614
|
+
this.logger.addLog({
|
|
615
|
+
type: 'error',
|
|
616
|
+
title: "[MenuModule] ".concat(title),
|
|
617
|
+
metadata: metadata || {}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
} catch (_unused3) {
|
|
621
|
+
// 日志记录失败不影响主流程
|
|
622
|
+
}
|
|
623
|
+
}
|
|
474
624
|
}]);
|
|
475
625
|
return MenuModule;
|
|
476
626
|
}(BaseModule);
|
|
@@ -13,6 +13,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
13
13
|
private store;
|
|
14
14
|
private request;
|
|
15
15
|
private dbManager;
|
|
16
|
+
private logger;
|
|
16
17
|
private otherParams;
|
|
17
18
|
private productsPriceCache;
|
|
18
19
|
private readonly CACHE_MAX_DAYS;
|
|
@@ -20,6 +21,24 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
20
21
|
private isPriceFormatterRegistered;
|
|
21
22
|
constructor(name?: string, version?: string);
|
|
22
23
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* 记录信息日志
|
|
26
|
+
* @param title 日志标题
|
|
27
|
+
* @param metadata 日志元数据
|
|
28
|
+
*/
|
|
29
|
+
private logInfo;
|
|
30
|
+
/**
|
|
31
|
+
* 记录警告日志
|
|
32
|
+
* @param title 日志标题
|
|
33
|
+
* @param metadata 日志元数据
|
|
34
|
+
*/
|
|
35
|
+
private logWarning;
|
|
36
|
+
/**
|
|
37
|
+
* 记录错误日志
|
|
38
|
+
* @param title 日志标题
|
|
39
|
+
* @param metadata 日志元数据
|
|
40
|
+
*/
|
|
41
|
+
private logError;
|
|
23
42
|
/**
|
|
24
43
|
* 加载商品价格(原始方法,不带缓存)
|
|
25
44
|
* @private
|