@24city/web-console 0.0.0-stage → 0.1.1

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 (100) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +168 -2
  4. package/dist/account/account-api.d.ts +24 -0
  5. package/dist/account/account-center-links.d.ts +35 -0
  6. package/dist/account/account-center-page.d.ts +7 -0
  7. package/dist/account/account-center-ui.d.ts +19 -0
  8. package/dist/account/account-menu.d.ts +23 -0
  9. package/dist/account/auth-provider.d.ts +6 -0
  10. package/dist/account/auth-store.d.ts +25 -0
  11. package/dist/account/benefit-copy.d.ts +15 -0
  12. package/dist/account/customization.d.ts +62 -0
  13. package/dist/account/index.d.ts +34 -0
  14. package/dist/account/index.js +87 -0
  15. package/dist/account/login-page.d.ts +6 -0
  16. package/dist/account/logout-signal.d.ts +13 -0
  17. package/dist/account/personal-nav.d.ts +29 -0
  18. package/dist/account/plan-benefits.d.ts +16 -0
  19. package/dist/account/plan-cards.d.ts +10 -0
  20. package/dist/account/plan-display.d.ts +44 -0
  21. package/dist/account/plan-panel.d.ts +16 -0
  22. package/dist/account/points-section.d.ts +8 -0
  23. package/dist/account/profile-section.d.ts +9 -0
  24. package/dist/account/quota-pill.d.ts +10 -0
  25. package/dist/account/quota.d.ts +12 -0
  26. package/dist/account/route-guard.d.ts +5 -0
  27. package/dist/account/session-sync.d.ts +1 -0
  28. package/dist/account/space-label.d.ts +10 -0
  29. package/dist/account/subscription-section.d.ts +11 -0
  30. package/dist/account/team-promo.d.ts +9 -0
  31. package/dist/account/types.d.ts +120 -0
  32. package/dist/account/upgrade-entry.d.ts +6 -0
  33. package/dist/account/upgrade-modal.d.ts +14 -0
  34. package/dist/account/use-account-center.d.ts +27 -0
  35. package/dist/account/use-logout.d.ts +13 -0
  36. package/dist/account/use-membership.d.ts +48 -0
  37. package/dist/account/use-plan-catalog.d.ts +2 -0
  38. package/dist/account/use-space-switch.d.ts +8 -0
  39. package/dist/account/wallet-badge.d.ts +2 -0
  40. package/dist/assets/coin-BhUDKCPy.webp +0 -0
  41. package/dist/assets/crown-D5kKk5rW.webp +0 -0
  42. package/dist/assets/diamond-BuDSsnw-.webp +0 -0
  43. package/dist/assets/engine-hero-BaSSoV-3.webp +0 -0
  44. package/dist/assets/member-gem-DTY0gTzl.webp +0 -0
  45. package/dist/assets/team-BeZ_oZcL.webp +0 -0
  46. package/dist/assets/upgrade-crown-Ci1IFoXi.webp +0 -0
  47. package/dist/chunks/auth-provider-CqiyTeOt.js +62 -0
  48. package/dist/chunks/console-layout-BibioK5M.js +198 -0
  49. package/dist/chunks/context-CaVim6ZO.js +13 -0
  50. package/dist/chunks/error-boundary-D3qiD7ov.js +35 -0
  51. package/dist/chunks/http-B3mTs9KZ.js +8 -0
  52. package/dist/chunks/link-button-giJEcTmG.js +42 -0
  53. package/dist/chunks/logout-signal-CiD_zY5M.js +365 -0
  54. package/dist/chunks/page-BaitnD--.js +89 -0
  55. package/dist/chunks/stale-build-DUKkQHuu.js +57 -0
  56. package/dist/chunks/text-link-FTsBp_QU.js +54 -0
  57. package/dist/chunks/upgrade-modal-DzdKuEkJ.js +667 -0
  58. package/dist/chunks/use-media-query-DvyinWNg.js +12 -0
  59. package/dist/chunks/wallet-badge-CnyMLpUO.js +565 -0
  60. package/dist/index.d.ts +6 -0
  61. package/dist/index.js +159 -0
  62. package/dist/layout/console-layout.d.ts +35 -0
  63. package/dist/layout/console-nav.d.ts +30 -0
  64. package/dist/layout/index.d.ts +2 -0
  65. package/dist/layout/index.js +8 -0
  66. package/dist/page/error-boundary.d.ts +20 -0
  67. package/dist/page/index.d.ts +7 -0
  68. package/dist/page/index.js +21 -0
  69. package/dist/page/link-button.d.ts +29 -0
  70. package/dist/page/not-found-page.d.ts +1 -0
  71. package/dist/page/page.d.ts +34 -0
  72. package/dist/page/startup-error.d.ts +2 -0
  73. package/dist/page/status-result.d.ts +17 -0
  74. package/dist/page/text-link.d.ts +22 -0
  75. package/dist/runtime/context.d.ts +19 -0
  76. package/dist/runtime/error-summary.d.ts +5 -0
  77. package/dist/runtime/format.d.ts +10 -0
  78. package/dist/runtime/http.d.ts +11 -0
  79. package/dist/runtime/index.d.ts +11 -0
  80. package/dist/runtime/index.js +41 -0
  81. package/dist/runtime/internal-path.d.ts +4 -0
  82. package/dist/runtime/providers.d.ts +16 -0
  83. package/dist/runtime/query-keys.d.ts +6 -0
  84. package/dist/runtime/response.d.ts +6 -0
  85. package/dist/runtime/runtime-config.d.ts +19 -0
  86. package/dist/runtime/stale-build.d.ts +11 -0
  87. package/dist/runtime/use-media-query.d.ts +2 -0
  88. package/dist/semi.d.ts +10 -0
  89. package/dist/semi.js +12 -0
  90. package/dist/styles.css +3224 -0
  91. package/dist/testing/fixtures.d.ts +15 -0
  92. package/dist/testing/fixtures.js +142 -0
  93. package/dist/testing/guard.d.ts +32 -0
  94. package/dist/testing/guard.js +61 -0
  95. package/dist/testing/jsdom.d.ts +2 -0
  96. package/dist/testing/jsdom.js +116 -0
  97. package/dist/theme/index.d.ts +24 -0
  98. package/dist/theme/index.js +51 -0
  99. package/dist/theme/palette.d.ts +6 -0
  100. package/package.json +98 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ - 修正 Semi 覆盖样式在打包后失效的问题(AdFlow Staging 上发现:整站回到 Semi 默认的蓝灰中性色、3px 圆角、32px 页面标题)。
6
+ Semi 把设计变量定义在 `body` 上,而消费方打包后 `@douyinfe/semi-ui` 的 `_base/base.css` 排在本包样式之后,同级选择器谁后谁赢;
7
+ 变量块改写在 `html body` 上,页面标题、侧栏菜单项、标签页字重等与 Semi 同级的规则各加一级,不再依赖样式表先后。
8
+ - 圆角:Semi 的 large 从 12px 改为 8px(卡片、弹窗与 Arco 时代一致);正文行高 1.5。
9
+ - 图标默认跟随文字字号(Semi 默认固定 16px,Arco 是 1em),元信息行里的小图标不再比字大。
10
+ - 侧栏菜单项 40px、图标 18px(Semi 给 Nav 图标加了 size="large");个人中心左侧菜单与账号菜单的图标、文字、箭头恢复 10px 间距
11
+ (Semi 把按钮子元素包进 `.semi-button-content`,间距要写在它上面)。
12
+
13
+ ## 0.1.0
14
+
15
+ - 由 AdFlow 用户端(`saas/24city-adflow` `apps/web`,2026-11-09)的工作台外壳、账号菜单、个人中心、会员引导、页面骨架和
16
+ 主题沉淀而来,来源记录见 `SOURCE_IMPORT.json`。
17
+ - 组件库由 AdFlow 原来的 Arco Design 改为 Semi Design(`@douyinfe/semi-ui` 2.104.0,ADR-0047):Semi 默认视觉更精致、每月更新、
18
+ 自带 Chat、Markdown 渲染、音视频播放器、裁图等 AI 产品要用的组件;主题覆盖改写为对 Semi 组件的细调。
19
+ 页面骨架的结果区块改为 `StatusResult`(Semi 插画),链接样按钮用 `LinkButton`(Semi 没有带 href 的按钮),文字链接用 `TextLink`。
20
+ - 外壳改为通用 `ConsoleLayout`:顶栏模块、侧栏分组、菜单项文字渲染和顶栏右侧都由产品传入;个人中心页面自动不显示侧栏。
21
+ - 品牌主色从主题文件里拿出来:产品在 runtime-config 的 `brand.primaryColor` 给一个色值,`applyBrand` 生成十级主色
22
+ (`--app-brand-1..10`,与 AdFlow 原主题相同的算法)并映射到 Semi 的主色、链接色和聚焦描边;中性灰、状态色、圆角、阴影由
23
+ `styles.css` 定死。Semi 组件的样式随组件引入,由产品的构建收集。
24
+ - 产品相关文案改为读 runtime-config 的品牌名;权益卡文案、功能键白话、团队版要点和积分明细组件改由 `customization` 传入。
25
+ - 退出登录的跨标签页信号改用固定的存储键。
26
+ - 新增 `/testing/guard`(界面守卫,比 AdFlow 原来的测试多了主题变量、整包 CSS、旧组件库和 Semi 版本检查)、`/testing/jsdom`
27
+ (测试环境的浏览器 API 垫片:matchMedia、ResizeObserver、canvas、Range、createObjectURL、animationend)和 `/testing/fixtures`。
28
+ - `/semi` 清掉 Semi 弹窗默认脚部按钮的英文 aria-label,并提供 `modalButtonProps` 合并产品自己的按钮属性。
29
+ - 个人中心可由产品追加分区(`customization.accountSections`):排在内置三项之后,账号菜单、左侧菜单和内容区一起识别;内置三项不可删改。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jike
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,169 @@
1
- # Temporary Holding Version
1
+ # @24city/web-console
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 24.city 产品用户 Web 的控制台底座:Semi Design 主题与品牌主色、工作台外壳(顶栏模块、侧栏、账号菜单)、统一账号接入
4
+ (会话、登录中转、退出、空间切换)、会员引导(开通入口、升级弹窗、权益卡)、个人中心三页,以及守卫测试和替身。
5
+ 界面从 AdFlow 用户端沉淀而来(`SOURCE_IMPORT.json`),由真实产品先消费。
6
+
7
+ > **孵化中。** 本包尚未进入 Standard Catalog。成熟标准和接入流程见 [`js/README.md`](../README.md)。
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ pnpm add @24city/web-console @24city/web-runtime @douyinfe/semi-ui@2.104.0 @douyinfe/semi-icons@2.104.0 @douyinfe/semi-illustrations@2.104.0
13
+ ```
14
+
15
+ Semi 的三个包必须精确声明为本包 `peerDependencies` 里的版本:本包的主题和守卫按这个版本写,组件与样式由产品安装,两边要同一个版本。
16
+ 还需要 React 18 或 19、React Router 7 或 8、TanStack Query 5。
17
+
18
+ ## 样式与品牌
19
+
20
+ 入口样式只有一行:Semi 各组件的样式随组件引入,由产品的构建收集;本文件是主题与本包组件的样式,产品不再引入 Semi 的整包 CSS:
21
+
22
+ ```css
23
+ @import "@24city/web-console/styles.css";
24
+ ```
25
+
26
+ 颜色分五层,只有品牌主色是产品的:
27
+
28
+ | 层 | 变量 | 谁定 |
29
+ | --- | --- | --- |
30
+ | 品牌 | `--app-brand-1..10`,Semi 的 `--semi-color-primary*`、`--semi-color-link*`、`--semi-color-focus-border` 跟随主色 | 产品在 runtime-config 给一个色值,本包生成十级 |
31
+ | 中性 | `--semi-grey-0..9` 及 Semi 由它推出的文字、填充、边框、背景 | 本包 |
32
+ | 状态 | Semi 的 red、green、orange、amber 色板与 success、warning、danger、info | Semi 原值,本包不改,产品不得改 |
33
+ | 形态 | 圆角、阴影、页面渐变、动效、顶栏高、内容宽(`--app-*`) | 本包 |
34
+ | 组件 | 对 Semi 组件的统一调整,`ConsoleSemiProvider` 的中文文案 | 本包 |
35
+
36
+ 产品只在 `public/runtime-config.json` 的 `brand` 里给三样东西,一行 CSS 都不用写:
37
+
38
+ ```json
39
+ "brand": {
40
+ "name": "示例产品",
41
+ "shortName": "示例",
42
+ "mark": "示",
43
+ "markUrl": "/brand/mark.svg",
44
+ "primaryColor": "#E04E06"
45
+ }
46
+ ```
47
+
48
+ `applyBrand({ primaryColor })` 在首屏渲染前由色值算出十级主色写到 `body` 上(与 AdFlow 原主题相同的色板算法,第 6 级是传入的颜色),
49
+ 并把 Semi 的主色、链接色和聚焦描边映射到这组颜色,没有闪动;不传时保持 Semi 默认主色。`markUrl` 是产品图标 SVG,没有时用 `mark` 字标。
50
+
51
+ 品牌色与状态色撞色不在守卫范围内:产品自己注意品牌和强调只用主色,状态标签才用状态色。
52
+
53
+ ## 入口
54
+
55
+ | 入口 | 内容 |
56
+ | --- | --- |
57
+ | `@24city/web-console` | 下面全部入口的合集 |
58
+ | `/semi` | `ConsoleSemiProvider`(中文文案,含 React 19 适配)、`modalButtonProps`(弹窗按钮属性,去掉 Semi 默认的英文 aria-label) |
59
+ | `/theme` | `applyBrand`、`brandPalette`、`BRAND_VARIABLES`、`SEMI_BRAND_VARIABLES` |
60
+ | `/runtime` | `ConsoleApp`、`ConsoleRuntimeProvider`、`useConsoleRuntime`、`createHttpRuntime`、`loadRuntimeConfig`、`earlyRuntimeConfigFetcher`、`productQueryKeys`、格式化函数、`reloadOnStaleBuild` |
61
+ | `/account` | `createAccountApi`、`AuthProvider`、`RouteGuard`、`LoginPage`、`useAuthState`、`useLogout`、`useSpaceSwitch`、`useMembership`、`AccountMenu`、`WalletBadge`、`UpgradeEntry`、`UpgradeModal`、`QuotaPill`、`AccountCenterPage`、`plansUrl`、`ConsoleCustomization` |
62
+ | `/layout` | `ConsoleLayout`、`BrandMark`、导航类型 |
63
+ | `/page` | `ProductPage`、`FullPage`、`LoadingCard`、`ErrorCard`、`EmptyCard`、`StatusResult`、`LinkButton`、`TextLink`、`SessionUnavailable`、`ErrorBoundary`、`RouteErrorPage`、`StartupError`、`NotFoundPage` |
64
+ | `/testing/guard` | `checkUiLibraryUsage`、`checkSemiVersion`(Node,用于 vitest) |
65
+ | `/testing/jsdom` | jsdom 测试环境的浏览器 API 垫片(matchMedia、ResizeObserver、canvas、Range),在 setup 里排在引入 Semi 之前 |
66
+ | `/testing/fixtures` | `createFixtureRuntime`、`createFixtureAccountApi` 等替身(UI-only 模式与测试) |
67
+ | `/styles.css` | 主题 + 本包组件样式(Semi 组件样式随组件引入) |
68
+
69
+ ## 装配
70
+
71
+ ```tsx
72
+ import { ConsoleSemiProvider } from '@24city/web-console/semi'
73
+ import { createAccountApi } from '@24city/web-console/account'
74
+ import { ConsoleApp, createHttpRuntime, earlyRuntimeConfigFetcher, loadRuntimeConfig } from '@24city/web-console/runtime'
75
+ import { applyBrand } from '@24city/web-console/theme'
76
+
77
+ const config = await loadRuntimeConfig(earlyRuntimeConfigFetcher())
78
+ applyBrand({ primaryColor: config.brand.primaryColor })
79
+ const http = createHttpRuntime()
80
+ http.configure({ baseUrl: config.api.baseUrl })
81
+ const runtime = { config, http, accountApi: createAccountApi(http.client, config.api.baseUrl), customization }
82
+
83
+ root.render(
84
+ <ConsoleSemiProvider>
85
+ <ConsoleApp runtime={runtime}>
86
+ <RouterProvider router={createBrowserRouter(routes)} />
87
+ </ConsoleApp>
88
+ </ConsoleSemiProvider>
89
+ )
90
+ ```
91
+
92
+ 路由里:公开首页、`routes.login` 放 `LoginPage`,`routes.app` 放 `RouteGuard` 包着 `ConsoleLayout`,子路由含
93
+ `account/:section` 的 `AccountCenterPage`。`ConsoleLayout` 接产品的顶栏模块和侧栏分组;个人中心页面自动不显示侧栏。
94
+
95
+ `customization` 是产品对账号页面的定制(都可选):套餐目录里本产品功能键的白话(`benefitCopy`)、按套餐编码的权益卡文案
96
+ (`planCopy`、`teamPlanCopy`)、开通团队版引导的要点(`teamPromoHighlights`)、「积分与明细」里的扣费明细组件(`PointsDetail`),
97
+ 以及产品追加的个人中心分区(`accountSections`)。
98
+
99
+ ### 个人中心
100
+
101
+ 账号与安全、订阅与套餐、积分与明细三页随包提供,所有产品一致:内置三项不能删、不能改顺序、不能改名。产品要加自己的页面,
102
+ 在 `accountSections` 里追加分区:
103
+
104
+ ```tsx
105
+ const customization: ConsoleCustomization = {
106
+ accountSections: [
107
+ { key: 'usage', label: '用量统计', description: '本产品的用量与配额。', icon: IconBarChart, Component: UsageSection },
108
+ ],
109
+ }
110
+ ```
111
+
112
+ 分区排在内置三项之后,地址是 `<app>/account/usage`,账号菜单、个人中心左侧菜单和内容区一起识别,路由仍是 `account/:section`。
113
+ `Component` 收到与内置分区相同的 `data`(会话、当前空间、昵称、钱包、当前套餐),只在会话可用时渲染,界面同样受守卫约束。
114
+ `key` 只能是小写字母开头的小写字母、数字和连字符,不能与内置分区重名,否则在开发时直接抛错。
115
+
116
+ ### 退出登录
117
+
118
+ 退出同时结束产品会话和 24.city 统一登录,然后回产品首页;其他标签页收到信号后停在“已退出登录”,不自动重新登录。
119
+ 产品不必自己写退出逻辑,账号菜单和个人中心已带确认框。
120
+
121
+ ### 首屏并行请求
122
+
123
+ 入口代码要先拿到运行时配置才开始渲染。在 `index.html` 里提前发出这次请求,`earlyRuntimeConfigFetcher()` 会直接用它:
124
+
125
+ ```html
126
+ <script>
127
+ ;(function () {
128
+ try {
129
+ var config = fetch('/runtime-config.json', { credentials: 'same-origin', cache: 'no-store', headers: { Accept: 'application/json' } })
130
+ config.catch(function () {})
131
+ window.__24cityRuntimeConfig = config
132
+ } catch (error) {}
133
+ })()
134
+ </script>
135
+ ```
136
+
137
+ ## 守卫测试
138
+
139
+ 产品加一个测试文件,界面就只能来自 Semi 和本包:
140
+
141
+ ```ts
142
+ import { checkSemiVersion, checkUiLibraryUsage } from '@24city/web-console/testing/guard'
143
+
144
+ it('界面只使用 Semi Design 与 @24city/web-console', () => {
145
+ expect(checkUiLibraryUsage({ sourceRoot: resolve(process.cwd(), 'src') })).toEqual([])
146
+ expect(checkSemiVersion(resolve(process.cwd(), 'package.json'))).toEqual([])
147
+ })
148
+ ```
149
+
150
+ 规则:不手写原生控件、表格、列表、标题、段落和链接(链接样按钮用 `LinkButton`,文字链接用 `TextLink`);不引用旧视觉层、Tailwind、lucide、Arco 和工具类字符串;
151
+ 不写死色值;不引入 Semi 的整包 CSS、不自己切 `theme-mode`;不声明任何 `--semi-*` 和 `--app-*` 变量。
152
+ 产品自己的装饰变量只能引用主题变量,例如 `--demo-stage-bg: var(--semi-color-fill-1)`。
153
+
154
+ 测试环境(jsdom)在 setup 里先引入 `@24city/web-console/testing/jsdom`,再引入 `@24city/web-console/semi`;Semi 自带的
155
+ Lottie 在模块加载时会用到 canvas,没有垫片时整个包都引不进来。垫片还补了 Range 的几何方法、`URL.createObjectURL`,并在 Semi 的
156
+ 动画类名出现时补发 `animationend`(Semi 的弹窗、提示靠它卸载,jsdom 不跑动画)。
157
+
158
+ ### 用 Semi 时的几个坑
159
+
160
+ - Semi 把设计变量定义在 `body` 上,而打包后 `@douyinfe/semi-ui` 的 `_base/base.css` 往往排在本包样式之后:覆盖 Semi 的规则不能只靠同级选择器与引入顺序。
161
+ 本包的变量写在 `html body` 上,组件覆盖在 Semi 的选择器之上再加一级;产品自己的模块样式若要盖住 Semi 的某条规则,同样要比它多一个类。
162
+ - Semi 的 `Input` 把 `className` 放在 `.semi-input-wrapper` 自己身上(Arco 在外面还有一层),模块样式要写成 `.mine:global(.semi-input-wrapper)` 而不是后代选择器。
163
+ - Arco 的 `type="text"` 按钮是主色文字,Semi 对应的是 `theme="borderless" type="primary"`;`type="tertiary"` 是灰色。
164
+ - Semi 的图标渲染为 `role="img"` 并带英文 `aria-label`,放在按钮文字旁会污染按钮的读屏名称:装饰性图标一律加 `aria-hidden="true"`。
165
+ - 弹窗默认脚部按钮带英文 `aria-label`(confirm / cancel):本包在 `/semi` 里清掉了默认值;自己传 `okButtonProps` 时用 `modalButtonProps({...})` 合并。
166
+ - `RadioGroup` 不传 `name` 时所有分组共用 `name="default"`,同页多个分组会互相抢选中:每个分组给独立的 `name`;它也不接受 `role`,需要
167
+ `radiogroup` 角色时在外面包一层。`Select` 不接受 `aria-label`(写死成 selected),用 `aria-labelledby`。
168
+ - Semi 的 Button 没有 `href`,链接样按钮用 `LinkButton`,文字链接用 `TextLink`;`Progress` 的 `percent` 不能是 NaN;表格根元素的角色是
169
+ `grid`(可展开行时是 `treegrid`);`SideSheet` 默认不响应 Esc(`closeOnEsc`)。
@@ -0,0 +1,24 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ import type { ProductEntitlement, ProductIdentityContext, ProductPlan, ProductProfile, ProductSession, ProductSpacesResponse, ProductSubscription, ProductWallet } from './types';
3
+ /** 产品服务端账号接入模块(STD-ACCOUNT-001 `/api/account/*`)在浏览器侧的客户端。 */
4
+ export interface AccountApi {
5
+ startLogin: (returnPath: string, appBasePath: string) => string;
6
+ getSession: () => Promise<ProductSession>;
7
+ getSpaces: () => Promise<ProductSpacesResponse>;
8
+ switchSpace: (spaceId: string) => Promise<ProductSession>;
9
+ /** 右上角显示的昵称:统一账号首次登录时给的展示名。 */
10
+ getProfile: () => Promise<ProductProfile>;
11
+ getWallet: () => Promise<ProductWallet>;
12
+ getEntitlements: () => Promise<ProductEntitlement[]>;
13
+ /** 当前空间的平台套餐;没有套餐时为 null。团队空间的团队版到期时接口返回 403(reason 为 team_subscription_required)。 */
14
+ getSubscription: () => Promise<ProductSubscription | null>;
15
+ /** 在售的平台套餐(价格、每月积分、本产品的功能),只用于升级引导的展示。 */
16
+ getPlans: () => Promise<ProductPlan[]>;
17
+ /** 结束产品会话;服务端开启统一退出时同时返回统一登录(Logto)的退出地址。 */
18
+ logout: () => Promise<{
19
+ endSessionUrl: string | null;
20
+ }>;
21
+ }
22
+ export declare const createAccountApi: (client: AxiosInstance, apiBaseUrl: string) => AccountApi;
23
+ /** 会话与空间列表一起读;两边的当前空间不一致时重读一次会话,仍不一致则视为服务端状态异常。 */
24
+ export declare const restoreIdentityContext: (api: AccountApi) => Promise<ProductIdentityContext>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 跳到 24.city 统一账号中心的地址。根地址是会话里的 `accountCenterUrl`(服务端配置的账号中心 Web 地址)。
3
+ *
4
+ * - 套餐页 `/plans?product_code=&return_url=&space_id=&space_type=` 是公司标准约定的产品入口
5
+ * (STD-BILLING-001「团队版:开通与购买入口」),付款后回到 return_url。
6
+ * - 账号设置、积分消耗、订单、空间与成员是账号中心用户后台现在的页面(账号中心仓库 `apps/account-web/src/consoleRoutes.ts`),
7
+ * 标准里没有约定;账号中心改了地址只改这里。
8
+ */
9
+ declare const CONSOLE_PAGES: {
10
+ /** 统一资料(显示名称)、修改登录密码、登录设备与导出个人数据 */
11
+ readonly settings: "/app/settings";
12
+ /** 当前空间在 24.city 各产品里的积分消耗 */
13
+ readonly points: "/app/points";
14
+ /** 套餐和商品订单 */
15
+ readonly orders: "/app/orders";
16
+ /** 加入的空间、团队成员与邀请 */
17
+ readonly spaces: "/app/spaces";
18
+ };
19
+ export type AccountCenterConsolePage = keyof typeof CONSOLE_PAGES;
20
+ export declare const accountCenterPageUrl: (accountCenterUrl: string | undefined, page: AccountCenterConsolePage) => string | null;
21
+ export interface PlansEntry {
22
+ /** 产品编码(钱包接口的 productCode);读不到时不带,账号中心显示全部套餐 */
23
+ productCode?: string;
24
+ /** 付款后回到的产品地址,必须与产品登记的回调地址同源(用户 Web 的域名) */
25
+ returnUrl: string;
26
+ /** 团队空间开通、续费或升级这个团队 */
27
+ spaceId?: string;
28
+ /** 个人空间开通团队版(随购买创建团队) */
29
+ spaceType?: 'team';
30
+ /** 套餐目录里的价格编码,账号中心套餐页预选这个价格 */
31
+ priceCode?: string;
32
+ }
33
+ /** 账号中心套餐页:个人空间升级、团队空间开通/续费(带 space_id)、个人空间开通团队版(space_type=team)。 */
34
+ export declare const plansUrl: (accountCenterUrl: string | undefined, entry: PlansEntry) => string | null;
35
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 个人中心:账号与安全、订阅与套餐、积分与明细,再接产品追加的分区(customization.accountSections),地址
3
+ * `<app>/account/<分区>`(路由参数 `section`)。
4
+ * 套在工作台顶栏下,但不显示左侧栏:整块内容在页面中间,左边是身份卡片(昵称、当前空间与角色、
5
+ * 套餐和积分摘要)加分区菜单与退出登录,右边是一整块白底面板,放分区标题和内容。窄屏时身份卡片在上,分区菜单变成一行横排。
6
+ */
7
+ export declare const AccountCenterPage: () => import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type LinkButtonSize } from '../page/link-button';
3
+ /** 去统一账号中心的按钮:新标签页打开,文字后带外链图标。地址不可用时不显示。 */
4
+ export declare const CenterLinkButton: ({ href, children, type, size, label, }: {
5
+ href: string | null;
6
+ children: ReactNode;
7
+ /** primary 主色实底、secondary 中性浅底、text 文字 */
8
+ type?: "primary" | "secondary" | "text";
9
+ size?: LinkButtonSize;
10
+ /** 读屏用的完整说明,例如“修改密码(在统一账号中心打开)” */
11
+ label?: string;
12
+ }) => import("react").JSX.Element | null;
13
+ /** 一行设置:左边图标块,中间标题和说明,右边操作。 */
14
+ export declare const SettingRow: ({ icon, title, description, action, }: {
15
+ icon: ReactNode;
16
+ title: ReactNode;
17
+ description: ReactNode;
18
+ action?: ReactNode;
19
+ }) => import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import type { ConsoleNavGroup } from '../layout/console-nav';
2
+ /** 昵称没读到或为空时的称呼。 */
3
+ export declare const FALLBACK_ACCOUNT_LABEL = "\u6211\u7684\u8D26\u53F7";
4
+ /** 头像:昵称首字放在主色渐变圆里;会员加一圈金边和小皇冠。 */
5
+ export declare const AccountAvatar: ({ nickName, member, size }: {
6
+ nickName: string;
7
+ member: boolean;
8
+ size: number;
9
+ }) => import("react").JSX.Element;
10
+ export interface AccountMenuProps {
11
+ /** 个人中心分组;默认按运行时配置的工作台根路径生成三个分区 */
12
+ personal?: ConsoleNavGroup;
13
+ /** 当前页面若是个人中心里的一项,就是它的 key */
14
+ selectedKey?: string;
15
+ /** 打开个人中心的一项;默认按 key 找到菜单项并跳转 */
16
+ onOpen?: (key: string) => void;
17
+ }
18
+ /**
19
+ * 右上角账号入口:顶栏只放头像,指针移上去或点一下展开账号卡片。卡片从上到下是
20
+ * 头像、昵称和套餐标签、当前空间(多个空间时可展开切换);套餐区(免费版是带起步价的升级引导,会员是黑金会员卡);
21
+ * 个人中心三个分区;退出登录。回首页点左上角的产品名称。
22
+ */
23
+ export declare const AccountMenu: ({ personal, selectedKey, onOpen }: AccountMenuProps) => import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { type PropsWithChildren } from 'react';
2
+ /**
3
+ * 会话恢复与同步:首次加载和其他标签页的会话变化时重读会话与空间;回到窗口时后台复核,用户、空间和用途都没变就保留
4
+ * 页面和缓存。给 HTTP 客户端配置 CSRF Token 和 401 处理:受保护路径下的 401 跳去登录页,其他标签页刚退出时不跳。
5
+ */
6
+ export declare const AuthProvider: ({ children }: PropsWithChildren) => import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import type { ProductIdentityContext, ProductSession, ProductSpace } from './types';
2
+ export interface AuthState {
3
+ session: ProductSession | null;
4
+ spaces: ProductSpace[];
5
+ bootstrapped: boolean;
6
+ /** 账号服务读不到(不是 401/403/404):页面停止加载受保护数据并提示重试。 */
7
+ serviceUnavailable: boolean;
8
+ }
9
+ type AuthListener = () => void;
10
+ export interface AuthStore {
11
+ subscribe: (listener: AuthListener) => () => void;
12
+ getState: () => AuthState;
13
+ getCsrfToken: () => string | null;
14
+ setContext: (context: ProductIdentityContext) => void;
15
+ setBootstrapping: () => void;
16
+ clear: (options?: {
17
+ unavailable?: boolean;
18
+ }) => void;
19
+ }
20
+ /** 身份状态只放内存:会话、空间列表和 CSRF Token 都不进浏览器存储。每个应用创建一份。 */
21
+ export declare const createAuthStore: () => AuthStore;
22
+ export declare const AuthStoreProvider: import("react").Provider<AuthStore | null>;
23
+ export declare const useAuthStore: () => AuthStore;
24
+ export declare const useAuthState: () => AuthState;
25
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ConsoleCustomization } from './customization';
2
+ import type { ProductPlan } from './types';
3
+ /** 权益卡上的一行:included 为 false 时是这一档的限制(例如“仅支持 720P 视频”),卡片上灰着显示。 */
4
+ export interface BenefitLine {
5
+ text: string;
6
+ included: boolean;
7
+ }
8
+ /** 写配额类功能的白话:有配额时写数量,配额为“不限”时用另一句。 */
9
+ export declare const quotaCopy: (text: (count: string) => string, unlimited: string) => (limit: number | null) => string;
10
+ /**
11
+ * 一个套餐在本产品的权益行,按产品给的 benefitCopy 顺序;不在表里的功能排在后面,用目录里的名称,保持原顺序。
12
+ * 传入整个套餐目录时可以逐档对比:别的套餐有、这个套餐没有的功能(目录只列打开的开关和大于 0 的配额)写成这一档的限制,
13
+ * 每个套餐都打开的开关不写。不传目录时只写这个套餐有的。
14
+ */
15
+ export declare const featureLines: (plan: ProductPlan, catalog?: ProductPlan[], custom?: ConsoleCustomization) => BenefitLine[];
@@ -0,0 +1,62 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { AccountCenterData } from './use-account-center';
3
+ /** 权益卡配色:免费版素白、标准档浅主色(推荐)、高档黑金、团队暖金。 */
4
+ export type PlanTone = 'basic' | 'standard' | 'pro' | 'team';
5
+ /** 一个套餐在权益卡上的文案与配色;价格、每月积分、席位和功能矩阵里的功能从套餐目录读,不写在这里。 */
6
+ export interface PlanCopy {
7
+ tone: PlanTone;
8
+ /** 卡片右上角的角标,例如“推荐” */
9
+ badge?: string;
10
+ /** 套餐名下面的一句话 */
11
+ tagline: string;
12
+ /** 产品自己写的权益;每月积分、团队席位和套餐目录里本产品的功能会自动排在前面 */
13
+ benefits: string[];
14
+ }
15
+ /** 套餐目录里一个功能键在权益卡、升级引导上的白话说法。 */
16
+ export interface BenefitCopy {
17
+ key: string;
18
+ /** 开关打开、或配额大于 0 时的白话;limit 是配额,开关为 null */
19
+ on: (limit: number | null) => string;
20
+ /** 开关关闭、或配额为 0 时的白话:这一档的限制 */
21
+ off: string;
22
+ }
23
+ export interface PointsDetailProps {
24
+ activeSpaceId: string;
25
+ globalUserId: string;
26
+ }
27
+ export interface AccountSectionProps {
28
+ /** 与内置分区相同的数据:会话、当前空间、昵称、钱包、当前套餐 */
29
+ data: AccountCenterData;
30
+ }
31
+ /**
32
+ * 产品追加的个人中心分区。排在内置的账号与安全、订阅与套餐、积分与明细之后,地址是 `<app>/account/<key>`,
33
+ * 账号菜单、个人中心左侧菜单和内容区一起识别;内置三项不能删、不能改顺序、不能改名。
34
+ */
35
+ export interface ProductAccountSection {
36
+ /** 地址里的分区名:小写字母开头,只含小写字母、数字和连字符,不能与内置分区重名 */
37
+ key: string;
38
+ label: string;
39
+ /** 页面标题下的一句说明 */
40
+ description: string;
41
+ icon?: ComponentType;
42
+ /** 分区内容;与内置分区一样只在会话可用时渲染,界面同样受守卫约束 */
43
+ Component: ComponentType<AccountSectionProps>;
44
+ }
45
+ /**
46
+ * 产品对账号页面的定制。全部可选:不给时权益卡用通用文案、功能名用套餐目录里的原文、积分页只显示余额。
47
+ * 文案只写产品确实提供的能力;套餐之间的差别以统一账号中心的功能矩阵为准。
48
+ */
49
+ export interface ConsoleCustomization {
50
+ /** 套餐目录里本产品功能键的白话说法与先后;不在表里的功能排在后面,用目录里的名称 */
51
+ benefitCopy?: BenefitCopy[];
52
+ /** 按统一账号中心的套餐编码对应的权益卡文案;没有列出的套餐按空间类型和档位套用通用文案 */
53
+ planCopy?: Record<string, PlanCopy>;
54
+ /** 团队套餐的权益卡文案 */
55
+ teamPlanCopy?: PlanCopy;
56
+ /** 开通团队版引导上的产品要点,接在“套餐和积分团队共用”之后 */
57
+ teamPromoHighlights?: string[];
58
+ /** 「积分与明细」里本产品的扣费明细;不给时只显示余额和去账号中心的入口 */
59
+ PointsDetail?: ComponentType<PointsDetailProps>;
60
+ /** 产品追加的个人中心分区,排在内置三项之后 */
61
+ accountSections?: ProductAccountSection[];
62
+ }
@@ -0,0 +1,34 @@
1
+ export * from './account-api';
2
+ export * from './account-center-links';
3
+ export * from './account-center-page';
4
+ export * from './account-center-ui';
5
+ export * from './account-menu';
6
+ export * from './auth-provider';
7
+ export * from './auth-store';
8
+ export * from './benefit-copy';
9
+ export * from './customization';
10
+ export * from './login-page';
11
+ export * from './logout-signal';
12
+ export * from './personal-nav';
13
+ export * from './plan-benefits';
14
+ export * from './plan-cards';
15
+ export * from './plan-display';
16
+ export * from './plan-panel';
17
+ export * from './points-section';
18
+ export * from './profile-section';
19
+ export * from './quota';
20
+ export * from './quota-pill';
21
+ export * from './route-guard';
22
+ export * from './session-sync';
23
+ export * from './space-label';
24
+ export * from './subscription-section';
25
+ export * from './team-promo';
26
+ export * from './types';
27
+ export * from './upgrade-entry';
28
+ export * from './upgrade-modal';
29
+ export * from './use-account-center';
30
+ export * from './use-logout';
31
+ export * from './use-membership';
32
+ export * from './use-plan-catalog';
33
+ export * from './use-space-switch';
34
+ export * from './wallet-badge';
@@ -0,0 +1,87 @@
1
+ import { A as e, a as t, c as o, b as n, i as r, d as i, l as u, n as c, r as l, e as g, f as p, u as A, g as S, w as P } from "../chunks/logout-signal-CiD_zY5M.js";
2
+ import { A as C, C as d, L as f, P as h, a as m, b as y, Q as N, R as T, S as E, c as O, T as b, U, d as F, p as _, e as x, f as v, g as w, y as B } from "../chunks/upgrade-modal-DzdKuEkJ.js";
3
+ import { A as I, a as q, b as D, E as K, F as M, P as Q, c as G, d as H, U as k, e as W, W as Y, f as j, g as z, h as J, i as V, j as X, k as Z, l as $, m as aa, n as sa, o as ea, p as ta, q as oa, r as na, s as ra, t as ia, u as ua, v as ca, w as la, x as ga, y as pa, z as Aa, B as Sa, C as Pa, D as La, G as Ca, H as da, I as fa, J as ha, K as ma, L as ya, M as Na, N as Ta, O as Ea, Q as Oa } from "../chunks/wallet-badge-CnyMLpUO.js";
4
+ import { A as Ua } from "../chunks/auth-provider-CqiyTeOt.js";
5
+ import { notifyCustomerSessionChanged as _a, subscribeCustomerSessionChanges as xa } from "@24city/web-runtime/session-sync";
6
+ export {
7
+ I as ACCOUNT_SECTIONS,
8
+ q as AccountAvatar,
9
+ C as AccountCenterPage,
10
+ D as AccountMenu,
11
+ Ua as AuthProvider,
12
+ e as AuthStoreProvider,
13
+ d as CenterLinkButton,
14
+ K as EXPIRING_SOON_DAYS,
15
+ M as FALLBACK_ACCOUNT_LABEL,
16
+ f as LoginPage,
17
+ Q as PERSONAL_NAV_KEYS,
18
+ G as PERSONAL_SPACE_LABEL,
19
+ h as PlanCards,
20
+ H as PlanPanel,
21
+ m as PointsSection,
22
+ y as ProfileSection,
23
+ N as QuotaPill,
24
+ T as RouteGuard,
25
+ E as SettingRow,
26
+ O as SubscriptionSection,
27
+ b as TeamPromo,
28
+ k as UNLIMITED_QUOTA,
29
+ W as UpgradeEntry,
30
+ U as UpgradeModal,
31
+ Y as WalletBadge,
32
+ F as accountCenterPageUrl,
33
+ j as accountQueryKeys,
34
+ z as accountSectionPath,
35
+ t as announceLogout,
36
+ J as buildPersonalNavigation,
37
+ V as canBuyForSpace,
38
+ X as catalogPlanOf,
39
+ o as createAccountApi,
40
+ n as createAuthStore,
41
+ Z as entryTeamPlan,
42
+ $ as featureLines,
43
+ aa as formatPlanAmount,
44
+ sa as formatPlanPrice,
45
+ ea as isAccountCenterPath,
46
+ ta as isAccountSection,
47
+ r as isLeavingForLogout,
48
+ i as isLoggedOutElsewhere,
49
+ oa as isTeamSpace,
50
+ na as isTeamSubscriptionRequired,
51
+ ra as isUnlimited,
52
+ u as leaveForLogout,
53
+ c as noteLogoutElsewhere,
54
+ _a as notifySessionChanged,
55
+ ia as offerHighlights,
56
+ ua as personalNavKey,
57
+ _ as planBenefitLines,
58
+ x as planCopy,
59
+ ca as planDaysLeft,
60
+ la as planFocusOf,
61
+ ga as planFocusState,
62
+ pa as planPeriodText,
63
+ Aa as planTitle,
64
+ v as plansUrl,
65
+ w as priceFor,
66
+ Sa as productAccountSections,
67
+ Pa as quotaCopy,
68
+ La as quotaFull,
69
+ Ca as quotaText,
70
+ l as releaseLogoutHold,
71
+ g as resetLogoutSignalForTest,
72
+ p as restoreIdentityContext,
73
+ da as spaceDisplayName,
74
+ fa as spaceRoleLabel,
75
+ ha as startingPrice,
76
+ xa as subscribeSessionChanged,
77
+ ma as upgradeOffer,
78
+ ya as useAccountCenter,
79
+ A as useAuthState,
80
+ S as useAuthStore,
81
+ Na as useLogout,
82
+ Ta as useMembership,
83
+ Ea as usePlanCatalog,
84
+ Oa as useSpaceSwitch,
85
+ P as withdrawLogout,
86
+ B as yearlyNote
87
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 登录页只是去统一登录前的一瞬间:不放品牌卡片,只留加载态;账号服务不可用时才给出操作。
3
+ * 退出登录期间不自动去统一登录(logout-signal.ts):本页正在离开时只留加载态;其他标签页刚退出时显示“已退出登录”,
4
+ * 由用户选择重新登录或回首页。
5
+ */
6
+ export declare const LoginPage: () => import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ /** 请求服务端退出之前写下:其他标签页在这期间遇到 401 时已经知道原因。 */
2
+ export declare function announceLogout(now?: number): void;
3
+ /** 服务端没有确认退出:撤回刚才的说明。 */
4
+ export declare function withdrawLogout(): void;
5
+ /** 本页正在离开去统一登录退出:此后不再发起登录,也不再跳转。 */
6
+ export declare function leaveForLogout(): void;
7
+ export declare function isLeavingForLogout(): boolean;
8
+ /** 另一个标签页刚刚退出时记住它:本页停在“已退出登录”,不自己发起登录。返回本页是否因此停住。 */
9
+ export declare function noteLogoutElsewhere(now?: number): boolean;
10
+ export declare function isLoggedOutElsewhere(): boolean;
11
+ /** 用户选择重新登录或回首页,或会话已经恢复:不再停住。 */
12
+ export declare function releaseLogoutHold(): void;
13
+ export declare function resetLogoutSignalForTest(): void;
@@ -0,0 +1,29 @@
1
+ import type { ConsoleNavGroup } from '../layout/console-nav';
2
+ import type { ConsoleCustomization, ProductAccountSection } from './customization';
3
+ /** 内置的三个分区;地址是 `<app>/account/<分区>`。 */
4
+ export type BuiltinAccountSection = 'profile' | 'subscription' | 'points';
5
+ /** @deprecated 改用 BuiltinAccountSection;产品追加的分区见 ProductAccountSection。 */
6
+ export type AccountSection = BuiltinAccountSection;
7
+ export declare const ACCOUNT_SECTIONS: readonly BuiltinAccountSection[];
8
+ export declare const isAccountSection: (value: string) => value is BuiltinAccountSection;
9
+ export declare const accountSectionPath: (appBase: string, section: string) => string;
10
+ /** 个人中心的页面:整体居中,不显示工作台侧栏。 */
11
+ export declare const isAccountCenterPath: (appBase: string, pathname: string) => boolean;
12
+ /** 个人中心菜单项的 key:内置与产品追加的分区都是 `account-<分区>`。 */
13
+ export declare const personalNavKey: (section: string) => string;
14
+ /** 内置分区的菜单 key,账号卡片里的套餐区按它打开对应分区。 */
15
+ export declare const PERSONAL_NAV_KEYS: {
16
+ readonly profile: string;
17
+ readonly subscription: string;
18
+ readonly points: string;
19
+ };
20
+ /**
21
+ * 产品追加的个人中心分区,校验后原样返回:key 合法、不与内置分区重名、不重复。
22
+ * 不合法时抛错:这是产品配置错误,应在开发时暴露,不是运行时状态。
23
+ */
24
+ export declare const productAccountSections: (custom: ConsoleCustomization) => ProductAccountSection[];
25
+ /**
26
+ * 个人中心:账号与安全、订阅与套餐、积分与明细,再接产品追加的分区。不占左侧栏,入口在右上角账号下拉,
27
+ * 个人中心页面自己的左侧也列这些项。
28
+ */
29
+ export declare const buildPersonalNavigation: (appBase: string, sections?: readonly ProductAccountSection[]) => ConsoleNavGroup;