create-secra 0.1.11 → 1.0.2
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/README.md +15 -5
- package/README.zh-CN.md +15 -4
- package/antd-adapter-template/README.md +24 -0
- package/antd-adapter-template/index.html +16 -0
- package/antd-adapter-template/package-lock.json +3420 -0
- package/antd-adapter-template/package.json +20 -47
- package/antd-adapter-template/src/app/App.tsx +7 -0
- package/antd-adapter-template/src/app/layouts/AppLayout.tsx +163 -0
- package/antd-adapter-template/src/app/router.ts +26 -0
- package/antd-adapter-template/src/app/routes/RouteTitleSync.tsx +26 -0
- package/antd-adapter-template/src/app/routes/dynamic-routes.ts +52 -0
- package/antd-adapter-template/src/app/routes/route-modules.ts +4 -0
- package/antd-adapter-template/src/app/routes/static-routes.tsx +110 -0
- package/antd-adapter-template/src/app/routes/types.ts +9 -0
- package/antd-adapter-template/src/features/auth/api/auth-api.ts +61 -0
- package/antd-adapter-template/src/features/auth/auth-store.ts +125 -0
- package/antd-adapter-template/src/features/auth/auth-types.ts +29 -0
- package/antd-adapter-template/src/features/auth/authorization.ts +46 -0
- package/antd-adapter-template/src/features/auth/use-auth.ts +10 -0
- package/antd-adapter-template/src/main.tsx +79 -0
- package/antd-adapter-template/src/pages/dashboard/DashboardPage.tsx +105 -0
- package/antd-adapter-template/src/pages/errors/ForbiddenPage.tsx +36 -0
- package/antd-adapter-template/src/pages/errors/NotFoundPage.tsx +36 -0
- package/antd-adapter-template/src/pages/home/HomePage.tsx +129 -0
- package/antd-adapter-template/src/pages/login/LoginPage.tsx +128 -0
- package/antd-adapter-template/src/pages/permission-test/PermissionTestPage.tsx +55 -0
- package/antd-adapter-template/src/pages/restricted/RestrictedDemoPage.tsx +17 -0
- package/antd-adapter-template/src/shared/kernel/app-kernel.ts +10 -0
- package/antd-adapter-template/src/shared/request/client.ts +46 -0
- package/antd-adapter-template/src/shared/request/contracts.ts +6 -0
- package/antd-adapter-template/src/shared/request/kv-adapter.ts +14 -0
- package/antd-adapter-template/src/shared/request/kv-backend.ts +244 -0
- package/antd-adapter-template/src/shared/request/ky-browser-stub.ts +6 -0
- package/antd-adapter-template/src/shared/request/undici-browser-stub.ts +4 -0
- package/antd-adapter-template/src/styles/global.css +185 -0
- package/antd-adapter-template/src/vite-env.d.ts +2 -0
- package/antd-adapter-template/tsconfig.app.json +10 -13
- package/antd-adapter-template/tsconfig.json +7 -2
- package/antd-adapter-template/tsconfig.node.json +6 -16
- package/antd-adapter-template/vite.config.ts +24 -0
- package/bin/index.mjs +32 -14
- package/package.json +2 -2
- package/{antd-adapter-template/apps/core → template}/index.html +2 -3
- package/template/package.json +14 -46
- package/template/src/App.tsx +48 -0
- package/template/src/main.tsx +36 -0
- package/template/src/styles.css +163 -0
- package/template/src/vite-env.d.ts +1 -0
- package/template/tsconfig.app.json +0 -5
- package/template/tsconfig.node.json +0 -5
- package/template/vite.config.ts +6 -0
- package/antd-adapter-template/apps/core/package.json +0 -18
- package/antd-adapter-template/apps/core/public/favicon.ico +0 -1
- package/antd-adapter-template/apps/core/public/favicon.svg +0 -1
- package/antd-adapter-template/apps/core/public/logo.svg +0 -1
- package/antd-adapter-template/apps/core/src/api/auth.ts +0 -49
- package/antd-adapter-template/apps/core/src/assets/react.svg +0 -1
- package/antd-adapter-template/apps/core/src/components/AntdGlobalProvider.tsx +0 -87
- package/antd-adapter-template/apps/core/src/components/AntdRootLayout.tsx +0 -10
- package/antd-adapter-template/apps/core/src/components/layout.tsx +0 -387
- package/antd-adapter-template/apps/core/src/guards/auth-route-guard.ts +0 -45
- package/antd-adapter-template/apps/core/src/main.tsx +0 -65
- package/antd-adapter-template/apps/core/src/pages/auth/components/account-login-fields.tsx +0 -60
- package/antd-adapter-template/apps/core/src/pages/auth/components/phone-login-fields.tsx +0 -60
- package/antd-adapter-template/apps/core/src/pages/auth/login.tsx +0 -169
- package/antd-adapter-template/apps/core/src/pages/index.tsx +0 -156
- package/antd-adapter-template/apps/core/src/router.ts +0 -42
- package/antd-adapter-template/apps/core/src/shims/use-sync-external-store-shim.ts +0 -3
- package/antd-adapter-template/apps/core/src/theme/theme.css +0 -48
- package/antd-adapter-template/apps/core/src/types/crypto-js.d.ts +0 -5
- package/antd-adapter-template/apps/core/src/utils/index.ts +0 -12
- package/antd-adapter-template/apps/core/src/utils/md5.ts +0 -6
- package/antd-adapter-template/apps/core/tsconfig.app.json +0 -11
- package/antd-adapter-template/apps/core/tsconfig.json +0 -13
- package/antd-adapter-template/apps/core/tsconfig.node.json +0 -7
- package/antd-adapter-template/apps/core/vite.config.ts +0 -118
- package/antd-adapter-template/eslint.config.js +0 -23
- package/antd-adapter-template/packages/sdk/.swcrc +0 -18
- package/antd-adapter-template/packages/sdk/package.json +0 -52
- package/antd-adapter-template/packages/sdk/src/build/index.ts +0 -28
- package/antd-adapter-template/packages/sdk/src/build/plugins/auto-import.ts +0 -46
- package/antd-adapter-template/packages/sdk/src/build/plugins/bundle-analyzer.ts +0 -33
- package/antd-adapter-template/packages/sdk/src/build/plugins/remove-console.ts +0 -23
- package/antd-adapter-template/packages/sdk/src/build/plugins/unocss.ts +0 -202
- package/antd-adapter-template/packages/sdk/src/build/plugins/unplugin-icon.ts +0 -43
- package/antd-adapter-template/packages/sdk/src/components/i18n-switch-dropdown.tsx +0 -139
- package/antd-adapter-template/packages/sdk/src/components/index.ts +0 -2
- package/antd-adapter-template/packages/sdk/src/components/theme-switch-dropdown.tsx +0 -131
- package/antd-adapter-template/packages/sdk/src/hooks/auth/core.ts +0 -101
- package/antd-adapter-template/packages/sdk/src/hooks/auth/index.ts +0 -139
- package/antd-adapter-template/packages/sdk/src/hooks/auth/with-auth.tsx +0 -41
- package/antd-adapter-template/packages/sdk/src/hooks/index.ts +0 -1
- package/antd-adapter-template/packages/sdk/src/i18n/index.ts +0 -150
- package/antd-adapter-template/packages/sdk/src/index.ts +0 -11
- package/antd-adapter-template/packages/sdk/src/request/index.ts +0 -436
- package/antd-adapter-template/packages/sdk/src/storage/README.md +0 -30
- package/antd-adapter-template/packages/sdk/src/storage/index.ts +0 -57
- package/antd-adapter-template/packages/sdk/src/styles/reset.css +0 -111
- package/antd-adapter-template/packages/sdk/src/theme/index.ts +0 -466
- package/antd-adapter-template/packages/sdk/tsconfig.json +0 -16
- package/antd-adapter-template/pnpm-workspace.yaml +0 -3
- package/antd-adapter-template/turbo.json +0 -17
- package/template/apps/core/index.html +0 -13
- package/template/apps/core/package.json +0 -18
- package/template/apps/core/public/favicon.ico +0 -1
- package/template/apps/core/public/favicon.svg +0 -1
- package/template/apps/core/public/logo.svg +0 -1
- package/template/apps/core/src/assets/react.svg +0 -1
- package/template/apps/core/src/main.tsx +0 -14
- package/template/apps/core/src/pages/index.tsx +0 -84
- package/template/apps/core/src/router.ts +0 -19
- package/template/apps/core/src/types/auto-imports.d.ts +0 -130
- package/template/apps/core/tsconfig.app.json +0 -7
- package/template/apps/core/tsconfig.json +0 -7
- package/template/apps/core/tsconfig.node.json +0 -7
- package/template/apps/core/vite.config.ts +0 -86
- package/template/eslint.config.js +0 -23
- package/template/packages/sdk/.swcrc +0 -18
- package/template/packages/sdk/package-lock.json +0 -1621
- package/template/packages/sdk/package.json +0 -32
- package/template/packages/sdk/src/build/index.ts +0 -33
- package/template/packages/sdk/src/build/plugins/auto-import.ts +0 -47
- package/template/packages/sdk/src/build/plugins/bundle-analyzer.ts +0 -35
- package/template/packages/sdk/src/build/plugins/remove-console.ts +0 -21
- package/template/packages/sdk/src/build/plugins/unocss.ts +0 -113
- package/template/packages/sdk/src/build/plugins/unplugin-icon.ts +0 -43
- package/template/packages/sdk/src/index.ts +0 -1
- package/template/packages/sdk/src/request/index.ts +0 -341
- package/template/packages/sdk/src/styles/reset.css +0 -111
- package/template/packages/sdk/tsconfig.json +0 -16
- package/template/pnpm-lock.yaml +0 -8055
- package/template/pnpm-workspace.yaml +0 -3
- package/template/turbo.json +0 -17
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
import { useConfig, useTheme, type ThemeConfig, type ThemeContextValue } from '@vlian/framework/core';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import type { ConfigProviderProps } from 'antd';
|
|
4
|
-
|
|
5
|
-
export type ThemeMode = NonNullable<ThemeConfig['mode']>;
|
|
6
|
-
|
|
7
|
-
type ResolvedThemeMode = Exclude<ThemeMode, 'system'>;
|
|
8
|
-
|
|
9
|
-
type CssThemeTokenName =
|
|
10
|
-
| 'background'
|
|
11
|
-
| 'foreground'
|
|
12
|
-
| 'card'
|
|
13
|
-
| 'card-foreground'
|
|
14
|
-
| 'popover'
|
|
15
|
-
| 'popover-foreground'
|
|
16
|
-
| 'primary'
|
|
17
|
-
| 'primary-foreground'
|
|
18
|
-
| 'secondary'
|
|
19
|
-
| 'secondary-foreground'
|
|
20
|
-
| 'muted'
|
|
21
|
-
| 'muted-foreground'
|
|
22
|
-
| 'accent'
|
|
23
|
-
| 'accent-foreground'
|
|
24
|
-
| 'destructive'
|
|
25
|
-
| 'destructive-foreground'
|
|
26
|
-
| 'border'
|
|
27
|
-
| 'input'
|
|
28
|
-
| 'ring';
|
|
29
|
-
|
|
30
|
-
type CssThemeTokenMap = Partial<Record<CssThemeTokenName, string>>;
|
|
31
|
-
|
|
32
|
-
type CssThemeConfig = Partial<Record<ResolvedThemeMode, CssThemeTokenMap>>;
|
|
33
|
-
|
|
34
|
-
const MODE_CYCLE: readonly ThemeMode[] = ['light', 'dark', 'system'] as const;
|
|
35
|
-
|
|
36
|
-
const DEFAULT_THEME_TOKENS: Record<ResolvedThemeMode, Record<CssThemeTokenName, string>> = {
|
|
37
|
-
light: {
|
|
38
|
-
background: '0 0% 100%',
|
|
39
|
-
foreground: '222.2 84% 4.9%',
|
|
40
|
-
card: '0 0% 100%',
|
|
41
|
-
'card-foreground': '222.2 84% 4.9%',
|
|
42
|
-
popover: '0 0% 100%',
|
|
43
|
-
'popover-foreground': '222.2 84% 4.9%',
|
|
44
|
-
primary: '221.2 83.2% 53.3%',
|
|
45
|
-
'primary-foreground': '210 40% 98%',
|
|
46
|
-
secondary: '210 40% 96.1%',
|
|
47
|
-
'secondary-foreground': '222.2 47.4% 11.2%',
|
|
48
|
-
muted: '210 40% 96.1%',
|
|
49
|
-
'muted-foreground': '215.4 16.3% 46.9%',
|
|
50
|
-
accent: '210 40% 96.1%',
|
|
51
|
-
'accent-foreground': '222.2 47.4% 11.2%',
|
|
52
|
-
destructive: '0 84.2% 60.2%',
|
|
53
|
-
'destructive-foreground': '210 40% 98%',
|
|
54
|
-
border: '214.3 31.8% 91.4%',
|
|
55
|
-
input: '214.3 31.8% 91.4%',
|
|
56
|
-
ring: '221.2 83.2% 53.3%',
|
|
57
|
-
},
|
|
58
|
-
dark: {
|
|
59
|
-
background: '222.2 84% 4.9%',
|
|
60
|
-
foreground: '210 40% 98%',
|
|
61
|
-
card: '222.2 84% 4.9%',
|
|
62
|
-
'card-foreground': '210 40% 98%',
|
|
63
|
-
popover: '222.2 84% 4.9%',
|
|
64
|
-
'popover-foreground': '210 40% 98%',
|
|
65
|
-
primary: '217.2 91.2% 59.8%',
|
|
66
|
-
'primary-foreground': '222.2 47.4% 11.2%',
|
|
67
|
-
secondary: '217.2 32.6% 17.5%',
|
|
68
|
-
'secondary-foreground': '210 40% 98%',
|
|
69
|
-
muted: '217.2 32.6% 17.5%',
|
|
70
|
-
'muted-foreground': '215 20.2% 65.1%',
|
|
71
|
-
accent: '217.2 32.6% 17.5%',
|
|
72
|
-
'accent-foreground': '210 40% 98%',
|
|
73
|
-
destructive: '0 62.8% 30.6%',
|
|
74
|
-
'destructive-foreground': '210 40% 98%',
|
|
75
|
-
border: '217.2 32.6% 17.5%',
|
|
76
|
-
input: '217.2 32.6% 17.5%',
|
|
77
|
-
ring: '224.3 76.3% 48%',
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const normalizeMode = (mode: ThemeConfig['mode']): ThemeMode => {
|
|
82
|
-
if (mode === 'light' || mode === 'dark' || mode === 'system') {
|
|
83
|
-
return mode;
|
|
84
|
-
}
|
|
85
|
-
return 'light';
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const normalizeHexColor = (value: string): string | null => {
|
|
89
|
-
const hex = value.trim().replace(/^#/, '');
|
|
90
|
-
if (!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(hex)) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
if (hex.length === 3) {
|
|
94
|
-
return `#${hex
|
|
95
|
-
.split('')
|
|
96
|
-
.map((char) => `${char}${char}`)
|
|
97
|
-
.join('')}`;
|
|
98
|
-
}
|
|
99
|
-
return `#${hex}`;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const hexToHslTriplet = (hexColor: string): string | null => {
|
|
103
|
-
const normalizedHex = normalizeHexColor(hexColor);
|
|
104
|
-
if (!normalizedHex) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const hex = normalizedHex.slice(1);
|
|
109
|
-
const r = parseInt(hex.slice(0, 2), 16) / 255;
|
|
110
|
-
const g = parseInt(hex.slice(2, 4), 16) / 255;
|
|
111
|
-
const b = parseInt(hex.slice(4, 6), 16) / 255;
|
|
112
|
-
|
|
113
|
-
const max = Math.max(r, g, b);
|
|
114
|
-
const min = Math.min(r, g, b);
|
|
115
|
-
const delta = max - min;
|
|
116
|
-
|
|
117
|
-
let h = 0;
|
|
118
|
-
const l = (max + min) / 2;
|
|
119
|
-
const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
120
|
-
|
|
121
|
-
if (delta !== 0) {
|
|
122
|
-
if (max === r) {
|
|
123
|
-
h = ((g - b) / delta) % 6;
|
|
124
|
-
} else if (max === g) {
|
|
125
|
-
h = (b - r) / delta + 2;
|
|
126
|
-
} else {
|
|
127
|
-
h = (r - g) / delta + 4;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const hue = Math.round((h * 60 + 360) % 360);
|
|
132
|
-
const saturation = Number((s * 100).toFixed(1));
|
|
133
|
-
const lightness = Number((l * 100).toFixed(1));
|
|
134
|
-
return `${hue} ${saturation}% ${lightness}%`;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const readThemeTokenConfig = (custom: ThemeConfig['custom']): CssThemeConfig => {
|
|
138
|
-
const source = (custom as { tokens?: CssThemeConfig } | undefined)?.tokens;
|
|
139
|
-
return source ?? {};
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const hasTokenDiff = (current: CssThemeTokenMap | undefined, next: CssThemeTokenMap): boolean => {
|
|
143
|
-
for (const [key, value] of Object.entries(next)) {
|
|
144
|
-
if (current?.[key as CssThemeTokenName] !== value) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const getSystemDark = (): boolean => {
|
|
152
|
-
if (typeof window === 'undefined') {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const toHslColor = (triplet: string): string => `hsl(${triplet})`;
|
|
159
|
-
|
|
160
|
-
export interface ThemeSwitchContextValue extends ThemeContextValue {
|
|
161
|
-
mode: ThemeMode;
|
|
162
|
-
resolvedMode: ResolvedThemeMode;
|
|
163
|
-
setThemeMode: (mode: ThemeMode) => void;
|
|
164
|
-
toggleThemeMode: () => void;
|
|
165
|
-
cycleThemeMode: () => void;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface UnifiedThemeSwitchContextValue extends ThemeSwitchContextValue {
|
|
169
|
-
setAntdTheme: (nextTheme: NonNullable<ConfigProviderProps['theme']>) => void;
|
|
170
|
-
setThemeTokens: (mode: ResolvedThemeMode, tokens: CssThemeTokenMap) => void;
|
|
171
|
-
themeTokens: Record<CssThemeTokenName, string>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export const useThemeSwitch = (): UnifiedThemeSwitchContextValue => {
|
|
175
|
-
const themeContext = useTheme();
|
|
176
|
-
const configContext = useConfig();
|
|
177
|
-
const mode = normalizeMode(themeContext.theme.mode);
|
|
178
|
-
const [isSystemDark, setIsSystemDark] = useState<boolean>(getSystemDark);
|
|
179
|
-
const { setTheme } = themeContext;
|
|
180
|
-
const { setAntdConfig, antdConfig } = configContext;
|
|
181
|
-
const antdConfigRef = useRef(antdConfig);
|
|
182
|
-
const resolvedMode: ResolvedThemeMode = mode === 'system' ? (isSystemDark ? 'dark' : 'light') : mode;
|
|
183
|
-
|
|
184
|
-
useEffect(() => {
|
|
185
|
-
antdConfigRef.current = antdConfig;
|
|
186
|
-
}, [antdConfig]);
|
|
187
|
-
|
|
188
|
-
const setThemeMode = useCallback(
|
|
189
|
-
(nextMode: ThemeMode) => {
|
|
190
|
-
setTheme((prev) => {
|
|
191
|
-
const previous = prev ?? {};
|
|
192
|
-
if (previous.mode === nextMode) {
|
|
193
|
-
return previous;
|
|
194
|
-
}
|
|
195
|
-
return { ...previous, mode: nextMode };
|
|
196
|
-
});
|
|
197
|
-
},
|
|
198
|
-
[setTheme],
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
const toggleThemeMode = useCallback(() => {
|
|
202
|
-
const nextMode: ThemeMode = mode === 'dark' ? 'light' : 'dark';
|
|
203
|
-
setThemeMode(nextMode);
|
|
204
|
-
}, [mode, setThemeMode]);
|
|
205
|
-
|
|
206
|
-
const cycleThemeMode = useCallback(() => {
|
|
207
|
-
const index = MODE_CYCLE.indexOf(mode);
|
|
208
|
-
const nextMode = MODE_CYCLE[(index + 1) % MODE_CYCLE.length];
|
|
209
|
-
setThemeMode(nextMode);
|
|
210
|
-
}, [mode, setThemeMode]);
|
|
211
|
-
|
|
212
|
-
const setAntdTheme = useCallback(
|
|
213
|
-
(nextTheme: NonNullable<ConfigProviderProps['theme']>) => {
|
|
214
|
-
const currentAntdConfig = antdConfigRef.current;
|
|
215
|
-
const currentTheme = (currentAntdConfig as ConfigProviderProps | undefined)?.theme;
|
|
216
|
-
setAntdConfig({
|
|
217
|
-
...(currentAntdConfig ?? {}),
|
|
218
|
-
theme: {
|
|
219
|
-
...(currentTheme ?? {}),
|
|
220
|
-
...nextTheme,
|
|
221
|
-
token: {
|
|
222
|
-
...(currentTheme?.token ?? {}),
|
|
223
|
-
...(nextTheme.token ?? {}),
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
[setAntdConfig],
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
const setThemeTokens = useCallback(
|
|
232
|
-
(targetMode: ResolvedThemeMode, tokens: CssThemeTokenMap) => {
|
|
233
|
-
setTheme((prev) => {
|
|
234
|
-
const previous = prev ?? {};
|
|
235
|
-
const themeTokenConfig = readThemeTokenConfig(previous.custom);
|
|
236
|
-
const currentTokens = themeTokenConfig[targetMode];
|
|
237
|
-
if (!hasTokenDiff(currentTokens, tokens)) {
|
|
238
|
-
return previous;
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
...previous,
|
|
242
|
-
custom: {
|
|
243
|
-
...(previous.custom ?? {}),
|
|
244
|
-
tokens: {
|
|
245
|
-
...themeTokenConfig,
|
|
246
|
-
[targetMode]: {
|
|
247
|
-
...(themeTokenConfig[targetMode] ?? {}),
|
|
248
|
-
...tokens,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
};
|
|
253
|
-
});
|
|
254
|
-
},
|
|
255
|
-
[setTheme],
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
useEffect(() => {
|
|
259
|
-
if (typeof window === 'undefined') {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
263
|
-
const handleChange = (event: MediaQueryListEvent) => {
|
|
264
|
-
setIsSystemDark(event.matches);
|
|
265
|
-
};
|
|
266
|
-
setIsSystemDark(mediaQuery.matches);
|
|
267
|
-
if (typeof mediaQuery.addEventListener === 'function') {
|
|
268
|
-
mediaQuery.addEventListener('change', handleChange);
|
|
269
|
-
return () => {
|
|
270
|
-
mediaQuery.removeEventListener('change', handleChange);
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
mediaQuery.addListener(handleChange);
|
|
275
|
-
return () => {
|
|
276
|
-
mediaQuery.removeListener(handleChange);
|
|
277
|
-
};
|
|
278
|
-
}, []);
|
|
279
|
-
|
|
280
|
-
const effectiveThemeTokens = useMemo(() => {
|
|
281
|
-
const fromCustom = readThemeTokenConfig(themeContext.theme.custom)[resolvedMode] ?? {};
|
|
282
|
-
const primaryFromTheme = themeContext.theme.primaryColor ? hexToHslTriplet(themeContext.theme.primaryColor) : null;
|
|
283
|
-
const base = DEFAULT_THEME_TOKENS[resolvedMode];
|
|
284
|
-
const primary = fromCustom.primary ?? primaryFromTheme ?? base.primary;
|
|
285
|
-
return {
|
|
286
|
-
...base,
|
|
287
|
-
...fromCustom,
|
|
288
|
-
primary,
|
|
289
|
-
ring: fromCustom.ring ?? primary,
|
|
290
|
-
};
|
|
291
|
-
}, [resolvedMode, themeContext.theme.custom, themeContext.theme.primaryColor]);
|
|
292
|
-
|
|
293
|
-
useEffect(() => {
|
|
294
|
-
if (typeof document === 'undefined') {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
const root = document.documentElement;
|
|
298
|
-
const isDark = resolvedMode === 'dark';
|
|
299
|
-
root.classList.toggle('dark', isDark);
|
|
300
|
-
root.style.colorScheme = isDark ? 'dark' : 'light';
|
|
301
|
-
root.dataset.theme = resolvedMode;
|
|
302
|
-
}, [resolvedMode]);
|
|
303
|
-
|
|
304
|
-
useEffect(() => {
|
|
305
|
-
if (typeof document === 'undefined') {
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
const root = document.documentElement;
|
|
309
|
-
for (const [tokenName, tokenValue] of Object.entries(effectiveThemeTokens)) {
|
|
310
|
-
root.style.setProperty(`--${tokenName}`, tokenValue);
|
|
311
|
-
}
|
|
312
|
-
}, [effectiveThemeTokens]);
|
|
313
|
-
|
|
314
|
-
return {
|
|
315
|
-
...themeContext,
|
|
316
|
-
mode,
|
|
317
|
-
resolvedMode,
|
|
318
|
-
setThemeMode,
|
|
319
|
-
toggleThemeMode,
|
|
320
|
-
cycleThemeMode,
|
|
321
|
-
setAntdTheme,
|
|
322
|
-
setThemeTokens,
|
|
323
|
-
themeTokens: effectiveThemeTokens,
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
export interface UnifiedThemePreset {
|
|
328
|
-
key: string;
|
|
329
|
-
label: string;
|
|
330
|
-
primaryColor: string;
|
|
331
|
-
tokens?: Record<ResolvedThemeMode, CssThemeTokenMap>;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
export interface UseUnifiedThemePresetOptions {
|
|
335
|
-
defaultPresetKey?: string;
|
|
336
|
-
borderRadius?: number;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export interface UnifiedThemePresetContextValue extends UnifiedThemeSwitchContextValue {
|
|
340
|
-
presetKey: string;
|
|
341
|
-
setPresetKey: (presetKey: string) => void;
|
|
342
|
-
activePreset: UnifiedThemePreset | null;
|
|
343
|
-
applyPreset: (presetKey: string) => void;
|
|
344
|
-
setUnifiedPrimaryColor: (primaryColor: string) => void;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
export const useUnifiedThemePreset = (
|
|
348
|
-
presets: readonly UnifiedThemePreset[],
|
|
349
|
-
options?: UseUnifiedThemePresetOptions,
|
|
350
|
-
): UnifiedThemePresetContextValue => {
|
|
351
|
-
const themeSwitch = useThemeSwitch();
|
|
352
|
-
const { setTheme, setThemeTokens, setAntdTheme, themeTokens, theme } = themeSwitch;
|
|
353
|
-
const { defaultPresetKey, borderRadius = 8 } = options ?? {};
|
|
354
|
-
|
|
355
|
-
const fallbackPreset = presets[0] ?? null;
|
|
356
|
-
const [presetKey, setPresetKey] = useState<string>(defaultPresetKey ?? fallbackPreset?.key ?? '');
|
|
357
|
-
const antdSyncSignatureRef = useRef<string>('');
|
|
358
|
-
|
|
359
|
-
const activePreset = useMemo(() => {
|
|
360
|
-
if (presets.length === 0) {
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
363
|
-
return presets.find((item) => item.key === presetKey) ?? fallbackPreset;
|
|
364
|
-
}, [fallbackPreset, presetKey, presets]);
|
|
365
|
-
|
|
366
|
-
useEffect(() => {
|
|
367
|
-
try {
|
|
368
|
-
if (!activePreset) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
const expectedPrimary = activePreset.primaryColor;
|
|
372
|
-
const shouldSyncPrimary = theme.primaryColor !== expectedPrimary;
|
|
373
|
-
if (shouldSyncPrimary) {
|
|
374
|
-
setTheme((prev) => {
|
|
375
|
-
const previous = prev ?? {};
|
|
376
|
-
if (previous.primaryColor === expectedPrimary) {
|
|
377
|
-
return previous;
|
|
378
|
-
}
|
|
379
|
-
return { ...previous, primaryColor: expectedPrimary };
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
if (activePreset.tokens?.light) {
|
|
383
|
-
setThemeTokens('light', activePreset.tokens.light);
|
|
384
|
-
}
|
|
385
|
-
if (activePreset.tokens?.dark) {
|
|
386
|
-
setThemeTokens('dark', activePreset.tokens.dark);
|
|
387
|
-
}
|
|
388
|
-
} catch (error) {
|
|
389
|
-
console.error('[sdk/useUnifiedThemePreset] apply preset failed', error);
|
|
390
|
-
}
|
|
391
|
-
}, [activePreset, setTheme, setThemeTokens, theme.primaryColor]);
|
|
392
|
-
|
|
393
|
-
useEffect(() => {
|
|
394
|
-
try {
|
|
395
|
-
const signature = [
|
|
396
|
-
theme.primaryColor ?? '',
|
|
397
|
-
themeTokens.background,
|
|
398
|
-
themeTokens.card,
|
|
399
|
-
themeTokens.foreground,
|
|
400
|
-
themeTokens.border,
|
|
401
|
-
themeTokens.accent,
|
|
402
|
-
String(borderRadius),
|
|
403
|
-
].join('|');
|
|
404
|
-
if (antdSyncSignatureRef.current === signature) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
antdSyncSignatureRef.current = signature;
|
|
408
|
-
setAntdTheme({
|
|
409
|
-
token: {
|
|
410
|
-
colorPrimary: theme.primaryColor,
|
|
411
|
-
colorInfo: theme.primaryColor,
|
|
412
|
-
colorBgBase: toHslColor(themeTokens.background),
|
|
413
|
-
colorBgContainer: toHslColor(themeTokens.card),
|
|
414
|
-
colorTextBase: toHslColor(themeTokens.foreground),
|
|
415
|
-
colorBorder: toHslColor(themeTokens.border),
|
|
416
|
-
colorFillSecondary: toHslColor(themeTokens.accent),
|
|
417
|
-
borderRadius,
|
|
418
|
-
},
|
|
419
|
-
});
|
|
420
|
-
} catch (error) {
|
|
421
|
-
console.error('[sdk/useUnifiedThemePreset] sync antd theme failed', error);
|
|
422
|
-
}
|
|
423
|
-
}, [
|
|
424
|
-
borderRadius,
|
|
425
|
-
setAntdTheme,
|
|
426
|
-
theme.primaryColor,
|
|
427
|
-
themeTokens.accent,
|
|
428
|
-
themeTokens.background,
|
|
429
|
-
themeTokens.border,
|
|
430
|
-
themeTokens.card,
|
|
431
|
-
themeTokens.foreground,
|
|
432
|
-
]);
|
|
433
|
-
|
|
434
|
-
const applyPreset = useCallback((nextPresetKey: string) => {
|
|
435
|
-
setPresetKey(nextPresetKey);
|
|
436
|
-
}, []);
|
|
437
|
-
|
|
438
|
-
const setUnifiedPrimaryColor = useCallback(
|
|
439
|
-
(primaryColor: string) => {
|
|
440
|
-
try {
|
|
441
|
-
setTheme((prev) => {
|
|
442
|
-
const previous = prev ?? {};
|
|
443
|
-
return { ...previous, primaryColor };
|
|
444
|
-
});
|
|
445
|
-
const hsl = hexToHslTriplet(primaryColor);
|
|
446
|
-
if (!hsl) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
setThemeTokens('light', { primary: hsl, ring: hsl });
|
|
450
|
-
setThemeTokens('dark', { primary: hsl, ring: hsl });
|
|
451
|
-
} catch (error) {
|
|
452
|
-
console.error('[sdk/useUnifiedThemePreset] set primary failed', error);
|
|
453
|
-
}
|
|
454
|
-
},
|
|
455
|
-
[setTheme, setThemeTokens],
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
return {
|
|
459
|
-
...themeSwitch,
|
|
460
|
-
presetKey,
|
|
461
|
-
setPresetKey,
|
|
462
|
-
activePreset,
|
|
463
|
-
applyPreset,
|
|
464
|
-
setUnifiedPrimaryColor,
|
|
465
|
-
};
|
|
466
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"lib": ["ES2022", "DOM"],
|
|
6
|
-
"jsx": "react-jsx",
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"types": ["react", "react-dom"],
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"outDir": "dist"
|
|
14
|
-
},
|
|
15
|
-
"include": ["src"]
|
|
16
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://turbo.build/schema.json",
|
|
3
|
-
"tasks": {
|
|
4
|
-
"build": {
|
|
5
|
-
"dependsOn": ["^build"],
|
|
6
|
-
"outputs": ["dist/**", "build/**"]
|
|
7
|
-
},
|
|
8
|
-
"dev": {
|
|
9
|
-
"cache": false,
|
|
10
|
-
"persistent": true
|
|
11
|
-
},
|
|
12
|
-
"lint": {},
|
|
13
|
-
"test": {
|
|
14
|
-
"dependsOn": ["^test"]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>core</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "core",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.1",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "tsc -b && vite build",
|
|
9
|
-
"lint": "eslint .",
|
|
10
|
-
"preview": "vite preview"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
"overrides": {
|
|
16
|
-
"vite": "npm:rolldown-vite@7.2.5"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 109.07 100"><path fill="#24d6fe" d="M54.65 100l18.21-25.37H36.22L54.65 100z"/><path fill="#24d6fe" d="M72.86 24.94l-.07-.09L54.54 0 36.28 24.85l18.26 24.84 18.32 24.94 18.18 24.75 18.03-25.14-36.21-49.3z"/><path fill="#9e5df9" opacity=".5" d="M72.79 24.85L54.54 0 36.28 24.85l18.26 24.84 18.25-24.84z"/><path fill="#9e5df9" d="M36.22 49.69H18.03L0 74.24 18.09 99.3l18.13-24.67 18.32-24.94H36.22z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 109.07 100"><path fill="#24d6fe" d="M54.65 100l18.21-25.37H36.22L54.65 100z"/><path fill="#24d6fe" d="M72.86 24.94l-.07-.09L54.54 0 36.28 24.85l18.26 24.84 18.32 24.94 18.18 24.75 18.03-25.14-36.21-49.3z"/><path fill="#9e5df9" opacity=".5" d="M72.79 24.85L54.54 0 36.28 24.85l18.26 24.84 18.25-24.84z"/><path fill="#9e5df9" d="M36.22 49.69H18.03L0 74.24 18.09 99.3l18.13-24.67 18.32-24.94H36.22z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 109.07 100"><path fill="#24d6fe" d="M54.65 100l18.21-25.37H36.22L54.65 100z"/><path fill="#24d6fe" d="M72.86 24.94l-.07-.09L54.54 0 36.28 24.85l18.26 24.84 18.32 24.94 18.18 24.75 18.03-25.14-36.21-49.3z"/><path fill="#9e5df9" opacity=".5" d="M72.79 24.85L54.54 0 36.28 24.85l18.26 24.84 18.25-24.84z"/><path fill="#9e5df9" d="M36.22 49.69H18.03L0 74.24 18.09 99.3l18.13-24.67 18.32-24.94H36.22z"/></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import '@vlian/sdk/reset.css';
|
|
2
|
-
import { startApp } from '@vlian/framework/core';
|
|
3
|
-
import { getRoutes } from './router';
|
|
4
|
-
|
|
5
|
-
startApp({
|
|
6
|
-
router: {
|
|
7
|
-
enabled: true,
|
|
8
|
-
routes: getRoutes,
|
|
9
|
-
mode: 'browser',
|
|
10
|
-
},
|
|
11
|
-
}).catch((error) => {
|
|
12
|
-
// eslint-disable-next-line no-console
|
|
13
|
-
console.error('启动失败:', error);
|
|
14
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties } from "react";
|
|
2
|
-
import reactLogo from "../assets/react.svg";
|
|
3
|
-
|
|
4
|
-
const cardStyle: CSSProperties = {
|
|
5
|
-
border: "1px solid #e5e7eb",
|
|
6
|
-
borderRadius: 12,
|
|
7
|
-
padding: 16,
|
|
8
|
-
background: "#ffffff",
|
|
9
|
-
boxShadow: "0 6px 24px rgba(15, 23, 42, 0.06)",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const Home = () => {
|
|
13
|
-
return (
|
|
14
|
-
<main
|
|
15
|
-
style={{
|
|
16
|
-
minHeight: "100vh",
|
|
17
|
-
padding: "48px 20px",
|
|
18
|
-
background: "linear-gradient(180deg, #f8fafc 0%, #ffffff 100%)",
|
|
19
|
-
color: "#0f172a",
|
|
20
|
-
}}
|
|
21
|
-
>
|
|
22
|
-
<section style={{ maxWidth: 920, margin: "0 auto" }}>
|
|
23
|
-
<header style={{ display: "flex", alignItems: "center", gap: 16, marginBottom: 24 }}>
|
|
24
|
-
<img src={reactLogo} alt="React Logo" width={48} height={48} />
|
|
25
|
-
<div>
|
|
26
|
-
<h1 style={{ fontSize: 34, lineHeight: 1.2, margin: 0 }}>
|
|
27
|
-
React + Vite + Secra
|
|
28
|
-
</h1>
|
|
29
|
-
<p style={{ margin: "8px 0 0", color: "#475569" }}>
|
|
30
|
-
A fast starter template for modern frontend projects.
|
|
31
|
-
</p>
|
|
32
|
-
</div>
|
|
33
|
-
</header>
|
|
34
|
-
|
|
35
|
-
<div
|
|
36
|
-
style={{
|
|
37
|
-
display: "grid",
|
|
38
|
-
gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))",
|
|
39
|
-
gap: 14,
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
<article style={cardStyle}>
|
|
43
|
-
<h3 style={{ marginTop: 0 }}>React</h3>
|
|
44
|
-
<p style={{ margin: 0, color: "#475569" }}>
|
|
45
|
-
Build component-based UI with a clean and maintainable structure.
|
|
46
|
-
</p>
|
|
47
|
-
</article>
|
|
48
|
-
<article style={cardStyle}>
|
|
49
|
-
<h3 style={{ marginTop: 0 }}>Vite</h3>
|
|
50
|
-
<p style={{ margin: 0, color: "#475569" }}>
|
|
51
|
-
Enjoy instant startup and fast HMR for daily development.
|
|
52
|
-
</p>
|
|
53
|
-
</article>
|
|
54
|
-
<article style={cardStyle}>
|
|
55
|
-
<h3 style={{ marginTop: 0 }}>Secra</h3>
|
|
56
|
-
<p style={{ margin: 0, color: "#475569" }}>
|
|
57
|
-
Structured app bootstrap, routing and engineering defaults out of the box.
|
|
58
|
-
</p>
|
|
59
|
-
</article>
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
<section style={{ ...cardStyle, marginTop: 18 }}>
|
|
63
|
-
<h2 style={{ marginTop: 0, fontSize: 20 }}>Quick Start</h2>
|
|
64
|
-
<pre
|
|
65
|
-
style={{
|
|
66
|
-
margin: 0,
|
|
67
|
-
padding: 14,
|
|
68
|
-
borderRadius: 8,
|
|
69
|
-
background: "#0f172a",
|
|
70
|
-
color: "#e2e8f0",
|
|
71
|
-
overflowX: "auto",
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
{`pnpm install
|
|
75
|
-
pnpm -r --filter "./packages/*" build
|
|
76
|
-
pnpm dev`}
|
|
77
|
-
</pre>
|
|
78
|
-
</section>
|
|
79
|
-
</section>
|
|
80
|
-
</main>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default Home;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { RouteConfig } from "@vlian/framework/core"
|
|
2
|
-
|
|
3
|
-
const HomePage = lazy(() => import("./pages/index"));
|
|
4
|
-
|
|
5
|
-
export const getRoutes = async (): Promise<RouteConfig[]> => {
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
path: "/",
|
|
9
|
-
name: "home",
|
|
10
|
-
page: async () => ({
|
|
11
|
-
default: HomePage,
|
|
12
|
-
}),
|
|
13
|
-
handle: {
|
|
14
|
-
title: "首页",
|
|
15
|
-
order: 1,
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
]
|
|
19
|
-
}
|