@pisell/pisellos 0.0.215 → 0.0.217
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/Customer/index.d.ts +33 -0
- package/dist/modules/Customer/index.js +316 -58
- package/dist/modules/Customer/types.d.ts +17 -1
- package/dist/modules/Customer/types.js +2 -0
- package/dist/modules/ProductList/index.d.ts +6 -0
- package/dist/modules/ProductList/index.js +20 -0
- package/dist/solution/BookingTicket/index.d.ts +33 -0
- package/dist/solution/BookingTicket/index.js +167 -21
- package/dist/solution/BookingTicket/types.d.ts +3 -1
- package/dist/solution/BookingTicket/types.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +15 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +99 -55
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +12 -4
- package/dist/solution/BookingTicket/utils/scan/index.js +32 -20
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/lib/modules/Customer/index.d.ts +33 -0
- package/lib/modules/Customer/index.js +168 -32
- package/lib/modules/Customer/types.d.ts +17 -1
- package/lib/modules/Customer/types.js +2 -0
- package/lib/modules/ProductList/index.d.ts +6 -0
- package/lib/modules/ProductList/index.js +18 -0
- package/lib/solution/BookingTicket/index.d.ts +33 -0
- package/lib/solution/BookingTicket/index.js +98 -8
- package/lib/solution/BookingTicket/types.d.ts +3 -1
- package/lib/solution/BookingTicket/types.js +2 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +23 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +58 -16
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +12 -4
- package/lib/solution/BookingTicket/utils/scan/index.js +16 -20
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/package.json +1 -1
|
@@ -10,10 +10,15 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
11
|
import watch from "../../../../utils/watch";
|
|
12
12
|
import Tasks from "../../../../utils/task";
|
|
13
|
-
|
|
13
|
+
var ScanResultType = /*#__PURE__*/function (ScanResultType) {
|
|
14
|
+
ScanResultType["Scanner"] = "scanner";
|
|
15
|
+
ScanResultType["NFC"] = "nfc";
|
|
16
|
+
ScanResultType["NativeScanner"] = "nativeScanner";
|
|
17
|
+
return ScanResultType;
|
|
18
|
+
}(ScanResultType || {});
|
|
19
|
+
var Scan = /*#__PURE__*/function () {
|
|
14
20
|
function Scan(solution, watchKey) {
|
|
15
|
-
var
|
|
16
|
-
_this$solution,
|
|
21
|
+
var _this$solution,
|
|
17
22
|
_this$solution$mountF,
|
|
18
23
|
_this = this;
|
|
19
24
|
_classCallCheck(this, Scan);
|
|
@@ -22,9 +27,9 @@ export var Scan = /*#__PURE__*/function () {
|
|
|
22
27
|
_defineProperty(this, "listenerConfig", new Map());
|
|
23
28
|
this.solution = solution;
|
|
24
29
|
this.watchKey = watchKey;
|
|
25
|
-
|
|
30
|
+
|
|
26
31
|
// 监听扫码结果
|
|
27
|
-
(_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', '
|
|
32
|
+
(_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', 'peripheralsResult', function (strVal) {
|
|
28
33
|
try {
|
|
29
34
|
var _result = JSON.parse(strVal);
|
|
30
35
|
console.log('nativeScannerResult>>>>>>>', _result);
|
|
@@ -42,7 +47,7 @@ export var Scan = /*#__PURE__*/function () {
|
|
|
42
47
|
*/
|
|
43
48
|
_createClass(Scan, [{
|
|
44
49
|
key: "addListener",
|
|
45
|
-
value: function addListener(event,
|
|
50
|
+
value: function addListener(event, scanCallback) {
|
|
46
51
|
var _this2 = this;
|
|
47
52
|
// 订阅事件
|
|
48
53
|
watch.subscribe(this.watchKey, event);
|
|
@@ -54,9 +59,10 @@ export var Scan = /*#__PURE__*/function () {
|
|
|
54
59
|
}
|
|
55
60
|
return _this2.handleScanResultFn.apply(_this2, [event.key].concat(args));
|
|
56
61
|
});
|
|
62
|
+
|
|
57
63
|
// 创建监听配置
|
|
58
64
|
this.listenerConfig.set(event.key, {
|
|
59
|
-
|
|
65
|
+
scanCallback: scanCallback,
|
|
60
66
|
task: task
|
|
61
67
|
});
|
|
62
68
|
return {
|
|
@@ -131,7 +137,8 @@ export var Scan = /*#__PURE__*/function () {
|
|
|
131
137
|
_ref,
|
|
132
138
|
type,
|
|
133
139
|
value,
|
|
134
|
-
|
|
140
|
+
data,
|
|
141
|
+
scanCallback,
|
|
135
142
|
_result2,
|
|
136
143
|
_args = arguments;
|
|
137
144
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -141,43 +148,47 @@ export var Scan = /*#__PURE__*/function () {
|
|
|
141
148
|
args[_key2] = _args[_key2];
|
|
142
149
|
}
|
|
143
150
|
eventKey = args[0], other = args[1];
|
|
144
|
-
_ref = (other === null || other === void 0 ? void 0 : other.scanResult) || {}, type = _ref.type, value = _ref.value;
|
|
145
|
-
|
|
146
|
-
if (!
|
|
147
|
-
_context.next =
|
|
151
|
+
_ref = (other === null || other === void 0 ? void 0 : other.scanResult) || {}, type = _ref.type, value = _ref.value, data = _ref.data;
|
|
152
|
+
scanCallback = (_this$getListenerConf = this.getListenerConfig(eventKey)) === null || _this$getListenerConf === void 0 ? void 0 : _this$getListenerConf.scanCallback;
|
|
153
|
+
if (!scanCallback) {
|
|
154
|
+
_context.next = 17;
|
|
148
155
|
break;
|
|
149
156
|
}
|
|
150
157
|
_context.prev = 5;
|
|
151
158
|
_context.next = 8;
|
|
152
|
-
return
|
|
159
|
+
return scanCallback({
|
|
153
160
|
type: type,
|
|
154
161
|
value: value
|
|
155
162
|
});
|
|
156
163
|
case 8:
|
|
157
164
|
_result2 = _context.sent;
|
|
165
|
+
console.log("".concat(eventKey, "_result>>>>>>>"), _result2);
|
|
158
166
|
watch.publishByEventKey(this.watchKey, eventKey, {
|
|
159
167
|
type: eventKey,
|
|
160
168
|
status: 'success',
|
|
161
169
|
scanType: type,
|
|
162
170
|
scanCode: value,
|
|
171
|
+
scanData: data,
|
|
163
172
|
result: _result2
|
|
164
173
|
});
|
|
165
|
-
_context.next =
|
|
174
|
+
_context.next = 17;
|
|
166
175
|
break;
|
|
167
|
-
case
|
|
168
|
-
_context.prev =
|
|
176
|
+
case 13:
|
|
177
|
+
_context.prev = 13;
|
|
169
178
|
_context.t0 = _context["catch"](5);
|
|
179
|
+
console.log("".concat(eventKey, "_result_error>>>>>>>"), _context.t0);
|
|
170
180
|
watch.publishByEventKey(this.watchKey, eventKey, {
|
|
171
181
|
type: eventKey,
|
|
172
182
|
status: 'failed',
|
|
173
183
|
scanType: type,
|
|
174
|
-
scanCode: value
|
|
184
|
+
scanCode: value,
|
|
185
|
+
scanData: data
|
|
175
186
|
});
|
|
176
|
-
case
|
|
187
|
+
case 17:
|
|
177
188
|
case "end":
|
|
178
189
|
return _context.stop();
|
|
179
190
|
}
|
|
180
|
-
}, _callee, this, [[5,
|
|
191
|
+
}, _callee, this, [[5, 13]]);
|
|
181
192
|
}));
|
|
182
193
|
function handleScanResultFn() {
|
|
183
194
|
return _handleScanResultFn.apply(this, arguments);
|
|
@@ -186,4 +197,5 @@ export var Scan = /*#__PURE__*/function () {
|
|
|
186
197
|
}())
|
|
187
198
|
}]);
|
|
188
199
|
return Scan;
|
|
189
|
-
}();
|
|
200
|
+
}();
|
|
201
|
+
export { Scan as default };
|
|
@@ -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;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
/**
|
|
9
|
+
* 简单的数据压缩函数
|
|
10
|
+
* @param data 要压缩的数据
|
|
11
|
+
* @returns 压缩后的字符串
|
|
12
|
+
*/
|
|
13
|
+
var compressData = function compressData(data) {
|
|
14
|
+
try {
|
|
15
|
+
// 处理undefined值
|
|
16
|
+
if (data === undefined) {
|
|
17
|
+
return 'undefined';
|
|
18
|
+
}
|
|
19
|
+
return JSON.stringify(data);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.warn('数据压缩失败:', error);
|
|
22
|
+
return JSON.stringify(data);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 数据解压缩函数
|
|
28
|
+
* @param compressedData 压缩后的数据
|
|
29
|
+
* @returns 解压缩后的数据
|
|
30
|
+
*/
|
|
31
|
+
var decompressData = function decompressData(compressedData) {
|
|
32
|
+
try {
|
|
33
|
+
// 处理undefined值
|
|
34
|
+
if (compressedData === 'undefined') {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return JSON.parse(compressedData);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.warn('数据解压缩失败:', error);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 双向链表节点
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* LRU缓存类,用于缓存接口数据
|
|
49
|
+
* 限制最多存储100条数据,超过时移除最久未使用的数据
|
|
50
|
+
* 支持数据压缩以减小缓存压力
|
|
51
|
+
* 尾部优先策略:新节点插入尾部,最近使用的节点移动到尾部,删除头部节点
|
|
52
|
+
*/
|
|
53
|
+
var LRUCache = /*#__PURE__*/function () {
|
|
54
|
+
function LRUCache() {
|
|
55
|
+
var maxSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
56
|
+
_classCallCheck(this, LRUCache);
|
|
57
|
+
_defineProperty(this, "head", null);
|
|
58
|
+
// 最久未使用的节点
|
|
59
|
+
_defineProperty(this, "tail", null);
|
|
60
|
+
// 最近使用的节点
|
|
61
|
+
_defineProperty(this, "keyMap", new Map());
|
|
62
|
+
// key到节点的映射(只存储引用)
|
|
63
|
+
_defineProperty(this, "maxSize", void 0);
|
|
64
|
+
this.maxSize = maxSize;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 将节点移动到链表尾部(最近使用)
|
|
69
|
+
* @param node 要移动的节点
|
|
70
|
+
*/
|
|
71
|
+
_createClass(LRUCache, [{
|
|
72
|
+
key: "moveToTail",
|
|
73
|
+
value: function moveToTail(node) {
|
|
74
|
+
if (this.tail === node) return; // 已经是尾部
|
|
75
|
+
|
|
76
|
+
// 从当前位置移除
|
|
77
|
+
if (node.prev) {
|
|
78
|
+
node.prev.next = node.next;
|
|
79
|
+
}
|
|
80
|
+
if (node.next) {
|
|
81
|
+
node.next.prev = node.prev;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 如果是头部,更新头部
|
|
85
|
+
if (this.head === node) {
|
|
86
|
+
this.head = node.next;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 移动到尾部
|
|
90
|
+
if (this.tail) {
|
|
91
|
+
this.tail.next = node;
|
|
92
|
+
}
|
|
93
|
+
node.prev = this.tail;
|
|
94
|
+
node.next = null;
|
|
95
|
+
this.tail = node;
|
|
96
|
+
|
|
97
|
+
// 如果链表为空,设置头部
|
|
98
|
+
if (!this.head) {
|
|
99
|
+
this.head = node;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 添加新节点到链表尾部
|
|
105
|
+
* @param key 缓存键
|
|
106
|
+
* @param compressedData 压缩后的数据
|
|
107
|
+
* @param timestamp 时间戳
|
|
108
|
+
*/
|
|
109
|
+
}, {
|
|
110
|
+
key: "addToTail",
|
|
111
|
+
value: function addToTail(key, compressedData, timestamp) {
|
|
112
|
+
// 先保存当前的tail引用
|
|
113
|
+
var oldTail = this.tail;
|
|
114
|
+
var node = {
|
|
115
|
+
key: key,
|
|
116
|
+
compressedData: compressedData,
|
|
117
|
+
timestamp: timestamp,
|
|
118
|
+
prev: oldTail,
|
|
119
|
+
// 使用保存的引用,避免循环引用
|
|
120
|
+
next: null
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// 存储节点引用
|
|
124
|
+
this.keyMap.set(key, node);
|
|
125
|
+
|
|
126
|
+
// 更新链表关系
|
|
127
|
+
if (oldTail) {
|
|
128
|
+
oldTail.next = node;
|
|
129
|
+
}
|
|
130
|
+
this.tail = node;
|
|
131
|
+
|
|
132
|
+
// 如果是第一个节点,设置head
|
|
133
|
+
if (!this.head) {
|
|
134
|
+
this.head = node;
|
|
135
|
+
}
|
|
136
|
+
return node;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 从链表中移除节点
|
|
141
|
+
* @param node 要移除的节点
|
|
142
|
+
*/
|
|
143
|
+
}, {
|
|
144
|
+
key: "removeNode",
|
|
145
|
+
value: function removeNode(node) {
|
|
146
|
+
if (node.prev) {
|
|
147
|
+
node.prev.next = node.next;
|
|
148
|
+
}
|
|
149
|
+
if (node.next) {
|
|
150
|
+
node.next.prev = node.prev;
|
|
151
|
+
}
|
|
152
|
+
if (this.head === node) {
|
|
153
|
+
this.head = node.next;
|
|
154
|
+
}
|
|
155
|
+
if (this.tail === node) {
|
|
156
|
+
this.tail = node.prev;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 从Map中移除引用
|
|
160
|
+
this.keyMap.delete(node.key);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 移除最久未使用的节点(链表头部)
|
|
165
|
+
*/
|
|
166
|
+
}, {
|
|
167
|
+
key: "removeOldest",
|
|
168
|
+
value: function removeOldest() {
|
|
169
|
+
if (this.head) {
|
|
170
|
+
this.removeNode(this.head);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 设置缓存
|
|
176
|
+
* @param key 缓存键
|
|
177
|
+
* @param data 缓存数据
|
|
178
|
+
*/
|
|
179
|
+
}, {
|
|
180
|
+
key: "set",
|
|
181
|
+
value: function set(key, data) {
|
|
182
|
+
// 压缩数据
|
|
183
|
+
var compressedData = compressData(data);
|
|
184
|
+
var timestamp = Date.now();
|
|
185
|
+
|
|
186
|
+
// 检查是否已存在该key
|
|
187
|
+
var existingNode = this.keyMap.get(key);
|
|
188
|
+
if (existingNode) {
|
|
189
|
+
// 如果已存在,更新数据并移动到链表尾部
|
|
190
|
+
existingNode.compressedData = compressedData;
|
|
191
|
+
existingNode.timestamp = timestamp;
|
|
192
|
+
this.moveToTail(existingNode);
|
|
193
|
+
} else {
|
|
194
|
+
// 如果是新数据且缓存已满,移除最久未使用的数据(头部)
|
|
195
|
+
if (this.keyMap.size >= this.maxSize) {
|
|
196
|
+
this.removeOldest();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 添加新数据到尾部
|
|
200
|
+
this.addToTail(key, compressedData, timestamp);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 获取缓存
|
|
206
|
+
* @param key 缓存键
|
|
207
|
+
* @returns 缓存数据或undefined
|
|
208
|
+
*/
|
|
209
|
+
}, {
|
|
210
|
+
key: "get",
|
|
211
|
+
value: function get(key) {
|
|
212
|
+
var node = this.keyMap.get(key);
|
|
213
|
+
if (node) {
|
|
214
|
+
// 解压缩数据
|
|
215
|
+
var decompressedData = decompressData(node.compressedData);
|
|
216
|
+
if (decompressedData !== null) {
|
|
217
|
+
// 更新访问时间戳并移动到链表尾部
|
|
218
|
+
node.timestamp = Date.now();
|
|
219
|
+
this.moveToTail(node);
|
|
220
|
+
return decompressedData;
|
|
221
|
+
} else {
|
|
222
|
+
// 如果解压缩失败,删除该缓存项
|
|
223
|
+
this.removeNode(node);
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 检查是否存在缓存
|
|
232
|
+
* @param key 缓存键
|
|
233
|
+
* @returns 是否存在
|
|
234
|
+
*/
|
|
235
|
+
}, {
|
|
236
|
+
key: "has",
|
|
237
|
+
value: function has(key) {
|
|
238
|
+
return this.keyMap.has(key);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 清除所有缓存
|
|
243
|
+
*/
|
|
244
|
+
}, {
|
|
245
|
+
key: "clear",
|
|
246
|
+
value: function clear() {
|
|
247
|
+
// 清除所有节点的引用关系,帮助垃圾回收
|
|
248
|
+
var current = this.head;
|
|
249
|
+
while (current) {
|
|
250
|
+
var next = current.next;
|
|
251
|
+
current.prev = null;
|
|
252
|
+
current.next = null;
|
|
253
|
+
current = next;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 清除Map和头尾指针
|
|
257
|
+
this.keyMap.clear();
|
|
258
|
+
this.head = null;
|
|
259
|
+
this.tail = null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 获取缓存大小
|
|
264
|
+
* @returns 当前缓存数量
|
|
265
|
+
*/
|
|
266
|
+
}, {
|
|
267
|
+
key: "size",
|
|
268
|
+
value: function size() {
|
|
269
|
+
return this.keyMap.size;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 获取缓存统计信息
|
|
274
|
+
* @returns 缓存统计信息
|
|
275
|
+
*/
|
|
276
|
+
}, {
|
|
277
|
+
key: "getStats",
|
|
278
|
+
value: function getStats() {
|
|
279
|
+
return {
|
|
280
|
+
size: this.keyMap.size,
|
|
281
|
+
maxSize: this.maxSize,
|
|
282
|
+
usage: Math.round(this.keyMap.size / this.maxSize * 100)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 删除指定的缓存项
|
|
288
|
+
* @param key 要删除的缓存键
|
|
289
|
+
* @returns 是否删除成功
|
|
290
|
+
*/
|
|
291
|
+
}, {
|
|
292
|
+
key: "delete",
|
|
293
|
+
value: function _delete(key) {
|
|
294
|
+
var node = this.keyMap.get(key);
|
|
295
|
+
if (node) {
|
|
296
|
+
this.removeNode(node);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
}]);
|
|
302
|
+
return LRUCache;
|
|
303
|
+
}(); // 创建全局缓存实例
|
|
304
|
+
var scanCache = new LRUCache();
|
|
305
|
+
export default scanCache;
|
|
@@ -11,6 +11,18 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
11
11
|
private fatherModule;
|
|
12
12
|
constructor(name?: string, version?: string);
|
|
13
13
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* 获取客户列表数据(内部方法)
|
|
16
|
+
* @param params 查询参数
|
|
17
|
+
* @returns API响应数据
|
|
18
|
+
*/
|
|
19
|
+
private fetchCustomerListData;
|
|
20
|
+
/**
|
|
21
|
+
* 处理客户列表操作的错误(内部方法)
|
|
22
|
+
* @param error 错误对象
|
|
23
|
+
* @param operation 操作名称
|
|
24
|
+
*/
|
|
25
|
+
private handleCustomerListError;
|
|
14
26
|
/**
|
|
15
27
|
* 获取客户列表
|
|
16
28
|
* @param params 查询参数
|
|
@@ -81,6 +93,27 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
81
93
|
* @returns 客户列表响应
|
|
82
94
|
*/
|
|
83
95
|
changeCustomerPage(page: number, pageSize?: number): Promise<ICustomerListResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
98
|
+
* @returns 客户列表响应
|
|
99
|
+
*/
|
|
100
|
+
loadMoreCustomers(): Promise<ICustomerListResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* 重置并重新开始滚动加载
|
|
103
|
+
* @param params 查询参数
|
|
104
|
+
* @returns 客户列表响应
|
|
105
|
+
*/
|
|
106
|
+
resetAndLoadCustomers(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* 检查是否还有更多数据可以加载
|
|
109
|
+
* @returns 是否还有更多数据
|
|
110
|
+
*/
|
|
111
|
+
hasMoreCustomers(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* 获取当前的搜索条件
|
|
114
|
+
* @returns 当前搜索条件
|
|
115
|
+
*/
|
|
116
|
+
getCurrentSearchParams(): Omit<ShopGetCustomerListParams, 'skip' | 'num'>;
|
|
84
117
|
/**
|
|
85
118
|
* 缓存状态变化
|
|
86
119
|
*/
|