@24city/web-console 0.3.11 → 0.3.12
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/CHANGELOG.md +12 -0
- package/dist/account/auth-provider.d.ts +3 -1
- package/dist/account/index.js +4 -4
- package/dist/account/route-guard.d.ts +1 -1
- package/dist/chunks/auth-provider-Cwib6lRM.js +72 -0
- package/dist/chunks/{console-layout-CTVkNVdl.js → console-layout-BhmLHO5v.js} +1 -1
- package/dist/chunks/{logout-signal-CsnJzWTz.js → logout-signal-qvHorCCF.js} +135 -131
- package/dist/chunks/{stale-build-CpZMSNSH.js → stale-build-CJ5c5sRp.js} +2 -2
- package/dist/chunks/{use-show-once-mq5WGTrX.js → use-show-once-Cwj5z_Lo.js} +6 -6
- package/dist/chunks/{wallet-badge-3oCaCiNm.js → wallet-badge-DnWl21es.js} +1 -1
- package/dist/index.js +221 -220
- package/dist/layout/index.js +1 -1
- package/dist/runtime/error-summary.d.ts +2 -0
- package/dist/runtime/index.js +19 -18
- package/package.json +1 -1
- package/dist/chunks/auth-provider-3AIfwcdS.js +0 -62
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.12
|
|
4
|
+
|
|
5
|
+
**修复:发布期间恢复会话停在不可用页**(`AuthProvider`、`RouteGuard`、`LoginPage`)
|
|
6
|
+
|
|
7
|
+
- 恢复会话时遇到网络失败、超时或网关 502/503/504(例如 Staging 发布正在替换容器),先在加载态里隔 1、2、4 秒重试;
|
|
8
|
+
仍不可达才显示不可用页,之后每 15 秒静默再查一次,服务恢复后自动回到应用。回到窗口时立即重查,并取消等待中的静默复查。
|
|
9
|
+
其他失败(500、返回内容无效)和 401/403/404 不重试,行为不变。原先回到窗口时恰逢发布,页面会一直停在不可用页,直到手动刷新。
|
|
10
|
+
- 不可用页的文案不再说账号服务出了故障:工作台改为「服务暂时不可用 / 服务可能正在更新,请稍后重新加载;长时间无法恢复请联系
|
|
11
|
+
管理员。」,登录中转页改为「服务暂时不可用 / 服务可能正在更新,请稍后重试。」。
|
|
12
|
+
- `@24city/web-console/runtime` 新增 `isTransientServiceError(error)`。
|
|
13
|
+
- 来自 SaaS Starter 的同一修复(Starter 模板的会话恢复已改由本包提供)。
|
|
14
|
+
|
|
3
15
|
## 0.3.11
|
|
4
16
|
|
|
5
17
|
**新增:行为事件**(`@24city/web-console/account`,统一账号中心 API 1.24.0;运营在统一中心后台按行为圈人,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type PropsWithChildren } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* 会话恢复与同步:首次加载和其他标签页的会话变化时重读会话与空间;回到窗口时后台复核,用户、空间和用途都没变就保留
|
|
4
|
-
*
|
|
4
|
+
* 页面和缓存。服务暂时不可达(网络失败、超时、502/503/504)时先在加载态里隔 1、2、4 秒重试,仍不可达才显示不可用页,
|
|
5
|
+
* 之后每 15 秒静默再查,恢复后自动回到应用;其他失败不重试。给 HTTP 客户端配置 CSRF Token 和 401 处理:受保护路径下的
|
|
6
|
+
* 401 跳去登录页,其他标签页刚退出时不跳。
|
|
5
7
|
*/
|
|
6
8
|
export declare const AuthProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
|
package/dist/account/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as s, a as o, c as t, b as n, i as r, d as u, l as i, n as c, r as l, e as g, f as p, u as S, g as A, w as P } from "../chunks/logout-signal-
|
|
2
|
-
import { A as C, a as d, C as h, L as f, P as m, b as T, c as y, Q as N, R as O, S as b, d as E, T as U, U as v, e as w, p as F, f as R, g as _, h as x, u as B, y as I } from "../chunks/use-show-once-
|
|
3
|
-
import { A as q, a as D, b as K, E as Q, F as k, P as G, c as H, d as W, U as Y, e as j, W as z, f as J, g as V, h as X, i as Z, j as $, k as aa, l as ea, m as sa, n as oa, o as ta, p as na, q as ra, r as ua, s as ia, t as ca, u as la, v as ga, w as pa, x as Sa, y as Aa, z as Pa, B as La, C as Ca, D as da, G as ha, H as fa, I as ma, J as Ta, K as ya, L as Na, M as Oa, N as ba, O as Ea, Q as Ua, R as va, S as wa, T as Fa } from "../chunks/wallet-badge-
|
|
4
|
-
import { A as _a } from "../chunks/auth-provider-
|
|
1
|
+
import { A as s, a as o, c as t, b as n, i as r, d as u, l as i, n as c, r as l, e as g, f as p, u as S, g as A, w as P } from "../chunks/logout-signal-qvHorCCF.js";
|
|
2
|
+
import { A as C, a as d, C as h, L as f, P as m, b as T, c as y, Q as N, R as O, S as b, d as E, T as U, U as v, e as w, p as F, f as R, g as _, h as x, u as B, y as I } from "../chunks/use-show-once-Cwj5z_Lo.js";
|
|
3
|
+
import { A as q, a as D, b as K, E as Q, F as k, P as G, c as H, d as W, U as Y, e as j, W as z, f as J, g as V, h as X, i as Z, j as $, k as aa, l as ea, m as sa, n as oa, o as ta, p as na, q as ra, r as ua, s as ia, t as ca, u as la, v as ga, w as pa, x as Sa, y as Aa, z as Pa, B as La, C as Ca, D as da, G as ha, H as fa, I as ma, J as Ta, K as ya, L as Na, M as Oa, N as ba, O as Ea, Q as Ua, R as va, S as wa, T as Fa } from "../chunks/wallet-badge-DnWl21es.js";
|
|
4
|
+
import { A as _a } from "../chunks/auth-provider-Cwib6lRM.js";
|
|
5
5
|
import { notifyCustomerSessionChanged as Ba, subscribeCustomerSessionChanges as Ia } from "@24city/web-runtime/session-sync";
|
|
6
6
|
export {
|
|
7
7
|
q as ACCOUNT_SECTIONS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
/**
|
|
2
|
+
/** 受保护路由:会话未恢复时整屏加载;服务不可用时提示重新加载;没有 user 会话时带回跳地址去登录页。 */
|
|
3
3
|
export declare const RouteGuard: ({ children }: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as U, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as T } from "react";
|
|
3
|
+
import { useQueryClient as I } from "@tanstack/react-query";
|
|
4
|
+
import { b as R } from "./context-CaVim6ZO.js";
|
|
5
|
+
import { g as A, n as y, i as c, v as k, f as S, r as x, y as P, t as h } from "./logout-signal-qvHorCCF.js";
|
|
6
|
+
import { subscribeCustomerSessionChanges as _ } from "@24city/web-runtime/session-sync";
|
|
7
|
+
const z = (e) => !h(e, 401) && !h(e, 403) && !h(e, 404), F = (e, i) => (e == null ? void 0 : e.purpose) === i.purpose && e.globalUserId === i.globalUserId && e.activeSpaceId === i.activeSpaceId, H = [1e3, 2e3, 4e3], Q = 15e3, B = (e) => new Promise((i) => setTimeout(i, e)), D = ({ children: e }) => {
|
|
8
|
+
const i = I(), o = A(), { accountApi: f, config: r, http: d } = R();
|
|
9
|
+
return T(() => {
|
|
10
|
+
let a = !0, n = 0, u;
|
|
11
|
+
const p = () => {
|
|
12
|
+
clearTimeout(u), u = void 0;
|
|
13
|
+
}, w = async () => {
|
|
14
|
+
await i.cancelQueries().catch(() => {
|
|
15
|
+
}), i.clear();
|
|
16
|
+
}, m = async (t) => {
|
|
17
|
+
try {
|
|
18
|
+
const s = await S(f);
|
|
19
|
+
return a && n === t && (x(), o.setContext(s)), !0;
|
|
20
|
+
} catch (s) {
|
|
21
|
+
return !a || n !== t ? !0 : P(s) ? !1 : (o.clear({ unavailable: z(s) }), !0);
|
|
22
|
+
}
|
|
23
|
+
}, v = (t) => {
|
|
24
|
+
u = setTimeout(async () => {
|
|
25
|
+
u = void 0, !(!a || n !== t || c()) && (await m(t) || v(t));
|
|
26
|
+
}, Q);
|
|
27
|
+
}, l = async () => {
|
|
28
|
+
if (c()) return;
|
|
29
|
+
p();
|
|
30
|
+
const t = ++n;
|
|
31
|
+
o.setBootstrapping(), await w();
|
|
32
|
+
for (const s of H)
|
|
33
|
+
if (await m(t) || (await B(s), !a || n !== t || c())) return;
|
|
34
|
+
await m(t) || (o.clear({ unavailable: !0 }), v(t));
|
|
35
|
+
}, b = async () => {
|
|
36
|
+
if (c() || (n += 1, p(), await w(), o.clear(), y())) return;
|
|
37
|
+
const t = window.location.pathname + window.location.search;
|
|
38
|
+
k(window.location.pathname, r.routes.app) && window.location.assign(`${r.routes.login}?returnPath=${encodeURIComponent(t)}`);
|
|
39
|
+
};
|
|
40
|
+
d.configure({
|
|
41
|
+
baseUrl: r.api.baseUrl,
|
|
42
|
+
getCsrfToken: o.getCsrfToken,
|
|
43
|
+
onUnauthorized: b
|
|
44
|
+
});
|
|
45
|
+
const C = async () => {
|
|
46
|
+
if (c()) return;
|
|
47
|
+
if (!o.getState().session) return l();
|
|
48
|
+
const t = ++n;
|
|
49
|
+
try {
|
|
50
|
+
const s = await S(f);
|
|
51
|
+
if (!a || n !== t) return;
|
|
52
|
+
if (F(o.getState().session, s.session)) {
|
|
53
|
+
o.setContext(s);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
if (!a || n !== t) return;
|
|
58
|
+
}
|
|
59
|
+
await l();
|
|
60
|
+
}, E = _(() => {
|
|
61
|
+
y(), l();
|
|
62
|
+
}), g = () => {
|
|
63
|
+
document.visibilityState !== "hidden" && C();
|
|
64
|
+
};
|
|
65
|
+
return window.addEventListener("focus", g), l(), () => {
|
|
66
|
+
a = !1, n += 1, p(), E(), window.removeEventListener("focus", g), d.configure({ getCsrfToken: null, onUnauthorized: null });
|
|
67
|
+
};
|
|
68
|
+
}, [f, o, r.api.baseUrl, r.routes.app, r.routes.login, d, i]), /* @__PURE__ */ U(L, { children: e });
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
D as A
|
|
72
|
+
};
|
|
@@ -3,7 +3,7 @@ import { useEffect as z, useState as b } from "react";
|
|
|
3
3
|
import { Layout as v, Button as f, Typography as q, Space as D, Nav as $ } from "@douyinfe/semi-ui";
|
|
4
4
|
import { IconSidebar as P } from "@douyinfe/semi-icons";
|
|
5
5
|
import { useLocation as F, useNavigate as Q, Outlet as Y } from "react-router";
|
|
6
|
-
import { T as J, h as V, i as X, D as Z, q as ee, e as te, W as ne, b as ae } from "./wallet-badge-
|
|
6
|
+
import { T as J, h as V, i as X, D as Z, q as ee, e as te, W as ne, b as ae } from "./wallet-badge-DnWl21es.js";
|
|
7
7
|
import { u as R, b as oe, a as se } from "./context-CaVim6ZO.js";
|
|
8
8
|
import { u as le } from "./use-media-query-DvyinWNg.js";
|
|
9
9
|
import { a as re } from "./scale-smFifpMm.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { sanitizeInternalReturnPath as A } from "@24city/web-runtime/core/internal-path";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { summarizeCustomerError as
|
|
2
|
+
import { createContext as x, useSyncExternalStore as F, useContext as z } from "react";
|
|
3
|
+
import { summarizeCustomerError as O } from "@24city/web-runtime/error-summary";
|
|
4
4
|
const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
5
|
-
const
|
|
6
|
-
return
|
|
5
|
+
const s = e.charCodeAt(0);
|
|
6
|
+
return s <= 31 || s === 127;
|
|
7
7
|
}), it = (t) => !v(t) && t.startsWith("/") && !t.startsWith("//") && (() => {
|
|
8
8
|
try {
|
|
9
9
|
const e = new URL(t, "https://product.invalid");
|
|
@@ -11,44 +11,44 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
11
11
|
} catch {
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
|
-
})(), ct = (t, e) => !v(t) && A(t, e) === t, M = (t, e) => !t || v(t) ? e : A(t, e),
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
14
|
+
})(), ct = (t, e) => !v(t) && A(t, e) === t, M = (t, e) => !t || v(t) ? e : A(t, e), U = (t) => typeof t == "object" && t !== null && !Array.isArray(t), l = (t, e) => {
|
|
15
|
+
const s = e.data;
|
|
16
|
+
if (!U(s) || s.code !== 0 || !("data" in s))
|
|
17
17
|
throw new Error(`接口 ${t} 返回了无效响应`);
|
|
18
|
-
return
|
|
19
|
-
}, u = (t, e,
|
|
20
|
-
if (!
|
|
18
|
+
return s.data;
|
|
19
|
+
}, u = (t, e, s) => {
|
|
20
|
+
if (!U(t)) throw new Error(`接口 ${e} 字段 ${s} 无效`);
|
|
21
21
|
return t;
|
|
22
|
-
},
|
|
22
|
+
}, o = (t, e, s) => {
|
|
23
23
|
const r = t[e];
|
|
24
24
|
if (typeof r != "string" || !r.trim())
|
|
25
|
-
throw new Error(`接口 ${
|
|
25
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
26
26
|
return r;
|
|
27
|
-
}, g = (t, e,
|
|
27
|
+
}, g = (t, e, s) => {
|
|
28
28
|
const r = t[e];
|
|
29
29
|
if (typeof r != "number" || !Number.isSafeInteger(r) || r < 0)
|
|
30
|
-
throw new Error(`接口 ${
|
|
30
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
31
31
|
return r;
|
|
32
|
-
}, d = "/account", c = `${d}/session`, E = `${d}/logout`, i = `${d}/spaces`, T = `${i}/switch`, $ = `${d}/profile`, h = `${d}/wallet`, P = `${d}/entitlements`, f = `${d}/subscription`, a = `${d}/plans`, y = `${d}/shown-prompts`, W = `${d}/events`, I = (t, e,
|
|
32
|
+
}, d = "/account", c = `${d}/session`, E = `${d}/logout`, i = `${d}/spaces`, T = `${i}/switch`, $ = `${d}/profile`, h = `${d}/wallet`, P = `${d}/entitlements`, f = `${d}/subscription`, a = `${d}/plans`, y = `${d}/shown-prompts`, W = `${d}/events`, I = (t, e, s) => {
|
|
33
33
|
const r = t[e];
|
|
34
34
|
if (r !== null && typeof r != "string")
|
|
35
|
-
throw new Error(`接口 ${
|
|
35
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
36
36
|
return r;
|
|
37
|
-
}, S = (t, e,
|
|
37
|
+
}, S = (t, e, s) => {
|
|
38
38
|
const r = t[e];
|
|
39
39
|
if (r != null) {
|
|
40
40
|
if (typeof r != "string")
|
|
41
|
-
throw new Error(`接口 ${
|
|
41
|
+
throw new Error(`接口 ${s} 字段 ${e} 无效`);
|
|
42
42
|
return r;
|
|
43
43
|
}
|
|
44
|
-
},
|
|
44
|
+
}, k = (t, e, s) => {
|
|
45
45
|
const r = t[e];
|
|
46
|
-
return r === null ? {} : u(r,
|
|
47
|
-
},
|
|
48
|
-
const e = u(t, E, "data"),
|
|
49
|
-
if (!
|
|
46
|
+
return r === null ? {} : u(r, s, e);
|
|
47
|
+
}, q = (t) => {
|
|
48
|
+
const e = u(t, E, "data"), s = S(e, "endSessionUrl", E);
|
|
49
|
+
if (!s) return null;
|
|
50
50
|
try {
|
|
51
|
-
return new URL(
|
|
51
|
+
return new URL(s).protocol === "https:" ? s : null;
|
|
52
52
|
} catch {
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
@@ -56,157 +56,157 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
56
56
|
const e = u(t, c, "data");
|
|
57
57
|
if (e.purpose !== "user") throw new Error("产品用户 Web 只接受 user Purpose 会话");
|
|
58
58
|
return {
|
|
59
|
-
globalUserId:
|
|
59
|
+
globalUserId: o(e, "globalUserId", c),
|
|
60
60
|
localUserId: g(e, "localUserId", c),
|
|
61
|
-
activeSpaceId:
|
|
61
|
+
activeSpaceId: o(e, "activeSpaceId", c),
|
|
62
62
|
authorityId: g(e, "authorityId", c),
|
|
63
63
|
orgId: g(e, "orgId", c),
|
|
64
64
|
purpose: "user",
|
|
65
|
-
csrfToken:
|
|
66
|
-
issuedAt:
|
|
67
|
-
lastSeenAt:
|
|
68
|
-
absoluteExpiresAt:
|
|
69
|
-
lastCentralVerifiedAt:
|
|
70
|
-
accountCenterUrl:
|
|
65
|
+
csrfToken: o(e, "csrfToken", c),
|
|
66
|
+
issuedAt: o(e, "issuedAt", c),
|
|
67
|
+
lastSeenAt: o(e, "lastSeenAt", c),
|
|
68
|
+
absoluteExpiresAt: o(e, "absoluteExpiresAt", c),
|
|
69
|
+
lastCentralVerifiedAt: o(e, "lastCentralVerifiedAt", c),
|
|
70
|
+
accountCenterUrl: o(e, "accountCenterUrl", c)
|
|
71
71
|
};
|
|
72
|
-
},
|
|
73
|
-
const r = u(t, e,
|
|
72
|
+
}, R = (t, e, s) => {
|
|
73
|
+
const r = u(t, e, s);
|
|
74
74
|
return {
|
|
75
|
-
id:
|
|
76
|
-
entitlementCode:
|
|
75
|
+
id: o(r, "id", e),
|
|
76
|
+
entitlementCode: o(r, "entitlementCode", e),
|
|
77
77
|
status: S(r, "status", e),
|
|
78
|
-
startsAt:
|
|
78
|
+
startsAt: o(r, "startsAt", e),
|
|
79
79
|
expiresAt: I(r, "expiresAt", e),
|
|
80
|
-
metadata:
|
|
80
|
+
metadata: k(r, "metadata", e)
|
|
81
81
|
};
|
|
82
82
|
}, B = (t, e) => {
|
|
83
|
-
const
|
|
83
|
+
const s = u(t, i, `spaces[${e}]`), r = u(s.entitlementSummary, i, "entitlementSummary"), n = r.codes, m = s.entitlements;
|
|
84
84
|
if (!Array.isArray(n) || n.some((b) => typeof b != "string"))
|
|
85
85
|
throw new Error(`接口 ${i} 字段 entitlementSummary.codes 无效`);
|
|
86
86
|
if (!Array.isArray(m))
|
|
87
87
|
throw new Error(`接口 ${i} 字段 entitlements 无效`);
|
|
88
88
|
return {
|
|
89
|
-
id: s
|
|
90
|
-
name: s
|
|
91
|
-
slug: s
|
|
92
|
-
type: s
|
|
93
|
-
role: s
|
|
94
|
-
status: s
|
|
95
|
-
membershipStatus: s
|
|
89
|
+
id: o(s, "id", i),
|
|
90
|
+
name: o(s, "name", i),
|
|
91
|
+
slug: o(s, "slug", i),
|
|
92
|
+
type: o(s, "type", i),
|
|
93
|
+
role: o(s, "role", i),
|
|
94
|
+
status: o(s, "status", i),
|
|
95
|
+
membershipStatus: o(s, "membershipStatus", i),
|
|
96
96
|
entitlementSummary: {
|
|
97
97
|
activeCount: g(r, "activeCount", i),
|
|
98
98
|
codes: [...n]
|
|
99
99
|
},
|
|
100
100
|
entitlements: m.map(
|
|
101
|
-
(b, p) =>
|
|
101
|
+
(b, p) => R(b, i, `entitlements[${p}]`)
|
|
102
102
|
)
|
|
103
103
|
};
|
|
104
104
|
}, V = (t) => {
|
|
105
|
-
const e = u(t, i, "data"),
|
|
105
|
+
const e = u(t, i, "data"), s = o(e, "activeSpaceId", i);
|
|
106
106
|
if (!Array.isArray(e.spaces)) throw new Error(`接口 ${i} 字段 spaces 无效`);
|
|
107
107
|
const r = e.spaces.map(B);
|
|
108
|
-
if (!r.some((n) => n.id ===
|
|
108
|
+
if (!r.some((n) => n.id === s))
|
|
109
109
|
throw new Error(`接口 ${i} 的当前空间不在可用空间列表中`);
|
|
110
|
-
return { activeSpaceId:
|
|
110
|
+
return { activeSpaceId: s, spaces: r };
|
|
111
111
|
}, H = (t) => {
|
|
112
112
|
const e = u(t, $, "data");
|
|
113
113
|
return { nickName: (S(e, "nickName", $) ?? "").trim() };
|
|
114
114
|
}, j = (t) => {
|
|
115
|
-
const e = u(t, h, "data"),
|
|
115
|
+
const e = u(t, h, "data"), s = (r) => {
|
|
116
116
|
const n = e[r];
|
|
117
117
|
if (typeof n != "number" || !Number.isSafeInteger(n))
|
|
118
118
|
throw new Error(`接口 ${h} 字段 ${r} 无效`);
|
|
119
119
|
return n;
|
|
120
120
|
};
|
|
121
121
|
return {
|
|
122
|
-
spaceId:
|
|
123
|
-
globalUserId:
|
|
124
|
-
productCode:
|
|
125
|
-
availablePoints:
|
|
126
|
-
reservedPoints:
|
|
127
|
-
globalAvailablePoints:
|
|
128
|
-
globalReservedPoints:
|
|
129
|
-
productAvailablePoints:
|
|
130
|
-
productReservedPoints:
|
|
131
|
-
walletAvailablePoints:
|
|
132
|
-
walletReservedPoints:
|
|
122
|
+
spaceId: o(e, "spaceId", h),
|
|
123
|
+
globalUserId: o(e, "globalUserId", h),
|
|
124
|
+
productCode: o(e, "productCode", h),
|
|
125
|
+
availablePoints: s("availablePoints"),
|
|
126
|
+
reservedPoints: s("reservedPoints"),
|
|
127
|
+
globalAvailablePoints: s("globalAvailablePoints"),
|
|
128
|
+
globalReservedPoints: s("globalReservedPoints"),
|
|
129
|
+
productAvailablePoints: s("productAvailablePoints"),
|
|
130
|
+
productReservedPoints: s("productReservedPoints"),
|
|
131
|
+
walletAvailablePoints: s("walletAvailablePoints"),
|
|
132
|
+
walletReservedPoints: s("walletReservedPoints"),
|
|
133
133
|
walletVersion: g(e, "walletVersion", h)
|
|
134
134
|
};
|
|
135
135
|
}, G = (t) => {
|
|
136
136
|
if (t === null) return null;
|
|
137
|
-
const e = u(t, f, "data"),
|
|
138
|
-
if (typeof
|
|
137
|
+
const e = u(t, f, "data"), s = e.tier;
|
|
138
|
+
if (typeof s != "number" || !Number.isSafeInteger(s))
|
|
139
139
|
throw new Error(`接口 ${f} 字段 tier 无效`);
|
|
140
140
|
if (typeof e.isDefault != "boolean")
|
|
141
141
|
throw new Error(`接口 ${f} 字段 isDefault 无效`);
|
|
142
142
|
return {
|
|
143
143
|
subscriptionId: I(e, "subscriptionId", f),
|
|
144
|
-
planCode:
|
|
144
|
+
planCode: o(e, "planCode", f),
|
|
145
145
|
planName: (S(e, "planName", f) ?? "").trim(),
|
|
146
|
-
tier:
|
|
146
|
+
tier: s,
|
|
147
147
|
isDefault: e.isDefault,
|
|
148
148
|
spaceType: S(e, "spaceType", f) ?? "",
|
|
149
149
|
currentPeriodEnd: I(e, "currentPeriodEnd", f)
|
|
150
150
|
};
|
|
151
151
|
}, K = /* @__PURE__ */ new Set(["month", "year", "one_time"]), X = (t, e) => {
|
|
152
|
-
const
|
|
152
|
+
const s = u(t, a, e), r = o(s, "billingPeriod", a);
|
|
153
153
|
if (!K.has(r)) throw new Error(`接口 ${a} 字段 ${e}.billingPeriod 无效`);
|
|
154
154
|
return {
|
|
155
|
-
code: s
|
|
156
|
-
amountCents: g(
|
|
157
|
-
currency: s
|
|
155
|
+
code: o(s, "code", a),
|
|
156
|
+
amountCents: g(s, "amountCents", a),
|
|
157
|
+
currency: o(s, "currency", a),
|
|
158
158
|
billingPeriod: r,
|
|
159
|
-
durationDays: g(
|
|
160
|
-
pointCycles: g(
|
|
159
|
+
durationDays: g(s, "durationDays", a),
|
|
160
|
+
pointCycles: g(s, "pointCycles", a)
|
|
161
161
|
};
|
|
162
162
|
}, Y = (t, e) => {
|
|
163
|
-
const
|
|
163
|
+
const s = u(t, a, e), r = s.limit;
|
|
164
164
|
if (r != null && (typeof r != "number" || !Number.isSafeInteger(r) || r < 0))
|
|
165
165
|
throw new Error(`接口 ${a} 字段 ${e}.limit 无效`);
|
|
166
|
-
const n = Array.isArray(
|
|
166
|
+
const n = Array.isArray(s.discounts) ? s.discounts.filter((m) => typeof m == "string") : [];
|
|
167
167
|
return {
|
|
168
|
-
key: S(
|
|
169
|
-
name: s
|
|
170
|
-
description: S(
|
|
168
|
+
key: S(s, "key", a) ?? "",
|
|
169
|
+
name: o(s, "name", a),
|
|
170
|
+
description: S(s, "description", a) ?? "",
|
|
171
171
|
limit: typeof r == "number" ? r : null,
|
|
172
172
|
discounts: n
|
|
173
173
|
};
|
|
174
174
|
}, J = (t, e) => {
|
|
175
|
-
const
|
|
176
|
-
if (n !== "personal" && n !== "team") throw new Error(`接口 ${a} 字段 ${
|
|
177
|
-
if (typeof r.tier != "number" || !Number.isSafeInteger(r.tier)) throw new Error(`接口 ${a} 字段 ${
|
|
178
|
-
if (typeof r.isDefault != "boolean") throw new Error(`接口 ${a} 字段 ${
|
|
179
|
-
if (!Array.isArray(r.prices)) throw new Error(`接口 ${a} 字段 ${
|
|
175
|
+
const s = `data[${e}]`, r = u(t, a, s), n = o(r, "spaceType", a);
|
|
176
|
+
if (n !== "personal" && n !== "team") throw new Error(`接口 ${a} 字段 ${s}.spaceType 无效`);
|
|
177
|
+
if (typeof r.tier != "number" || !Number.isSafeInteger(r.tier)) throw new Error(`接口 ${a} 字段 ${s}.tier 无效`);
|
|
178
|
+
if (typeof r.isDefault != "boolean") throw new Error(`接口 ${a} 字段 ${s}.isDefault 无效`);
|
|
179
|
+
if (!Array.isArray(r.prices)) throw new Error(`接口 ${a} 字段 ${s}.prices 无效`);
|
|
180
180
|
const m = Array.isArray(r.benefits) ? r.benefits : [], b = Array.isArray(r.otherProducts) ? r.otherProducts.filter((p) => typeof p == "string" && p.trim() !== "").map((p) => p.trim()) : [];
|
|
181
181
|
return {
|
|
182
|
-
code:
|
|
183
|
-
name:
|
|
182
|
+
code: o(r, "code", a),
|
|
183
|
+
name: o(r, "name", a).trim(),
|
|
184
184
|
spaceType: n,
|
|
185
185
|
tier: r.tier,
|
|
186
186
|
isDefault: r.isDefault,
|
|
187
187
|
includedSeats: g(r, "includedSeats", a),
|
|
188
188
|
monthlyPoints: g(r, "monthlyPoints", a),
|
|
189
|
-
prices: r.prices.map((p, N) => X(p, `${
|
|
190
|
-
benefits: m.map((p, N) => Y(p, `${
|
|
189
|
+
prices: r.prices.map((p, N) => X(p, `${s}.prices[${N}]`)),
|
|
190
|
+
benefits: m.map((p, N) => Y(p, `${s}.benefits[${N}]`)),
|
|
191
191
|
otherProducts: b
|
|
192
192
|
};
|
|
193
193
|
}, L = (t, e) => {
|
|
194
|
-
const
|
|
195
|
-
if (!Array.isArray(
|
|
194
|
+
const s = u(t, y, "data")[e];
|
|
195
|
+
if (!Array.isArray(s) || s.some((r) => typeof r != "string"))
|
|
196
196
|
throw new Error(`接口 ${y} 字段 ${e} 无效`);
|
|
197
|
-
return [...
|
|
197
|
+
return [...s];
|
|
198
198
|
}, Q = (t) => {
|
|
199
199
|
if (!Array.isArray(t)) throw new Error(`接口 ${a} 字段 data 无效`);
|
|
200
200
|
return t.map(J);
|
|
201
201
|
}, ut = (t, e) => {
|
|
202
|
-
const
|
|
202
|
+
const s = e === "/" ? "" : e;
|
|
203
203
|
return {
|
|
204
204
|
async reportBehaviorEvents(r) {
|
|
205
205
|
r.length !== 0 && await t.post(W, { events: r });
|
|
206
206
|
},
|
|
207
207
|
startLogin(r, n) {
|
|
208
208
|
const m = M(r, n);
|
|
209
|
-
return `${
|
|
209
|
+
return `${s}${d}/startLogin?returnPath=${encodeURIComponent(m)}`;
|
|
210
210
|
},
|
|
211
211
|
async getSession() {
|
|
212
212
|
return D(l(c, await t.get(c)));
|
|
@@ -227,7 +227,7 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
227
227
|
async getEntitlements() {
|
|
228
228
|
const r = l(P, await t.get(P));
|
|
229
229
|
if (!Array.isArray(r)) throw new Error(`接口 ${P} 字段 data 无效`);
|
|
230
|
-
return r.map((n, m) =>
|
|
230
|
+
return r.map((n, m) => R(n, P, `entitlements[${m}]`));
|
|
231
231
|
},
|
|
232
232
|
async getSubscription() {
|
|
233
233
|
return G(l(f, await t.get(f)));
|
|
@@ -237,7 +237,7 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
237
237
|
},
|
|
238
238
|
async logout() {
|
|
239
239
|
const r = l(E, await t.post(E));
|
|
240
|
-
return { endSessionUrl:
|
|
240
|
+
return { endSessionUrl: q(r) };
|
|
241
241
|
},
|
|
242
242
|
async getShownPrompts(r) {
|
|
243
243
|
const n = await t.get(y, { params: { keys: r.join(",") } });
|
|
@@ -250,18 +250,18 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
250
250
|
};
|
|
251
251
|
}, lt = async (t) => {
|
|
252
252
|
let e = await t.getSession();
|
|
253
|
-
const
|
|
254
|
-
if (
|
|
253
|
+
const s = await t.getSpaces();
|
|
254
|
+
if (s.activeSpaceId !== e.activeSpaceId && (e = await t.getSession()), s.activeSpaceId !== e.activeSpaceId)
|
|
255
255
|
throw new Error("产品会话与统一空间上下文不一致");
|
|
256
|
-
return { session: e, spaces:
|
|
256
|
+
return { session: e, spaces: s.spaces };
|
|
257
257
|
}, dt = (t) => t == null || !Number.isFinite(t) ? "暂无" : t >= 1e8 ? `${(Math.floor(t / 1e7) / 10).toFixed(1)}亿` : t >= 1e4 ? `${(Math.floor(t / 1e3) / 10).toFixed(1)}万` : t.toLocaleString("zh-CN"), mt = (t) => t.toLocaleString("zh-CN", { maximumFractionDigits: 0 }), pt = (t) => t > 0 && t < 0.01 ? "<0.01" : t.toLocaleString("zh-CN", { maximumFractionDigits: 2 }), ft = (t) => t ? `¥${(t / 100).toLocaleString("zh-CN", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}` : "暂无", gt = (t) => {
|
|
258
258
|
if (t === void 0 || t <= 0) return "";
|
|
259
|
-
const e = Math.floor(t / 60),
|
|
260
|
-
return `${e}:${String(
|
|
259
|
+
const e = Math.floor(t / 60), s = Math.floor(t % 60);
|
|
260
|
+
return `${e}:${String(s).padStart(2, "0")}`;
|
|
261
261
|
}, wt = (t) => {
|
|
262
262
|
if (t === void 0 || t <= 0) return "暂无";
|
|
263
|
-
const e = Math.floor(t / 3600),
|
|
264
|
-
return e > 0 ? `${e}小时${
|
|
263
|
+
const e = Math.floor(t / 3600), s = Math.floor(t % 3600 / 60), r = t % 60;
|
|
264
|
+
return e > 0 ? `${e}小时${s}分` : s > 0 ? `${s}分${r}秒` : `${r}秒`;
|
|
265
265
|
}, ht = (t) => {
|
|
266
266
|
const e = new Date(t);
|
|
267
267
|
return Number.isNaN(e.getTime()) ? "暂无" : new Intl.DateTimeFormat("zh-CN", { dateStyle: "short", timeStyle: "short" }).format(e);
|
|
@@ -276,7 +276,7 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
276
276
|
serviceUnavailable: !1
|
|
277
277
|
}), yt = () => {
|
|
278
278
|
let t = Z();
|
|
279
|
-
const e = /* @__PURE__ */ new Set(),
|
|
279
|
+
const e = /* @__PURE__ */ new Set(), s = (r) => {
|
|
280
280
|
t = r, e.forEach((n) => n());
|
|
281
281
|
};
|
|
282
282
|
return {
|
|
@@ -289,23 +289,26 @@ const v = (t) => t.includes("\\") || [...t].some((e) => {
|
|
|
289
289
|
return ((r = t.session) == null ? void 0 : r.csrfToken) ?? null;
|
|
290
290
|
},
|
|
291
291
|
setContext(r) {
|
|
292
|
-
|
|
292
|
+
s({ session: r.session, spaces: [...r.spaces], bootstrapped: !0, serviceUnavailable: !1 });
|
|
293
293
|
},
|
|
294
294
|
setBootstrapping() {
|
|
295
|
-
|
|
295
|
+
s({ ...t, bootstrapped: !1, serviceUnavailable: !1 });
|
|
296
296
|
},
|
|
297
297
|
clear(r = {}) {
|
|
298
|
-
|
|
298
|
+
s({ session: null, spaces: [], bootstrapped: !0, serviceUnavailable: r.unavailable ?? !1 });
|
|
299
299
|
}
|
|
300
300
|
};
|
|
301
|
-
},
|
|
302
|
-
const t =
|
|
301
|
+
}, _ = x(null), bt = _.Provider, tt = () => {
|
|
302
|
+
const t = z(_);
|
|
303
303
|
if (!t) throw new Error("AuthStoreProvider 尚未初始化");
|
|
304
304
|
return t;
|
|
305
305
|
}, Pt = () => {
|
|
306
306
|
const t = tt();
|
|
307
|
-
return
|
|
308
|
-
}, Et = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", $t = (t, e) =>
|
|
307
|
+
return F(t.subscribe, t.getState, t.getState);
|
|
308
|
+
}, Et = (t) => t instanceof Error && t.message.trim() ? t.message : "请稍后重试;如问题持续,请联系管理员。", $t = (t, e) => O(t).status === e, Nt = (t) => {
|
|
309
|
+
const { category: e, status: s } = O(t);
|
|
310
|
+
return e === "network" || e === "timeout" || s === 502 || s === 503 || s === 504;
|
|
311
|
+
}, C = "24city.console.logout-at", et = 15e3;
|
|
309
312
|
let w = null;
|
|
310
313
|
const rt = () => {
|
|
311
314
|
try {
|
|
@@ -314,68 +317,69 @@ const rt = () => {
|
|
|
314
317
|
return Number.NaN;
|
|
315
318
|
}
|
|
316
319
|
};
|
|
317
|
-
function
|
|
320
|
+
function It(t = Date.now()) {
|
|
318
321
|
try {
|
|
319
322
|
window.localStorage.setItem(C, String(t));
|
|
320
323
|
} catch {
|
|
321
324
|
}
|
|
322
325
|
}
|
|
323
|
-
function
|
|
326
|
+
function st() {
|
|
324
327
|
try {
|
|
325
328
|
window.localStorage.removeItem(C);
|
|
326
329
|
} catch {
|
|
327
330
|
}
|
|
328
331
|
}
|
|
329
|
-
function
|
|
332
|
+
function At() {
|
|
330
333
|
w = "leaving";
|
|
331
334
|
}
|
|
332
|
-
function
|
|
335
|
+
function vt() {
|
|
333
336
|
return w === "leaving";
|
|
334
337
|
}
|
|
335
|
-
function
|
|
338
|
+
function Ct(t = Date.now()) {
|
|
336
339
|
if (w === "leaving") return !1;
|
|
337
340
|
const e = t - rt();
|
|
338
341
|
return e >= 0 && e < et && (w = "logged-out"), w === "logged-out";
|
|
339
342
|
}
|
|
340
|
-
function
|
|
343
|
+
function Tt() {
|
|
341
344
|
return w === "logged-out";
|
|
342
345
|
}
|
|
343
|
-
function
|
|
346
|
+
function Dt() {
|
|
344
347
|
w === "logged-out" && (w = null);
|
|
345
348
|
}
|
|
346
|
-
function
|
|
347
|
-
w = null,
|
|
349
|
+
function Lt() {
|
|
350
|
+
w = null, st();
|
|
348
351
|
}
|
|
349
352
|
export {
|
|
350
353
|
bt as A,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
u as B,
|
|
355
|
+
o as C,
|
|
356
|
+
M as D,
|
|
357
|
+
Et as E,
|
|
358
|
+
l as F,
|
|
359
|
+
It as a,
|
|
356
360
|
yt as b,
|
|
357
361
|
ut as c,
|
|
358
|
-
|
|
359
|
-
|
|
362
|
+
Tt as d,
|
|
363
|
+
Lt as e,
|
|
360
364
|
lt as f,
|
|
361
365
|
tt as g,
|
|
362
366
|
pt as h,
|
|
363
|
-
|
|
367
|
+
vt as i,
|
|
364
368
|
gt as j,
|
|
365
369
|
St as k,
|
|
366
|
-
|
|
370
|
+
At as l,
|
|
367
371
|
ht as m,
|
|
368
|
-
|
|
372
|
+
Ct as n,
|
|
369
373
|
wt as o,
|
|
370
374
|
dt as p,
|
|
371
375
|
mt as q,
|
|
372
|
-
|
|
376
|
+
Dt as r,
|
|
373
377
|
ft as s,
|
|
374
378
|
$t as t,
|
|
375
379
|
Pt as u,
|
|
376
380
|
ct as v,
|
|
377
|
-
|
|
381
|
+
st as w,
|
|
378
382
|
it as x,
|
|
379
|
-
|
|
380
|
-
|
|
383
|
+
Nt as y,
|
|
384
|
+
g as z
|
|
381
385
|
};
|
|
@@ -2,8 +2,8 @@ import { jsx as t } from "react/jsx-runtime";
|
|
|
2
2
|
import { QueryClient as c, QueryClientProvider as l } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo as i } from "react";
|
|
4
4
|
import { CustomerRuntimeConfigProvider as f } from "@24city/web-runtime/runtime-config-provider";
|
|
5
|
-
import { A as d } from "./auth-provider-
|
|
6
|
-
import { b as m, A as p } from "./logout-signal-
|
|
5
|
+
import { A as d } from "./auth-provider-Cwib6lRM.js";
|
|
6
|
+
import { b as m, A as p } from "./logout-signal-qvHorCCF.js";
|
|
7
7
|
import { U as C, E as y } from "./unsupported-browser-Dwq1mNRy.js";
|
|
8
8
|
import { C as h } from "./context-CaVim6ZO.js";
|
|
9
9
|
import { parseCustomerRuntimeConfig as R, loadCustomerRuntimeConfig as v } from "@24city/web-runtime/core/runtime-config";
|