@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,15 @@
|
|
|
1
|
+
import type { AccountApi } from '../account/account-api';
|
|
2
|
+
import type { ProductPlan, ProductProfile, ProductSession, ProductSpace, ProductSubscription, ProductWallet } from '../account/types';
|
|
3
|
+
import type { ConsoleRuntimeConfig } from '../runtime/runtime-config';
|
|
4
|
+
import type { ConsoleRuntime } from '../runtime/context';
|
|
5
|
+
export declare const fixtureRuntimeConfig: (overrides?: Partial<ConsoleRuntimeConfig>) => ConsoleRuntimeConfig;
|
|
6
|
+
export declare const fixtureSession: (overrides?: Partial<ProductSession>) => ProductSession;
|
|
7
|
+
export declare const fixtureSpaces: () => ProductSpace[];
|
|
8
|
+
export declare const fixtureProfile: () => ProductProfile;
|
|
9
|
+
export declare const fixtureWallet: (overrides?: Partial<ProductWallet>) => ProductWallet;
|
|
10
|
+
export declare const fixtureSubscription: () => ProductSubscription;
|
|
11
|
+
export declare const fixturePlans: () => ProductPlan[];
|
|
12
|
+
/** 账号接口替身:全部返回固定数据,`startLogin` 返回 `#`,退出不跳转。可按需覆盖单个方法。 */
|
|
13
|
+
export declare const createFixtureAccountApi: (overrides?: Partial<AccountApi>) => AccountApi;
|
|
14
|
+
/** UI-only 模式的运行时:固定配置、不发请求的 HTTP 客户端和账号接口替身。 */
|
|
15
|
+
export declare const createFixtureRuntime: (overrides?: Partial<ConsoleRuntime>) => ConsoleRuntime;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { c as a } from "../chunks/http-B3mTs9KZ.js";
|
|
2
|
+
const n = (e = {}) => ({
|
|
3
|
+
brand: { name: "示例产品", shortName: "示例", mark: "示", description: "@24city/web-console 示例", primaryColor: "#E04E06" },
|
|
4
|
+
routes: { publicHome: "/", login: "/login", app: "/app" },
|
|
5
|
+
api: { baseUrl: "/api" },
|
|
6
|
+
enabledModules: [],
|
|
7
|
+
...e
|
|
8
|
+
}), o = (e = {}) => ({
|
|
9
|
+
globalUserId: "user-fixture",
|
|
10
|
+
localUserId: 1,
|
|
11
|
+
activeSpaceId: "space-personal",
|
|
12
|
+
authorityId: 1,
|
|
13
|
+
orgId: 1,
|
|
14
|
+
purpose: "user",
|
|
15
|
+
csrfToken: "fixture-csrf",
|
|
16
|
+
issuedAt: "2026-01-01T00:00:00Z",
|
|
17
|
+
lastSeenAt: "2026-01-01T00:00:00Z",
|
|
18
|
+
absoluteExpiresAt: "2026-12-31T00:00:00Z",
|
|
19
|
+
lastCentralVerifiedAt: "2026-01-01T00:00:00Z",
|
|
20
|
+
accountCenterUrl: "https://account.example.invalid",
|
|
21
|
+
...e
|
|
22
|
+
}), i = () => [
|
|
23
|
+
{
|
|
24
|
+
id: "space-personal",
|
|
25
|
+
name: "示例用户的空间",
|
|
26
|
+
slug: "demo",
|
|
27
|
+
type: "personal",
|
|
28
|
+
role: "owner",
|
|
29
|
+
status: "active",
|
|
30
|
+
membershipStatus: "active",
|
|
31
|
+
entitlementSummary: { activeCount: 1, codes: ["platform-free"] },
|
|
32
|
+
entitlements: []
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "space-team",
|
|
36
|
+
name: "示例团队",
|
|
37
|
+
slug: "demo-team",
|
|
38
|
+
type: "team",
|
|
39
|
+
role: "owner",
|
|
40
|
+
status: "active",
|
|
41
|
+
membershipStatus: "active",
|
|
42
|
+
entitlementSummary: { activeCount: 1, codes: ["team-standard"] },
|
|
43
|
+
entitlements: []
|
|
44
|
+
}
|
|
45
|
+
], r = () => ({ nickName: "示例用户" }), c = (e = {}) => ({
|
|
46
|
+
spaceId: "space-personal",
|
|
47
|
+
globalUserId: "user-fixture",
|
|
48
|
+
productCode: "demo",
|
|
49
|
+
availablePoints: 1280,
|
|
50
|
+
reservedPoints: 0,
|
|
51
|
+
globalAvailablePoints: 1280,
|
|
52
|
+
globalReservedPoints: 0,
|
|
53
|
+
productAvailablePoints: 0,
|
|
54
|
+
productReservedPoints: 0,
|
|
55
|
+
walletAvailablePoints: 1280,
|
|
56
|
+
walletReservedPoints: 0,
|
|
57
|
+
walletVersion: 1,
|
|
58
|
+
...e
|
|
59
|
+
}), l = () => ({
|
|
60
|
+
subscriptionId: null,
|
|
61
|
+
planCode: "platform-free",
|
|
62
|
+
planName: "免费版",
|
|
63
|
+
tier: 0,
|
|
64
|
+
isDefault: !0,
|
|
65
|
+
spaceType: "personal",
|
|
66
|
+
currentPeriodEnd: null
|
|
67
|
+
}), p = () => [
|
|
68
|
+
{ code: "platform-free", name: "免费版", spaceType: "personal", tier: 0, isDefault: !0, includedSeats: 1, monthlyPoints: 500, prices: [], benefits: [], otherProducts: [] },
|
|
69
|
+
{
|
|
70
|
+
code: "platform-premium",
|
|
71
|
+
name: "标准版",
|
|
72
|
+
spaceType: "personal",
|
|
73
|
+
tier: 1,
|
|
74
|
+
isDefault: !1,
|
|
75
|
+
includedSeats: 1,
|
|
76
|
+
monthlyPoints: 3e3,
|
|
77
|
+
prices: [
|
|
78
|
+
{ code: "premium-month", amountCents: 7800, currency: "CNY", billingPeriod: "month", durationDays: 30, pointCycles: 1 },
|
|
79
|
+
{ code: "premium-year", amountCents: 78e3, currency: "CNY", billingPeriod: "year", durationDays: 365, pointCycles: 12 }
|
|
80
|
+
],
|
|
81
|
+
benefits: [{ key: "demo.export", name: "导出成品", description: "", limit: null, discounts: [] }],
|
|
82
|
+
otherProducts: []
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
code: "platform-pro",
|
|
86
|
+
name: "专业版",
|
|
87
|
+
spaceType: "personal",
|
|
88
|
+
tier: 2,
|
|
89
|
+
isDefault: !1,
|
|
90
|
+
includedSeats: 1,
|
|
91
|
+
monthlyPoints: 1e4,
|
|
92
|
+
prices: [{ code: "pro-month", amountCents: 19800, currency: "CNY", billingPeriod: "month", durationDays: 30, pointCycles: 1 }],
|
|
93
|
+
benefits: [
|
|
94
|
+
{ key: "demo.export", name: "导出成品", description: "", limit: null, discounts: [] },
|
|
95
|
+
{ key: "demo.projects", name: "项目数", description: "", limit: 50, discounts: [] }
|
|
96
|
+
],
|
|
97
|
+
otherProducts: []
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
code: "team-standard",
|
|
101
|
+
name: "团队版",
|
|
102
|
+
spaceType: "team",
|
|
103
|
+
tier: 1,
|
|
104
|
+
isDefault: !1,
|
|
105
|
+
includedSeats: 5,
|
|
106
|
+
monthlyPoints: 2e4,
|
|
107
|
+
prices: [{ code: "team-month", amountCents: 49900, currency: "CNY", billingPeriod: "month", durationDays: 30, pointCycles: 1 }],
|
|
108
|
+
benefits: [],
|
|
109
|
+
otherProducts: []
|
|
110
|
+
}
|
|
111
|
+
], u = (e = {}) => {
|
|
112
|
+
let t = o();
|
|
113
|
+
return {
|
|
114
|
+
startLogin: () => "#",
|
|
115
|
+
getSession: async () => t,
|
|
116
|
+
getSpaces: async () => ({ activeSpaceId: t.activeSpaceId, spaces: i() }),
|
|
117
|
+
switchSpace: async (s) => (t = { ...t, activeSpaceId: s }, t),
|
|
118
|
+
getProfile: async () => r(),
|
|
119
|
+
getWallet: async () => c({ spaceId: t.activeSpaceId }),
|
|
120
|
+
getEntitlements: async () => [],
|
|
121
|
+
getSubscription: async () => l(),
|
|
122
|
+
getPlans: async () => p(),
|
|
123
|
+
logout: async () => ({ endSessionUrl: null }),
|
|
124
|
+
...e
|
|
125
|
+
};
|
|
126
|
+
}, m = (e = {}) => ({
|
|
127
|
+
config: n(),
|
|
128
|
+
http: a(),
|
|
129
|
+
accountApi: u(),
|
|
130
|
+
...e
|
|
131
|
+
});
|
|
132
|
+
export {
|
|
133
|
+
u as createFixtureAccountApi,
|
|
134
|
+
m as createFixtureRuntime,
|
|
135
|
+
p as fixturePlans,
|
|
136
|
+
r as fixtureProfile,
|
|
137
|
+
n as fixtureRuntimeConfig,
|
|
138
|
+
o as fixtureSession,
|
|
139
|
+
i as fixtureSpaces,
|
|
140
|
+
l as fixtureSubscription,
|
|
141
|
+
c as fixtureWallet
|
|
142
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface UiGuardViolation {
|
|
2
|
+
/** 相对 sourceRoot 的文件路径 */
|
|
3
|
+
file: string;
|
|
4
|
+
rule: string;
|
|
5
|
+
detail: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UiGuardOptions {
|
|
8
|
+
/** 产品 `src` 目录的绝对路径 */
|
|
9
|
+
sourceRoot: string;
|
|
10
|
+
/** 不检查的目录或文件(相对 sourceRoot),默认只跳过 `test/` 和 `*.test.ts(x)` */
|
|
11
|
+
exclude?: (relativePath: string) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/** 只允许无语义样式的布局容器与 Semi 没有对应组件的 video;控件、列表、表格、标题、段落和链接一律用 Semi 组件(链接样按钮用本包的 LinkButton)。 */
|
|
14
|
+
export declare const RAW_ELEMENT_PATTERN: RegExp;
|
|
15
|
+
/** 旧视觉层、工具类方案、上一代组件库,以及绕过本包主题的写法。 */
|
|
16
|
+
export declare const FORBIDDEN_SNIPPETS: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* 产品不得自己声明的 CSS 变量:Semi 的全部变量(色板、语义色、圆角、阴影)和本包的 `--app-*`。
|
|
19
|
+
* 品牌主色只能通过 runtime-config 的 brand.primaryColor 进来。
|
|
20
|
+
*/
|
|
21
|
+
export declare const RESERVED_VARIABLE_PREFIXES: readonly string[];
|
|
22
|
+
/** 返回全部违规;空数组表示通过。产品的测试里 `expect(checkUiLibraryUsage({ sourceRoot })).toEqual([])`。 */
|
|
23
|
+
export declare const checkUiLibraryUsage: ({ sourceRoot, exclude }: UiGuardOptions) => UiGuardViolation[];
|
|
24
|
+
/** 本包要求的 Semi 包与精确版本(peerDependencies):组件库、图标、插画三个包必须同一版本。 */
|
|
25
|
+
export declare const SEMI_PACKAGES: readonly ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"];
|
|
26
|
+
/** 本包要求的 Semi 精确版本。 */
|
|
27
|
+
export declare const EXPECTED_SEMI_VERSION: string;
|
|
28
|
+
/**
|
|
29
|
+
* 检查产品声明的 Semi 版本与本包要求一致:本包的样式和守卫按这个版本写,组件由产品安装,两边必须同一个版本;
|
|
30
|
+
* 图标与插画包若有声明也必须是同一版本。传产品 `apps/web/package.json` 的路径;返回空数组表示一致。
|
|
31
|
+
*/
|
|
32
|
+
export declare const checkSemiVersion: (productPackageJsonPath: string) => UiGuardViolation[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { readFileSync as m, readdirSync as E, statSync as S } from "node:fs";
|
|
2
|
+
import { relative as y, join as $ } from "node:path";
|
|
3
|
+
const v = { "@douyinfe/semi-ui": "2.104.0" }, b = {
|
|
4
|
+
peerDependencies: v
|
|
5
|
+
}, x = /<(button|input|select|textarea|option|label|form|table|thead|tbody|tr|td|th|details|summary|dialog|img|a|ul|ol|li|dl|dt|dd|h[1-6]|p)(\s|>|\/)/, A = [
|
|
6
|
+
"lucide-react",
|
|
7
|
+
"@nuwa/customer-ui",
|
|
8
|
+
"@nuwa/customer-shell",
|
|
9
|
+
"@nuwa/customer-experience",
|
|
10
|
+
"tailwind",
|
|
11
|
+
"class-variance-authority",
|
|
12
|
+
"from 'clsx'",
|
|
13
|
+
"@arco-design/",
|
|
14
|
+
".arco-",
|
|
15
|
+
"@douyinfe/semi-ui/dist/css",
|
|
16
|
+
"theme-mode"
|
|
17
|
+
], R = ["--semi-", "--app-"], _ = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, g = /\b(?:rgba?|hsla?)\((?!\s*var\()/, D = new RegExp(`(?:^|[\\s{;'"])(${R.map((t) => t.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), p = (t) => E(t).flatMap((o) => {
|
|
18
|
+
const e = $(t, o);
|
|
19
|
+
return S(e).isDirectory() ? p(e) : [e];
|
|
20
|
+
}), F = (t) => /\.test\.(ts|tsx)$/.test(t) || t.startsWith("test/") || t.endsWith(".d.ts"), O = ({ sourceRoot: t, exclude: o = F }) => {
|
|
21
|
+
const e = [], a = p(t).map((i) => ({ path: i, file: y(t, i) })).filter(({ file: i }) => !o(i));
|
|
22
|
+
for (const { path: i, file: s } of a) {
|
|
23
|
+
const n = s.endsWith(".tsx");
|
|
24
|
+
if (!/\.(tsx?|css)$/.test(s)) continue;
|
|
25
|
+
const r = m(i, "utf8");
|
|
26
|
+
if (n) {
|
|
27
|
+
const c = r.match(x);
|
|
28
|
+
c && e.push({ file: s, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${c[0].trim()}` }), /className="/.test(r) && e.push({ file: s, rule: "class-string", detail: "className 应引用 CSS Module,不写工具类字符串" });
|
|
29
|
+
}
|
|
30
|
+
for (const c of A)
|
|
31
|
+
r.includes(c) && e.push({ file: s, rule: "forbidden-import", detail: `不应引用 ${c}` });
|
|
32
|
+
const u = r.match(_);
|
|
33
|
+
u && e.push({ file: s, rule: "color-literal", detail: `含有写死的色值 ${u[0]}` });
|
|
34
|
+
const d = r.match(g);
|
|
35
|
+
d && e.push({ file: s, rule: "color-literal", detail: `含有写死的色值 ${d[0]}` });
|
|
36
|
+
const f = r.match(D);
|
|
37
|
+
f && e.push({ file: s, rule: "reserved-variable", detail: `不得声明主题变量 ${f[1]}…,品牌主色只能通过 runtime-config 的 brand.primaryColor 设置` });
|
|
38
|
+
}
|
|
39
|
+
return e;
|
|
40
|
+
}, I = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], N = b.peerDependencies, l = N["@douyinfe/semi-ui"], T = (t) => {
|
|
41
|
+
var a, i;
|
|
42
|
+
const o = JSON.parse(m(t, "utf8")), e = [];
|
|
43
|
+
for (const s of I) {
|
|
44
|
+
const n = ((a = o.dependencies) == null ? void 0 : a[s]) ?? ((i = o.devDependencies) == null ? void 0 : i[s]);
|
|
45
|
+
!(s === "@douyinfe/semi-ui" || n !== void 0) || n === l || e.push({
|
|
46
|
+
file: "package.json",
|
|
47
|
+
rule: "semi-version",
|
|
48
|
+
detail: n ? `${s} 必须精确声明为 ${l},现在是 ${n}` : `必须声明 ${s} ${l}`
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return e;
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
l as EXPECTED_SEMI_VERSION,
|
|
55
|
+
A as FORBIDDEN_SNIPPETS,
|
|
56
|
+
x as RAW_ELEMENT_PATTERN,
|
|
57
|
+
R as RESERVED_VARIABLE_PREFIXES,
|
|
58
|
+
I as SEMI_PACKAGES,
|
|
59
|
+
T as checkSemiVersion,
|
|
60
|
+
O as checkUiLibraryUsage
|
|
61
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const i = (t, e) => {
|
|
2
|
+
t in window || Object.defineProperty(window, t, { writable: !0, configurable: !0, value: e });
|
|
3
|
+
}, o = (t) => {
|
|
4
|
+
const e = () => {
|
|
5
|
+
}, n = () => ({ data: new Uint8ClampedArray(4), width: 1, height: 1 });
|
|
6
|
+
return {
|
|
7
|
+
canvas: t,
|
|
8
|
+
fillStyle: "",
|
|
9
|
+
strokeStyle: "",
|
|
10
|
+
lineWidth: 1,
|
|
11
|
+
globalAlpha: 1,
|
|
12
|
+
fillRect: e,
|
|
13
|
+
clearRect: e,
|
|
14
|
+
strokeRect: e,
|
|
15
|
+
getImageData: n,
|
|
16
|
+
putImageData: e,
|
|
17
|
+
createImageData: n,
|
|
18
|
+
setTransform: e,
|
|
19
|
+
resetTransform: e,
|
|
20
|
+
drawImage: e,
|
|
21
|
+
save: e,
|
|
22
|
+
restore: e,
|
|
23
|
+
beginPath: e,
|
|
24
|
+
closePath: e,
|
|
25
|
+
moveTo: e,
|
|
26
|
+
lineTo: e,
|
|
27
|
+
bezierCurveTo: e,
|
|
28
|
+
quadraticCurveTo: e,
|
|
29
|
+
arc: e,
|
|
30
|
+
rect: e,
|
|
31
|
+
fill: e,
|
|
32
|
+
stroke: e,
|
|
33
|
+
clip: e,
|
|
34
|
+
translate: e,
|
|
35
|
+
scale: e,
|
|
36
|
+
rotate: e,
|
|
37
|
+
transform: e,
|
|
38
|
+
measureText: () => ({ width: 0 }),
|
|
39
|
+
fillText: e,
|
|
40
|
+
strokeText: e,
|
|
41
|
+
createLinearGradient: () => ({ addColorStop: e }),
|
|
42
|
+
createRadialGradient: () => ({ addColorStop: e }),
|
|
43
|
+
createPattern: () => null,
|
|
44
|
+
setLineDash: e,
|
|
45
|
+
getLineDash: () => []
|
|
46
|
+
};
|
|
47
|
+
}, a = () => {
|
|
48
|
+
if (!(typeof window > "u")) {
|
|
49
|
+
if (window.matchMedia || Object.defineProperty(window, "matchMedia", {
|
|
50
|
+
writable: !0,
|
|
51
|
+
configurable: !0,
|
|
52
|
+
value: (t) => ({
|
|
53
|
+
matches: !1,
|
|
54
|
+
media: t,
|
|
55
|
+
onchange: null,
|
|
56
|
+
addListener: () => {
|
|
57
|
+
},
|
|
58
|
+
removeListener: () => {
|
|
59
|
+
},
|
|
60
|
+
addEventListener: () => {
|
|
61
|
+
},
|
|
62
|
+
removeEventListener: () => {
|
|
63
|
+
},
|
|
64
|
+
dispatchEvent: () => !1
|
|
65
|
+
})
|
|
66
|
+
}), i(
|
|
67
|
+
"ResizeObserver",
|
|
68
|
+
class {
|
|
69
|
+
observe() {
|
|
70
|
+
}
|
|
71
|
+
unobserve() {
|
|
72
|
+
}
|
|
73
|
+
disconnect() {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
), i(
|
|
77
|
+
"IntersectionObserver",
|
|
78
|
+
class {
|
|
79
|
+
observe() {
|
|
80
|
+
}
|
|
81
|
+
unobserve() {
|
|
82
|
+
}
|
|
83
|
+
disconnect() {
|
|
84
|
+
}
|
|
85
|
+
takeRecords() {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
), typeof HTMLCanvasElement < "u") {
|
|
90
|
+
const t = HTMLCanvasElement.prototype;
|
|
91
|
+
t.__24cityStub || (t.__24cityStub = !0, t.getContext = function() {
|
|
92
|
+
return o(this);
|
|
93
|
+
}, t.toDataURL = () => "data:image/png;base64,");
|
|
94
|
+
}
|
|
95
|
+
if (typeof Range < "u") {
|
|
96
|
+
const t = Range.prototype;
|
|
97
|
+
if (!t.__24cityStub) {
|
|
98
|
+
t.__24cityStub = !0;
|
|
99
|
+
const e = () => ({ x: 0, y: 0, top: 0, left: 0, right: 0, bottom: 0, width: 0, height: 0, toJSON: () => ({}) });
|
|
100
|
+
t.getBoundingClientRect = e, t.getClientRects = () => ({ length: 0, item: () => null, [Symbol.iterator]: [][Symbol.iterator] });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
typeof MutationObserver < "u" && typeof document < "u" && !document.__24cityAnimationShim && (document.__24cityAnimationShim = !0, new MutationObserver((e) => {
|
|
104
|
+
for (const n of e) {
|
|
105
|
+
const r = n.target;
|
|
106
|
+
!(r instanceof HTMLElement) || !/(?:^|\s)semi-[a-z-]*(?:animate|animation)[a-z_-]*/.test(r.className) || setTimeout(() => r.dispatchEvent(new Event("animationend", { bubbles: !0 })), 0);
|
|
107
|
+
}
|
|
108
|
+
}).observe(document.documentElement, { subtree: !0, attributes: !0, attributeFilter: ["class"] })), typeof URL < "u" && typeof URL.createObjectURL != "function" && (Object.defineProperty(URL, "createObjectURL", { writable: !0, configurable: !0, value: () => "blob:jsdom" }), Object.defineProperty(URL, "revokeObjectURL", { writable: !0, configurable: !0, value: () => {
|
|
109
|
+
} })), window.scrollTo = () => {
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
a();
|
|
114
|
+
export {
|
|
115
|
+
a as installJsdomShims
|
|
116
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import './theme.css';
|
|
2
|
+
/**
|
|
3
|
+
* 由一个品牌色生成十级主色(第 6 级即传入的颜色),返回 "R, G, B" 写法。
|
|
4
|
+
* 本包的样式用 `--app-brand-1..10` 引用这组颜色;Semi 组件的主色、链接色与聚焦描边由同一组颜色映射。
|
|
5
|
+
*/
|
|
6
|
+
export declare const brandPalette: (primaryColor: string) => string[];
|
|
7
|
+
/** 本包的十级品牌色变量:`--app-brand-1..10`("R, G, B"),由 applyBrand 写到 body 上。 */
|
|
8
|
+
export declare const BRAND_VARIABLES: readonly string[];
|
|
9
|
+
/**
|
|
10
|
+
* Semi 的语义主色到十级色板的映射:主色第 6 级,悬停 7、按下 8、禁用 3,浅底 1/2/3;链接色跟随主色,聚焦描边用主色。
|
|
11
|
+
* 状态色(成功、警告、危险、信息)不在其中,由 Semi 的默认色板定死。
|
|
12
|
+
*/
|
|
13
|
+
export declare const SEMI_BRAND_VARIABLES: Readonly<Record<string, number>>;
|
|
14
|
+
export interface ApplyBrandOptions {
|
|
15
|
+
/** 六位十六进制品牌主色,例如 `#E04E06`;不传时清掉之前写的值,恢复 Semi 默认主色。 */
|
|
16
|
+
primaryColor?: string;
|
|
17
|
+
/** 写变量的元素,默认 `document.body`(Semi 的设计变量定义在 body 上)。 */
|
|
18
|
+
target?: HTMLElement;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 把品牌主色写到 body 上。在首屏渲染前调用一次(runtime-config 加载后),页面不会先闪默认色。
|
|
22
|
+
* 这是产品唯一可以改的颜色;中性灰、状态色、字色由 theme.css 定死。
|
|
23
|
+
*/
|
|
24
|
+
export declare const applyBrand: ({ primaryColor, target }?: ApplyBrandOptions) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const E = /^#[0-9a-fA-F]{6}$/, h = (t) => [
|
|
2
|
+
parseInt(t.slice(1, 3), 16),
|
|
3
|
+
parseInt(t.slice(3, 5), 16),
|
|
4
|
+
parseInt(t.slice(5, 7), 16)
|
|
5
|
+
], _ = ([t, l, r]) => {
|
|
6
|
+
const s = t / 255, e = l / 255, o = r / 255, c = Math.max(s, e, o), A = Math.min(s, e, o), a = c - A;
|
|
7
|
+
let n = 0;
|
|
8
|
+
return a !== 0 && (c === s ? n = (e - o) / a % 6 : c === e ? n = (o - s) / a + 2 : n = (s - e) / a + 4, n *= 60, n < 0 && (n += 360)), { h: n, s: c === 0 ? 0 : a / c * 100, v: c * 100 };
|
|
9
|
+
}, p = ({ h: t, s: l, v: r }) => {
|
|
10
|
+
const s = l / 100, e = r / 100, o = e * s, c = o * (1 - Math.abs(t / 60 % 2 - 1)), A = e - o, [a, n, m] = t < 60 ? [o, c, 0] : t < 120 ? [c, o, 0] : t < 180 ? [0, o, c] : t < 240 ? [0, c, o] : t < 300 ? [c, 0, o] : [o, 0, c];
|
|
11
|
+
return [Math.round((a + A) * 255), Math.round((n + A) * 255), Math.round((m + A) * 255)];
|
|
12
|
+
};
|
|
13
|
+
const v = (t, l) => {
|
|
14
|
+
const r = l < 6, s = r ? 6 - l : l - 6;
|
|
15
|
+
if (l === 6) return t;
|
|
16
|
+
let e = t.h >= 60 && t.h <= 240 ? r ? t.h - 2 * s : t.h + 2 * s : r ? t.h + 2 * s : t.h - 2 * s;
|
|
17
|
+
e < 0 ? e += 360 : e >= 360 && (e -= 360);
|
|
18
|
+
const o = r ? t.s <= 9 ? t.s : t.s - (t.s - 9) / 5 * s : t.s + (100 - t.s) / 4 * s, c = r ? t.v + (100 - t.v) / 5 * s : t.v <= 30 ? t.v : t.v - (t.v - 30) / 4 * s;
|
|
19
|
+
return { h: Math.round(e), s: o, v: c };
|
|
20
|
+
}, T = (t) => {
|
|
21
|
+
if (!E.test(t)) throw new Error("品牌主色必须是六位十六进制颜色,例如 #E04E06");
|
|
22
|
+
const l = _(h(t));
|
|
23
|
+
return Array.from({ length: 10 }, (r, s) => p(v(l, s + 1)).join(", "));
|
|
24
|
+
};
|
|
25
|
+
const y = (t) => T(t), M = Array.from({ length: 10 }, (t, l) => `--app-brand-${l + 1}`), f = {
|
|
26
|
+
"--semi-color-primary": 6,
|
|
27
|
+
"--semi-color-primary-hover": 7,
|
|
28
|
+
"--semi-color-primary-active": 8,
|
|
29
|
+
"--semi-color-primary-disabled": 3,
|
|
30
|
+
"--semi-color-primary-light-default": 1,
|
|
31
|
+
"--semi-color-primary-light-hover": 2,
|
|
32
|
+
"--semi-color-primary-light-active": 3,
|
|
33
|
+
"--semi-color-focus-border": 6,
|
|
34
|
+
"--semi-color-link": 6,
|
|
35
|
+
"--semi-color-link-hover": 7,
|
|
36
|
+
"--semi-color-link-active": 8,
|
|
37
|
+
"--semi-color-link-visited": 6
|
|
38
|
+
}, I = ({ primaryColor: t, target: l } = {}) => {
|
|
39
|
+
const r = l ?? document.body, s = t ? y(t) : null;
|
|
40
|
+
M.forEach((e, o) => {
|
|
41
|
+
s ? r.style.setProperty(e, s[o]) : r.style.removeProperty(e);
|
|
42
|
+
}), Object.entries(f).forEach(([e, o]) => {
|
|
43
|
+
s ? r.style.setProperty(e, `rgb(${s[o - 1]})`) : r.style.removeProperty(e);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
M as BRAND_VARIABLES,
|
|
48
|
+
f as SEMI_BRAND_VARIABLES,
|
|
49
|
+
I as applyBrand,
|
|
50
|
+
y as brandPalette
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,101 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24city/web-console",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "24.city 产品用户端的控制台外壳、账号菜单、个人中心、会员引导与 Semi Design 主题",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"*.css"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
"README.md",
|
|
12
|
+
"CHANGELOG.md",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"axios": "^1.13.2"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@24city/web-runtime": ">=0.2.0 <1",
|
|
21
|
+
"@douyinfe/semi-icons": "2.104.0",
|
|
22
|
+
"@douyinfe/semi-illustrations": "2.104.0",
|
|
23
|
+
"@douyinfe/semi-ui": "2.104.0",
|
|
24
|
+
"@tanstack/react-query": ">=5.0.0 <6",
|
|
25
|
+
"react": ">=18.0.0 <20",
|
|
26
|
+
"react-dom": ">=18.0.0 <20",
|
|
27
|
+
"react-router": ">=7.0.0 <9"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@douyinfe/semi-icons": "2.104.0",
|
|
31
|
+
"@douyinfe/semi-illustrations": "2.104.0",
|
|
32
|
+
"@douyinfe/semi-ui": "2.104.0",
|
|
33
|
+
"@tanstack/react-query": "^5.90.14",
|
|
34
|
+
"@types/node": "^22.15.0",
|
|
35
|
+
"@types/react": "^19.2.7",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
38
|
+
"react": "^19.2.3",
|
|
39
|
+
"react-dom": "^19.2.3",
|
|
40
|
+
"react-router": "7.9.6",
|
|
41
|
+
"vite": "^6.4.1",
|
|
42
|
+
"@24city/web-runtime": "0.2.0"
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
"./account": {
|
|
46
|
+
"types": "./dist/account/index.d.ts",
|
|
47
|
+
"import": "./dist/account/index.js",
|
|
48
|
+
"default": "./dist/account/index.js"
|
|
49
|
+
},
|
|
50
|
+
".": {
|
|
51
|
+
"types": "./dist/index.d.ts",
|
|
52
|
+
"import": "./dist/index.js",
|
|
53
|
+
"default": "./dist/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./layout": {
|
|
56
|
+
"types": "./dist/layout/index.d.ts",
|
|
57
|
+
"import": "./dist/layout/index.js",
|
|
58
|
+
"default": "./dist/layout/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./page": {
|
|
61
|
+
"types": "./dist/page/index.d.ts",
|
|
62
|
+
"import": "./dist/page/index.js",
|
|
63
|
+
"default": "./dist/page/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./runtime": {
|
|
66
|
+
"types": "./dist/runtime/index.d.ts",
|
|
67
|
+
"import": "./dist/runtime/index.js",
|
|
68
|
+
"default": "./dist/runtime/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./semi": {
|
|
71
|
+
"types": "./dist/semi.d.ts",
|
|
72
|
+
"import": "./dist/semi.js",
|
|
73
|
+
"default": "./dist/semi.js"
|
|
74
|
+
},
|
|
75
|
+
"./testing/fixtures": {
|
|
76
|
+
"types": "./dist/testing/fixtures.d.ts",
|
|
77
|
+
"import": "./dist/testing/fixtures.js",
|
|
78
|
+
"default": "./dist/testing/fixtures.js"
|
|
79
|
+
},
|
|
80
|
+
"./testing/guard": {
|
|
81
|
+
"types": "./dist/testing/guard.d.ts",
|
|
82
|
+
"import": "./dist/testing/guard.js",
|
|
83
|
+
"default": "./dist/testing/guard.js"
|
|
84
|
+
},
|
|
85
|
+
"./testing/jsdom": {
|
|
86
|
+
"types": "./dist/testing/jsdom.d.ts",
|
|
87
|
+
"import": "./dist/testing/jsdom.js",
|
|
88
|
+
"default": "./dist/testing/jsdom.js"
|
|
89
|
+
},
|
|
90
|
+
"./theme": {
|
|
91
|
+
"types": "./dist/theme/index.d.ts",
|
|
92
|
+
"import": "./dist/theme/index.js",
|
|
93
|
+
"default": "./dist/theme/index.js"
|
|
94
|
+
},
|
|
95
|
+
"./styles.css": "./dist/styles.css",
|
|
96
|
+
"./package.json": "./package.json"
|
|
97
|
+
},
|
|
98
|
+
"scripts": {
|
|
99
|
+
"build": "vite build && tsc -p tsconfig.build.json"
|
|
100
|
+
}
|
|
6
101
|
}
|