@pisell/pisellos 3.0.56 → 3.0.57
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/core/index.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Cart/index.js +1 -1
- package/dist/modules/Cart/utils/changePrice.d.ts +2 -2
- package/dist/modules/Cart/utils/changePrice.js +1 -1
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +122 -0
- package/dist/modules/Customer/index.js +697 -0
- package/dist/modules/Customer/types.d.ts +146 -0
- package/dist/modules/Customer/types.js +41 -0
- package/dist/modules/Payment/cash.d.ts +11 -0
- package/dist/modules/Payment/cash.js +78 -0
- package/dist/modules/Payment/eftpos.d.ts +11 -0
- package/dist/modules/Payment/eftpos.js +80 -0
- package/dist/modules/Payment/index.d.ts +273 -9
- package/dist/modules/Payment/index.js +2525 -109
- package/dist/modules/Payment/types.d.ts +382 -30
- package/dist/modules/Payment/types.js +116 -14
- package/dist/modules/Payment/wallet.d.ts +11 -0
- package/dist/modules/Payment/wallet.js +78 -0
- package/dist/modules/Payment/walletpass.d.ts +0 -0
- package/dist/modules/Payment/walletpass.js +0 -0
- package/dist/modules/ProductList/index.d.ts +13 -3
- package/dist/modules/ProductList/index.js +52 -42
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +27 -14
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/app-types/app/app.d.ts +83 -0
- package/dist/plugins/app-types/app/const.d.ts +4 -0
- package/dist/plugins/app-types/app/index.d.ts +14 -0
- package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/dist/plugins/app-types/config.d.ts +3 -0
- package/dist/plugins/app-types/cookie/index.d.ts +13 -0
- package/dist/plugins/app-types/data/index.d.ts +8 -0
- package/dist/plugins/app-types/history/config.d.ts +24 -0
- package/dist/plugins/app-types/history/index.d.ts +20 -0
- package/dist/plugins/app-types/history/type.d.ts +2 -0
- package/dist/plugins/app-types/hooks/index.d.ts +12 -0
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/dist/plugins/app-types/index.d.ts +6 -0
- package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
- package/dist/plugins/app-types/locales/en.d.ts +3 -0
- package/dist/plugins/app-types/locales/index.d.ts +37 -0
- package/dist/plugins/app-types/locales/original.d.ts +3 -0
- package/dist/plugins/app-types/locales/type.d.ts +19 -0
- package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
- package/dist/plugins/app-types/logger/index.d.ts +122 -0
- package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
- package/dist/plugins/app-types/models/global.d.ts +32 -0
- package/dist/plugins/app-types/models/index.d.ts +45 -0
- package/dist/plugins/app-types/models/type.d.ts +2 -0
- package/dist/plugins/app-types/package.json +15 -0
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
- package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
- package/dist/plugins/app-types/request/cache.d.ts +46 -0
- package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/dist/plugins/app-types/request/config.d.ts +3 -0
- package/dist/plugins/app-types/request/constants.d.ts +2 -0
- package/dist/plugins/app-types/request/index.d.ts +24 -0
- package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/dist/plugins/app-types/request/type.d.ts +41 -0
- package/dist/plugins/app-types/request/utils.d.ts +46 -0
- package/dist/plugins/app-types/routes/config.d.ts +7 -0
- package/dist/plugins/app-types/routes/index.d.ts +28 -0
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
- package/dist/plugins/app-types/socket/constants.d.ts +33 -0
- package/dist/plugins/app-types/socket/events.d.ts +31 -0
- package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/dist/plugins/app-types/socket/index.d.ts +61 -0
- package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
- package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/dist/plugins/app-types/socket/socket.d.ts +129 -0
- package/dist/plugins/app-types/socket/types.d.ts +85 -0
- package/dist/plugins/app-types/storage/index.d.ts +17 -0
- package/dist/plugins/app-types/tasks/index.d.ts +77 -0
- package/dist/plugins/app-types/tasks/type.d.ts +62 -0
- package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/dist/plugins/app-types/type.d.ts +2 -0
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/dist/plugins/app-types/variables/config.d.ts +3 -0
- package/dist/plugins/app-types/variables/index.d.ts +6 -0
- package/dist/plugins/app-types/variables/type.d.ts +2 -0
- package/dist/plugins/app-types/website/index.d.ts +6 -0
- package/dist/plugins/app.d.ts +8 -0
- package/dist/plugins/app.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +59 -35
- package/dist/solution/BookingByStep/types.d.ts +3 -2
- package/dist/solution/BookingTicket/index.d.ts +172 -0
- package/dist/solution/BookingTicket/index.js +665 -0
- package/dist/solution/BookingTicket/types.d.ts +68 -0
- package/dist/solution/BookingTicket/types.js +43 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +174 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/dist/solution/BuyTickets/index.d.ts +2 -2
- package/dist/solution/BuyTickets/index.js +1 -1
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +181 -0
- package/dist/solution/Checkout/index.js +1596 -0
- package/dist/solution/Checkout/types.d.ts +550 -0
- package/dist/solution/Checkout/types.js +132 -0
- package/dist/solution/Checkout/utils/index.d.ts +73 -0
- package/dist/solution/Checkout/utils/index.js +371 -0
- package/dist/solution/ShopDiscount/index.js +4 -2
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/task.js +171 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Cart/index.js +1 -1
- package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
- package/lib/modules/Cart/utils/changePrice.js +1 -1
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +122 -0
- package/lib/modules/Customer/index.js +440 -0
- package/lib/modules/Customer/types.d.ts +146 -0
- package/lib/modules/Customer/types.js +37 -0
- package/lib/modules/Payment/cash.d.ts +11 -0
- package/lib/modules/Payment/cash.js +51 -0
- package/lib/modules/Payment/eftpos.d.ts +11 -0
- package/lib/modules/Payment/eftpos.js +51 -0
- package/lib/modules/Payment/index.d.ts +273 -9
- package/lib/modules/Payment/index.js +1285 -50
- package/lib/modules/Payment/types.d.ts +382 -30
- package/lib/modules/Payment/types.js +41 -6
- package/lib/modules/Payment/wallet.d.ts +11 -0
- package/lib/modules/Payment/wallet.js +51 -0
- package/lib/modules/Payment/walletpass.d.ts +0 -0
- package/lib/modules/Payment/walletpass.js +0 -0
- package/lib/modules/ProductList/index.d.ts +13 -3
- package/lib/modules/ProductList/index.js +37 -26
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/Rules/index.js +20 -12
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/app-types/app/app.d.ts +83 -0
- package/lib/plugins/app-types/app/const.d.ts +4 -0
- package/lib/plugins/app-types/app/index.d.ts +14 -0
- package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/lib/plugins/app-types/config.d.ts +3 -0
- package/lib/plugins/app-types/cookie/index.d.ts +13 -0
- package/lib/plugins/app-types/data/index.d.ts +8 -0
- package/lib/plugins/app-types/history/config.d.ts +24 -0
- package/lib/plugins/app-types/history/index.d.ts +20 -0
- package/lib/plugins/app-types/history/type.d.ts +2 -0
- package/lib/plugins/app-types/hooks/index.d.ts +12 -0
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/lib/plugins/app-types/index.d.ts +6 -0
- package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
- package/lib/plugins/app-types/locales/en.d.ts +3 -0
- package/lib/plugins/app-types/locales/index.d.ts +37 -0
- package/lib/plugins/app-types/locales/original.d.ts +3 -0
- package/lib/plugins/app-types/locales/type.d.ts +19 -0
- package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
- package/lib/plugins/app-types/logger/index.d.ts +122 -0
- package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
- package/lib/plugins/app-types/models/global.d.ts +32 -0
- package/lib/plugins/app-types/models/index.d.ts +45 -0
- package/lib/plugins/app-types/models/type.d.ts +2 -0
- package/lib/plugins/app-types/package.json +15 -0
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
- package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
- package/lib/plugins/app-types/request/cache.d.ts +46 -0
- package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/lib/plugins/app-types/request/config.d.ts +3 -0
- package/lib/plugins/app-types/request/constants.d.ts +2 -0
- package/lib/plugins/app-types/request/index.d.ts +24 -0
- package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/lib/plugins/app-types/request/type.d.ts +41 -0
- package/lib/plugins/app-types/request/utils.d.ts +46 -0
- package/lib/plugins/app-types/routes/config.d.ts +7 -0
- package/lib/plugins/app-types/routes/index.d.ts +28 -0
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
- package/lib/plugins/app-types/socket/constants.d.ts +33 -0
- package/lib/plugins/app-types/socket/events.d.ts +31 -0
- package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/lib/plugins/app-types/socket/index.d.ts +61 -0
- package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
- package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/lib/plugins/app-types/socket/socket.d.ts +129 -0
- package/lib/plugins/app-types/socket/types.d.ts +85 -0
- package/lib/plugins/app-types/storage/index.d.ts +17 -0
- package/lib/plugins/app-types/tasks/index.d.ts +77 -0
- package/lib/plugins/app-types/tasks/type.d.ts +62 -0
- package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/lib/plugins/app-types/type.d.ts +2 -0
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/lib/plugins/app-types/variables/config.d.ts +3 -0
- package/lib/plugins/app-types/variables/index.d.ts +6 -0
- package/lib/plugins/app-types/variables/type.d.ts +2 -0
- package/lib/plugins/app-types/website/index.d.ts +6 -0
- package/lib/plugins/app.d.ts +8 -0
- package/lib/plugins/app.js +17 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +40 -29
- package/lib/solution/BookingByStep/types.d.ts +3 -2
- package/lib/solution/BookingTicket/index.d.ts +172 -0
- package/lib/solution/BookingTicket/index.js +399 -0
- package/lib/solution/BookingTicket/types.d.ts +68 -0
- package/lib/solution/BookingTicket/types.js +72 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +125 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/lib/solution/BuyTickets/index.d.ts +2 -2
- package/lib/solution/BuyTickets/index.js +1 -1
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +181 -0
- package/lib/solution/Checkout/index.js +864 -0
- package/lib/solution/Checkout/types.d.ts +550 -0
- package/lib/solution/Checkout/types.js +75 -0
- package/lib/solution/Checkout/utils/index.d.ts +73 -0
- package/lib/solution/Checkout/utils/index.js +266 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/task.js +109 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +4 -2
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RequestPlugin } from '../../../../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* 搜索通用识别码
|
|
4
|
+
*/
|
|
5
|
+
export declare const searchWalletPass: (request: RequestPlugin, code: string) => Promise<{
|
|
6
|
+
searchType: string;
|
|
7
|
+
response: any;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* 搜索钱包
|
|
11
|
+
*/
|
|
12
|
+
export declare const searchWallet: (request: RequestPlugin, code: string) => Promise<{
|
|
13
|
+
searchType: string;
|
|
14
|
+
response: any;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* 搜索商品
|
|
18
|
+
*/
|
|
19
|
+
export declare const searchProduct: (request: RequestPlugin, code: string) => Promise<{
|
|
20
|
+
searchType: string;
|
|
21
|
+
response: any;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/BookingTicket/utils/scan/cloudSearch.ts
|
|
20
|
+
var cloudSearch_exports = {};
|
|
21
|
+
__export(cloudSearch_exports, {
|
|
22
|
+
searchProduct: () => searchProduct,
|
|
23
|
+
searchWallet: () => searchWallet,
|
|
24
|
+
searchWalletPass: () => searchWalletPass
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(cloudSearch_exports);
|
|
27
|
+
var searchWalletPass = async (request, code) => {
|
|
28
|
+
const params = {
|
|
29
|
+
code,
|
|
30
|
+
translate_flag: 1,
|
|
31
|
+
// 翻译识别码名称 0:不翻译 1:翻译
|
|
32
|
+
relation_product: 1,
|
|
33
|
+
// 组装关联商品: 0不处理 1处理
|
|
34
|
+
with: ["customer"],
|
|
35
|
+
tags: [
|
|
36
|
+
"point_card",
|
|
37
|
+
// 积分卡
|
|
38
|
+
"gift_card",
|
|
39
|
+
// 充值卡
|
|
40
|
+
"product_voucher",
|
|
41
|
+
// 代金券
|
|
42
|
+
"product_discount_card",
|
|
43
|
+
// 折扣卡
|
|
44
|
+
"good_pass",
|
|
45
|
+
// 商品券
|
|
46
|
+
"session_ticket",
|
|
47
|
+
// 场次票
|
|
48
|
+
"appointment_ticket"
|
|
49
|
+
// 预约类门票
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
const res = await (request == null ? void 0 : request.get(
|
|
54
|
+
"/machinecode/batch-search",
|
|
55
|
+
params
|
|
56
|
+
));
|
|
57
|
+
if ((res == null ? void 0 : res.code) == 200 && !!(res == null ? void 0 : res.data)) {
|
|
58
|
+
return { searchType: "walletPass", response: res };
|
|
59
|
+
}
|
|
60
|
+
throw new Error("没有找到对应的识别码");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var searchWallet = async (request, code) => {
|
|
66
|
+
const params = { code, with_customer: 1 };
|
|
67
|
+
try {
|
|
68
|
+
const res = await (request == null ? void 0 : request.post(
|
|
69
|
+
"/wallet/detail/search",
|
|
70
|
+
params
|
|
71
|
+
));
|
|
72
|
+
if ((res == null ? void 0 : res.code) == 200 && !!(res == null ? void 0 : res.data)) {
|
|
73
|
+
return { searchType: "wallet", response: res };
|
|
74
|
+
}
|
|
75
|
+
throw new Error("没有找到对应的识别码");
|
|
76
|
+
} catch (error) {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var searchProduct = async (request, code) => {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
const params = {
|
|
83
|
+
exact_search: code,
|
|
84
|
+
open_bundle: 0,
|
|
85
|
+
// 套餐子信息
|
|
86
|
+
open_quotation: 1,
|
|
87
|
+
// 报价单
|
|
88
|
+
skip: 1,
|
|
89
|
+
num: 20,
|
|
90
|
+
status: "published",
|
|
91
|
+
with: ["variantGroup"],
|
|
92
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
93
|
+
exclude_extension_type: [
|
|
94
|
+
"product_party",
|
|
95
|
+
"product_event",
|
|
96
|
+
"product_series_event",
|
|
97
|
+
"product_package_ticket",
|
|
98
|
+
"ticket",
|
|
99
|
+
"event_item"
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
try {
|
|
103
|
+
const res = await (request == null ? void 0 : request.post("/product/query", params));
|
|
104
|
+
if ((res == null ? void 0 : res.code) == 200 && ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) == null ? void 0 : _b.length) > 0) {
|
|
105
|
+
return { searchType: "product", response: res };
|
|
106
|
+
}
|
|
107
|
+
throw new Error("没有找到对应的识别码");
|
|
108
|
+
} catch (error) {
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
searchProduct,
|
|
115
|
+
searchWallet,
|
|
116
|
+
searchWalletPass
|
|
117
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestPlugin } from '../../../../plugins';
|
|
2
|
+
/**
|
|
3
|
+
* 处理全局扫码
|
|
4
|
+
* @param request 请求插件
|
|
5
|
+
* @returns 处理结果
|
|
6
|
+
*/
|
|
7
|
+
export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
|
|
8
|
+
type: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 处理客户扫码
|
|
13
|
+
* @param request 请求插件
|
|
14
|
+
* @returns 处理结果
|
|
15
|
+
*/
|
|
16
|
+
export declare const handleCustomerScan: () => () => Promise<{}>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/solution/BookingTicket/utils/scan/handleScan.ts
|
|
30
|
+
var handleScan_exports = {};
|
|
31
|
+
__export(handleScan_exports, {
|
|
32
|
+
handleCustomerScan: () => handleCustomerScan,
|
|
33
|
+
handleGlobalScan: () => handleGlobalScan
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(handleScan_exports);
|
|
36
|
+
var import_cloudSearch = require("./cloudSearch");
|
|
37
|
+
var import_scanCache = __toESM(require("./scanCache"));
|
|
38
|
+
var promiseAny = async (promises) => {
|
|
39
|
+
if (promises.length === 0) {
|
|
40
|
+
throw new Error("No promises provided");
|
|
41
|
+
}
|
|
42
|
+
const errors = [];
|
|
43
|
+
let completedCount = 0;
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
promises.forEach((promise, index) => {
|
|
46
|
+
promise.then((result) => {
|
|
47
|
+
resolve(result);
|
|
48
|
+
}).catch((error) => {
|
|
49
|
+
errors[index] = error;
|
|
50
|
+
completedCount++;
|
|
51
|
+
if (completedCount === promises.length) {
|
|
52
|
+
const errorMessage = `All promises were rejected. Errors: ${errors.map((e) => e.message).join(", ")}`;
|
|
53
|
+
const combinedError = new Error(errorMessage);
|
|
54
|
+
combinedError.errors = errors;
|
|
55
|
+
reject(combinedError);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var handleScanFn = (getRequestList, localSearch) => {
|
|
62
|
+
return async (scanResult) => {
|
|
63
|
+
const { value } = scanResult || {};
|
|
64
|
+
try {
|
|
65
|
+
const localResult = localSearch == null ? void 0 : localSearch(value);
|
|
66
|
+
if ((localResult == null ? void 0 : localResult.length) > 0) {
|
|
67
|
+
console.log("本地搜索到数据>>>>>>>", localResult);
|
|
68
|
+
return {
|
|
69
|
+
searchType: "local_product",
|
|
70
|
+
response: { data: { list: localResult } }
|
|
71
|
+
};
|
|
72
|
+
} else {
|
|
73
|
+
console.log("本地搜索无数据>>>>>>>");
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error("本地搜索到数据失败>>>>>>>", error);
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
if (import_scanCache.default.has(value)) {
|
|
80
|
+
const result = import_scanCache.default.get(value);
|
|
81
|
+
console.log("缓存中搜索到数据>>>>>>>", result);
|
|
82
|
+
return result;
|
|
83
|
+
} else {
|
|
84
|
+
console.log("缓存中无数据>>>>>>>");
|
|
85
|
+
}
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("缓存中搜索数据失败>>>>>>>", error);
|
|
88
|
+
}
|
|
89
|
+
const requestList = (getRequestList == null ? void 0 : getRequestList(value)) || [];
|
|
90
|
+
if (requestList.length === 0) {
|
|
91
|
+
throw new Error("requestList is empty");
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const result = await promiseAny(requestList);
|
|
95
|
+
import_scanCache.default.set(value, result);
|
|
96
|
+
return result;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
var handleGlobalScan = (request, localSearch) => {
|
|
103
|
+
const getRequestList = (value) => {
|
|
104
|
+
let requestList = [];
|
|
105
|
+
if (value.startsWith("WL")) {
|
|
106
|
+
requestList = [(0, import_cloudSearch.searchWallet)(request, value)];
|
|
107
|
+
} else {
|
|
108
|
+
requestList = [
|
|
109
|
+
(0, import_cloudSearch.searchWalletPass)(request, value),
|
|
110
|
+
(0, import_cloudSearch.searchWallet)(request, value),
|
|
111
|
+
(0, import_cloudSearch.searchProduct)(request, value)
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
return requestList;
|
|
115
|
+
};
|
|
116
|
+
return handleScanFn(getRequestList, localSearch);
|
|
117
|
+
};
|
|
118
|
+
var handleCustomerScan = () => {
|
|
119
|
+
return () => Promise.resolve({});
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
handleCustomerScan,
|
|
124
|
+
handleGlobalScan
|
|
125
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { WatchEventItem } from '../../../../utils/watch';
|
|
2
|
+
import { BookingTicketImpl } from '../../index';
|
|
3
|
+
import Tasks from '../../../../utils/task';
|
|
4
|
+
interface ScanResult {
|
|
5
|
+
type: ScanResultType;
|
|
6
|
+
value: string;
|
|
7
|
+
data?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
declare enum ScanResultType {
|
|
12
|
+
Scanner = "scanner",
|
|
13
|
+
NFC = "nfc",
|
|
14
|
+
NativeScanner = "nativeScanner"
|
|
15
|
+
}
|
|
16
|
+
export default class Scan {
|
|
17
|
+
private solution;
|
|
18
|
+
private watchKey;
|
|
19
|
+
private listenerConfig;
|
|
20
|
+
constructor(solution: BookingTicketImpl, watchKey: string);
|
|
21
|
+
/**
|
|
22
|
+
* 处理扫码事件
|
|
23
|
+
* @param eventKey 事件key
|
|
24
|
+
* @param value 扫码结果
|
|
25
|
+
*/
|
|
26
|
+
handleScan(result: {
|
|
27
|
+
type: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}): void;
|
|
30
|
+
/**
|
|
31
|
+
* 生成uuid
|
|
32
|
+
* @returns uuid
|
|
33
|
+
*/
|
|
34
|
+
generateUuid(): string;
|
|
35
|
+
/**
|
|
36
|
+
* 添加扫码信息监听
|
|
37
|
+
* @param watchKey 监听的key
|
|
38
|
+
* @param event 事件
|
|
39
|
+
*/
|
|
40
|
+
addListener(event: WatchEventItem, scanCallback?: (result: ScanResult) => Promise<any>): {
|
|
41
|
+
remove: () => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 移除扫码信息监听
|
|
45
|
+
* @param watchKey 监听的key
|
|
46
|
+
* @param event 事件
|
|
47
|
+
*/
|
|
48
|
+
removeListener(event: WatchEventItem): void;
|
|
49
|
+
/**
|
|
50
|
+
* 移除所有监听
|
|
51
|
+
*/
|
|
52
|
+
removeAllListeners(): void;
|
|
53
|
+
/**
|
|
54
|
+
* 启用所有监听
|
|
55
|
+
*/
|
|
56
|
+
enableAllListeners(): void;
|
|
57
|
+
/**
|
|
58
|
+
* 禁用所有监听,并清空任务执行队列
|
|
59
|
+
*/
|
|
60
|
+
disableAllListeners(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
63
|
+
* @param eventKey 事件key
|
|
64
|
+
*/
|
|
65
|
+
clearTaskQueue(eventKey?: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* 获取监听配置
|
|
68
|
+
* @param eventKey 事件key
|
|
69
|
+
* @returns 监听配置
|
|
70
|
+
*/
|
|
71
|
+
getListenerConfig(eventKey: string): {
|
|
72
|
+
scanCallback?: ((result: ScanResult) => Promise<any>) | undefined;
|
|
73
|
+
task: Tasks;
|
|
74
|
+
} | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* 扫码任务执行函数
|
|
77
|
+
* @param args 参数
|
|
78
|
+
*/
|
|
79
|
+
scanTaskAction(...args: any[]): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/solution/BookingTicket/utils/scan/index.ts
|
|
30
|
+
var scan_exports = {};
|
|
31
|
+
__export(scan_exports, {
|
|
32
|
+
default: () => Scan
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(scan_exports);
|
|
35
|
+
var import_watch = __toESM(require("../../../../utils/watch"));
|
|
36
|
+
var import_task = __toESM(require("../../../../utils/task"));
|
|
37
|
+
var Scan = class {
|
|
38
|
+
constructor(solution, watchKey) {
|
|
39
|
+
this.listenerConfig = /* @__PURE__ */ new Map();
|
|
40
|
+
var _a, _b, _c, _d, _e;
|
|
41
|
+
this.solution = solution;
|
|
42
|
+
this.watchKey = watchKey;
|
|
43
|
+
(_e = (_d = (_c = (_b = (_a = this.solution) == null ? void 0 : _a.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.mountFunction) == null ? void 0 : _e.call(
|
|
44
|
+
_d,
|
|
45
|
+
"global",
|
|
46
|
+
"peripheralsResult",
|
|
47
|
+
(strVal) => {
|
|
48
|
+
try {
|
|
49
|
+
const result = JSON.parse(strVal);
|
|
50
|
+
console.log("nativeScannerResult>>>>>>>", result);
|
|
51
|
+
this.handleScan(result);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
console.error(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 处理扫码事件
|
|
60
|
+
* @param eventKey 事件key
|
|
61
|
+
* @param value 扫码结果
|
|
62
|
+
*/
|
|
63
|
+
handleScan(result) {
|
|
64
|
+
const lastEnableEventKey = import_watch.default.getLastEnableEventKey(this.watchKey);
|
|
65
|
+
if (lastEnableEventKey) {
|
|
66
|
+
const listenerConfig = this.listenerConfig.get(lastEnableEventKey);
|
|
67
|
+
if (listenerConfig) {
|
|
68
|
+
listenerConfig.task.addTask({
|
|
69
|
+
uuid: this.generateUuid(),
|
|
70
|
+
type: lastEnableEventKey,
|
|
71
|
+
actionParams: {
|
|
72
|
+
scanResult: result
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 生成uuid
|
|
80
|
+
* @returns uuid
|
|
81
|
+
*/
|
|
82
|
+
generateUuid() {
|
|
83
|
+
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) + Date.now().toString(36);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 添加扫码信息监听
|
|
87
|
+
* @param watchKey 监听的key
|
|
88
|
+
* @param event 事件
|
|
89
|
+
*/
|
|
90
|
+
addListener(event, scanCallback) {
|
|
91
|
+
import_watch.default.subscribe(this.watchKey, event);
|
|
92
|
+
const task = new import_task.default();
|
|
93
|
+
task.addAction(
|
|
94
|
+
event.key,
|
|
95
|
+
(...args) => this.scanTaskAction(event.key, ...args)
|
|
96
|
+
);
|
|
97
|
+
this.listenerConfig.set(event.key, { scanCallback, task });
|
|
98
|
+
return {
|
|
99
|
+
remove: () => {
|
|
100
|
+
this.removeListener(event);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 移除扫码信息监听
|
|
106
|
+
* @param watchKey 监听的key
|
|
107
|
+
* @param event 事件
|
|
108
|
+
*/
|
|
109
|
+
removeListener(event) {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
import_watch.default.unsubscribe(this.watchKey, event);
|
|
112
|
+
(_b = (_a = this.listenerConfig.get(event.key)) == null ? void 0 : _a.task) == null ? void 0 : _b.clear();
|
|
113
|
+
this.listenerConfig.delete(event.key);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 移除所有监听
|
|
117
|
+
*/
|
|
118
|
+
removeAllListeners() {
|
|
119
|
+
var _a, _b, _c, _d;
|
|
120
|
+
import_watch.default.clearEvent(this.watchKey);
|
|
121
|
+
(_b = (_a = this.listenerConfig) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (item) => {
|
|
122
|
+
var _a2;
|
|
123
|
+
(_a2 = item == null ? void 0 : item.task) == null ? void 0 : _a2.clear();
|
|
124
|
+
});
|
|
125
|
+
(_d = (_c = this.listenerConfig) == null ? void 0 : _c.clear) == null ? void 0 : _d.call(_c);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 启用所有监听
|
|
129
|
+
*/
|
|
130
|
+
enableAllListeners() {
|
|
131
|
+
import_watch.default.enableAllEventByWatchKey(this.watchKey);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 禁用所有监听,并清空任务执行队列
|
|
135
|
+
*/
|
|
136
|
+
disableAllListeners() {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
import_watch.default.disabledAllEventByWatchKey(this.watchKey);
|
|
139
|
+
(_b = (_a = this.listenerConfig) == null ? void 0 : _a.forEach) == null ? void 0 : _b.call(_a, (item) => {
|
|
140
|
+
var _a2;
|
|
141
|
+
(_a2 = item == null ? void 0 : item.task) == null ? void 0 : _a2.clearTaskQueue();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 清空监听对应的任务执行队列,不传入eventKey则清空所有监听对应的任务执行队列
|
|
146
|
+
* @param eventKey 事件key
|
|
147
|
+
*/
|
|
148
|
+
clearTaskQueue(eventKey) {
|
|
149
|
+
var _a, _b, _c;
|
|
150
|
+
console.log("clearTaskQueue>>>>>>>", eventKey);
|
|
151
|
+
if (eventKey) {
|
|
152
|
+
(_a = this.listenerConfig.get(eventKey)) == null ? void 0 : _a.task.clearTaskQueue();
|
|
153
|
+
} else {
|
|
154
|
+
(_c = (_b = this.listenerConfig) == null ? void 0 : _b.forEach) == null ? void 0 : _c.call(_b, (item) => {
|
|
155
|
+
var _a2;
|
|
156
|
+
(_a2 = item == null ? void 0 : item.task) == null ? void 0 : _a2.clearTaskQueue();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 获取监听配置
|
|
162
|
+
* @param eventKey 事件key
|
|
163
|
+
* @returns 监听配置
|
|
164
|
+
*/
|
|
165
|
+
getListenerConfig(eventKey) {
|
|
166
|
+
var _a;
|
|
167
|
+
return (_a = this.listenerConfig) == null ? void 0 : _a.get(eventKey);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 扫码任务执行函数
|
|
171
|
+
* @param args 参数
|
|
172
|
+
*/
|
|
173
|
+
async scanTaskAction(...args) {
|
|
174
|
+
const [eventKey, other] = args;
|
|
175
|
+
const { type, value, data } = (other == null ? void 0 : other.scanResult) || {};
|
|
176
|
+
const taskItemUuid = other == null ? void 0 : other.uuid;
|
|
177
|
+
const { scanCallback, task } = this.getListenerConfig(eventKey) || {};
|
|
178
|
+
if (scanCallback) {
|
|
179
|
+
try {
|
|
180
|
+
const result = await scanCallback({ type, value });
|
|
181
|
+
console.log(`${eventKey}_result>>>>>>>`, result);
|
|
182
|
+
if (taskItemUuid && (task == null ? void 0 : task.isTaskExist(taskItemUuid))) {
|
|
183
|
+
import_watch.default.publishByEventKey(this.watchKey, eventKey, {
|
|
184
|
+
type: eventKey,
|
|
185
|
+
status: "success",
|
|
186
|
+
scanType: type,
|
|
187
|
+
scanCode: value,
|
|
188
|
+
scanData: data,
|
|
189
|
+
result
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
console.warn(`${eventKey}_result_task_not_exist>>>>>>>`, task);
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.log(`${eventKey}_result_error>>>>>>>`, error);
|
|
196
|
+
if (taskItemUuid && (task == null ? void 0 : task.isTaskExist(taskItemUuid))) {
|
|
197
|
+
import_watch.default.publishByEventKey(this.watchKey, eventKey, {
|
|
198
|
+
type: eventKey,
|
|
199
|
+
status: "failed",
|
|
200
|
+
scanType: type,
|
|
201
|
+
scanCode: value,
|
|
202
|
+
scanData: data
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
console.warn(`${eventKey}_result_error_task_not_exist>>>>>>>`, task);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU缓存类,用于缓存接口数据
|
|
3
|
+
* 限制最多存储100条数据,超过时移除最久未使用的数据
|
|
4
|
+
* 支持数据压缩以减小缓存压力
|
|
5
|
+
* 尾部优先策略:新节点插入尾部,最近使用的节点移动到尾部,删除头部节点
|
|
6
|
+
*/
|
|
7
|
+
declare class LRUCache<T> {
|
|
8
|
+
private head;
|
|
9
|
+
private tail;
|
|
10
|
+
private keyMap;
|
|
11
|
+
private readonly maxSize;
|
|
12
|
+
constructor(maxSize?: number);
|
|
13
|
+
/**
|
|
14
|
+
* 将节点移动到链表尾部(最近使用)
|
|
15
|
+
* @param node 要移动的节点
|
|
16
|
+
*/
|
|
17
|
+
private moveToTail;
|
|
18
|
+
/**
|
|
19
|
+
* 添加新节点到链表尾部
|
|
20
|
+
* @param key 缓存键
|
|
21
|
+
* @param compressedData 压缩后的数据
|
|
22
|
+
* @param timestamp 时间戳
|
|
23
|
+
*/
|
|
24
|
+
private addToTail;
|
|
25
|
+
/**
|
|
26
|
+
* 从链表中移除节点
|
|
27
|
+
* @param node 要移除的节点
|
|
28
|
+
*/
|
|
29
|
+
private removeNode;
|
|
30
|
+
/**
|
|
31
|
+
* 移除最久未使用的节点(链表头部)
|
|
32
|
+
*/
|
|
33
|
+
private removeOldest;
|
|
34
|
+
/**
|
|
35
|
+
* 设置缓存
|
|
36
|
+
* @param key 缓存键
|
|
37
|
+
* @param data 缓存数据
|
|
38
|
+
*/
|
|
39
|
+
set(key: string, data: T): void;
|
|
40
|
+
/**
|
|
41
|
+
* 获取缓存
|
|
42
|
+
* @param key 缓存键
|
|
43
|
+
* @returns 缓存数据或undefined
|
|
44
|
+
*/
|
|
45
|
+
get(key: string): T | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* 检查是否存在缓存
|
|
48
|
+
* @param key 缓存键
|
|
49
|
+
* @returns 是否存在
|
|
50
|
+
*/
|
|
51
|
+
has(key: string): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* 清除所有缓存
|
|
54
|
+
*/
|
|
55
|
+
clear(): void;
|
|
56
|
+
/**
|
|
57
|
+
* 获取缓存大小
|
|
58
|
+
* @returns 当前缓存数量
|
|
59
|
+
*/
|
|
60
|
+
size(): number;
|
|
61
|
+
/**
|
|
62
|
+
* 获取缓存统计信息
|
|
63
|
+
* @returns 缓存统计信息
|
|
64
|
+
*/
|
|
65
|
+
getStats(): {
|
|
66
|
+
size: number;
|
|
67
|
+
maxSize: number;
|
|
68
|
+
usage: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* 删除指定的缓存项
|
|
72
|
+
* @param key 要删除的缓存键
|
|
73
|
+
* @returns 是否删除成功
|
|
74
|
+
*/
|
|
75
|
+
delete(key: string): boolean;
|
|
76
|
+
}
|
|
77
|
+
declare const scanCache: LRUCache<any>;
|
|
78
|
+
export default scanCache;
|