best-unit 1.2.12 → 1.2.14
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/best-unit.cjs +13 -13
- package/dist/best-unit.js +1459 -1442
- package/dist/types/global.d.ts +14 -0
- package/dist/types/index.ts +4 -0
- package/package.json +1 -1
- package/src/api/axiosInstance.ts +34 -40
- package/src/components/business/recharge-sdk/components/offline-transfer-form/index.tsx +1 -1
- package/src/components/business/recharge-sdk/components/offline-transfer-form/theme.tsx +42 -43
- package/src/components/business/recharge-sdk/components/online-recharge-form/theme.tsx +27 -27
- package/src/components/business/recharge-sdk/components/recharge/index.tsx +9 -2
- package/src/components/business/recharge-sdk/components/recharge/theme.tsx +6 -7
- package/src/components/business/statistical-balance/theme.tsx +24 -23
- package/src/components/common/button/theme.tsx +6 -6
- package/src/components/common/modal/index.tsx +7 -5
- package/src/components/common/modal/theme.tsx +18 -18
- package/src/components/common/select/index.tsx +23 -14
- package/src/components/common/upload/index.tsx +26 -9
- package/src/components/common/upload/theme.tsx +19 -17
- package/src/demo/App.tsx +10 -9
- package/src/types/global.d.ts +14 -0
- package/src/types/index.ts +4 -0
- package/src/utils/business/index.ts +5 -1
- package/src/api/waitUnit.ts +0 -62
package/src/api/waitUnit.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// 等待 fund_unit_params 就绪的工具
|
|
2
|
-
|
|
3
|
-
type ResolveFn = () => void;
|
|
4
|
-
|
|
5
|
-
let pendingResolvers: ResolveFn[] = [];
|
|
6
|
-
let pollingTimer: number | null = null;
|
|
7
|
-
|
|
8
|
-
function readFundUnitParams(): Record<string, any> {
|
|
9
|
-
try {
|
|
10
|
-
const raw = sessionStorage.getItem("fund_unit_params") || "{}";
|
|
11
|
-
return JSON.parse(raw);
|
|
12
|
-
} catch (e) {
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function isFundUnitParamsReady(): boolean {
|
|
18
|
-
const params = readFundUnitParams();
|
|
19
|
-
// 判定“非空对象”
|
|
20
|
-
return params && typeof params === "object" && Object.keys(params).length > 0;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getFundUnitParams(): Record<string, any> {
|
|
24
|
-
return readFundUnitParams();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function startPollingIfNeeded(): void {
|
|
28
|
-
if (pollingTimer !== null) return;
|
|
29
|
-
// 轻量轮询,检测到就绪后立即 resolve 并停止
|
|
30
|
-
pollingTimer = window.setInterval(() => {
|
|
31
|
-
if (isFundUnitParamsReady()) {
|
|
32
|
-
if (pollingTimer !== null) {
|
|
33
|
-
window.clearInterval(pollingTimer);
|
|
34
|
-
pollingTimer = null;
|
|
35
|
-
}
|
|
36
|
-
const resolvers = pendingResolvers.slice();
|
|
37
|
-
pendingResolvers = [];
|
|
38
|
-
resolvers.forEach((resolve) => resolve());
|
|
39
|
-
}
|
|
40
|
-
}, 100);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 对外暴露:等待 fund_unit_params 就绪
|
|
44
|
-
export function waitFundUnitReady(): Promise<void> {
|
|
45
|
-
if (isFundUnitParamsReady()) return Promise.resolve();
|
|
46
|
-
startPollingIfNeeded();
|
|
47
|
-
return new Promise<void>((resolve) => {
|
|
48
|
-
pendingResolvers.push(resolve);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 可选:手动通知(如果你在别处设置了 fund_unit_params 后希望立刻触发)
|
|
53
|
-
export function notifyFundUnitParamsUpdated(): void {
|
|
54
|
-
if (!isFundUnitParamsReady()) return;
|
|
55
|
-
const resolvers = pendingResolvers.slice();
|
|
56
|
-
pendingResolvers = [];
|
|
57
|
-
resolvers.forEach((resolve) => resolve());
|
|
58
|
-
if (pollingTimer !== null) {
|
|
59
|
-
window.clearInterval(pollingTimer);
|
|
60
|
-
pollingTimer = null;
|
|
61
|
-
}
|
|
62
|
-
}
|