@24city/web-console 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +17 -1
- package/dist/account/account-api.d.ts +14 -0
- package/dist/account/auth-provider.d.ts +3 -1
- package/dist/account/index.d.ts +1 -0
- package/dist/account/index.js +64 -61
- package/dist/account/route-guard.d.ts +1 -1
- package/dist/account/upgrade-modal.d.ts +3 -1
- package/dist/account/use-track.d.ts +32 -0
- package/dist/chunks/auth-provider-Cwib6lRM.js +72 -0
- package/dist/chunks/console-layout-BhmLHO5v.js +214 -0
- package/dist/chunks/logout-signal-qvHorCCF.js +385 -0
- package/dist/chunks/{stale-build-DwUlkKYm.js → stale-build-CJ5c5sRp.js} +2 -2
- package/dist/chunks/use-show-once-Cwj5z_Lo.js +785 -0
- package/dist/chunks/wallet-badge-DnWl21es.js +629 -0
- package/dist/index.js +222 -218
- package/dist/layout/index.js +1 -1
- package/dist/runtime/error-summary.d.ts +2 -0
- package/dist/runtime/index.js +19 -18
- package/package.json +1 -1
- package/dist/chunks/auth-provider-7FOj7Y84.js +0 -62
- package/dist/chunks/console-layout-B4OlW1IZ.js +0 -210
- package/dist/chunks/logout-signal-CLdquzzn.js +0 -378
- package/dist/chunks/use-show-once-Bz1ojVqb.js +0 -768
- package/dist/chunks/wallet-badge-COpdEDYI.js +0 -575
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.12
|
|
4
|
+
|
|
5
|
+
**修复:发布期间恢复会话停在不可用页**(`AuthProvider`、`RouteGuard`、`LoginPage`)
|
|
6
|
+
|
|
7
|
+
- 恢复会话时遇到网络失败、超时或网关 502/503/504(例如 Staging 发布正在替换容器),先在加载态里隔 1、2、4 秒重试;
|
|
8
|
+
仍不可达才显示不可用页,之后每 15 秒静默再查一次,服务恢复后自动回到应用。回到窗口时立即重查,并取消等待中的静默复查。
|
|
9
|
+
其他失败(500、返回内容无效)和 401/403/404 不重试,行为不变。原先回到窗口时恰逢发布,页面会一直停在不可用页,直到手动刷新。
|
|
10
|
+
- 不可用页的文案不再说账号服务出了故障:工作台改为「服务暂时不可用 / 服务可能正在更新,请稍后重新加载;长时间无法恢复请联系
|
|
11
|
+
管理员。」,登录中转页改为「服务暂时不可用 / 服务可能正在更新,请稍后重试。」。
|
|
12
|
+
- `@24city/web-console/runtime` 新增 `isTransientServiceError(error)`。
|
|
13
|
+
- 来自 SaaS Starter 的同一修复(Starter 模板的会话恢复已改由本包提供)。
|
|
14
|
+
|
|
15
|
+
## 0.3.11
|
|
16
|
+
|
|
17
|
+
**新增:行为事件**(`@24city/web-console/account`,统一账号中心 API 1.24.0;运营在统一中心后台按行为圈人,
|
|
18
|
+
例如「打开升级引导后没有付款」的用户)
|
|
19
|
+
|
|
20
|
+
- `useTrack()` 记录已登录用户的页面、点击;`AccountApi.reportBehaviorEvents` 发到产品自己的 `POST /api/account/events`
|
|
21
|
+
(account-client 0.9.0 的 ginaccount 提供),用户与空间由服务端按会话补上。可选:自己实现 AccountApi 的产品不写也能编译。
|
|
22
|
+
- 自动记录:`ConsoleLayout` 的页面浏览(`page.viewed`,路由模板去掉真实 ID 和非 ASCII 段)、`UpgradeModal` 的打开与关闭
|
|
23
|
+
(停留时长、是否点「立即升级」,新增可选属性 `trigger`)、`UpgradeEntry` 的点击、权益卡付款按钮的 `plan.selected`。
|
|
24
|
+
- 2 秒或 20 条一批;会话恢复前先排队,确认已登录才发,确认未登录则丢掉;失败不提示、不重试;后端没有转发接口(404)时
|
|
25
|
+
本次会话停止上报,升级 web-console 而产品后端还没升级 account-client 不会报错。
|
|
26
|
+
|
|
3
27
|
## 0.3.10
|
|
4
28
|
|
|
5
29
|
**新增:图文入口 `CoverTabs` 的说明行 `description`**(`@24city/web-console/list`,来自 AdFlow 素材页:2026-11-14 改成图文入口后,原来分类卡片上的副标题没有了,负责人要求加回来)
|
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ initColorMode({ dark: true }) // 首屏渲染前调用:读出用户上次的
|
|
|
88
88
|
| `/semi` | `ConsoleSemiProvider`(中文文案,含 React 19 适配)、`modalButtonProps`(弹窗按钮属性,去掉 Semi 默认的英文 aria-label) |
|
|
89
89
|
| `/theme` | `applyBrand`、`brandPalette`、`brandDarkPalette`、`BRAND_VARIABLES`、`BRAND_SOURCE_VARIABLES`、`SEMI_BRAND_VARIABLES`;颜色模式 `initColorMode`、`setColorModePreference`、`useColorMode`、`getColorMode`;设计阶梯 `FONT_SIZE_SCALE`、`DISPLAY_SIZES`、`BREAKPOINTS`、`breakpointUp`、`breakpointDown` |
|
|
90
90
|
| `/runtime` | `ConsoleApp`、`supportsCascadeLayers`、`ConsoleRuntimeProvider`、`useConsoleRuntime`、`createHttpRuntime`、`loadRuntimeConfig`、`earlyRuntimeConfigFetcher`、`productQueryKeys`、格式化函数、`reloadOnStaleBuild` |
|
|
91
|
-
| `/account` | `createAccountApi`、`AuthProvider`、`RouteGuard`、`LoginPage`、`useAuthState`、`useLogout`、`useSpaceSwitch`、`useMembership`、`useShowOnce`(每个账号只弹一次)、`AccountMenu`、`WalletBadge`、`UpgradeEntry`、`UpgradeModal`、`QuotaPill`、`AllowanceMeter`、`AccountCenterPage`、`plansUrl`、`ConsoleCustomization` |
|
|
91
|
+
| `/account` | `createAccountApi`、`AuthProvider`、`RouteGuard`、`LoginPage`、`useAuthState`、`useLogout`、`useSpaceSwitch`、`useMembership`、`useShowOnce`(每个账号只弹一次)、`useTrack`(行为事件)、`AccountMenu`、`WalletBadge`、`UpgradeEntry`、`UpgradeModal`、`QuotaPill`、`AllowanceMeter`、`AccountCenterPage`、`plansUrl`、`ConsoleCustomization` |
|
|
92
92
|
| `/layout` | `ConsoleLayout`、`BrandMark`、导航类型 |
|
|
93
93
|
| `/page` | `ProductPage`(`back`、`titleAfter`、`width`)、`FullPage`、`Toolbar`、`LoadingCard`、`ErrorCard`、`EmptyCard`、`EmptyBlock`、`LoadingBlock`、`StatusResult`、`GuideModal`(功能引导弹窗)、`LinkButton`、`TextLink`、`SelectLabel`、`ColorModeSwitch`、`SessionUnavailable`、`ErrorBoundary`、`RouteErrorPage`、`StartupError`、`NotFoundPage`、`UnsupportedBrowser` |
|
|
94
94
|
| `/list` | 列表页:`ListToolbar`、`SelectionBar`、`TableScroll`;`FilterPanel`(`FilterRow`、`FilterOptions`、`FilterSelected`、`FilterSelectText`、`FilterRangeText`、`FilterCapsules`、`SortBar`)、`FilterDropdown`、`ChoiceCards`、`Waterfall`、`ContentSquare`(`SquareSearch`、`SquareAccent`、`SquareFooter`) |
|
|
@@ -165,6 +165,22 @@ const customization: ConsoleCustomization = {
|
|
|
165
165
|
`Component` 收到与内置分区相同的 `data`(会话、当前空间、昵称、钱包、当前套餐),只在会话可用时渲染,界面同样受守卫约束。
|
|
166
166
|
`key` 只能是小写字母开头的小写字母、数字和连字符,不能与内置分区重名,否则在开发时直接抛错。
|
|
167
167
|
|
|
168
|
+
### 行为事件
|
|
169
|
+
|
|
170
|
+
已登录用户的关键页面和点击自动上报到统一账号中心(统一中心 `docs/用户行为事件.md`),运营在统一中心后台按行为圈人:
|
|
171
|
+
|
|
172
|
+
- `ConsoleLayout` 每到一个页面记一次 `page.viewed`,`target` 是路由模板(像 ID 的路径段换成 `:id`);
|
|
173
|
+
- `UpgradeModal` 记 `upgrade_modal.opened` / `upgrade_modal.closed`(停留时长、有没有点「立即升级」),`trigger` 属性写触发它的
|
|
174
|
+
功能键(例如 `adflow.video_generate`),不传时用插画名;
|
|
175
|
+
- `UpgradeEntry` 记 `upgrade_entry.clicked`,权益卡的付款按钮记 `plan.selected`(`target` 是价格编码)。
|
|
176
|
+
|
|
177
|
+
产品自己的点击用 `useTrack()`:`track('works.exported', { target: '/works/:id', props: { format: 'mp4' } })`。事件名为
|
|
178
|
+
「对象.过去式动作」;`target` 只放低基数的值,`props` 最多 20 个短字符串、数字或布尔,不放手机号、邮箱和输入内容。导出成功、
|
|
179
|
+
生成完成这类关键动作以服务端为准,用 account-client 的 `Account.Track` 在业务成功后记。
|
|
180
|
+
|
|
181
|
+
上报经产品自己的 `POST /api/account/events`(account-client 0.9.0 起由 ginaccount 提供,用户与空间按会话补上),
|
|
182
|
+
2 秒或 20 条一批;会话恢复前先排队,确认已登录才发,未登录不发;失败不提示,后端还没有这个接口(404)时本次会话不再上报。
|
|
183
|
+
|
|
168
184
|
### 退出登录
|
|
169
185
|
|
|
170
186
|
退出同时结束产品会话和 24.city 统一登录,然后回产品首页;其他标签页收到信号后停在“已退出登录”,不自动重新登录。
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { AxiosInstance } from 'axios';
|
|
2
2
|
import type { ProductEntitlement, ProductIdentityContext, ProductPlan, ProductProfile, ProductSession, ProductSpacesResponse, ProductSubscription, ProductWallet } from './types';
|
|
3
|
+
export type BehaviorPropValue = string | number | boolean;
|
|
4
|
+
/** 浏览器上报的一条行为事件;用户与空间由产品服务端按会话补上(统一中心 docs/用户行为事件.md)。 */
|
|
5
|
+
export interface BehaviorEventInput {
|
|
6
|
+
eventId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
target?: string;
|
|
9
|
+
occurredAt: string;
|
|
10
|
+
props?: Record<string, BehaviorPropValue>;
|
|
11
|
+
}
|
|
3
12
|
/** 产品服务端账号接入模块(STD-ACCOUNT-001 `/api/account/*`)在浏览器侧的客户端。 */
|
|
4
13
|
export interface AccountApi {
|
|
5
14
|
startLogin: (returnPath: string, appBasePath: string) => string;
|
|
@@ -25,6 +34,11 @@ export interface AccountApi {
|
|
|
25
34
|
getShownPrompts?: (keys: readonly string[]) => Promise<string[]>;
|
|
26
35
|
/** 记下这些提示已弹出,返回这次新记下的,只弹这些(`POST /api/account/shown-prompts`)。 */
|
|
27
36
|
claimShownPrompts?: (keys: readonly string[]) => Promise<string[]>;
|
|
37
|
+
/**
|
|
38
|
+
* 上报当前用户的行为事件(`POST /api/account/events`,account-client 0.9.0 起由 ginaccount 提供)。可选:
|
|
39
|
+
* 自己实现 AccountApi 的产品不写也能编译,只是 `useTrack` 不上报。
|
|
40
|
+
*/
|
|
41
|
+
reportBehaviorEvents?: (events: BehaviorEventInput[]) => Promise<void>;
|
|
28
42
|
}
|
|
29
43
|
export declare const createAccountApi: (client: AxiosInstance, apiBaseUrl: string) => AccountApi;
|
|
30
44
|
/** 会话与空间列表一起读;两边的当前空间不一致时重读一次会话,仍不一致则视为服务端状态异常。 */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type PropsWithChildren } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* 会话恢复与同步:首次加载和其他标签页的会话变化时重读会话与空间;回到窗口时后台复核,用户、空间和用途都没变就保留
|
|
4
|
-
*
|
|
4
|
+
* 页面和缓存。服务暂时不可达(网络失败、超时、502/503/504)时先在加载态里隔 1、2、4 秒重试,仍不可达才显示不可用页,
|
|
5
|
+
* 之后每 15 秒静默再查,恢复后自动回到应用;其他失败不重试。给 HTTP 客户端配置 CSRF Token 和 401 处理:受保护路径下的
|
|
6
|
+
* 401 跳去登录页,其他标签页刚退出时不跳。
|
|
5
7
|
*/
|
|
6
8
|
export declare const AuthProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
|
package/dist/account/index.d.ts
CHANGED
package/dist/account/index.js
CHANGED
|
@@ -1,89 +1,92 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { A as C, a as d, C as
|
|
3
|
-
import { A as q, a as D, b as K, E as Q, F as
|
|
4
|
-
import { A as
|
|
5
|
-
import { notifyCustomerSessionChanged as
|
|
1
|
+
import { A as s, a as o, c as t, b as n, i as r, d as u, l as i, n as c, r as l, e as g, f as p, u as S, g as A, w as P } from "../chunks/logout-signal-qvHorCCF.js";
|
|
2
|
+
import { A as C, a as d, C as h, L as f, P as m, b as T, c as y, Q as N, R as O, S as b, d as E, T as U, U as v, e as w, p as F, f as R, g as _, h as x, u as B, y as I } from "../chunks/use-show-once-Cwj5z_Lo.js";
|
|
3
|
+
import { A as q, a as D, b as K, E as Q, F as k, P as G, c as H, d as W, U as Y, e as j, W as z, f as J, g as V, h as X, i as Z, j as $, k as aa, l as ea, m as sa, n as oa, o as ta, p as na, q as ra, r as ua, s as ia, t as ca, u as la, v as ga, w as pa, x as Sa, y as Aa, z as Pa, B as La, C as Ca, D as da, G as ha, H as fa, I as ma, J as Ta, K as ya, L as Na, M as Oa, N as ba, O as Ea, Q as Ua, R as va, S as wa, T as Fa } from "../chunks/wallet-badge-DnWl21es.js";
|
|
4
|
+
import { A as _a } from "../chunks/auth-provider-Cwib6lRM.js";
|
|
5
|
+
import { notifyCustomerSessionChanged as Ba, subscribeCustomerSessionChanges as Ia } from "@24city/web-runtime/session-sync";
|
|
6
6
|
export {
|
|
7
7
|
q as ACCOUNT_SECTIONS,
|
|
8
8
|
D as AccountAvatar,
|
|
9
9
|
C as AccountCenterPage,
|
|
10
10
|
K as AccountMenu,
|
|
11
11
|
d as AllowanceMeter,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
_a as AuthProvider,
|
|
13
|
+
s as AuthStoreProvider,
|
|
14
|
+
h as CenterLinkButton,
|
|
15
15
|
Q as EXPIRING_SOON_DAYS,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
k as FALLBACK_ACCOUNT_LABEL,
|
|
17
|
+
f as LoginPage,
|
|
18
|
+
G as PERSONAL_NAV_KEYS,
|
|
19
|
+
H as PERSONAL_SPACE_LABEL,
|
|
20
20
|
m as PlanCards,
|
|
21
21
|
W as PlanPanel,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
T as PointsSection,
|
|
23
|
+
y as ProfileSection,
|
|
24
|
+
N as QuotaPill,
|
|
25
|
+
O as RouteGuard,
|
|
26
|
+
b as SettingRow,
|
|
27
|
+
E as SubscriptionSection,
|
|
28
28
|
U as TeamPromo,
|
|
29
29
|
Y as UNLIMITED_QUOTA,
|
|
30
30
|
j as UpgradeEntry,
|
|
31
|
-
|
|
31
|
+
v as UpgradeModal,
|
|
32
32
|
z as WalletBadge,
|
|
33
|
-
|
|
33
|
+
w as accountCenterPageUrl,
|
|
34
34
|
J as accountQueryKeys,
|
|
35
35
|
V as accountSectionPath,
|
|
36
36
|
o as announceLogout,
|
|
37
|
-
X as
|
|
38
|
-
Z as
|
|
39
|
-
$ as
|
|
37
|
+
X as behaviorRouteTemplate,
|
|
38
|
+
Z as buildPersonalNavigation,
|
|
39
|
+
$ as canBuyForSpace,
|
|
40
|
+
aa as catalogPlanOf,
|
|
40
41
|
t as createAccountApi,
|
|
41
42
|
n as createAuthStore,
|
|
42
|
-
|
|
43
|
-
sa as
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
ea as createBehaviorTracker,
|
|
44
|
+
sa as entryTeamPlan,
|
|
45
|
+
oa as featureLines,
|
|
46
|
+
ta as formatPlanAmount,
|
|
47
|
+
na as formatPlanPrice,
|
|
48
|
+
ra as isAccountCenterPath,
|
|
49
|
+
ua as isAccountSection,
|
|
48
50
|
r as isLeavingForLogout,
|
|
49
51
|
u as isLoggedOutElsewhere,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
ia as isTeamSpace,
|
|
53
|
+
ca as isTeamSubscriptionRequired,
|
|
54
|
+
la as isUnlimited,
|
|
53
55
|
i as leaveForLogout,
|
|
54
56
|
c as noteLogoutElsewhere,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
Ba as notifySessionChanged,
|
|
58
|
+
ga as offerHighlights,
|
|
59
|
+
pa as personalNavKey,
|
|
60
|
+
F as planBenefitLines,
|
|
61
|
+
R as planCopy,
|
|
62
|
+
Sa as planDaysLeft,
|
|
63
|
+
Aa as planFocusOf,
|
|
64
|
+
Pa as planFocusState,
|
|
65
|
+
La as planPeriodText,
|
|
66
|
+
Ca as planTitle,
|
|
67
|
+
_ as plansUrl,
|
|
68
|
+
x as priceFor,
|
|
69
|
+
da as productAccountSections,
|
|
70
|
+
ha as quotaCopy,
|
|
71
|
+
fa as quotaFull,
|
|
72
|
+
ma as quotaText,
|
|
71
73
|
l as releaseLogoutHold,
|
|
72
74
|
g as resetLogoutSignalForTest,
|
|
73
75
|
p as restoreIdentityContext,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
Ta as spaceDisplayName,
|
|
77
|
+
ya as spaceRoleLabel,
|
|
78
|
+
Na as startingPrice,
|
|
79
|
+
Ia as subscribeSessionChanged,
|
|
80
|
+
Oa as upgradeOffer,
|
|
81
|
+
ba as useAccountCenter,
|
|
82
|
+
S as useAuthState,
|
|
83
|
+
A as useAuthStore,
|
|
84
|
+
Ea as useLogout,
|
|
85
|
+
Ua as useMembership,
|
|
86
|
+
va as usePlanCatalog,
|
|
87
|
+
B as useShowOnce,
|
|
88
|
+
wa as useSpaceSwitch,
|
|
89
|
+
Fa as useTrack,
|
|
87
90
|
P as withdrawLogout,
|
|
88
91
|
I as yearlyNote
|
|
89
92
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
/**
|
|
2
|
+
/** 受保护路由:会话未恢复时整屏加载;服务不可用时提示重新加载;没有 user 会话时带回跳地址去登录页。 */
|
|
3
3
|
export declare const RouteGuard: ({ children }: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
}) => import("react").JSX.Element;
|
|
@@ -6,9 +6,11 @@ export type UpgradeArt = 'engine' | 'crown';
|
|
|
6
6
|
* 再从权益卡去统一账号中心付款,不直接跳账号中心。团队空间的非所有者看不到按钮,只说明请所有者升级。
|
|
7
7
|
* 用在用户点了当前套餐不含的功能时。
|
|
8
8
|
*/
|
|
9
|
-
export declare const UpgradeModal: ({ title, description, art, onClose, }: {
|
|
9
|
+
export declare const UpgradeModal: ({ title, description, art, trigger, onClose, }: {
|
|
10
10
|
title: string;
|
|
11
11
|
description: string;
|
|
12
12
|
art?: UpgradeArt;
|
|
13
|
+
/** 为什么弹:触发它的功能键或场景(如 `adflow.video_generate`),记在行为事件的 target 上;不传时用插画名。 */
|
|
14
|
+
trigger?: string;
|
|
13
15
|
onClose: () => void;
|
|
14
16
|
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BehaviorEventInput, BehaviorPropValue } from './account-api';
|
|
2
|
+
export interface TrackOptions {
|
|
3
|
+
/** 低基数的作用对象:页面路由模板、套餐编码、弹窗名等;不放用户输入和真实 ID。 */
|
|
4
|
+
target?: string;
|
|
5
|
+
/** 最多 20 个短字符串、数字或布尔;不放手机号、邮箱、Token、输入内容。 */
|
|
6
|
+
props?: Record<string, BehaviorPropValue>;
|
|
7
|
+
}
|
|
8
|
+
/** `track('works.exported', { target: '/works/:id', props: { format: 'mp4' } })`;事件名为「对象.过去式动作」。 */
|
|
9
|
+
export type Track = (name: string, options?: TrackOptions) => void;
|
|
10
|
+
interface Tracker {
|
|
11
|
+
track: Track;
|
|
12
|
+
flush: () => Promise<void>;
|
|
13
|
+
/** 登录状态:未知时事件先排队不发;确认已登录后照常发送,确认未登录则丢掉队列。 */
|
|
14
|
+
setSignedIn: (signedIn: boolean | undefined) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 一个账号接口一份队列:2 秒或满 20 条发一次;产品后端没有转发接口(404)时本次会话不再上报。
|
|
18
|
+
* 不传 signedIn 时视为已登录(直接用队列的场景);useTrack 按会话恢复的结果设置。
|
|
19
|
+
*/
|
|
20
|
+
export declare const createBehaviorTracker: (report: (events: BehaviorEventInput[]) => Promise<void>, signedIn?: boolean | undefined) => Tracker;
|
|
21
|
+
/**
|
|
22
|
+
* 记录当前用户的行为。只在已登录时上报;自己实现 AccountApi 且没有 `reportBehaviorEvents` 的产品什么也不发。
|
|
23
|
+
* 关键动作(导出成功、生成完成)以服务端为准,用 account-client 的 `Account.Track` 在业务成功后记;
|
|
24
|
+
* 这里记页面和点击这类只有前端知道的事。
|
|
25
|
+
*/
|
|
26
|
+
export declare const useTrack: () => Track;
|
|
27
|
+
/**
|
|
28
|
+
* 页面的路由模板:像 ID 的路径段(数字、UUID、长十六进制、16 位以上含数字的串)和含其他字符的段(中文、编码后的关键词)
|
|
29
|
+
* 都换成 `:id`,去掉末尾斜杠。
|
|
30
|
+
*/
|
|
31
|
+
export declare const behaviorRouteTemplate: (pathname: string) => string;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as U, Fragment as L } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as T } from "react";
|
|
3
|
+
import { useQueryClient as I } from "@tanstack/react-query";
|
|
4
|
+
import { b as R } from "./context-CaVim6ZO.js";
|
|
5
|
+
import { g as A, n as y, i as c, v as k, f as S, r as x, y as P, t as h } from "./logout-signal-qvHorCCF.js";
|
|
6
|
+
import { subscribeCustomerSessionChanges as _ } from "@24city/web-runtime/session-sync";
|
|
7
|
+
const z = (e) => !h(e, 401) && !h(e, 403) && !h(e, 404), F = (e, i) => (e == null ? void 0 : e.purpose) === i.purpose && e.globalUserId === i.globalUserId && e.activeSpaceId === i.activeSpaceId, H = [1e3, 2e3, 4e3], Q = 15e3, B = (e) => new Promise((i) => setTimeout(i, e)), D = ({ children: e }) => {
|
|
8
|
+
const i = I(), o = A(), { accountApi: f, config: r, http: d } = R();
|
|
9
|
+
return T(() => {
|
|
10
|
+
let a = !0, n = 0, u;
|
|
11
|
+
const p = () => {
|
|
12
|
+
clearTimeout(u), u = void 0;
|
|
13
|
+
}, w = async () => {
|
|
14
|
+
await i.cancelQueries().catch(() => {
|
|
15
|
+
}), i.clear();
|
|
16
|
+
}, m = async (t) => {
|
|
17
|
+
try {
|
|
18
|
+
const s = await S(f);
|
|
19
|
+
return a && n === t && (x(), o.setContext(s)), !0;
|
|
20
|
+
} catch (s) {
|
|
21
|
+
return !a || n !== t ? !0 : P(s) ? !1 : (o.clear({ unavailable: z(s) }), !0);
|
|
22
|
+
}
|
|
23
|
+
}, v = (t) => {
|
|
24
|
+
u = setTimeout(async () => {
|
|
25
|
+
u = void 0, !(!a || n !== t || c()) && (await m(t) || v(t));
|
|
26
|
+
}, Q);
|
|
27
|
+
}, l = async () => {
|
|
28
|
+
if (c()) return;
|
|
29
|
+
p();
|
|
30
|
+
const t = ++n;
|
|
31
|
+
o.setBootstrapping(), await w();
|
|
32
|
+
for (const s of H)
|
|
33
|
+
if (await m(t) || (await B(s), !a || n !== t || c())) return;
|
|
34
|
+
await m(t) || (o.clear({ unavailable: !0 }), v(t));
|
|
35
|
+
}, b = async () => {
|
|
36
|
+
if (c() || (n += 1, p(), await w(), o.clear(), y())) return;
|
|
37
|
+
const t = window.location.pathname + window.location.search;
|
|
38
|
+
k(window.location.pathname, r.routes.app) && window.location.assign(`${r.routes.login}?returnPath=${encodeURIComponent(t)}`);
|
|
39
|
+
};
|
|
40
|
+
d.configure({
|
|
41
|
+
baseUrl: r.api.baseUrl,
|
|
42
|
+
getCsrfToken: o.getCsrfToken,
|
|
43
|
+
onUnauthorized: b
|
|
44
|
+
});
|
|
45
|
+
const C = async () => {
|
|
46
|
+
if (c()) return;
|
|
47
|
+
if (!o.getState().session) return l();
|
|
48
|
+
const t = ++n;
|
|
49
|
+
try {
|
|
50
|
+
const s = await S(f);
|
|
51
|
+
if (!a || n !== t) return;
|
|
52
|
+
if (F(o.getState().session, s.session)) {
|
|
53
|
+
o.setContext(s);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
if (!a || n !== t) return;
|
|
58
|
+
}
|
|
59
|
+
await l();
|
|
60
|
+
}, E = _(() => {
|
|
61
|
+
y(), l();
|
|
62
|
+
}), g = () => {
|
|
63
|
+
document.visibilityState !== "hidden" && C();
|
|
64
|
+
};
|
|
65
|
+
return window.addEventListener("focus", g), l(), () => {
|
|
66
|
+
a = !1, n += 1, p(), E(), window.removeEventListener("focus", g), d.configure({ getCsrfToken: null, onUnauthorized: null });
|
|
67
|
+
};
|
|
68
|
+
}, [f, o, r.api.baseUrl, r.routes.app, r.routes.login, d, i]), /* @__PURE__ */ U(L, { children: e });
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
D as A
|
|
72
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { jsx as t, jsxs as c, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as z, useState as b } from "react";
|
|
3
|
+
import { Layout as v, Button as f, Typography as q, Space as D, Nav as $ } from "@douyinfe/semi-ui";
|
|
4
|
+
import { IconSidebar as P } from "@douyinfe/semi-icons";
|
|
5
|
+
import { useLocation as F, useNavigate as Q, Outlet as Y } from "react-router";
|
|
6
|
+
import { T as J, h as V, i as X, D as Z, q as ee, e as te, W as ne, b as ae } from "./wallet-badge-DnWl21es.js";
|
|
7
|
+
import { u as R, b as oe, a as se } from "./context-CaVim6ZO.js";
|
|
8
|
+
import { u as le } from "./use-media-query-DvyinWNg.js";
|
|
9
|
+
import { a as re } from "./scale-smFifpMm.js";
|
|
10
|
+
const ce = "_layout_1vz0g_6", ie = "_header_1vz0g_13", de = "_headerLeft_1vz0g_34", ue = "_logo_1vz0g_43", me = "_logoMark_1vz0g_58", pe = "_logoText_1vz0g_65", _e = "_modules_1vz0g_75", he = "_module_1vz0g_75", ge = "_moduleText_1vz0g_123", ve = "_moduleIcon_1vz0g_143", fe = "_moduleInk_1vz0g_147", ke = "_headerRight_1vz0g_167", ye = "_walletSlot_1vz0g_172", Ne = "_body_1vz0g_180", ze = "_sider_1vz0g_186", be = "_siderInner_1vz0g_200", Ie = "_panel_1vz0g_207", we = "_expandButton_1vz0g_244", xe = "_menu_1vz0g_260", Ce = "_menuGroup_1vz0g_271", Me = "_menuGroupPlain_1vz0g_280", Te = "_menuGroupTitle_1vz0g_285", Be = "_menuList_1vz0g_296", Le = "_collapseButton_1vz0g_419", Ge = "_mask_1vz0g_440", Se = "_content_1vz0g_449", $e = "_contentCentered_1vz0g_455", Pe = "_contentInner_1vz0g_467", Re = "_letterMark_1vz0g_520", e = {
|
|
11
|
+
layout: ce,
|
|
12
|
+
header: ie,
|
|
13
|
+
headerLeft: de,
|
|
14
|
+
logo: ue,
|
|
15
|
+
logoMark: me,
|
|
16
|
+
logoText: pe,
|
|
17
|
+
modules: _e,
|
|
18
|
+
module: he,
|
|
19
|
+
moduleText: ge,
|
|
20
|
+
moduleIcon: ve,
|
|
21
|
+
moduleInk: fe,
|
|
22
|
+
headerRight: ke,
|
|
23
|
+
walletSlot: ye,
|
|
24
|
+
body: Ne,
|
|
25
|
+
sider: ze,
|
|
26
|
+
siderInner: be,
|
|
27
|
+
panel: Ie,
|
|
28
|
+
expandButton: we,
|
|
29
|
+
menu: xe,
|
|
30
|
+
menuGroup: Ce,
|
|
31
|
+
menuGroupPlain: Me,
|
|
32
|
+
menuGroupTitle: Te,
|
|
33
|
+
menuList: Be,
|
|
34
|
+
collapseButton: Le,
|
|
35
|
+
mask: Ge,
|
|
36
|
+
content: Se,
|
|
37
|
+
contentCentered: $e,
|
|
38
|
+
contentInner: Pe,
|
|
39
|
+
letterMark: Re
|
|
40
|
+
}, Ue = (a, l) => a === l || a.startsWith(`${l}/`), Ae = (a, l) => a.flatMap((o) => o.items).find((o) => new URL(o.to, "http://console.local").pathname === l), Ee = (a, l) => {
|
|
41
|
+
var o;
|
|
42
|
+
return (o = [...a].map((r) => ({ module: r, path: new URL(r.to, "http://console.local").pathname })).filter(({ path: r }) => Ue(l, r)).sort((r, u) => u.path.length - r.path.length)[0]) == null ? void 0 : o.module;
|
|
43
|
+
}, Ke = () => {
|
|
44
|
+
const [a, l] = b(!1);
|
|
45
|
+
return z(() => {
|
|
46
|
+
const o = () => l(window.scrollY > 0);
|
|
47
|
+
return o(), window.addEventListener("scroll", o, { passive: !0 }), () => window.removeEventListener("scroll", o);
|
|
48
|
+
}, []), a;
|
|
49
|
+
}, We = ({ size: a = 30, className: l }) => {
|
|
50
|
+
const o = R(), r = (u) => l ? `${u} ${l}` : u;
|
|
51
|
+
return o.markUrl ? /* @__PURE__ */ t(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: r(e.logoMark),
|
|
55
|
+
style: { width: a, height: a, backgroundImage: `url("${o.markUrl}")` },
|
|
56
|
+
"aria-hidden": "true"
|
|
57
|
+
}
|
|
58
|
+
) : /* @__PURE__ */ t("span", { className: r(e.letterMark), style: { width: a, height: a }, "aria-hidden": "true", children: Array.from(o.mark).slice(0, 2).join("") });
|
|
59
|
+
}, Ve = ({
|
|
60
|
+
modules: a = [],
|
|
61
|
+
activeModuleKey: l,
|
|
62
|
+
moduleTarget: o,
|
|
63
|
+
sidebar: r = [],
|
|
64
|
+
selectedKey: u,
|
|
65
|
+
renderItemLabel: I,
|
|
66
|
+
headerRight: U,
|
|
67
|
+
menuLabel: A = "工作台菜单",
|
|
68
|
+
children: E,
|
|
69
|
+
extra: K
|
|
70
|
+
}) => {
|
|
71
|
+
var S;
|
|
72
|
+
const { config: w } = oe(), x = R(), p = F(), C = J();
|
|
73
|
+
z(() => {
|
|
74
|
+
C("page.viewed", { target: V(p.pathname) });
|
|
75
|
+
}, [p.pathname, C]);
|
|
76
|
+
const k = Q(), M = w.routes.app, h = X(M, Z(se())), T = ee(M, p.pathname), g = T ? [] : r ?? [], B = g.length > 0, W = l ?? ((S = Ee(a, p.pathname)) == null ? void 0 : S.key), m = Ae([...g, h], p.pathname), L = u ?? (m == null ? void 0 : m.key), i = le(re("desktop")), j = Ke(), [_, y] = b(!i), [N, d] = b(!1), H = new Map([...g, h].flatMap((n) => n.items.map((s) => [s.key, s])));
|
|
77
|
+
z(() => {
|
|
78
|
+
y(!i), d(!1);
|
|
79
|
+
}, [i]);
|
|
80
|
+
const G = (n) => {
|
|
81
|
+
const s = H.get(n);
|
|
82
|
+
s && k(s.to), d(!1);
|
|
83
|
+
};
|
|
84
|
+
return /* @__PURE__ */ c(v, { className: e.layout, children: [
|
|
85
|
+
/* @__PURE__ */ c(v.Header, { className: e.header, "data-scrolled": j ? "true" : "false", children: [
|
|
86
|
+
/* @__PURE__ */ c("div", { className: e.headerLeft, children: [
|
|
87
|
+
/* @__PURE__ */ c(
|
|
88
|
+
f,
|
|
89
|
+
{
|
|
90
|
+
theme: "borderless",
|
|
91
|
+
type: "tertiary",
|
|
92
|
+
className: e.logo,
|
|
93
|
+
"aria-label": `${x.shortName} 首页`,
|
|
94
|
+
onClick: () => k(w.routes.publicHome),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ t(We, {}),
|
|
97
|
+
/* @__PURE__ */ t(q.Text, { className: e.logoText, children: x.shortName })
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
a.length ? /* @__PURE__ */ t("div", { className: e.modules, role: "navigation", "aria-label": "产品模块", children: a.map((n) => /* @__PURE__ */ c(
|
|
102
|
+
f,
|
|
103
|
+
{
|
|
104
|
+
theme: "borderless",
|
|
105
|
+
type: "tertiary",
|
|
106
|
+
className: e.module,
|
|
107
|
+
"aria-current": W === n.key ? "page" : void 0,
|
|
108
|
+
onClick: () => k(o ? o(n) : n.to),
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ c("span", { className: e.moduleText, children: [
|
|
111
|
+
n.icon ? /* @__PURE__ */ t("span", { className: e.moduleIcon, children: /* @__PURE__ */ t(n.icon, {}) }) : null,
|
|
112
|
+
n.label
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ t("span", { className: e.moduleInk, "aria-hidden": "true" })
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
n.key
|
|
118
|
+
)) }) : null
|
|
119
|
+
] }),
|
|
120
|
+
/* @__PURE__ */ t(D, { spacing: 10, className: e.headerRight, children: U ?? /* @__PURE__ */ c(O, { children: [
|
|
121
|
+
/* @__PURE__ */ t(te, {}),
|
|
122
|
+
/* @__PURE__ */ t("span", { className: e.walletSlot, children: /* @__PURE__ */ t(ne, {}) }),
|
|
123
|
+
/* @__PURE__ */ t(ae, { personal: h, selectedKey: m && h.items.includes(m) ? m.key : void 0, onOpen: G })
|
|
124
|
+
] }) })
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ c(v, { className: e.body, children: [
|
|
127
|
+
B ? /* @__PURE__ */ t("aside", { className: e.sider, "data-collapsed": _ ? "true" : "false", children: /* @__PURE__ */ c(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
className: e.siderInner,
|
|
131
|
+
"data-collapsed": _ ? "true" : "false",
|
|
132
|
+
"data-peek": N ? "true" : "false",
|
|
133
|
+
onMouseEnter: () => {
|
|
134
|
+
_ && i && d(!0);
|
|
135
|
+
},
|
|
136
|
+
onMouseLeave: () => {
|
|
137
|
+
i && d(!1);
|
|
138
|
+
},
|
|
139
|
+
children: [
|
|
140
|
+
_ ? /* @__PURE__ */ t(
|
|
141
|
+
f,
|
|
142
|
+
{
|
|
143
|
+
theme: "light",
|
|
144
|
+
type: "tertiary",
|
|
145
|
+
className: e.expandButton,
|
|
146
|
+
icon: /* @__PURE__ */ t(P, { "aria-hidden": "true" }),
|
|
147
|
+
"aria-label": "展开侧边栏",
|
|
148
|
+
"aria-expanded": N,
|
|
149
|
+
onClick: () => {
|
|
150
|
+
i ? (y(!1), d(!1)) : d((n) => !n);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
) : null,
|
|
154
|
+
/* @__PURE__ */ c("div", { className: e.panel, children: [
|
|
155
|
+
/* @__PURE__ */ t("nav", { className: e.menu, "aria-label": A, children: g.map((n) => /* @__PURE__ */ c(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: n.label ? e.menuGroup : `${e.menuGroup} ${e.menuGroupPlain}`,
|
|
159
|
+
role: "group",
|
|
160
|
+
"aria-label": n.label || void 0,
|
|
161
|
+
children: [
|
|
162
|
+
n.label ? /* @__PURE__ */ t("div", { className: e.menuGroupTitle, children: n.label }) : null,
|
|
163
|
+
/* @__PURE__ */ t(
|
|
164
|
+
$,
|
|
165
|
+
{
|
|
166
|
+
mode: "vertical",
|
|
167
|
+
className: e.menuList,
|
|
168
|
+
selectedKeys: L ? [L] : [],
|
|
169
|
+
onSelect: ({ itemKey: s }) => G(String(s)),
|
|
170
|
+
children: n.items.map((s) => /* @__PURE__ */ t(
|
|
171
|
+
$.Item,
|
|
172
|
+
{
|
|
173
|
+
itemKey: s.key,
|
|
174
|
+
icon: s.icon ? /* @__PURE__ */ t(s.icon, {}) : void 0,
|
|
175
|
+
text: I ? I(s) : s.label
|
|
176
|
+
},
|
|
177
|
+
s.key
|
|
178
|
+
))
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
n.key
|
|
184
|
+
)) }),
|
|
185
|
+
i ? /* @__PURE__ */ t(
|
|
186
|
+
f,
|
|
187
|
+
{
|
|
188
|
+
theme: "borderless",
|
|
189
|
+
type: "tertiary",
|
|
190
|
+
className: e.collapseButton,
|
|
191
|
+
icon: /* @__PURE__ */ t(P, { "aria-hidden": "true" }),
|
|
192
|
+
onClick: () => {
|
|
193
|
+
y((n) => !n), d(!1);
|
|
194
|
+
},
|
|
195
|
+
children: _ ? "固定侧边栏" : "收起侧边栏"
|
|
196
|
+
}
|
|
197
|
+
) : null
|
|
198
|
+
] })
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
) }) : null,
|
|
202
|
+
N && !i && B ? /* @__PURE__ */ t("div", { className: e.mask, "aria-hidden": "true", onClick: () => d(!1) }) : null,
|
|
203
|
+
/* @__PURE__ */ t(v.Content, { className: T ? `${e.content} ${e.contentCentered}` : e.content, children: /* @__PURE__ */ t("div", { className: e.contentInner, children: E ?? /* @__PURE__ */ t(Y, {}) }) })
|
|
204
|
+
] }),
|
|
205
|
+
K
|
|
206
|
+
] });
|
|
207
|
+
};
|
|
208
|
+
export {
|
|
209
|
+
We as B,
|
|
210
|
+
Ve as C,
|
|
211
|
+
Ae as a,
|
|
212
|
+
Ee as f,
|
|
213
|
+
Ue as i
|
|
214
|
+
};
|