@24city/web-console 0.3.0 → 0.3.2
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 +16 -1
- package/GUIDELINES.md +3 -1
- package/README.md +20 -3
- package/dist/account/account-menu.d.ts +1 -1
- package/dist/account/allowance-meter.d.ts +21 -0
- package/dist/account/customization.d.ts +9 -0
- package/dist/account/index.d.ts +1 -0
- package/dist/account/index.js +64 -63
- package/dist/chunks/{console-layout-D58Ux9DC.js → console-layout-Os4sQzMP.js} +1 -1
- package/dist/chunks/upgrade-modal-BWnNve0z.js +696 -0
- package/dist/chunks/wallet-badge-Dt8fv-Du.js +575 -0
- package/dist/index.js +197 -196
- package/dist/layout/index.js +1 -1
- package/dist/styles.css +134 -55
- package/dist/testing/guard.js +54 -48
- package/package.json +1 -1
- package/dist/chunks/upgrade-modal-DIINHIt0.js +0 -667
- package/dist/chunks/wallet-badge-n1ASGYJY.js +0 -573
|
@@ -1,573 +0,0 @@
|
|
|
1
|
-
import { jsx as s, jsxs as p, Fragment as pe } from "react/jsx-runtime";
|
|
2
|
-
import { useState as M, useRef as me, useCallback as Te, useEffect as Ae } from "react";
|
|
3
|
-
import { Skeleton as ie, Button as b, Toast as _e, Modal as xe, Avatar as Pe, Popover as Le, Tooltip as Ee } from "@douyinfe/semi-ui";
|
|
4
|
-
import { IconUser as D, IconCrown as Ie, IconGift as $e, IconChevronRight as V, IconUserGroup as re, IconChevronUp as Oe, IconChevronDown as Be, IconTick as Me, IconMoon as De } from "@douyinfe/semi-icons";
|
|
5
|
-
import { useNavigate as J } from "react-router";
|
|
6
|
-
import { C as Fe } from "./color-mode-switch-BinpVuZ0.js";
|
|
7
|
-
import { a as he, b as g } from "./context-CaVim6ZO.js";
|
|
8
|
-
import { u as Re } from "./color-mode-DC4KIKya.js";
|
|
9
|
-
import { q as v, k as Ue, a as Ke, t as ye, w as qe, l as ze, u as R, g as We, f as le } from "./logout-signal-CiD_zY5M.js";
|
|
10
|
-
import { useQueryClient as fe, useQuery as x } from "@tanstack/react-query";
|
|
11
|
-
import { notifyCustomerSessionChanged as be } from "@24city/web-runtime/session-sync";
|
|
12
|
-
const Ye = "_trigger_i8lt2_6", Ge = "_avatarWrap_i8lt2_27", je = "_avatar_i8lt2_27", Qe = "_card_i8lt2_80", Ve = "_identity_i8lt2_90", He = "_who_i8lt2_98", Xe = "_nameRow_i8lt2_107", Je = "_name_i8lt2_107", Ze = "_planChip_i8lt2_124", et = "_diamond_i8lt2_154", tt = "_spaceToggle_i8lt2_162", nt = "_spaceStatic_i8lt2_163", at = "_spaceSwitchText_i8lt2_184", st = "_spaceName_i8lt2_190", ot = "_spaceType_i8lt2_196", ct = "_spaceList_i8lt2_206", it = "_spaceOption_i8lt2_215", rt = "_spaceCheck_i8lt2_237", lt = "_plan_i8lt2_124", ut = "_links_i8lt2_249", dt = "_link_i8lt2_249", pt = "_linkIcon_i8lt2_287", mt = "_linkLabel_i8lt2_298", _t = "_linkArrow_i8lt2_303", ht = "_appearance_i8lt2_310", yt = "_divider_i8lt2_320", ft = "_logout_i8lt2_326", r = {
|
|
13
|
-
trigger: Ye,
|
|
14
|
-
avatarWrap: Ge,
|
|
15
|
-
avatar: je,
|
|
16
|
-
card: Qe,
|
|
17
|
-
identity: Ve,
|
|
18
|
-
who: He,
|
|
19
|
-
nameRow: Xe,
|
|
20
|
-
name: Je,
|
|
21
|
-
planChip: Ze,
|
|
22
|
-
diamond: et,
|
|
23
|
-
spaceToggle: tt,
|
|
24
|
-
spaceStatic: nt,
|
|
25
|
-
spaceSwitchText: at,
|
|
26
|
-
spaceName: st,
|
|
27
|
-
spaceType: ot,
|
|
28
|
-
spaceList: ct,
|
|
29
|
-
spaceOption: it,
|
|
30
|
-
spaceCheck: rt,
|
|
31
|
-
plan: lt,
|
|
32
|
-
links: ut,
|
|
33
|
-
link: dt,
|
|
34
|
-
linkIcon: pt,
|
|
35
|
-
linkLabel: mt,
|
|
36
|
-
linkArrow: _t,
|
|
37
|
-
appearance: ht,
|
|
38
|
-
divider: yt,
|
|
39
|
-
logout: ft
|
|
40
|
-
}, bt = ["profile", "subscription", "points"], gt = (e) => bt.includes(e), w = (e, t) => `${e}/account/${t}`, Yn = (e, t) => t === `${e}/account` || t.startsWith(`${e}/account/`), B = (e) => `account-${e}`, P = {
|
|
41
|
-
profile: B("profile"),
|
|
42
|
-
subscription: B("subscription"),
|
|
43
|
-
points: B("points")
|
|
44
|
-
}, kt = /^[a-z][a-z0-9-]{0,31}$/, Nt = (e) => {
|
|
45
|
-
const t = e.accountSections ?? [], n = /* @__PURE__ */ new Set();
|
|
46
|
-
for (const a of t) {
|
|
47
|
-
if (!kt.test(a.key))
|
|
48
|
-
throw new Error(`个人中心分区 key 不合法:${a.key}(小写字母开头,只含小写字母、数字和连字符)`);
|
|
49
|
-
if (gt(a.key)) throw new Error(`个人中心分区 key 与内置分区重名:${a.key}`);
|
|
50
|
-
if (n.has(a.key)) throw new Error(`个人中心分区 key 重复:${a.key}`);
|
|
51
|
-
n.add(a.key);
|
|
52
|
-
}
|
|
53
|
-
return t;
|
|
54
|
-
}, wt = (e, t = []) => ({
|
|
55
|
-
key: "personal",
|
|
56
|
-
label: "个人中心",
|
|
57
|
-
items: [
|
|
58
|
-
{ key: P.profile, label: "账号与安全", to: w(e, "profile"), icon: D },
|
|
59
|
-
{ key: P.subscription, label: "订阅与套餐", to: w(e, "subscription"), icon: Ie },
|
|
60
|
-
{ key: P.points, label: "积分与明细", to: w(e, "points"), icon: $e },
|
|
61
|
-
...t.map(
|
|
62
|
-
(n) => ({
|
|
63
|
-
key: B(n.key),
|
|
64
|
-
label: n.label,
|
|
65
|
-
to: w(e, n.key),
|
|
66
|
-
icon: n.icon
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
]
|
|
70
|
-
}), vt = 1e6, Z = (e) => e != null && e >= vt, Gn = (e) => !!e && e.limit !== null && e.used >= e.limit, jn = (e, t) => e.limit === null ? `已有 ${e.used} ${t}` : e.limit === 0 && e.used === 0 ? "套餐未包含" : Z(e.limit) ? `已有 ${e.used} ${t} · 不限` : `已用 ${e.used}/${e.limit}`, Qn = (e, t) => (n) => n !== null && Z(n) ? t : e(v(n ?? 0)), ge = (e, t) => e.find((n) => n.key === t), ue = (e, t) => {
|
|
71
|
-
const n = e.findIndex((a) => a.key === t);
|
|
72
|
-
return n === -1 ? e.length : n;
|
|
73
|
-
}, Ct = (e, t) => {
|
|
74
|
-
const n = ge(e, t.key), a = n ? n.on(t.limit) : t.limit === null ? t.name : `${t.name} ${Z(t.limit) ? "不限" : v(t.limit)}`;
|
|
75
|
-
return t.discounts.length ? `${a}(${t.discounts.join("、")})` : a;
|
|
76
|
-
}, St = (e) => {
|
|
77
|
-
if (e.length < 2) return /* @__PURE__ */ new Set();
|
|
78
|
-
const t = new Set(e.flatMap((n) => n.benefits.filter((a) => a.limit === null).map((a) => a.key)));
|
|
79
|
-
return new Set(
|
|
80
|
-
[...t].filter((n) => e.every((a) => a.benefits.some((o) => o.key === n && o.limit === null)))
|
|
81
|
-
);
|
|
82
|
-
}, Tt = (e, t = [], n = {}) => {
|
|
83
|
-
var d;
|
|
84
|
-
const a = n.benefitCopy ?? [], o = St(t), c = [];
|
|
85
|
-
for (const i of [...e.benefits, ...t.flatMap((m) => m.benefits)])
|
|
86
|
-
!c.includes(i.key) && !o.has(i.key) && c.push(i.key);
|
|
87
|
-
const u = [];
|
|
88
|
-
for (const i of [...c].sort((m, _) => ue(a, m) - ue(a, _) || c.indexOf(m) - c.indexOf(_))) {
|
|
89
|
-
const m = e.benefits.find((y) => y.key === i);
|
|
90
|
-
if (m) {
|
|
91
|
-
u.push({ text: Ct(a, m), included: !0 });
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
const _ = (d = ge(a, i)) == null ? void 0 : d.off;
|
|
95
|
-
_ && u.push({ text: _, included: !1 });
|
|
96
|
-
}
|
|
97
|
-
return u;
|
|
98
|
-
}, H = (e) => e.planName || e.planCode, At = (e) => e.isDefault || !e.currentPeriodEnd ? "长期有效" : `有效期至 ${Ue(e.currentPeriodEnd)}`, xt = 1440 * 60 * 1e3, Pt = (e, t = Date.now()) => {
|
|
99
|
-
if (e.isDefault || !e.currentPeriodEnd) return null;
|
|
100
|
-
const n = Date.parse(e.currentPeriodEnd);
|
|
101
|
-
return Number.isFinite(n) ? Math.max(0, Math.ceil((n - t) / xt)) : null;
|
|
102
|
-
}, Lt = 7, Et = { month: "/月", year: "/年", one_time: "" }, It = (e) => {
|
|
103
|
-
const t = (e.amountCents / 100).toLocaleString("zh-CN", { maximumFractionDigits: 2 });
|
|
104
|
-
return e.currency === "CNY" ? `¥${t}` : `${e.currency} ${t}`;
|
|
105
|
-
}, Vn = (e) => e ? { focusPlan: e } : void 0, Hn = (e) => {
|
|
106
|
-
if (typeof e != "object" || e === null) return;
|
|
107
|
-
const t = e.focusPlan;
|
|
108
|
-
return typeof t == "string" && t ? t : void 0;
|
|
109
|
-
}, $t = (e) => `${It(e)}${Et[e.billingPeriod]}`, Ot = (e) => {
|
|
110
|
-
const t = e.prices.filter((o) => o.amountCents > 0), n = t.filter((o) => o.billingPeriod === "month");
|
|
111
|
-
return (n.length ? n : t).reduce((o, c) => !o || c.amountCents < o.amountCents ? c : o, null);
|
|
112
|
-
}, Bt = (e, t, n) => {
|
|
113
|
-
const o = (e ?? []).filter(
|
|
114
|
-
(c) => c.spaceType === t && !c.isDefault && (n === null || c.tier > n)
|
|
115
|
-
).map((c) => ({ plan: c, price: Ot(c) }));
|
|
116
|
-
return o.sort(
|
|
117
|
-
(c, u) => {
|
|
118
|
-
var d, i;
|
|
119
|
-
return c.plan.tier - u.plan.tier || (((d = c.price) == null ? void 0 : d.amountCents) ?? Number.MAX_SAFE_INTEGER) - (((i = u.price) == null ? void 0 : i.amountCents) ?? Number.MAX_SAFE_INTEGER);
|
|
120
|
-
}
|
|
121
|
-
), o[0] ?? null;
|
|
122
|
-
}, Xn = (e) => e == null ? void 0 : e.filter((t) => t.spaceType === "team" && !t.isDefault).sort((t, n) => t.tier - n.tier)[0], Mt = (e, t) => e == null ? void 0 : e.find((n) => n.code === t.planCode), Dt = (e, t = [], n = {}) => {
|
|
123
|
-
if (!e) return ["积分按月发放", "24.city 全产品通用"];
|
|
124
|
-
const a = [];
|
|
125
|
-
e.monthlyPoints > 0 && a.push(`每月 ${v(e.monthlyPoints)} 积分`);
|
|
126
|
-
for (const o of Tt(e, t, n).filter((c) => c.included).slice(0, 2)) a.push(o.text);
|
|
127
|
-
return a.length < 2 && a.push("24.city 全产品通用"), a;
|
|
128
|
-
}, Ft = "_promo_uc5su_6", Rt = "_member_uc5su_7", Ut = "_plain_uc5su_8", Kt = "_promoArt_uc5su_28", qt = "_promoBody_uc5su_38", zt = "_promoTitle_uc5su_44", Wt = "_promoText_uc5su_55", Yt = "_cta_uc5su_63", Gt = "_ctaButton_uc5su_69", jt = "_ctaTag_uc5su_89", Qt = "_ownerOnly_uc5su_106", Vt = "_memberArt_uc5su_122", Ht = "_memberBody_uc5su_132", Xt = "_memberEyebrow_uc5su_139", Jt = "_memberTitle_uc5su_145", Zt = "_memberMeta_uc5su_159", en = "_memberCta_uc5su_166", tn = "_plainBody_uc5su_200", nn = "_plainText_uc5su_207", an = "_retry_uc5su_212", sn = "_loading_uc5su_216", on = "_assets_uc5su_224", cn = "_asset_uc5su_224", rn = "_coin_uc5su_279", ln = "_assetLabel_uc5su_287", un = "_assetValue_uc5su_291", dn = "_assetArrow_uc5su_299", pn = "_assetDivider_uc5su_312", l = {
|
|
129
|
-
promo: Ft,
|
|
130
|
-
member: Rt,
|
|
131
|
-
plain: Ut,
|
|
132
|
-
promoArt: Kt,
|
|
133
|
-
promoBody: qt,
|
|
134
|
-
promoTitle: zt,
|
|
135
|
-
promoText: Wt,
|
|
136
|
-
cta: Yt,
|
|
137
|
-
ctaButton: Gt,
|
|
138
|
-
ctaTag: jt,
|
|
139
|
-
ownerOnly: Qt,
|
|
140
|
-
memberArt: Vt,
|
|
141
|
-
memberBody: Ht,
|
|
142
|
-
memberEyebrow: Xt,
|
|
143
|
-
memberTitle: Jt,
|
|
144
|
-
memberMeta: Zt,
|
|
145
|
-
memberCta: en,
|
|
146
|
-
plainBody: tn,
|
|
147
|
-
plainText: nn,
|
|
148
|
-
retry: an,
|
|
149
|
-
loading: sn,
|
|
150
|
-
assets: on,
|
|
151
|
-
asset: cn,
|
|
152
|
-
coin: rn,
|
|
153
|
-
assetLabel: ln,
|
|
154
|
-
assetValue: un,
|
|
155
|
-
assetArrow: dn,
|
|
156
|
-
assetDivider: pn
|
|
157
|
-
}, mn = P.points, ee = P.subscription, _n = ({ membership: e, text: t, onOpen: n }) => {
|
|
158
|
-
const { canBuy: a, offer: o } = e;
|
|
159
|
-
return a ? /* @__PURE__ */ p("span", { className: l.cta, children: [
|
|
160
|
-
/* @__PURE__ */ s(b, { theme: "light", type: "tertiary", block: !0, className: l.ctaButton, onClick: () => n(ee), children: t }),
|
|
161
|
-
o != null && o.price ? /* @__PURE__ */ p("span", { className: l.ctaTag, children: [
|
|
162
|
-
$t(o.price),
|
|
163
|
-
"起"
|
|
164
|
-
] }) : null
|
|
165
|
-
] }) : /* @__PURE__ */ s("span", { className: l.ownerOnly, children: "请团队所有者在统一账号中心续费" });
|
|
166
|
-
}, z = ({
|
|
167
|
-
membership: e,
|
|
168
|
-
extra: t,
|
|
169
|
-
onOpen: n
|
|
170
|
-
}) => {
|
|
171
|
-
const { wallet: a } = e, o = a.isPending ? "…" : a.data ? v(a.data.availablePoints) : "暂不可用";
|
|
172
|
-
return /* @__PURE__ */ p("div", { className: l.assets, children: [
|
|
173
|
-
/* @__PURE__ */ p(b, { theme: "borderless", type: "tertiary", className: l.asset, "aria-label": `可用积分 ${o},查看积分与明细`, onClick: () => n(mn), children: [
|
|
174
|
-
/* @__PURE__ */ s("span", { className: l.coin, "aria-hidden": "true" }),
|
|
175
|
-
/* @__PURE__ */ s("span", { className: l.assetLabel, children: "积分" }),
|
|
176
|
-
/* @__PURE__ */ s("span", { className: l.assetValue, children: o }),
|
|
177
|
-
/* @__PURE__ */ s(V, { className: l.assetArrow, "aria-hidden": "true" })
|
|
178
|
-
] }),
|
|
179
|
-
t ? /* @__PURE__ */ p(pe, { children: [
|
|
180
|
-
/* @__PURE__ */ s("span", { className: l.assetDivider, "aria-hidden": "true" }),
|
|
181
|
-
/* @__PURE__ */ p(b, { theme: "borderless", type: "tertiary", className: l.asset, "data-tone": t.tone, onClick: t.onClick ?? (() => n(ee)), children: [
|
|
182
|
-
/* @__PURE__ */ s("span", { className: l.assetValue, children: t.label }),
|
|
183
|
-
/* @__PURE__ */ s(V, { className: l.assetArrow, "aria-hidden": "true" })
|
|
184
|
-
] })
|
|
185
|
-
] }) : null
|
|
186
|
-
] });
|
|
187
|
-
}, hn = ({ membership: e, onOpen: t }) => {
|
|
188
|
-
const n = he(), { state: a, offer: o, currentPlan: c, subscription: u } = e;
|
|
189
|
-
if (a.kind === "loading")
|
|
190
|
-
return /* @__PURE__ */ s("div", { className: l.loading, children: /* @__PURE__ */ s(ie, { loading: !0, active: !0, placeholder: /* @__PURE__ */ s(ie.Paragraph, { rows: 3 }) }) });
|
|
191
|
-
if (a.kind === "error")
|
|
192
|
-
return /* @__PURE__ */ p("div", { className: l.plain, children: [
|
|
193
|
-
/* @__PURE__ */ p("div", { className: l.plainBody, children: [
|
|
194
|
-
/* @__PURE__ */ s("span", { className: l.plainText, children: "套餐信息暂时读不到" }),
|
|
195
|
-
/* @__PURE__ */ s(b, { theme: "borderless", type: "tertiary", size: "small", className: l.retry, onClick: () => void u.refetch(), children: "重试" })
|
|
196
|
-
] }),
|
|
197
|
-
/* @__PURE__ */ s(z, { membership: e, onOpen: t })
|
|
198
|
-
] });
|
|
199
|
-
if (a.kind === "member") {
|
|
200
|
-
const { subscription: y, daysLeft: f } = a, S = f !== null && f <= Lt, T = (c == null ? void 0 : c.monthlyPoints) ?? 0;
|
|
201
|
-
return /* @__PURE__ */ p("div", { className: `${l.member} semi-always-light`, "data-expiring": S ? "true" : "false", children: [
|
|
202
|
-
/* @__PURE__ */ s("span", { className: l.memberArt, "aria-hidden": "true" }),
|
|
203
|
-
/* @__PURE__ */ p("div", { className: l.memberBody, children: [
|
|
204
|
-
/* @__PURE__ */ p("span", { className: l.memberEyebrow, children: [
|
|
205
|
-
"当前会员",
|
|
206
|
-
T > 0 ? ` · 每月 ${v(T)} 积分` : ""
|
|
207
|
-
] }),
|
|
208
|
-
/* @__PURE__ */ s("span", { className: l.memberTitle, children: H(y) }),
|
|
209
|
-
/* @__PURE__ */ s("span", { className: l.memberMeta, children: At(y) }),
|
|
210
|
-
e.canBuy ? /* @__PURE__ */ s(b, { theme: "light", type: "tertiary", size: "small", className: l.memberCta, onClick: () => t(ee), children: S ? "立即续费" : o ? "续费或升级" : "续费" }) : null
|
|
211
|
-
] }),
|
|
212
|
-
/* @__PURE__ */ s(
|
|
213
|
-
z,
|
|
214
|
-
{
|
|
215
|
-
membership: e,
|
|
216
|
-
onOpen: t,
|
|
217
|
-
extra: f === null ? void 0 : { label: f === 0 ? "今天到期" : `剩余 ${f} 天`, tone: S ? "warning" : void 0 }
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
] });
|
|
221
|
-
}
|
|
222
|
-
const d = a.kind === "team-expired", i = d ? "团队版已到期" : o ? `升级${o.plan.name},畅享更多` : "开通会员畅享", m = d ? "续费后团队成员继续共用套餐和积分" : Dt(o == null ? void 0 : o.plan, e.plans.data ?? [], n).join(" · "), _ = d ? 0 : (c == null ? void 0 : c.monthlyPoints) ?? 0;
|
|
223
|
-
return /* @__PURE__ */ p("div", { className: l.promo, "data-tone": d ? "team" : "free", children: [
|
|
224
|
-
/* @__PURE__ */ s("span", { className: l.promoArt, "aria-hidden": "true" }),
|
|
225
|
-
/* @__PURE__ */ p("div", { className: l.promoBody, children: [
|
|
226
|
-
/* @__PURE__ */ s("span", { className: l.promoTitle, children: i }),
|
|
227
|
-
/* @__PURE__ */ s("span", { className: l.promoText, children: m }),
|
|
228
|
-
/* @__PURE__ */ s(_n, { membership: e, text: d ? "续费团队版" : "立即开通会员", onOpen: t })
|
|
229
|
-
] }),
|
|
230
|
-
/* @__PURE__ */ s(z, { membership: e, onOpen: t, extra: _ > 0 ? { label: `免费版每月赠 ${v(_)}` } : void 0 })
|
|
231
|
-
] });
|
|
232
|
-
}, yn = "个人空间", F = (e) => e.type === "team", X = (e) => e.type === "personal" ? yn : e.name || e.slug, fn = { owner: "所有者", admin: "管理员", member: "成员" }, Jn = (e) => e ? fn[e] ?? "" : "", bn = (e) => !!(e && (e.type === "personal" || e.role === "owner")), gn = () => {
|
|
233
|
-
const [e, t] = M(!1), n = fe(), { accountApi: a, config: o } = g(), c = async () => {
|
|
234
|
-
if (e) return;
|
|
235
|
-
t(!0), Ke();
|
|
236
|
-
let d = o.routes.publicHome;
|
|
237
|
-
try {
|
|
238
|
-
const { endSessionUrl: i } = await a.logout();
|
|
239
|
-
i && (d = i);
|
|
240
|
-
} catch (i) {
|
|
241
|
-
if (!ye(i, 401)) {
|
|
242
|
-
qe(), _e.error("退出失败,请重试"), t(!1);
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return ze(), await n.cancelQueries().catch(() => {
|
|
247
|
-
}), be(), window.location.assign(d), new Promise(() => {
|
|
248
|
-
});
|
|
249
|
-
};
|
|
250
|
-
return { confirmLogout: () => {
|
|
251
|
-
e || xe.confirm({
|
|
252
|
-
title: "退出登录",
|
|
253
|
-
content: "将同时退出 24.city 统一账号并回到首页,再次进入工作台需要重新登录。",
|
|
254
|
-
okText: "退出登录",
|
|
255
|
-
cancelText: "取消",
|
|
256
|
-
okButtonProps: { type: "danger" },
|
|
257
|
-
onOk: c
|
|
258
|
-
});
|
|
259
|
-
}, logout: c, pending: e };
|
|
260
|
-
}, W = (e) => typeof e == "object" && e !== null && !Array.isArray(e), kn = (e) => {
|
|
261
|
-
if (!ye(e, 403) || !W(e) || !W(e.response)) return !1;
|
|
262
|
-
const t = e.response.data;
|
|
263
|
-
return W(t) && t.reason === "team_subscription_required";
|
|
264
|
-
}, L = {
|
|
265
|
-
profile: (e) => ["product-profile", e],
|
|
266
|
-
wallet: (e, t) => ["product-wallet", e, t],
|
|
267
|
-
subscription: (e, t) => ["product-subscription", e, t],
|
|
268
|
-
plans: ["product-plans"]
|
|
269
|
-
}, Nn = () => {
|
|
270
|
-
const { accountApi: e } = g(), { session: t, spaces: n } = R(), a = (t == null ? void 0 : t.activeSpaceId) ?? "", o = (t == null ? void 0 : t.globalUserId) ?? "", c = (t == null ? void 0 : t.purpose) === "user" && !!(a && o), u = n.find((_) => _.id === a), d = x({
|
|
271
|
-
queryKey: L.profile(o),
|
|
272
|
-
queryFn: () => e.getProfile(),
|
|
273
|
-
enabled: !!o,
|
|
274
|
-
staleTime: 1 / 0
|
|
275
|
-
}), i = x({
|
|
276
|
-
queryKey: L.wallet(a, o),
|
|
277
|
-
queryFn: () => e.getWallet(),
|
|
278
|
-
enabled: c
|
|
279
|
-
}), m = x({
|
|
280
|
-
queryKey: L.subscription(a, o),
|
|
281
|
-
queryFn: () => e.getSubscription(),
|
|
282
|
-
enabled: c
|
|
283
|
-
});
|
|
284
|
-
return { session: t, allowed: c, activeSpace: u, activeSpaceId: a, globalUserId: o, profile: d, wallet: i, subscription: m };
|
|
285
|
-
}, wn = 5 * 6e4, vn = (e) => {
|
|
286
|
-
const { accountApi: t } = g();
|
|
287
|
-
return x({
|
|
288
|
-
queryKey: L.plans,
|
|
289
|
-
queryFn: () => t.getPlans(),
|
|
290
|
-
enabled: e,
|
|
291
|
-
staleTime: wn
|
|
292
|
-
});
|
|
293
|
-
}, ke = () => {
|
|
294
|
-
var f;
|
|
295
|
-
const { config: e } = g(), t = Nn(), { activeSpace: n, subscription: a, allowed: o } = t, c = vn(o), u = n ? F(n) : !1, d = u ? "team" : "personal";
|
|
296
|
-
let i;
|
|
297
|
-
!o || a.isPending ? i = { kind: "loading" } : a.isError ? i = kn(a.error) ? { kind: "team-expired" } : { kind: "error" } : !a.data || a.data.isDefault ? i = { kind: "free", subscription: a.data ?? null } : i = { kind: "member", subscription: a.data, daysLeft: Pt(a.data) };
|
|
298
|
-
const m = i.kind === "free" || i.kind === "member" ? ((f = i.subscription) == null ? void 0 : f.tier) ?? null : null, _ = i.kind === "free" || i.kind === "member" || i.kind === "team-expired" ? Bt(c.data, d, m) : null, y = (i.kind === "free" || i.kind === "member") && i.subscription ? Mt(c.data, i.subscription) : void 0;
|
|
299
|
-
return {
|
|
300
|
-
...t,
|
|
301
|
-
plans: c,
|
|
302
|
-
state: i,
|
|
303
|
-
offer: _,
|
|
304
|
-
currentPlan: y,
|
|
305
|
-
team: u,
|
|
306
|
-
/** 个人空间是自己的;团队空间只有所有者能买(STD-BILLING-001) */
|
|
307
|
-
canBuy: bn(n),
|
|
308
|
-
/** 「订阅与套餐」的站内地址 */
|
|
309
|
-
subscriptionPath: w(e.routes.app, "subscription")
|
|
310
|
-
};
|
|
311
|
-
}, Cn = () => {
|
|
312
|
-
const e = fe(), t = We(), { session: n } = R(), { accountApi: a } = g(), [o, c] = M(!1), u = me(0), d = n == null ? void 0 : n.activeSpaceId, i = Te(
|
|
313
|
-
async (m) => {
|
|
314
|
-
if (!m || m === d || o) return;
|
|
315
|
-
const _ = ++u.current;
|
|
316
|
-
c(!0);
|
|
317
|
-
try {
|
|
318
|
-
if (await e.cancelQueries(), e.clear(), (await a.switchSpace(m)).activeSpaceId !== m) throw new Error("空间切换响应与请求不一致");
|
|
319
|
-
const f = await le(a);
|
|
320
|
-
if (u.current !== _) return;
|
|
321
|
-
t.setContext(f), be();
|
|
322
|
-
} catch {
|
|
323
|
-
if (u.current !== _) return;
|
|
324
|
-
try {
|
|
325
|
-
const y = await le(a);
|
|
326
|
-
e.clear(), t.setContext(y), y.session.activeSpaceId !== m && _e.error("空间切换失败,请稍后重试");
|
|
327
|
-
} catch {
|
|
328
|
-
e.clear(), t.clear({ unavailable: !0 });
|
|
329
|
-
}
|
|
330
|
-
} finally {
|
|
331
|
-
u.current === _ && c(!1);
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
[a, d, t, e, o]
|
|
335
|
-
);
|
|
336
|
-
return { switching: o, switchSpace: i };
|
|
337
|
-
}, Y = "我的账号", Sn = 80, Tn = 200, G = ({ space: e }) => /* @__PURE__ */ p(pe, { children: [
|
|
338
|
-
/* @__PURE__ */ s("span", { className: r.spaceName, children: X(e) }),
|
|
339
|
-
F(e) ? /* @__PURE__ */ s("span", { className: r.spaceType, children: "团队" }) : null
|
|
340
|
-
] }), de = ({ nickName: e, member: t, size: n }) => /* @__PURE__ */ s("span", { className: r.avatarWrap, "data-member": t ? "true" : "false", "data-size": n > 40 ? "large" : "small", children: /* @__PURE__ */ s(Pe, { size: "small", shape: "circle", className: r.avatar, style: { width: n, height: n }, children: e ? Array.from(e)[0] : /* @__PURE__ */ s(D, { "aria-hidden": "true" }) }) }), An = ({ state: e }) => e.kind === "member" ? /* @__PURE__ */ p("span", { className: r.planChip, "data-tone": "member", children: [
|
|
341
|
-
/* @__PURE__ */ s("span", { className: r.diamond, "aria-hidden": "true" }),
|
|
342
|
-
H(e.subscription)
|
|
343
|
-
] }) : e.kind === "free" ? /* @__PURE__ */ s("span", { className: r.planChip, "data-tone": "free", children: e.subscription ? H(e.subscription) : "未开通" }) : e.kind === "team-expired" ? /* @__PURE__ */ s("span", { className: r.planChip, "data-tone": "warning", children: "团队版已到期" }) : null, Zn = ({ personal: e, selectedKey: t, onOpen: n }) => {
|
|
344
|
-
var ce;
|
|
345
|
-
const { config: a } = g(), o = he(), c = J(), u = e ?? wt(a.routes.app, Nt(o)), d = ke(), { profile: i, state: m } = d, { session: _, spaces: y } = R(), { confirmLogout: f, pending: S } = gn(), { switching: T, switchSpace: Ne } = Cn(), { darkAvailable: we } = Re(), [U, E] = M(!1), [K, I] = M(!1), A = me(void 0), q = ((ce = i.data) == null ? void 0 : ce.nickName) ?? "", $ = q || (i.isPending ? "" : Y), te = (_ == null ? void 0 : _.activeSpaceId) ?? "", k = y.find((h) => h.id === te), ne = y.length > 1, ae = m.kind === "member", C = () => {
|
|
346
|
-
A.current !== void 0 && (window.clearTimeout(A.current), A.current = void 0);
|
|
347
|
-
};
|
|
348
|
-
Ae(() => C, []);
|
|
349
|
-
const O = () => {
|
|
350
|
-
C(), E(!1), I(!1);
|
|
351
|
-
}, ve = () => {
|
|
352
|
-
C(), A.current = window.setTimeout(() => E(!0), Sn);
|
|
353
|
-
}, se = () => {
|
|
354
|
-
C(), A.current = window.setTimeout(() => {
|
|
355
|
-
E(!1), I(!1);
|
|
356
|
-
}, Tn);
|
|
357
|
-
}, oe = (h) => {
|
|
358
|
-
if (O(), n) {
|
|
359
|
-
n(h);
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
const N = u.items.find((Se) => Se.key === h);
|
|
363
|
-
N && c(N.to);
|
|
364
|
-
}, Ce = /* @__PURE__ */ p("div", { className: r.card, role: "dialog", "aria-label": "账号", onMouseEnter: C, onMouseLeave: se, children: [
|
|
365
|
-
/* @__PURE__ */ p("div", { className: r.identity, children: [
|
|
366
|
-
/* @__PURE__ */ s(de, { nickName: q, member: ae, size: 52 }),
|
|
367
|
-
/* @__PURE__ */ p("div", { className: r.who, children: [
|
|
368
|
-
/* @__PURE__ */ p("div", { className: r.nameRow, children: [
|
|
369
|
-
/* @__PURE__ */ s("span", { className: r.name, title: $ || Y, children: $ || Y }),
|
|
370
|
-
/* @__PURE__ */ s(An, { state: m })
|
|
371
|
-
] }),
|
|
372
|
-
k ? ne ? /* @__PURE__ */ p(
|
|
373
|
-
b,
|
|
374
|
-
{
|
|
375
|
-
theme: "borderless",
|
|
376
|
-
type: "tertiary",
|
|
377
|
-
size: "small",
|
|
378
|
-
className: r.spaceToggle,
|
|
379
|
-
"aria-expanded": K,
|
|
380
|
-
"aria-label": `当前空间:${X(k)},切换空间`,
|
|
381
|
-
onClick: () => I((h) => !h),
|
|
382
|
-
children: [
|
|
383
|
-
F(k) ? /* @__PURE__ */ s(re, { "aria-hidden": "true" }) : /* @__PURE__ */ s(D, { "aria-hidden": "true" }),
|
|
384
|
-
/* @__PURE__ */ s(G, { space: k }),
|
|
385
|
-
/* @__PURE__ */ s("span", { className: r.spaceSwitchText, children: "切换" }),
|
|
386
|
-
K ? /* @__PURE__ */ s(Oe, { "aria-hidden": "true" }) : /* @__PURE__ */ s(Be, { "aria-hidden": "true" })
|
|
387
|
-
]
|
|
388
|
-
}
|
|
389
|
-
) : /* @__PURE__ */ p("span", { className: r.spaceStatic, "aria-label": `当前空间:${X(k)}`, children: [
|
|
390
|
-
F(k) ? /* @__PURE__ */ s(re, { "aria-hidden": "true" }) : /* @__PURE__ */ s(D, { "aria-hidden": "true" }),
|
|
391
|
-
/* @__PURE__ */ s(G, { space: k })
|
|
392
|
-
] }) : null
|
|
393
|
-
] })
|
|
394
|
-
] }),
|
|
395
|
-
ne && K ? /* @__PURE__ */ s("div", { className: r.spaceList, role: "group", "aria-label": "切换空间", children: y.map((h) => {
|
|
396
|
-
const N = h.id === te;
|
|
397
|
-
return /* @__PURE__ */ p(
|
|
398
|
-
b,
|
|
399
|
-
{
|
|
400
|
-
theme: "borderless",
|
|
401
|
-
type: "tertiary",
|
|
402
|
-
block: !0,
|
|
403
|
-
className: r.spaceOption,
|
|
404
|
-
"aria-current": N ? "true" : void 0,
|
|
405
|
-
disabled: T && !N,
|
|
406
|
-
onClick: () => {
|
|
407
|
-
N || (O(), Ne(h.id));
|
|
408
|
-
},
|
|
409
|
-
children: [
|
|
410
|
-
/* @__PURE__ */ s("span", { className: r.spaceCheck, children: N ? /* @__PURE__ */ s(Me, { "aria-hidden": "true" }) : null }),
|
|
411
|
-
/* @__PURE__ */ s(G, { space: h })
|
|
412
|
-
]
|
|
413
|
-
},
|
|
414
|
-
h.id
|
|
415
|
-
);
|
|
416
|
-
}) }) : null,
|
|
417
|
-
/* @__PURE__ */ s("div", { className: r.plan, children: /* @__PURE__ */ s(hn, { membership: d, onOpen: oe }) }),
|
|
418
|
-
/* @__PURE__ */ s("div", { className: r.links, role: "group", "aria-label": u.label, children: u.items.map((h) => /* @__PURE__ */ p(
|
|
419
|
-
b,
|
|
420
|
-
{
|
|
421
|
-
theme: "borderless",
|
|
422
|
-
type: "tertiary",
|
|
423
|
-
block: !0,
|
|
424
|
-
className: r.link,
|
|
425
|
-
"aria-current": h.key === t ? "page" : void 0,
|
|
426
|
-
onClick: () => oe(h.key),
|
|
427
|
-
children: [
|
|
428
|
-
h.icon ? /* @__PURE__ */ s("span", { className: r.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ s(h.icon, {}) }) : null,
|
|
429
|
-
/* @__PURE__ */ s("span", { className: r.linkLabel, children: h.label }),
|
|
430
|
-
/* @__PURE__ */ s(V, { className: r.linkArrow, "aria-hidden": "true" })
|
|
431
|
-
]
|
|
432
|
-
},
|
|
433
|
-
h.key
|
|
434
|
-
)) }),
|
|
435
|
-
we ? /* @__PURE__ */ p("div", { className: r.appearance, children: [
|
|
436
|
-
/* @__PURE__ */ s("span", { className: r.linkIcon, "aria-hidden": "true", children: /* @__PURE__ */ s(De, {}) }),
|
|
437
|
-
/* @__PURE__ */ s("span", { className: r.linkLabel, children: "外观" }),
|
|
438
|
-
/* @__PURE__ */ s(Fe, {})
|
|
439
|
-
] }) : null,
|
|
440
|
-
/* @__PURE__ */ s("div", { className: r.divider, "aria-hidden": "true" }),
|
|
441
|
-
/* @__PURE__ */ s(
|
|
442
|
-
b,
|
|
443
|
-
{
|
|
444
|
-
theme: "borderless",
|
|
445
|
-
type: "tertiary",
|
|
446
|
-
block: !0,
|
|
447
|
-
className: r.logout,
|
|
448
|
-
disabled: S,
|
|
449
|
-
onClick: () => {
|
|
450
|
-
O(), f();
|
|
451
|
-
},
|
|
452
|
-
children: "退出登录"
|
|
453
|
-
}
|
|
454
|
-
)
|
|
455
|
-
] });
|
|
456
|
-
return /* @__PURE__ */ s(
|
|
457
|
-
Le,
|
|
458
|
-
{
|
|
459
|
-
trigger: "custom",
|
|
460
|
-
visible: U,
|
|
461
|
-
position: "bottomRight",
|
|
462
|
-
showArrow: !1,
|
|
463
|
-
spacing: 8,
|
|
464
|
-
className: r.popover,
|
|
465
|
-
content: Ce,
|
|
466
|
-
onClickOutSide: O,
|
|
467
|
-
children: /* @__PURE__ */ s(
|
|
468
|
-
b,
|
|
469
|
-
{
|
|
470
|
-
theme: "borderless",
|
|
471
|
-
type: "tertiary",
|
|
472
|
-
className: r.trigger,
|
|
473
|
-
"aria-label": $ ? `${$},账号菜单` : "账号菜单",
|
|
474
|
-
"aria-haspopup": "dialog",
|
|
475
|
-
"aria-expanded": U,
|
|
476
|
-
loading: T,
|
|
477
|
-
onMouseEnter: ve,
|
|
478
|
-
onMouseLeave: se,
|
|
479
|
-
onClick: () => {
|
|
480
|
-
C(), E((h) => !h), U && I(!1);
|
|
481
|
-
},
|
|
482
|
-
children: /* @__PURE__ */ s(de, { nickName: q, member: ae, size: 34 })
|
|
483
|
-
}
|
|
484
|
-
)
|
|
485
|
-
}
|
|
486
|
-
);
|
|
487
|
-
}, xn = "_upgrade_1dxl7_2", Pn = "_crown_1dxl7_25", Ln = "_text_1dxl7_37", j = {
|
|
488
|
-
upgrade: xn,
|
|
489
|
-
crown: Pn,
|
|
490
|
-
text: Ln
|
|
491
|
-
}, ea = () => {
|
|
492
|
-
const { config: e } = g(), t = J(), { state: n, canBuy: a } = ke();
|
|
493
|
-
if (!a || n.kind !== "free" && n.kind !== "team-expired") return null;
|
|
494
|
-
const o = n.kind === "team-expired" ? "续费团队版" : "开通会员";
|
|
495
|
-
return /* @__PURE__ */ p(b, { theme: "light", type: "tertiary", className: j.upgrade, onClick: () => t(w(e.routes.app, "subscription")), children: [
|
|
496
|
-
/* @__PURE__ */ s("span", { className: j.crown, "aria-hidden": "true" }),
|
|
497
|
-
/* @__PURE__ */ s("span", { className: j.text, children: o })
|
|
498
|
-
] });
|
|
499
|
-
}, En = "_wallet_e6uma_2", In = "_coin_e6uma_25", $n = "_value_e6uma_32", Q = {
|
|
500
|
-
wallet: En,
|
|
501
|
-
coin: In,
|
|
502
|
-
value: $n
|
|
503
|
-
}, ta = () => {
|
|
504
|
-
const { accountApi: e, config: t } = g(), { session: n } = R(), a = J(), o = (n == null ? void 0 : n.activeSpaceId) ?? "", c = (n == null ? void 0 : n.globalUserId) ?? "", u = x({
|
|
505
|
-
queryKey: L.wallet(o, c),
|
|
506
|
-
queryFn: () => e.getWallet(),
|
|
507
|
-
enabled: !!n,
|
|
508
|
-
refetchOnWindowFocus: !0
|
|
509
|
-
});
|
|
510
|
-
if (!n) return null;
|
|
511
|
-
const d = u.isPending ? "读取中" : u.data ? v(u.data.availablePoints) : "积分暂不可用";
|
|
512
|
-
return /* @__PURE__ */ s(Ee, { content: "当前空间可用积分,由统一账号中心记账", children: /* @__PURE__ */ p(
|
|
513
|
-
b,
|
|
514
|
-
{
|
|
515
|
-
theme: "light",
|
|
516
|
-
type: "tertiary",
|
|
517
|
-
className: Q.wallet,
|
|
518
|
-
"aria-label": u.data ? `积分 ${d}` : d,
|
|
519
|
-
onClick: () => a(w(t.routes.app, "points")),
|
|
520
|
-
children: [
|
|
521
|
-
/* @__PURE__ */ s("span", { className: Q.coin, "aria-hidden": "true" }),
|
|
522
|
-
/* @__PURE__ */ s("span", { className: Q.value, children: d })
|
|
523
|
-
]
|
|
524
|
-
}
|
|
525
|
-
) });
|
|
526
|
-
};
|
|
527
|
-
export {
|
|
528
|
-
bt as A,
|
|
529
|
-
Nt as B,
|
|
530
|
-
Qn as C,
|
|
531
|
-
Gn as D,
|
|
532
|
-
Lt as E,
|
|
533
|
-
Y as F,
|
|
534
|
-
jn as G,
|
|
535
|
-
X as H,
|
|
536
|
-
Jn as I,
|
|
537
|
-
Ot as J,
|
|
538
|
-
Bt as K,
|
|
539
|
-
Nn as L,
|
|
540
|
-
gn as M,
|
|
541
|
-
ke as N,
|
|
542
|
-
vn as O,
|
|
543
|
-
P,
|
|
544
|
-
Cn as Q,
|
|
545
|
-
vt as U,
|
|
546
|
-
ta as W,
|
|
547
|
-
de as a,
|
|
548
|
-
Zn as b,
|
|
549
|
-
yn as c,
|
|
550
|
-
hn as d,
|
|
551
|
-
ea as e,
|
|
552
|
-
L as f,
|
|
553
|
-
w as g,
|
|
554
|
-
wt as h,
|
|
555
|
-
bn as i,
|
|
556
|
-
Mt as j,
|
|
557
|
-
Xn as k,
|
|
558
|
-
Tt as l,
|
|
559
|
-
It as m,
|
|
560
|
-
$t as n,
|
|
561
|
-
Yn as o,
|
|
562
|
-
gt as p,
|
|
563
|
-
F as q,
|
|
564
|
-
kn as r,
|
|
565
|
-
Z as s,
|
|
566
|
-
Dt as t,
|
|
567
|
-
B as u,
|
|
568
|
-
Pt as v,
|
|
569
|
-
Hn as w,
|
|
570
|
-
Vn as x,
|
|
571
|
-
At as y,
|
|
572
|
-
H as z
|
|
573
|
-
};
|