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