@24city/web-console 0.2.0 → 0.3.0

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