@pisell/pisellos 2.2.87 → 2.2.89
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.
|
@@ -1175,7 +1175,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1175
1175
|
return this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1176
1176
|
case 8:
|
|
1177
1177
|
_context16.next = 10;
|
|
1178
|
-
return this.dbManager.
|
|
1178
|
+
return this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
1179
1179
|
case 10:
|
|
1180
1180
|
perfMark('saveProductsToIndexDB', performance.now() - t0, {
|
|
1181
1181
|
count: products.length
|
|
@@ -1435,7 +1435,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1435
1435
|
key: "processProductSyncMessages",
|
|
1436
1436
|
value: (function () {
|
|
1437
1437
|
var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1438
|
-
var messages, deleteIds, bodyUpdates, sseRefreshIds, _iterator5, _step5, msg, channelKey, _msg$change_types, _msg$ids2, _msg$ids, ids,
|
|
1438
|
+
var messages, deleteIds, bodyUpdates, sseRefreshIds, _iterator5, _step5, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _msg$relation_product2, uniqueDeleteIds, uniqueSSEIds, freshProducts;
|
|
1439
1439
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1440
1440
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1441
1441
|
case 0:
|
|
@@ -1467,30 +1467,31 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1467
1467
|
_context18.next = 30;
|
|
1468
1468
|
break;
|
|
1469
1469
|
}
|
|
1470
|
+
if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
|
|
1471
|
+
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
|
|
1472
|
+
}
|
|
1473
|
+
// 1. 删除场景:operation === 'delete' 或 action === 'delete'
|
|
1470
1474
|
if (!(msg.operation === 'delete' || msg.action === 'delete')) {
|
|
1471
|
-
_context18.next =
|
|
1475
|
+
_context18.next = 19;
|
|
1472
1476
|
break;
|
|
1473
1477
|
}
|
|
1474
1478
|
if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));else if (msg.id) deleteIds.push(msg.id);
|
|
1475
1479
|
return _context18.abrupt("continue", 31);
|
|
1476
|
-
case
|
|
1480
|
+
case 19:
|
|
1477
1481
|
if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
|
|
1478
|
-
_context18.next =
|
|
1482
|
+
_context18.next = 23;
|
|
1479
1483
|
break;
|
|
1480
1484
|
}
|
|
1481
1485
|
ids = msg.ids || (msg.id ? [msg.id] : []);
|
|
1482
1486
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(ids));
|
|
1483
1487
|
return _context18.abrupt("continue", 31);
|
|
1484
|
-
case
|
|
1488
|
+
case 23:
|
|
1485
1489
|
if (!msg.body) {
|
|
1486
1490
|
_context18.next = 27;
|
|
1487
1491
|
break;
|
|
1488
1492
|
}
|
|
1489
1493
|
bodyId = msg.body.id || msg.id;
|
|
1490
1494
|
if (bodyId) bodyUpdates.set(bodyId, msg.body);
|
|
1491
|
-
if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
|
|
1492
|
-
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
|
|
1493
|
-
}
|
|
1494
1495
|
return _context18.abrupt("continue", 31);
|
|
1495
1496
|
case 27:
|
|
1496
1497
|
// 5. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
|
|
@@ -673,7 +673,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
673
673
|
try {
|
|
674
674
|
const t0 = performance.now();
|
|
675
675
|
await this.dbManager.clear(INDEXDB_STORE_NAME);
|
|
676
|
-
await this.dbManager.
|
|
676
|
+
await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
677
677
|
(0, import_product.perfMark)("saveProductsToIndexDB", performance.now() - t0, { count: products.length });
|
|
678
678
|
console.log(
|
|
679
679
|
`[Products] 已将 ${products.length} 个商品平铺保存到 IndexDB`
|
|
@@ -860,14 +860,17 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
860
860
|
for (const msg of messages) {
|
|
861
861
|
const channelKey = msg._channelKey || msg.module || "product";
|
|
862
862
|
if (channelKey === "product") {
|
|
863
|
+
if ((_a = msg.relation_product_ids) == null ? void 0 : _a.length) {
|
|
864
|
+
sseRefreshIds.push(...msg.relation_product_ids);
|
|
865
|
+
}
|
|
863
866
|
if (msg.operation === "delete" || msg.action === "delete") {
|
|
864
|
-
if ((
|
|
867
|
+
if ((_b = msg.ids) == null ? void 0 : _b.length)
|
|
865
868
|
deleteIds.push(...msg.ids);
|
|
866
869
|
else if (msg.id)
|
|
867
870
|
deleteIds.push(msg.id);
|
|
868
871
|
continue;
|
|
869
872
|
}
|
|
870
|
-
if ((
|
|
873
|
+
if ((_c = msg.change_types) == null ? void 0 : _c.includes("price")) {
|
|
871
874
|
const ids = msg.ids || (msg.id ? [msg.id] : []);
|
|
872
875
|
sseRefreshIds.push(...ids);
|
|
873
876
|
continue;
|
|
@@ -876,9 +879,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
876
879
|
const bodyId = msg.body.id || msg.id;
|
|
877
880
|
if (bodyId)
|
|
878
881
|
bodyUpdates.set(bodyId, msg.body);
|
|
879
|
-
if ((_c = msg.relation_product_ids) == null ? void 0 : _c.length) {
|
|
880
|
-
sseRefreshIds.push(...msg.relation_product_ids);
|
|
881
|
-
}
|
|
882
882
|
continue;
|
|
883
883
|
}
|
|
884
884
|
if ((_d = msg.ids) == null ? void 0 : _d.length) {
|