@24city/web-console 0.0.0-stage → 0.1.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.
- package/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +164 -2
- package/dist/account/account-api.d.ts +24 -0
- package/dist/account/account-center-links.d.ts +35 -0
- package/dist/account/account-center-page.d.ts +7 -0
- package/dist/account/account-center-ui.d.ts +19 -0
- package/dist/account/account-menu.d.ts +23 -0
- package/dist/account/auth-provider.d.ts +6 -0
- package/dist/account/auth-store.d.ts +25 -0
- package/dist/account/benefit-copy.d.ts +15 -0
- package/dist/account/customization.d.ts +62 -0
- package/dist/account/index.d.ts +34 -0
- package/dist/account/index.js +87 -0
- package/dist/account/login-page.d.ts +6 -0
- package/dist/account/logout-signal.d.ts +13 -0
- package/dist/account/personal-nav.d.ts +29 -0
- package/dist/account/plan-benefits.d.ts +16 -0
- package/dist/account/plan-cards.d.ts +10 -0
- package/dist/account/plan-display.d.ts +44 -0
- package/dist/account/plan-panel.d.ts +16 -0
- package/dist/account/points-section.d.ts +8 -0
- package/dist/account/profile-section.d.ts +9 -0
- package/dist/account/quota-pill.d.ts +10 -0
- package/dist/account/quota.d.ts +12 -0
- package/dist/account/route-guard.d.ts +5 -0
- package/dist/account/session-sync.d.ts +1 -0
- package/dist/account/space-label.d.ts +10 -0
- package/dist/account/subscription-section.d.ts +11 -0
- package/dist/account/team-promo.d.ts +9 -0
- package/dist/account/types.d.ts +120 -0
- package/dist/account/upgrade-entry.d.ts +6 -0
- package/dist/account/upgrade-modal.d.ts +14 -0
- package/dist/account/use-account-center.d.ts +27 -0
- package/dist/account/use-logout.d.ts +13 -0
- package/dist/account/use-membership.d.ts +48 -0
- package/dist/account/use-plan-catalog.d.ts +2 -0
- package/dist/account/use-space-switch.d.ts +8 -0
- package/dist/account/wallet-badge.d.ts +2 -0
- package/dist/assets/coin-BhUDKCPy.webp +0 -0
- package/dist/assets/crown-D5kKk5rW.webp +0 -0
- package/dist/assets/diamond-BuDSsnw-.webp +0 -0
- package/dist/assets/engine-hero-BaSSoV-3.webp +0 -0
- package/dist/assets/member-gem-DTY0gTzl.webp +0 -0
- package/dist/assets/team-BeZ_oZcL.webp +0 -0
- package/dist/assets/upgrade-crown-Ci1IFoXi.webp +0 -0
- package/dist/chunks/auth-provider-CqiyTeOt.js +62 -0
- package/dist/chunks/console-layout-CcUiJPf0.js +198 -0
- package/dist/chunks/context-CaVim6ZO.js +13 -0
- package/dist/chunks/error-boundary-BgTZsJA_.js +35 -0
- package/dist/chunks/http-B3mTs9KZ.js +8 -0
- package/dist/chunks/link-button-giJEcTmG.js +42 -0
- package/dist/chunks/logout-signal-CiD_zY5M.js +365 -0
- package/dist/chunks/page-BhfOrziX.js +89 -0
- package/dist/chunks/stale-build-D4N21gap.js +57 -0
- package/dist/chunks/text-link-7A--UEc3.js +54 -0
- package/dist/chunks/upgrade-modal-BbsM2VE2.js +667 -0
- package/dist/chunks/use-media-query-DvyinWNg.js +12 -0
- package/dist/chunks/wallet-badge-D7AFqTLx.js +565 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +159 -0
- package/dist/layout/console-layout.d.ts +35 -0
- package/dist/layout/console-nav.d.ts +30 -0
- package/dist/layout/index.d.ts +2 -0
- package/dist/layout/index.js +8 -0
- package/dist/page/error-boundary.d.ts +20 -0
- package/dist/page/index.d.ts +7 -0
- package/dist/page/index.js +21 -0
- package/dist/page/link-button.d.ts +29 -0
- package/dist/page/not-found-page.d.ts +1 -0
- package/dist/page/page.d.ts +34 -0
- package/dist/page/startup-error.d.ts +2 -0
- package/dist/page/status-result.d.ts +17 -0
- package/dist/page/text-link.d.ts +22 -0
- package/dist/runtime/context.d.ts +19 -0
- package/dist/runtime/error-summary.d.ts +5 -0
- package/dist/runtime/format.d.ts +10 -0
- package/dist/runtime/http.d.ts +11 -0
- package/dist/runtime/index.d.ts +11 -0
- package/dist/runtime/index.js +41 -0
- package/dist/runtime/internal-path.d.ts +4 -0
- package/dist/runtime/providers.d.ts +16 -0
- package/dist/runtime/query-keys.d.ts +6 -0
- package/dist/runtime/response.d.ts +6 -0
- package/dist/runtime/runtime-config.d.ts +19 -0
- package/dist/runtime/stale-build.d.ts +11 -0
- package/dist/runtime/use-media-query.d.ts +2 -0
- package/dist/semi.d.ts +10 -0
- package/dist/semi.js +12 -0
- package/dist/styles.css +3192 -0
- package/dist/testing/fixtures.d.ts +15 -0
- package/dist/testing/fixtures.js +142 -0
- package/dist/testing/guard.d.ts +32 -0
- package/dist/testing/guard.js +61 -0
- package/dist/testing/jsdom.d.ts +2 -0
- package/dist/testing/jsdom.js +116 -0
- package/dist/theme/index.d.ts +24 -0
- package/dist/theme/index.js +51 -0
- package/dist/theme/palette.d.ts +6 -0
- package/package.json +98 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ConsoleCustomization } from './customization';
|
|
2
|
+
import type { ProductPlan, ProductPlanPrice, ProductSubscription } from './types';
|
|
3
|
+
/** 套餐名称:账号中心没给名称时用编码。 */
|
|
4
|
+
export declare const planTitle: (subscription: ProductSubscription) => string;
|
|
5
|
+
/** 套餐有效期:免费版(默认套餐)或没有到期时间的长期有效。 */
|
|
6
|
+
export declare const planPeriodText: (subscription: ProductSubscription) => string;
|
|
7
|
+
/** 当期还剩几天(不足一天算一天,已过期为 0);免费版或没有到期时间时为 null。 */
|
|
8
|
+
export declare const planDaysLeft: (subscription: ProductSubscription, now?: number) => number | null;
|
|
9
|
+
/** 剩这么多天以内算“即将到期”,会员卡上突出续费。 */
|
|
10
|
+
export declare const EXPIRING_SOON_DAYS = 7;
|
|
11
|
+
/** 价格金额:人民币写 ¥78、¥78.5,其他币种带代码(USD 9.9)。 */
|
|
12
|
+
export declare const formatPlanAmount: (price: Pick<ProductPlanPrice, "amountCents" | "currency">) => string;
|
|
13
|
+
/**
|
|
14
|
+
* 升级弹窗打开「订阅与套餐」时带的路由状态:弹窗推荐的套餐编码,页面滚到会员套餐并标出这张卡。
|
|
15
|
+
* 只在站内跳转时带上,刷新或直接打开地址时没有。
|
|
16
|
+
*/
|
|
17
|
+
export interface PlanFocusState {
|
|
18
|
+
focusPlan: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const planFocusState: (planCode: string | undefined) => PlanFocusState | undefined;
|
|
21
|
+
export declare const planFocusOf: (state: unknown) => string | undefined;
|
|
22
|
+
/** 价格带周期:¥78/月、¥698/年;一次性付费只写金额。 */
|
|
23
|
+
export declare const formatPlanPrice: (price: ProductPlanPrice) => string;
|
|
24
|
+
/** 一个套餐的起步价:有月付取最低的月付,没有月付取最低价;免费(0 元)的价格不算。 */
|
|
25
|
+
export declare const startingPrice: (plan: ProductPlan) => ProductPlanPrice | null;
|
|
26
|
+
export interface UpgradeOffer {
|
|
27
|
+
plan: ProductPlan;
|
|
28
|
+
price: ProductPlanPrice | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 升级引导推荐的套餐:当前空间类型的付费套餐里,档位比当前高的最低一档(同档取起步价更低的)。
|
|
32
|
+
* 当前没有套餐时(团队版已到期)从同类最低档开始。没有更高档时为 null。
|
|
33
|
+
*/
|
|
34
|
+
export declare const upgradeOffer: (plans: ProductPlan[] | undefined, spaceType: string, currentTier: number | null) => UpgradeOffer | null;
|
|
35
|
+
/** 套餐目录里最低一档的团队套餐(开通团队版的引导用它的席位、每月积分和起步价);读不到目录时为 undefined。 */
|
|
36
|
+
export declare const entryTeamPlan: (plans: ProductPlan[] | undefined) => ProductPlan | undefined;
|
|
37
|
+
/** 套餐目录里与当前订阅对应的套餐(按编码)。 */
|
|
38
|
+
export declare const catalogPlanOf: (plans: ProductPlan[] | undefined, subscription: ProductSubscription) => ProductPlan | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* 升级卡片上的一句卖点:每月积分加本产品最先列出的两项功能(与权益卡同样的白话),不够两项时补“24.city 全产品通用”
|
|
41
|
+
* (套餐对所有产品同时生效,STD-BILLING-001)。传入套餐目录时,每个套餐都有的开关不算卖点。
|
|
42
|
+
* 读不到套餐目录时只说套餐积分按月发放。
|
|
43
|
+
*/
|
|
44
|
+
export declare const offerHighlights: (plan: ProductPlan | undefined, catalog?: ProductPlan[], custom?: ConsoleCustomization) => string[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Membership } from './use-membership';
|
|
2
|
+
interface PlanPanelProps {
|
|
3
|
+
membership: Membership;
|
|
4
|
+
/** 打开个人中心的一个分区(积分与明细、订阅与套餐),并收起卡片 */
|
|
5
|
+
onOpen: (key: string) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 账号卡片里的套餐区:
|
|
9
|
+
* - 免费版:浅主色渐变的升级引导,标题写推荐套餐,卖点来自套餐目录,黑色主按钮挂起步价;
|
|
10
|
+
* - 会员:黑金会员卡,套餐名、有效期、剩余天数,快到期时突出续费;
|
|
11
|
+
* - 团队版已到期:同样的引导块,换成“续费团队版”(团队随购买创建,团队空间里的 403 只会是到期);
|
|
12
|
+
* - 读不到:一句说明加重试。
|
|
13
|
+
* 开通、续费、升级的按钮都打开「订阅与套餐」,付款在那里的权益卡上去统一账号中心。
|
|
14
|
+
*/
|
|
15
|
+
export declare const PlanPanel: ({ membership, onOpen }: PlanPanelProps) => import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AccountCenterData } from './use-account-center';
|
|
2
|
+
/**
|
|
3
|
+
* 积分与明细:当前空间的可用积分(统一账号中心记账,只读;不显示预占积分)、去账号中心看全部积分消耗,
|
|
4
|
+
* 以及产品给的本人扣费明细(customization.PointsDetail)。
|
|
5
|
+
*/
|
|
6
|
+
export declare const PointsSection: ({ data }: {
|
|
7
|
+
data: AccountCenterData;
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AccountCenterData } from './use-account-center';
|
|
2
|
+
/**
|
|
3
|
+
* 账号与安全:账号信息(昵称、统一账号 ID、当前空间与角色、本次登录有效期)和登录安全的入口。
|
|
4
|
+
* 密码、登录设备、空间成员都由统一账号中心管理,这里只放去账号中心对应页面的按钮;产品不保存密码。
|
|
5
|
+
* 昵称是统一账号首次登录本产品时带来的名称,之后在账号中心改名不会同步过来,所以这里不放“修改”。
|
|
6
|
+
*/
|
|
7
|
+
export declare const ProfileSection: ({ data }: {
|
|
8
|
+
data: AccountCenterData;
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type QuotaView } from './quota';
|
|
2
|
+
/**
|
|
3
|
+
* 套餐数量的小胶囊:写着用了多少、上限多少;满了变成暖色并带“升级”按钮,点它弹出订阅升级引导。
|
|
4
|
+
* 没有数量信息(旧接口或未开启套餐限制)时不显示。
|
|
5
|
+
*/
|
|
6
|
+
export declare const QuotaPill: ({ quota, unit, onUpgrade }: {
|
|
7
|
+
quota?: QuotaView | null;
|
|
8
|
+
unit: string;
|
|
9
|
+
onUpgrade: () => void;
|
|
10
|
+
}) => import("react").JSX.Element | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 服务端返回的套餐数量上限:已有多少个和上限;上限读不到时为 null。 */
|
|
2
|
+
export interface QuotaView {
|
|
3
|
+
used: number;
|
|
4
|
+
limit: number | null;
|
|
5
|
+
}
|
|
6
|
+
/** 套餐写 1000000 表示不限(统一账号中心的配额只能是整数)。 */
|
|
7
|
+
export declare const UNLIMITED_QUOTA = 1000000;
|
|
8
|
+
export declare const isUnlimited: (limit: number | null | undefined) => boolean;
|
|
9
|
+
/** 已经达到上限,再新建会被服务端拒绝;上限读不到时不拦,由服务端判断。 */
|
|
10
|
+
export declare const quotaFull: (quota: QuotaView | null | undefined) => boolean;
|
|
11
|
+
/** 胶囊上的文字:已用 2/3、已有 12 个 · 不限;读不到上限时只写已有多少个。 */
|
|
12
|
+
export declare const quotaText: (quota: QuotaView, unit: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { notifyCustomerSessionChanged as notifySessionChanged, subscribeCustomerSessionChanges as subscribeSessionChanged, } from '@24city/web-runtime/session-sync';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProductSpace } from './types';
|
|
2
|
+
/** 个人空间每人只有一个,界面上统一叫“个人空间”,不显示统一账号里的空间全称。 */
|
|
3
|
+
export declare const PERSONAL_SPACE_LABEL = "\u4E2A\u4EBA\u7A7A\u95F4";
|
|
4
|
+
export declare const isTeamSpace: (space: Pick<ProductSpace, "type">) => boolean;
|
|
5
|
+
/** 空间在界面上的名称:个人空间固定为“个人空间”,其他空间用名称(没有名称时用 slug)。 */
|
|
6
|
+
export declare const spaceDisplayName: (space: Pick<ProductSpace, "type" | "name" | "slug">) => string;
|
|
7
|
+
/** 统一账号中心给的空间角色(owner、admin、member)的中文名;不认识的角色返回空字符串。 */
|
|
8
|
+
export declare const spaceRoleLabel: (role: string | undefined) => string;
|
|
9
|
+
/** 能不能给当前空间买套餐:个人空间是自己的;团队空间只有所有者能买(STD-BILLING-001)。 */
|
|
10
|
+
export declare const canBuyForSpace: (space: Pick<ProductSpace, "type" | "role"> | undefined) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AccountCenterData } from './use-account-center';
|
|
2
|
+
/**
|
|
3
|
+
* 订阅与套餐:当前空间的套餐(名称、有效期,升级或续费去账号中心套餐页)、在售套餐的权益卡(plan-cards.tsx)、
|
|
4
|
+
* 个人空间开通团队版的引导卡(team-promo.tsx)。
|
|
5
|
+
* 套餐属于空间,对 24.city 所有产品同时生效;团队空间只有所有者能买,其他成员看到“请团队所有者购买”。
|
|
6
|
+
* 团队版到期时接口回 403(team_subscription_required),这里显示统一的续费提示。
|
|
7
|
+
*/
|
|
8
|
+
export declare const SubscriptionSection: ({ data, focusPlan }: {
|
|
9
|
+
data: AccountCenterData;
|
|
10
|
+
focusPlan?: string;
|
|
11
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProductPlan } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 个人空间里开通团队版的引导:浅主色到暖金的渐变卡片,左边团队插画,中间标题、一句说明和团队版要点(席位、每月积分来自套餐目录,
|
|
4
|
+
* 读不到时只写共用),右边去统一账号中心开通,下面是起步价。开通团队版会新建一个团队空间,所以个人空间的所有者都能点。
|
|
5
|
+
*/
|
|
6
|
+
export declare const TeamPromo: ({ href, plan }: {
|
|
7
|
+
href: string | null;
|
|
8
|
+
plan: ProductPlan | undefined;
|
|
9
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** 产品服务端 `GET /api/account/session` 返回的用户端会话(只接受 user Purpose)。 */
|
|
2
|
+
export interface ProductSession {
|
|
3
|
+
globalUserId: string;
|
|
4
|
+
localUserId: number;
|
|
5
|
+
activeSpaceId: string;
|
|
6
|
+
authorityId: number;
|
|
7
|
+
orgId: number;
|
|
8
|
+
purpose: 'user';
|
|
9
|
+
csrfToken: string;
|
|
10
|
+
issuedAt: string;
|
|
11
|
+
lastSeenAt: string;
|
|
12
|
+
absoluteExpiresAt: string;
|
|
13
|
+
lastCentralVerifiedAt: string;
|
|
14
|
+
/** 统一账号中心用户后台的地址,由产品服务端配置。 */
|
|
15
|
+
accountCenterUrl: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ProductEntitlement {
|
|
18
|
+
id: string;
|
|
19
|
+
entitlementCode: string;
|
|
20
|
+
status?: string;
|
|
21
|
+
startsAt: string;
|
|
22
|
+
expiresAt: string | null;
|
|
23
|
+
metadata: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface ProductSpace {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
type: string;
|
|
30
|
+
role: string;
|
|
31
|
+
status: string;
|
|
32
|
+
membershipStatus: string;
|
|
33
|
+
entitlementSummary: {
|
|
34
|
+
activeCount: number;
|
|
35
|
+
codes: string[];
|
|
36
|
+
};
|
|
37
|
+
entitlements: ProductEntitlement[];
|
|
38
|
+
}
|
|
39
|
+
export interface ProductSpacesResponse {
|
|
40
|
+
activeSpaceId: string;
|
|
41
|
+
spaces: ProductSpace[];
|
|
42
|
+
}
|
|
43
|
+
export interface ProductProfile {
|
|
44
|
+
/** 统一账号首次登录时给的展示名,可能为空 */
|
|
45
|
+
nickName: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ProductWallet {
|
|
48
|
+
spaceId: string;
|
|
49
|
+
globalUserId: string;
|
|
50
|
+
productCode: string;
|
|
51
|
+
availablePoints: number;
|
|
52
|
+
reservedPoints: number;
|
|
53
|
+
globalAvailablePoints: number;
|
|
54
|
+
globalReservedPoints: number;
|
|
55
|
+
productAvailablePoints: number;
|
|
56
|
+
productReservedPoints: number;
|
|
57
|
+
walletAvailablePoints: number;
|
|
58
|
+
walletReservedPoints: number;
|
|
59
|
+
walletVersion: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 当前空间的平台套餐(`GET /api/account/subscription`,账号接入模块转读统一账号中心),只用于展示。
|
|
63
|
+
* 功能开不开、扣不扣积分仍由服务端判断。没有套餐管着这个空间时接口返回 null。
|
|
64
|
+
*/
|
|
65
|
+
export interface ProductSubscription {
|
|
66
|
+
/** 免费版(默认套餐)没有订阅编号 */
|
|
67
|
+
subscriptionId: string | null;
|
|
68
|
+
planCode: string;
|
|
69
|
+
planName: string;
|
|
70
|
+
/** 套餐档位,越大越高 */
|
|
71
|
+
tier: number;
|
|
72
|
+
isDefault: boolean;
|
|
73
|
+
spaceType: string;
|
|
74
|
+
/** 当期到期时间;免费版为 null */
|
|
75
|
+
currentPeriodEnd: string | null;
|
|
76
|
+
}
|
|
77
|
+
/** 套餐目录里的一个当前价格;最终价格以统一账号中心收银台为准。 */
|
|
78
|
+
export interface ProductPlanPrice {
|
|
79
|
+
/** 去账号中心套餐页时用 price_code 预选这个价格 */
|
|
80
|
+
code: string;
|
|
81
|
+
amountCents: number;
|
|
82
|
+
/** ISO 4217 币种,例如 CNY */
|
|
83
|
+
currency: string;
|
|
84
|
+
billingPeriod: 'month' | 'year' | 'one_time';
|
|
85
|
+
durationDays: number;
|
|
86
|
+
/** 这个价格买到几个订阅月(几次每月积分) */
|
|
87
|
+
pointCycles: number;
|
|
88
|
+
}
|
|
89
|
+
/** 套餐在本产品打开的一项功能:名称和说明是功能矩阵里的原文。 */
|
|
90
|
+
export interface ProductPlanBenefit {
|
|
91
|
+
key: string;
|
|
92
|
+
name: string;
|
|
93
|
+
description: string;
|
|
94
|
+
/** 配额上限;开关为 null */
|
|
95
|
+
limit: number | null;
|
|
96
|
+
/** 这项功能带来的会员价标签,例如“8 折” */
|
|
97
|
+
discounts: string[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 在售的平台套餐(`GET /api/account/plans`,产品转读统一账号中心的套餐目录),只用于升级卡片展示。
|
|
101
|
+
* 功能开不开仍以当前空间的订阅为准,不按套餐目录或套餐编码判断。
|
|
102
|
+
*/
|
|
103
|
+
export interface ProductPlan {
|
|
104
|
+
code: string;
|
|
105
|
+
name: string;
|
|
106
|
+
spaceType: 'personal' | 'team';
|
|
107
|
+
tier: number;
|
|
108
|
+
isDefault: boolean;
|
|
109
|
+
includedSeats: number;
|
|
110
|
+
/** 每个订阅月发放的积分;免费版是平台每月赠送的积分 */
|
|
111
|
+
monthlyPoints: number;
|
|
112
|
+
prices: ProductPlanPrice[];
|
|
113
|
+
benefits: ProductPlanBenefit[];
|
|
114
|
+
/** 这个套餐在 24.city 其他产品里也打开了功能的产品名称(只用于“其他产品的高级权益”引导) */
|
|
115
|
+
otherProducts: string[];
|
|
116
|
+
}
|
|
117
|
+
export interface ProductIdentityContext {
|
|
118
|
+
session: ProductSession;
|
|
119
|
+
spaces: ProductSpace[];
|
|
120
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** 弹窗插画:engine 是带皇冠的电影机(生成类功能),crown 是皇冠(数量上限等)。 */
|
|
2
|
+
export type UpgradeArt = 'engine' | 'crown';
|
|
3
|
+
/**
|
|
4
|
+
* 订阅升级引导弹窗:上半是插画、“会员专享”角标、标题和说明,下半是推荐套餐的权益(来自套餐目录)和「立即升级」。
|
|
5
|
+
* 「立即升级」和顶栏「开通会员」一样先打开「订阅与套餐」(滚到会员套餐、标出推荐的这一档),用户对比各档权益后
|
|
6
|
+
* 再从权益卡去统一账号中心付款,不直接跳账号中心。团队空间的非所有者看不到按钮,只说明请所有者升级。
|
|
7
|
+
* 用在用户点了当前套餐不含的功能时。
|
|
8
|
+
*/
|
|
9
|
+
export declare const UpgradeModal: ({ title, description, art, onClose, }: {
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
art?: UpgradeArt;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 团队版到期时,账号接入模块统一回 403,reason 为 team_subscription_required。团队随购买创建,切得进来的团队都开通过,
|
|
3
|
+
* 所以界面上把它当作“团队版已到期”。
|
|
4
|
+
*/
|
|
5
|
+
export declare const isTeamSubscriptionRequired: (error: unknown) => boolean;
|
|
6
|
+
/** 账号相关查询的 Query Key;产品页面读同一份数据时用同样的键,共用缓存。 */
|
|
7
|
+
export declare const accountQueryKeys: {
|
|
8
|
+
profile: (globalUserId: string) => readonly ["product-profile", string];
|
|
9
|
+
wallet: (activeSpaceId: string, globalUserId: string) => readonly ["product-wallet", string, string];
|
|
10
|
+
subscription: (activeSpaceId: string, globalUserId: string) => readonly ["product-subscription", string, string];
|
|
11
|
+
plans: readonly ["product-plans"];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 个人中心共用的数据:会话与当前空间、昵称、钱包、当前套餐。左侧身份卡片和各分区读同一份缓存。
|
|
15
|
+
* 昵称的 Query Key 与右上角账号下拉相同;钱包、套餐按空间和用户区分,切换空间后重新读取。
|
|
16
|
+
*/
|
|
17
|
+
export declare const useAccountCenter: () => {
|
|
18
|
+
session: import("./types").ProductSession | null;
|
|
19
|
+
allowed: boolean;
|
|
20
|
+
activeSpace: import("./types").ProductSpace | undefined;
|
|
21
|
+
activeSpaceId: string;
|
|
22
|
+
globalUserId: string;
|
|
23
|
+
profile: import("@tanstack/react-query").UseQueryResult<import("./types").ProductProfile, Error>;
|
|
24
|
+
wallet: import("@tanstack/react-query").UseQueryResult<import("./types").ProductWallet, Error>;
|
|
25
|
+
subscription: import("@tanstack/react-query").UseQueryResult<import("./types").ProductSubscription | null, Error>;
|
|
26
|
+
};
|
|
27
|
+
export type AccountCenterData = ReturnType<typeof useAccountCenter>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 退出登录:确认后结束产品会话,再经统一登录的退出地址结束 24.city 统一登录,最后回到产品首页。
|
|
3
|
+
* 不回登录页:登录页会自动发起统一登录,统一登录仍有效时会立即重新登录。
|
|
4
|
+
* 服务端未确认退出时保持当前登录并提示重试,不清空本地状态。
|
|
5
|
+
*
|
|
6
|
+
* 离开前不清空登录状态和缓存:清空会让路由守卫立刻跳去登录页,登录页再跳统一登录,取消这次退出跳转,
|
|
7
|
+
* 结果是统一登录没退掉又登录回来。本页停在原处(确认框按钮保持加载)直到浏览器离开,见 logout-signal.ts。
|
|
8
|
+
*/
|
|
9
|
+
export declare const useLogout: () => {
|
|
10
|
+
confirmLogout: () => void;
|
|
11
|
+
logout: () => Promise<void>;
|
|
12
|
+
pending: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type UpgradeOffer } from './plan-display';
|
|
2
|
+
import type { ProductSubscription } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 当前空间的会员状态:
|
|
5
|
+
* - free:免费版,或个人空间没有任何套餐(`subscription` 为 null),要强引导升级;
|
|
6
|
+
* - member:付费套餐生效中;
|
|
7
|
+
* - team-expired:团队版已到期(403 team_subscription_required)。团队随购买创建,切得进来的团队都开通过,所以这个 403 只会是到期;
|
|
8
|
+
* - loading / error:还没读到或读取失败。
|
|
9
|
+
*/
|
|
10
|
+
export type MembershipState = {
|
|
11
|
+
kind: 'loading';
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'error';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'team-expired';
|
|
16
|
+
} | {
|
|
17
|
+
kind: 'free';
|
|
18
|
+
subscription: ProductSubscription | null;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'member';
|
|
21
|
+
subscription: ProductSubscription;
|
|
22
|
+
daysLeft: number | null;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 右上角账号卡片、顶栏“开通会员”、升级弹窗和头像共用的数据:会话、昵称、钱包、当前套餐(与个人中心同一份缓存),
|
|
26
|
+
* 加套餐目录算出的升级推荐和「订阅与套餐」的站内地址。这些入口都先打开「订阅与套餐」,在权益卡上对比后再去统一账号中心付款,
|
|
27
|
+
* 不直接跳账号中心。只用于展示,功能和扣费仍由服务端判断。
|
|
28
|
+
*/
|
|
29
|
+
export declare const useMembership: () => {
|
|
30
|
+
plans: import("@tanstack/react-query").UseQueryResult<import("./types").ProductPlan[], Error>;
|
|
31
|
+
state: MembershipState;
|
|
32
|
+
offer: UpgradeOffer | null;
|
|
33
|
+
currentPlan: import("./types").ProductPlan | undefined;
|
|
34
|
+
team: boolean;
|
|
35
|
+
/** 个人空间是自己的;团队空间只有所有者能买(STD-BILLING-001) */
|
|
36
|
+
canBuy: boolean;
|
|
37
|
+
/** 「订阅与套餐」的站内地址 */
|
|
38
|
+
subscriptionPath: string;
|
|
39
|
+
session: import("./types").ProductSession | null;
|
|
40
|
+
allowed: boolean;
|
|
41
|
+
activeSpace: import("./types").ProductSpace | undefined;
|
|
42
|
+
activeSpaceId: string;
|
|
43
|
+
globalUserId: string;
|
|
44
|
+
profile: import("@tanstack/react-query").UseQueryResult<import("./types").ProductProfile, Error>;
|
|
45
|
+
wallet: import("@tanstack/react-query").UseQueryResult<import("./types").ProductWallet, Error>;
|
|
46
|
+
subscription: import("@tanstack/react-query").UseQueryResult<ProductSubscription | null, Error>;
|
|
47
|
+
};
|
|
48
|
+
export type Membership = ReturnType<typeof useMembership>;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as y, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as S } from "react";
|
|
3
|
+
import { useQueryClient as U } from "@tanstack/react-query";
|
|
4
|
+
import { b as I } from "./context-CaVim6ZO.js";
|
|
5
|
+
import { g as L, n as g, i as d, v as x, f as m, r as A, t as f } from "./logout-signal-CiD_zY5M.js";
|
|
6
|
+
import { subscribeCustomerSessionChanges as E } from "@24city/web-runtime/session-sync";
|
|
7
|
+
const P = (t) => !f(t, 401) && !f(t, 403) && !f(t, 404), k = (t, n) => (t == null ? void 0 : t.purpose) === n.purpose && t.globalUserId === n.globalUserId && t.activeSpaceId === n.activeSpaceId, $ = ({ children: t }) => {
|
|
8
|
+
const n = U(), e = L(), { accountApi: u, config: s, http: l } = I();
|
|
9
|
+
return S(() => {
|
|
10
|
+
let r = !0, o = 0;
|
|
11
|
+
const p = async () => {
|
|
12
|
+
await n.cancelQueries().catch(() => {
|
|
13
|
+
}), n.clear();
|
|
14
|
+
}, c = async () => {
|
|
15
|
+
if (d()) return;
|
|
16
|
+
const a = ++o;
|
|
17
|
+
e.setBootstrapping(), await p();
|
|
18
|
+
try {
|
|
19
|
+
const i = await m(u);
|
|
20
|
+
r && o === a && (A(), e.setContext(i));
|
|
21
|
+
} catch (i) {
|
|
22
|
+
if (!r || o !== a) return;
|
|
23
|
+
e.clear({ unavailable: P(i) });
|
|
24
|
+
}
|
|
25
|
+
}, v = async () => {
|
|
26
|
+
if (d() || (o += 1, await p(), e.clear(), g())) return;
|
|
27
|
+
const a = window.location.pathname + window.location.search;
|
|
28
|
+
x(window.location.pathname, s.routes.app) && window.location.assign(`${s.routes.login}?returnPath=${encodeURIComponent(a)}`);
|
|
29
|
+
};
|
|
30
|
+
l.configure({
|
|
31
|
+
baseUrl: s.api.baseUrl,
|
|
32
|
+
getCsrfToken: e.getCsrfToken,
|
|
33
|
+
onUnauthorized: v
|
|
34
|
+
});
|
|
35
|
+
const w = async () => {
|
|
36
|
+
if (d()) return;
|
|
37
|
+
if (!e.getState().session) return c();
|
|
38
|
+
const a = ++o;
|
|
39
|
+
try {
|
|
40
|
+
const i = await m(u);
|
|
41
|
+
if (!r || o !== a) return;
|
|
42
|
+
if (k(e.getState().session, i.session)) {
|
|
43
|
+
e.setContext(i);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
if (!r || o !== a) return;
|
|
48
|
+
}
|
|
49
|
+
await c();
|
|
50
|
+
}, b = E(() => {
|
|
51
|
+
g(), c();
|
|
52
|
+
}), h = () => {
|
|
53
|
+
document.visibilityState !== "hidden" && w();
|
|
54
|
+
};
|
|
55
|
+
return window.addEventListener("focus", h), c(), () => {
|
|
56
|
+
r = !1, o += 1, b(), window.removeEventListener("focus", h), l.configure({ getCsrfToken: null, onUnauthorized: null });
|
|
57
|
+
};
|
|
58
|
+
}, [u, e, s.api.baseUrl, s.routes.app, s.routes.login, l, n]), /* @__PURE__ */ y(C, { children: t });
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
$ as A
|
|
62
|
+
};
|