@pisell/private-materials 6.4.70 → 6.4.71
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +4 -4
- package/build/lowcode/render/default/view.js +5 -5
- package/build/lowcode/view.js +3 -3
- package/es/components/booking/forms/sendModal/useSendModal.d.ts +1 -1
- package/es/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/es/components/ticketBooking/hooks/pisellos/useProducts.js +106 -32
- package/lib/components/booking/forms/sendModal/useSendModal.d.ts +1 -1
- package/lib/components/checkout/hooks/useWalletPass.d.ts +1 -1
- package/lib/components/ticketBooking/hooks/pisellos/useProducts.js +54 -9
- package/package.json +13 -13
|
@@ -4,6 +4,6 @@ declare const useSendModal: (bookingId?: number) => {
|
|
|
4
4
|
setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
5
5
|
handleOpen: () => void;
|
|
6
6
|
handleValuesChange: (val: any) => void;
|
|
7
|
-
handleOk: (values: SendModalValues) => Promise<
|
|
7
|
+
handleOk: (values: SendModalValues) => Promise<boolean | undefined>;
|
|
8
8
|
};
|
|
9
9
|
export default useSendModal;
|
|
@@ -17,7 +17,7 @@ export declare const useWalletPass: (props: {
|
|
|
17
17
|
cardData: any;
|
|
18
18
|
handleSelectWallet: (value: number[]) => void;
|
|
19
19
|
selectedWalletIds: any[];
|
|
20
|
-
expiredWalletIds: any;
|
|
20
|
+
expiredWalletIds: any[];
|
|
21
21
|
expiredWalletData: any;
|
|
22
22
|
disabledWalletData: any[];
|
|
23
23
|
clearAllSelectedWallet: () => void;
|
|
@@ -13,7 +13,15 @@ import { useBookingTicket } from "./bookingTicket";
|
|
|
13
13
|
import { useState, useRef } from 'react';
|
|
14
14
|
import { useOsKey } from "../../context/OsKeyContext";
|
|
15
15
|
import { getProductCache, setProductCache } from "../../utils/productCache";
|
|
16
|
+
import { useEngineContext } from "../../../../hooks";
|
|
17
|
+
// 等待函数
|
|
18
|
+
var sleep = function sleep(ms) {
|
|
19
|
+
return new Promise(function (resolve) {
|
|
20
|
+
return setTimeout(resolve, ms);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
16
23
|
export var useProducts = function useProducts(notAvailableRef) {
|
|
24
|
+
var _context$appHelper;
|
|
17
25
|
var bookingTicket = useBookingTicket();
|
|
18
26
|
var osKey = useOsKey();
|
|
19
27
|
var _useState = useState([]),
|
|
@@ -26,17 +34,21 @@ export var useProducts = function useProducts(notAvailableRef) {
|
|
|
26
34
|
setLoading = _useState4[1];
|
|
27
35
|
var isFirstLoadRef = useRef(true);
|
|
28
36
|
var isFirstLoadDataRef = useRef(true);
|
|
37
|
+
var context = useEngineContext();
|
|
38
|
+
var _ref = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
|
|
39
|
+
getApp = _ref.getApp;
|
|
40
|
+
var app = getApp();
|
|
29
41
|
var getProducts = useMemoizedFn( /*#__PURE__*/function () {
|
|
30
|
-
var
|
|
31
|
-
var cachedProducts, freshProducts, _notAvailableRef$curr;
|
|
42
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
|
|
43
|
+
var cachedProducts, maxRetries, lastError, freshProducts, attempt, _app$logger, _app$logger$addLog, _app$logger2, _app$logger3, _app$logger3$addLog, _lastError, _notAvailableRef$curr;
|
|
32
44
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
45
|
while (1) switch (_context.prev = _context.next) {
|
|
34
46
|
case 0:
|
|
35
47
|
// 1. 如果是首次加载,尝试从缓存中获取数据
|
|
36
48
|
if (isFirstLoadRef.current && osKey) {
|
|
37
49
|
cachedProducts = getProductCache(osKey);
|
|
38
|
-
if (cachedProducts) {
|
|
39
|
-
//
|
|
50
|
+
if (cachedProducts && cachedProducts.length > 0) {
|
|
51
|
+
// 先展示缓存数据(只有非空时才展示)
|
|
40
52
|
setProducts(cachedProducts);
|
|
41
53
|
setLoading(false);
|
|
42
54
|
}
|
|
@@ -45,45 +57,107 @@ export var useProducts = function useProducts(notAvailableRef) {
|
|
|
45
57
|
setLoading(true);
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
// 2.
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
// 2. 重试逻辑:最多尝试3次,每次等待1秒
|
|
61
|
+
maxRetries = 3;
|
|
62
|
+
lastError = null;
|
|
63
|
+
freshProducts = [];
|
|
64
|
+
attempt = 1;
|
|
65
|
+
case 5:
|
|
66
|
+
if (!(attempt <= maxRetries)) {
|
|
67
|
+
_context.next = 33;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
_context.prev = 6;
|
|
71
|
+
console.log("[ProductCache] \u5C1D\u8BD5\u52A0\u8F7D\u6570\u636E\uFF0C\u7B2C ".concat(attempt, "/").concat(maxRetries, " \u6B21"));
|
|
72
|
+
_context.next = 10;
|
|
51
73
|
return bookingTicket.loadProducts(params);
|
|
52
|
-
case
|
|
74
|
+
case 10:
|
|
53
75
|
freshProducts = _context.sent;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
if (!(freshProducts && freshProducts.length > 0)) {
|
|
77
|
+
_context.next = 14;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
console.log("[ProductCache] \u7B2C ".concat(attempt, " \u6B21\u5C1D\u8BD5\u6210\u529F\uFF0C\u83B7\u53D6\u5230 ").concat(freshProducts.length, " \u6761\u6570\u636E"));
|
|
81
|
+
return _context.abrupt("break", 33);
|
|
82
|
+
case 14:
|
|
83
|
+
// 数据为空,记录并准备重试
|
|
84
|
+
console.log("[ProductCache] \u7B2C ".concat(attempt, " \u6B21\u5C1D\u8BD5\u8FD4\u56DE\u7A7A\u6570\u636E"));
|
|
85
|
+
if (!(attempt < maxRetries)) {
|
|
86
|
+
_context.next = 19;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
console.log("[ProductCache] \u7B49\u5F85 1 \u79D2\u540E\u91CD\u8BD5...");
|
|
90
|
+
_context.next = 19;
|
|
91
|
+
return sleep(1000);
|
|
92
|
+
case 19:
|
|
93
|
+
_context.next = 30;
|
|
94
|
+
break;
|
|
95
|
+
case 21:
|
|
96
|
+
_context.prev = 21;
|
|
97
|
+
_context.t0 = _context["catch"](6);
|
|
98
|
+
lastError = _context.t0;
|
|
99
|
+
console.log("[ProductCache] \u7B2C ".concat(attempt, " \u6B21\u5C1D\u8BD5\u5931\u8D25:"), _context.t0);
|
|
100
|
+
app === null || app === void 0 || (_app$logger = app.logger) === null || _app$logger === void 0 || (_app$logger$addLog = (_app$logger2 = _app$logger).addLog) === null || _app$logger$addLog === void 0 || _app$logger$addLog.call(_app$logger2, {
|
|
101
|
+
type: 'info',
|
|
102
|
+
title: "[getProduct] bookingTicket.loadProducts error (attempt ".concat(attempt, "/").concat(maxRetries, ")"),
|
|
103
|
+
metadata: {
|
|
104
|
+
error: _context.t0,
|
|
105
|
+
attempt: attempt
|
|
106
|
+
}
|
|
107
|
+
});
|
|
57
108
|
|
|
58
|
-
//
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
109
|
+
// 如果还有重试机会,等待后继续
|
|
110
|
+
if (!(attempt < maxRetries)) {
|
|
111
|
+
_context.next = 30;
|
|
112
|
+
break;
|
|
62
113
|
}
|
|
63
|
-
|
|
114
|
+
console.log("[ProductCache] \u7B49\u5F85 1 \u79D2\u540E\u91CD\u8BD5...");
|
|
115
|
+
_context.next = 30;
|
|
116
|
+
return sleep(1000);
|
|
117
|
+
case 30:
|
|
118
|
+
attempt++;
|
|
119
|
+
_context.next = 5;
|
|
64
120
|
break;
|
|
65
|
-
case
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
(
|
|
121
|
+
case 33:
|
|
122
|
+
// 3. 处理最终结果
|
|
123
|
+
if (freshProducts && freshProducts.length > 0) {
|
|
124
|
+
// 成功获取到数据
|
|
125
|
+
isFirstLoadDataRef.current = false;
|
|
126
|
+
setProducts(freshProducts);
|
|
127
|
+
|
|
128
|
+
// 将新数据缓存到 storage
|
|
129
|
+
if (osKey) {
|
|
130
|
+
setProductCache(osKey, freshProducts);
|
|
131
|
+
console.log('[ProductCache] 已更新缓存');
|
|
132
|
+
}
|
|
133
|
+
setLoading(false);
|
|
134
|
+
} else {
|
|
135
|
+
// 3次尝试后仍然没有数据
|
|
136
|
+
console.log('[ProductCache] 3次尝试后仍未获取到数据');
|
|
137
|
+
app === null || app === void 0 || (_app$logger3 = app.logger) === null || _app$logger3 === void 0 || (_app$logger3$addLog = _app$logger3.addLog) === null || _app$logger3$addLog === void 0 || _app$logger3$addLog.call(_app$logger3, {
|
|
138
|
+
type: 'error',
|
|
139
|
+
title: '[getProduct] 3次尝试后仍未获取到数据',
|
|
140
|
+
metadata: {
|
|
141
|
+
error: lastError
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// 只有在第一次加载或之前有数据时才显示 notAvailable
|
|
146
|
+
if (((_lastError = lastError) === null || _lastError === void 0 ? void 0 : _lastError.code) === 607100 && (isFirstLoadDataRef.current || products.length > 0)) {
|
|
147
|
+
(_notAvailableRef$curr = notAvailableRef.current) === null || _notAvailableRef$curr === void 0 || _notAvailableRef$curr.open();
|
|
148
|
+
}
|
|
149
|
+
setLoading(false);
|
|
150
|
+
setProducts([]);
|
|
151
|
+
isFirstLoadDataRef.current = false;
|
|
71
152
|
}
|
|
72
|
-
|
|
73
|
-
setProducts([]);
|
|
74
|
-
isFirstLoadDataRef.current = false;
|
|
75
|
-
case 16:
|
|
76
|
-
_context.prev = 16;
|
|
77
|
-
setLoading(false);
|
|
78
|
-
return _context.finish(16);
|
|
79
|
-
case 19:
|
|
153
|
+
case 34:
|
|
80
154
|
case "end":
|
|
81
155
|
return _context.stop();
|
|
82
156
|
}
|
|
83
|
-
}, _callee, null, [[
|
|
157
|
+
}, _callee, null, [[6, 21]]);
|
|
84
158
|
}));
|
|
85
159
|
return function (_x) {
|
|
86
|
-
return
|
|
160
|
+
return _ref2.apply(this, arguments);
|
|
87
161
|
};
|
|
88
162
|
}());
|
|
89
163
|
return {
|
|
@@ -4,6 +4,6 @@ declare const useSendModal: (bookingId?: number) => {
|
|
|
4
4
|
setOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
5
5
|
handleOpen: () => void;
|
|
6
6
|
handleValuesChange: (val: any) => void;
|
|
7
|
-
handleOk: (values: SendModalValues) => Promise<
|
|
7
|
+
handleOk: (values: SendModalValues) => Promise<boolean | undefined>;
|
|
8
8
|
};
|
|
9
9
|
export default useSendModal;
|
|
@@ -17,7 +17,7 @@ export declare const useWalletPass: (props: {
|
|
|
17
17
|
cardData: any;
|
|
18
18
|
handleSelectWallet: (value: number[]) => void;
|
|
19
19
|
selectedWalletIds: any[];
|
|
20
|
-
expiredWalletIds: any;
|
|
20
|
+
expiredWalletIds: any[];
|
|
21
21
|
expiredWalletData: any;
|
|
22
22
|
disabledWalletData: any[];
|
|
23
23
|
clearAllSelectedWallet: () => void;
|
|
@@ -27,18 +27,24 @@ var import_bookingTicket = require("./bookingTicket");
|
|
|
27
27
|
var import_react = require("react");
|
|
28
28
|
var import_OsKeyContext = require("../../context/OsKeyContext");
|
|
29
29
|
var import_productCache = require("../../utils/productCache");
|
|
30
|
+
var import_hooks = require("../../../../hooks");
|
|
31
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
30
32
|
var useProducts = (notAvailableRef) => {
|
|
33
|
+
var _a;
|
|
31
34
|
const bookingTicket = (0, import_bookingTicket.useBookingTicket)();
|
|
32
35
|
const osKey = (0, import_OsKeyContext.useOsKey)();
|
|
33
36
|
const [products, setProducts] = (0, import_react.useState)([]);
|
|
34
37
|
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
35
38
|
const isFirstLoadRef = (0, import_react.useRef)(true);
|
|
36
39
|
const isFirstLoadDataRef = (0, import_react.useRef)(true);
|
|
40
|
+
const context = (0, import_hooks.useEngineContext)();
|
|
41
|
+
const { getApp } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
|
|
42
|
+
const app = getApp();
|
|
37
43
|
const getProducts = (0, import_ahooks.useMemoizedFn)(async (params) => {
|
|
38
|
-
var
|
|
44
|
+
var _a2, _b, _c, _d, _e;
|
|
39
45
|
if (isFirstLoadRef.current && osKey) {
|
|
40
46
|
const cachedProducts = (0, import_productCache.getProductCache)(osKey);
|
|
41
|
-
if (cachedProducts) {
|
|
47
|
+
if (cachedProducts && cachedProducts.length > 0) {
|
|
42
48
|
setProducts(cachedProducts);
|
|
43
49
|
setLoading(false);
|
|
44
50
|
}
|
|
@@ -46,23 +52,62 @@ var useProducts = (notAvailableRef) => {
|
|
|
46
52
|
} else {
|
|
47
53
|
setLoading(true);
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
const maxRetries = 3;
|
|
56
|
+
let lastError = null;
|
|
57
|
+
let freshProducts = [];
|
|
58
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
59
|
+
try {
|
|
60
|
+
console.log(`[ProductCache] 尝试加载数据,第 ${attempt}/${maxRetries} 次`);
|
|
61
|
+
freshProducts = await bookingTicket.loadProducts(params);
|
|
62
|
+
if (freshProducts && freshProducts.length > 0) {
|
|
63
|
+
console.log(`[ProductCache] 第 ${attempt} 次尝试成功,获取到 ${freshProducts.length} 条数据`);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
console.log(`[ProductCache] 第 ${attempt} 次尝试返回空数据`);
|
|
67
|
+
if (attempt < maxRetries) {
|
|
68
|
+
console.log(`[ProductCache] 等待 1 秒后重试...`);
|
|
69
|
+
await sleep(1e3);
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
lastError = error;
|
|
73
|
+
console.log(`[ProductCache] 第 ${attempt} 次尝试失败:`, error);
|
|
74
|
+
(_b = (_a2 = app == null ? void 0 : app.logger) == null ? void 0 : _a2.addLog) == null ? void 0 : _b.call(_a2, {
|
|
75
|
+
type: "info",
|
|
76
|
+
title: `[getProduct] bookingTicket.loadProducts error (attempt ${attempt}/${maxRetries})`,
|
|
77
|
+
metadata: {
|
|
78
|
+
error,
|
|
79
|
+
attempt
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (attempt < maxRetries) {
|
|
83
|
+
console.log(`[ProductCache] 等待 1 秒后重试...`);
|
|
84
|
+
await sleep(1e3);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (freshProducts && freshProducts.length > 0) {
|
|
51
89
|
isFirstLoadDataRef.current = false;
|
|
52
90
|
setProducts(freshProducts);
|
|
53
91
|
if (osKey) {
|
|
54
92
|
(0, import_productCache.setProductCache)(osKey, freshProducts);
|
|
55
93
|
console.log("[ProductCache] 已更新缓存");
|
|
56
94
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
95
|
+
setLoading(false);
|
|
96
|
+
} else {
|
|
97
|
+
console.log("[ProductCache] 3次尝试后仍未获取到数据");
|
|
98
|
+
(_d = (_c = app == null ? void 0 : app.logger) == null ? void 0 : _c.addLog) == null ? void 0 : _d.call(_c, {
|
|
99
|
+
type: "error",
|
|
100
|
+
title: "[getProduct] 3次尝试后仍未获取到数据",
|
|
101
|
+
metadata: {
|
|
102
|
+
error: lastError
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
if ((lastError == null ? void 0 : lastError.code) === 607100 && (isFirstLoadDataRef.current || products.length > 0)) {
|
|
106
|
+
(_e = notAvailableRef.current) == null ? void 0 : _e.open();
|
|
60
107
|
}
|
|
61
108
|
setLoading(false);
|
|
62
109
|
setProducts([]);
|
|
63
110
|
isFirstLoadDataRef.current = false;
|
|
64
|
-
} finally {
|
|
65
|
-
setLoading(false);
|
|
66
111
|
}
|
|
67
112
|
});
|
|
68
113
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.71",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "father dev",
|
|
6
|
+
"build": "father build",
|
|
7
|
+
"lowcode:dev": "build-scripts start --config ./build.lowcode.js",
|
|
8
|
+
"lowcode:build": " build-scripts build --config ./build.lowcode.js"
|
|
9
|
+
},
|
|
4
10
|
"main": "./lib/index.js",
|
|
5
11
|
"module": "./es/index.js",
|
|
6
12
|
"types": "./lib/index.d.ts",
|
|
@@ -50,6 +56,10 @@
|
|
|
50
56
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
51
57
|
"@dnd-kit/sortable": "^7.0.2",
|
|
52
58
|
"@dnd-kit/utilities": "^3.2.1",
|
|
59
|
+
"@pisell/date-picker": "workspace:*",
|
|
60
|
+
"@pisell/icon": "workspace:*",
|
|
61
|
+
"@pisell/materials": "workspace:*",
|
|
62
|
+
"@pisell/utils": "workspace:*",
|
|
53
63
|
"ahooks": "^3.7.6",
|
|
54
64
|
"antd": "^5.6.3",
|
|
55
65
|
"classnames": "^2.3.2",
|
|
@@ -60,11 +70,7 @@
|
|
|
60
70
|
"react-resizable": "^3.0.5",
|
|
61
71
|
"styled-components": "^6.0.0-rc.3",
|
|
62
72
|
"@react-spring/web": "^9.6.1",
|
|
63
|
-
"@use-gesture/react": "^10.3.1"
|
|
64
|
-
"@pisell/icon": "0.0.11",
|
|
65
|
-
"@pisell/utils": "3.0.2",
|
|
66
|
-
"@pisell/date-picker": "3.0.7",
|
|
67
|
-
"@pisell/materials": "6.4.17"
|
|
73
|
+
"@use-gesture/react": "^10.3.1"
|
|
68
74
|
},
|
|
69
75
|
"peerDependencies": {
|
|
70
76
|
"react": "^18.0.0",
|
|
@@ -72,11 +78,5 @@
|
|
|
72
78
|
},
|
|
73
79
|
"componentConfig": {
|
|
74
80
|
"materialSchema": "https://unpkg.com/@pisell/materials@1.0.1/build/lowcode/assets-prod.json"
|
|
75
|
-
},
|
|
76
|
-
"scripts": {
|
|
77
|
-
"dev": "father dev",
|
|
78
|
-
"build": "father build",
|
|
79
|
-
"lowcode:dev": "build-scripts start --config ./build.lowcode.js",
|
|
80
|
-
"lowcode:build": " build-scripts build --config ./build.lowcode.js"
|
|
81
81
|
}
|
|
82
|
-
}
|
|
82
|
+
}
|