@qlover/create-app 0.3.2 → 0.3.4
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 +139 -0
- package/package.json +4 -4
- package/templates/react-app/README.md +311 -120
- package/templates/react-app/config/Identifier.I18n.ts +1048 -0
- package/templates/react-app/config/app.router.json +7 -7
- package/templates/react-app/config/common.ts +13 -0
- package/templates/react-app/config/theme.json +7 -88
- package/templates/react-app/package.json +11 -5
- package/templates/react-app/postcss.config.js +1 -2
- package/templates/react-app/public/locales/en/common.json +142 -1
- package/templates/react-app/public/locales/zh/common.json +142 -1
- package/templates/react-app/src/App.tsx +16 -3
- package/templates/react-app/src/base/apis/AiApi.ts +4 -4
- package/templates/react-app/src/base/apis/feApi/FeApiAdapter.ts +2 -2
- package/templates/react-app/src/base/apis/userApi/UserApiAdapter.ts +2 -2
- package/templates/react-app/src/base/cases/AppConfig.ts +103 -0
- package/templates/react-app/src/base/cases/{appError/AppError.ts → AppError.ts} +0 -3
- package/templates/react-app/src/base/cases/DialogHandler.ts +86 -0
- package/templates/react-app/src/base/cases/RequestLogger.ts +1 -1
- package/templates/react-app/src/base/cases/RouterLoader.ts +166 -0
- package/templates/react-app/src/base/port/InteractionHubInterface.ts +94 -0
- package/templates/react-app/src/base/services/I18nService.ts +50 -3
- package/templates/react-app/src/base/services/ProcesserService.ts +0 -1
- package/templates/react-app/src/base/types/deprecated-antd.d.ts +60 -0
- package/templates/react-app/src/core/IOC.ts +18 -8
- package/templates/react-app/src/core/bootstrap.ts +41 -62
- package/templates/react-app/src/core/bootstraps/PrintBootstrap.ts +14 -0
- package/templates/react-app/src/core/bootstraps/index.ts +36 -7
- package/templates/react-app/src/core/globals.ts +8 -1
- package/templates/react-app/src/core/registers/RegisterApi.ts +2 -5
- package/templates/react-app/src/core/registers/RegisterCommon.ts +38 -29
- package/templates/react-app/src/core/registers/RegisterControllers.ts +5 -10
- package/templates/react-app/src/core/registers/RegisterGlobals.ts +21 -17
- package/templates/react-app/src/core/registers/index.ts +27 -13
- package/templates/react-app/src/main.tsx +1 -1
- package/templates/react-app/src/pages/404.tsx +1 -1
- package/templates/react-app/src/pages/500.tsx +1 -1
- package/templates/react-app/src/pages/auth/Login.tsx +128 -36
- package/templates/react-app/src/pages/base/About.tsx +118 -2
- package/templates/react-app/src/pages/base/ErrorIdentifier.tsx +38 -19
- package/templates/react-app/src/pages/base/Executor.tsx +442 -29
- package/templates/react-app/src/pages/base/Home.tsx +99 -93
- package/templates/react-app/src/pages/base/JSONStorage.tsx +47 -38
- package/templates/react-app/src/pages/base/Layout.tsx +5 -2
- package/templates/react-app/src/pages/base/Request.tsx +90 -208
- package/templates/react-app/src/pages/base/components/BaseHeader.tsx +13 -5
- package/templates/react-app/src/styles/css/antd-themes/_default.css +239 -0
- package/templates/react-app/src/styles/css/antd-themes/dark.css +176 -0
- package/templates/react-app/src/styles/css/antd-themes/index.css +3 -0
- package/templates/react-app/src/styles/css/antd-themes/no-context.css +34 -0
- package/templates/react-app/src/styles/css/antd-themes/pink.css +199 -0
- package/templates/react-app/src/{uikit/styles → styles}/css/index.css +3 -0
- package/templates/react-app/src/styles/css/page.css +11 -0
- package/templates/react-app/src/styles/css/tailwind.css +5 -0
- package/templates/react-app/src/styles/css/themes/_default.css +29 -0
- package/templates/react-app/src/styles/css/themes/dark.css +29 -0
- package/templates/react-app/src/styles/css/themes/index.css +3 -0
- package/templates/react-app/src/styles/css/themes/pink.css +29 -0
- package/templates/react-app/src/uikit/components/LanguageSwitcher.tsx +56 -0
- package/templates/react-app/src/uikit/components/Loading.tsx +27 -21
- package/templates/react-app/src/uikit/components/RouterRenderComponent.tsx +1 -1
- package/templates/react-app/src/uikit/components/ThemeSwitcher.tsx +63 -13
- package/templates/react-app/src/uikit/contexts/BaseRouteContext.ts +1 -1
- package/templates/react-app/src/uikit/controllers/RouterController.ts +1 -1
- package/templates/react-app/src/uikit/controllers/UserController.ts +2 -2
- package/templates/react-app/tailwind.config.js +1 -15
- package/templates/react-app/tsconfig.json +3 -2
- package/templates/react-app/tsconfig.node.json +2 -1
- package/templates/react-app/vite.config.ts +15 -3
- package/templates/react-app/lib/tailwind/root10px.js +0 -178
- package/templates/react-app/lib/tailwind/theme-generator.js +0 -238
- package/templates/react-app/public/locales/en/about.json +0 -3
- package/templates/react-app/public/locales/en/executor.json +0 -6
- package/templates/react-app/public/locales/en/home.json +0 -10
- package/templates/react-app/public/locales/en/jsonStorage.json +0 -11
- package/templates/react-app/public/locales/en/login.json +0 -7
- package/templates/react-app/public/locales/en/request.json +0 -15
- package/templates/react-app/public/locales/zh/about.json +0 -3
- package/templates/react-app/public/locales/zh/executor.json +0 -6
- package/templates/react-app/public/locales/zh/home.json +0 -10
- package/templates/react-app/public/locales/zh/jsonStorage.json +0 -11
- package/templates/react-app/public/locales/zh/login.json +0 -7
- package/templates/react-app/public/locales/zh/request.json +0 -15
- package/templates/react-app/src/base/cases/router-loader/index.ts +0 -90
- package/templates/react-app/src/base/port/InversifyIocInterface.ts +0 -9
- package/templates/react-app/src/core/AppConfig.ts +0 -36
- package/templates/react-app/src/uikit/styles/css/page.css +0 -3
- package/templates/react-app/src/uikit/styles/css/tailwind.css +0 -3
- /package/templates/react-app/config/{ErrorIdentifier.ts → Identifier.Error.ts} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* theme variables - for tailwind */
|
|
2
|
+
@layer base {
|
|
3
|
+
:root {
|
|
4
|
+
/* 基础背景色 */
|
|
5
|
+
--color-bg-base: 255 255 255;
|
|
6
|
+
--color-bg-secondary: 241 245 249; /* slate-100 */
|
|
7
|
+
--color-bg-elevated: 248 250 252; /* slate-50 */
|
|
8
|
+
|
|
9
|
+
/* 文字颜色 */
|
|
10
|
+
--color-text-primary: 15 23 42; /* slate-900 */
|
|
11
|
+
--color-text-secondary: 71 85 105; /* slate-600 */
|
|
12
|
+
--color-text-tertiary: 100 116 139; /* slate-500 */
|
|
13
|
+
|
|
14
|
+
/* 边框颜色 */
|
|
15
|
+
--color-border: 226 232 240; /* slate-200 */
|
|
16
|
+
|
|
17
|
+
/* 品牌色 */
|
|
18
|
+
--color-brand: 37 99 235; /* blue-600 */
|
|
19
|
+
--color-brand-hover: 59 130 246; /* blue-500 */
|
|
20
|
+
|
|
21
|
+
/* 登录页特定样式 */
|
|
22
|
+
--login-card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
23
|
+
--login-input-bg: var(--fe-color-bg-container);
|
|
24
|
+
--login-input-border: var(--fe-color-border);
|
|
25
|
+
--login-button-text: rgb(255 255 255);
|
|
26
|
+
--login-social-button-bg: var(--fe-color-bg-container);
|
|
27
|
+
--login-social-button-border: var(--fe-color-border);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* theme variables - for tailwind */
|
|
2
|
+
@layer base {
|
|
3
|
+
[data-theme='dark'] {
|
|
4
|
+
/* 基础背景色 */
|
|
5
|
+
--color-bg-base: 15 23 42; /* slate-900 */
|
|
6
|
+
--color-bg-secondary: 30 41 59; /* slate-800 */
|
|
7
|
+
--color-bg-elevated: 51 65 85; /* slate-700 */
|
|
8
|
+
|
|
9
|
+
/* 文字颜色 */
|
|
10
|
+
--color-text-primary: 255 255 255;
|
|
11
|
+
--color-text-secondary: 148 163 184; /* slate-400 */
|
|
12
|
+
--color-text-tertiary: 100 116 139; /* slate-500 */
|
|
13
|
+
|
|
14
|
+
/* 边框颜色 */
|
|
15
|
+
--color-border: 51 65 85; /* slate-700 */
|
|
16
|
+
|
|
17
|
+
/* 品牌色 */
|
|
18
|
+
--color-brand: 37 99 235; /* blue-600 */
|
|
19
|
+
--color-brand-hover: 59 130 246; /* blue-500 */
|
|
20
|
+
|
|
21
|
+
/* 登录页特定样式 */
|
|
22
|
+
--login-card-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
|
23
|
+
--login-input-bg: var(--fe-color-bg-container);
|
|
24
|
+
--login-input-border: var(--fe-color-border);
|
|
25
|
+
--login-button-text: rgb(255 255 255);
|
|
26
|
+
--login-social-button-bg: var(--fe-color-bg-container);
|
|
27
|
+
--login-social-button-border: var(--fe-color-border);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* theme variables - for tailwind */
|
|
2
|
+
@layer base {
|
|
3
|
+
[data-theme='pink'] {
|
|
4
|
+
/* 基础背景色 */
|
|
5
|
+
--color-bg-base: 255 241 242; /* rose-50 */
|
|
6
|
+
--color-bg-secondary: 255 228 230; /* rose-100 */
|
|
7
|
+
--color-bg-elevated: 254 205 211; /* rose-200 */
|
|
8
|
+
|
|
9
|
+
/* 文字颜色 */
|
|
10
|
+
--color-text-primary: 190 18 60; /* rose-700 */
|
|
11
|
+
--color-text-secondary: 225 29 72; /* rose-600 */
|
|
12
|
+
--color-text-tertiary: 244 63 94; /* rose-500 */
|
|
13
|
+
|
|
14
|
+
/* 边框颜色 */
|
|
15
|
+
--color-border: 254 205 211; /* rose-200 */
|
|
16
|
+
|
|
17
|
+
/* 品牌色 */
|
|
18
|
+
--color-brand: 225 29 72; /* rose-600 */
|
|
19
|
+
--color-brand-hover: 244 63 94; /* rose-500 */
|
|
20
|
+
|
|
21
|
+
/* 登录页特定样式 */
|
|
22
|
+
--login-card-shadow: 0 4px 12px rgba(244 63 94 / 0.15);
|
|
23
|
+
--login-input-bg: var(--ant-color-bg-container);
|
|
24
|
+
--login-input-border: var(--ant-color-border);
|
|
25
|
+
--login-button-text: rgb(255 255 255);
|
|
26
|
+
--login-social-button-bg: var(--ant-color-bg-container);
|
|
27
|
+
--login-social-button-border: var(--ant-color-border);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Select } from 'antd';
|
|
2
|
+
import { GlobalOutlined } from '@ant-design/icons';
|
|
3
|
+
import { useNavigate, useParams } from 'react-router-dom';
|
|
4
|
+
import i18nConfig from '@config/i18n';
|
|
5
|
+
import { IOC } from '@/core/IOC';
|
|
6
|
+
import { I18nService, I18nServiceLocale } from '@/base/services/I18nService';
|
|
7
|
+
import { useCallback } from 'react';
|
|
8
|
+
import { useSliceStore } from '@qlover/slice-store-react';
|
|
9
|
+
|
|
10
|
+
const { supportedLngs } = i18nConfig;
|
|
11
|
+
|
|
12
|
+
export default function LanguageSwitcher() {
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const i18nService = IOC(I18nService);
|
|
15
|
+
const loading = useSliceStore(i18nService, i18nService.selector.loading);
|
|
16
|
+
const { lng } = useParams<{ lng: I18nServiceLocale }>();
|
|
17
|
+
const currentPath = window.location.pathname;
|
|
18
|
+
|
|
19
|
+
const languageOptions = supportedLngs.map((lang) => ({
|
|
20
|
+
key: lang,
|
|
21
|
+
value: lang,
|
|
22
|
+
label: (
|
|
23
|
+
<div className="flex items-center gap-2">
|
|
24
|
+
<GlobalOutlined />
|
|
25
|
+
<span>{lang.toUpperCase()}</span>
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const handleLanguageChange = useCallback(
|
|
31
|
+
async (newLang: I18nServiceLocale) => {
|
|
32
|
+
i18nService.changeLoading(true);
|
|
33
|
+
// Change i18n language
|
|
34
|
+
await i18nService.changeLanguage(newLang);
|
|
35
|
+
// Update URL path
|
|
36
|
+
const newPath = currentPath.replace(`/${lng}`, `/${newLang}`);
|
|
37
|
+
navigate(newPath);
|
|
38
|
+
i18nService.changeLoading(false);
|
|
39
|
+
},
|
|
40
|
+
[lng, currentPath, navigate, i18nService]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className="flex items-center gap-2">
|
|
45
|
+
<Select
|
|
46
|
+
loading={loading}
|
|
47
|
+
disabled={loading}
|
|
48
|
+
value={lng}
|
|
49
|
+
onChange={handleLanguageChange}
|
|
50
|
+
options={languageOptions}
|
|
51
|
+
style={{ width: 100 }}
|
|
52
|
+
className="min-w-24 max-w-full"
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Loading component
|
|
3
5
|
*
|
|
@@ -14,28 +16,32 @@
|
|
|
14
16
|
export function Loading({ fullscreen = false }: { fullscreen?: boolean }) {
|
|
15
17
|
return (
|
|
16
18
|
<div
|
|
17
|
-
className={
|
|
19
|
+
className={clsx('flex justify-center items-center', {
|
|
20
|
+
'fixed inset-0 backdrop-blur-sm z-50': fullscreen,
|
|
21
|
+
relative: !fullscreen
|
|
22
|
+
})}
|
|
23
|
+
style={{
|
|
24
|
+
backgroundColor: fullscreen
|
|
25
|
+
? 'var(--fe-color-bg-container)'
|
|
26
|
+
: 'transparent'
|
|
27
|
+
}}
|
|
18
28
|
>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
fill="currentColor"
|
|
36
|
-
d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
|
|
37
|
-
></path>
|
|
38
|
-
</svg>
|
|
29
|
+
<div className="flex space-x-3">
|
|
30
|
+
{[0, 1, 2].map((i) => (
|
|
31
|
+
<div
|
|
32
|
+
key={i}
|
|
33
|
+
className={clsx(
|
|
34
|
+
'w-3 h-3 rounded-full',
|
|
35
|
+
'bg-[var(--fe-color-primary)]',
|
|
36
|
+
'animate-[bounce_1s_ease-in-out_infinite]'
|
|
37
|
+
)}
|
|
38
|
+
style={{
|
|
39
|
+
animationDelay: `${i * 0.2}s`,
|
|
40
|
+
opacity: 0.6
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
))}
|
|
44
|
+
</div>
|
|
39
45
|
</div>
|
|
40
46
|
);
|
|
41
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Suspense } from 'react';
|
|
2
2
|
import { Loading } from './Loading';
|
|
3
3
|
import BaseRouteProvider from '@/uikit/providers/BaseRouteProvider';
|
|
4
|
-
import { RouterLoaderRender } from '@/base/cases/
|
|
4
|
+
import { RouterLoaderRender } from '@/base/cases/RouterLoader';
|
|
5
5
|
|
|
6
6
|
export const RouterRenderComponent: RouterLoaderRender = (route) => {
|
|
7
7
|
const Component = route.element();
|
|
@@ -2,6 +2,37 @@ import { IOC } from '@/core/IOC';
|
|
|
2
2
|
import { ThemeService } from '@qlover/corekit-bridge';
|
|
3
3
|
import { useSliceStore } from '@qlover/slice-store-react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Select } from 'antd';
|
|
6
|
+
import {
|
|
7
|
+
BulbOutlined,
|
|
8
|
+
BulbFilled,
|
|
9
|
+
HeartFilled,
|
|
10
|
+
HeartOutlined
|
|
11
|
+
} from '@ant-design/icons';
|
|
12
|
+
import clsx from 'clsx';
|
|
13
|
+
import { useMemo } from 'react';
|
|
14
|
+
import * as i18nKeys from '@config/Identifier.I18n';
|
|
15
|
+
|
|
16
|
+
const colorMap: Record<
|
|
17
|
+
string,
|
|
18
|
+
{ i18nkey: string; colors: string[]; icons: React.ElementType[] }
|
|
19
|
+
> = {
|
|
20
|
+
default: {
|
|
21
|
+
i18nkey: i18nKeys.HEADER_THEME_DEFAULT,
|
|
22
|
+
colors: ['text-text', 'text-text-secondary'],
|
|
23
|
+
icons: [BulbFilled, BulbOutlined]
|
|
24
|
+
},
|
|
25
|
+
dark: {
|
|
26
|
+
i18nkey: i18nKeys.HEADER_THEME_DARK,
|
|
27
|
+
colors: ['text-[#9333ea]', 'text-[#a855f7]'],
|
|
28
|
+
icons: [BulbFilled, BulbOutlined]
|
|
29
|
+
},
|
|
30
|
+
pink: {
|
|
31
|
+
i18nkey: i18nKeys.HEADER_THEME_PINK,
|
|
32
|
+
colors: ['text-[#f472b6]', 'text-[#ec4899]'],
|
|
33
|
+
icons: [HeartFilled, HeartOutlined]
|
|
34
|
+
}
|
|
35
|
+
};
|
|
5
36
|
|
|
6
37
|
export default function ThemeSwitcher() {
|
|
7
38
|
const themeService = IOC(ThemeService);
|
|
@@ -9,22 +40,41 @@ export default function ThemeSwitcher() {
|
|
|
9
40
|
const themes = themeService.getSupportedThemes();
|
|
10
41
|
const { t } = useTranslation('common');
|
|
11
42
|
|
|
43
|
+
const themeOptions = useMemo(() => {
|
|
44
|
+
return themes.map((themeName) => {
|
|
45
|
+
const { i18nkey, colors, icons } =
|
|
46
|
+
colorMap[themeName] || colorMap.default;
|
|
47
|
+
const [currentColor, normalColor] = colors;
|
|
48
|
+
const [CurrentIcon, NormalIcon] = icons;
|
|
49
|
+
const isSelf = theme === themeName;
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
key: themeName + i18nkey,
|
|
53
|
+
value: themeName,
|
|
54
|
+
label: (
|
|
55
|
+
<div
|
|
56
|
+
className={clsx(
|
|
57
|
+
'flex items-center gap-2',
|
|
58
|
+
isSelf ? currentColor : normalColor
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
{isSelf ? <CurrentIcon /> : <NormalIcon />}
|
|
62
|
+
<span>{t(i18nkey)}</span>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}, [theme, themes, t]);
|
|
68
|
+
|
|
12
69
|
return (
|
|
13
70
|
<div className="flex items-center gap-2">
|
|
14
|
-
<
|
|
15
|
-
{t('header.theme.label')}
|
|
16
|
-
</label>
|
|
17
|
-
<select
|
|
18
|
-
id="theme-select"
|
|
71
|
+
<Select
|
|
19
72
|
value={theme}
|
|
20
|
-
onChange={(
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</option>
|
|
26
|
-
))}
|
|
27
|
-
</select>
|
|
73
|
+
onChange={(value) => themeService.changeTheme(value)}
|
|
74
|
+
options={themeOptions}
|
|
75
|
+
style={{ width: 120 }}
|
|
76
|
+
className="min-w-40 max-w-full"
|
|
77
|
+
/>
|
|
28
78
|
</div>
|
|
29
79
|
);
|
|
30
80
|
}
|
|
@@ -5,7 +5,7 @@ import { RouteMeta } from '@/base/types/Page';
|
|
|
5
5
|
import { createContext } from 'react';
|
|
6
6
|
import merge from 'lodash/merge';
|
|
7
7
|
import i18nConfig from '@config/i18n';
|
|
8
|
-
import { WITHIN_PAGE_PROVIDER } from '@config/
|
|
8
|
+
import { WITHIN_PAGE_PROVIDER } from '@config/Identifier.Error';
|
|
9
9
|
|
|
10
10
|
const { defaultNS } = i18nConfig;
|
|
11
11
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RouteConfigValue } from '@/base/cases/
|
|
1
|
+
import type { RouteConfigValue } from '@/base/cases/RouterLoader';
|
|
2
2
|
import type { NavigateFunction, NavigateOptions } from 'react-router-dom';
|
|
3
3
|
import type { UIDependenciesInterface } from '@/base/port/UIDependenciesInterface';
|
|
4
4
|
import type { LoggerInterface } from '@qlover/logger';
|
|
@@ -9,8 +9,8 @@ import { inject, injectable } from 'inversify';
|
|
|
9
9
|
import { IOCIdentifier } from '@/core/IOC';
|
|
10
10
|
import { LoginInterface } from '@/base/port/LoginInterface';
|
|
11
11
|
import { UserApi } from '@/base/apis/userApi/UserApi';
|
|
12
|
-
import { AppError } from '@/base/cases/
|
|
13
|
-
import { LOCAL_NO_USER_TOKEN } from '@config/
|
|
12
|
+
import { AppError } from '@/base/cases/AppError';
|
|
13
|
+
import { LOCAL_NO_USER_TOKEN } from '@config/Identifier.Error';
|
|
14
14
|
import { SliceStore } from '@qlover/slice-store-react';
|
|
15
15
|
|
|
16
16
|
class UserControllerState {
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import root10px from './lib/tailwind/root10px';
|
|
2
|
-
import themeCreate from './lib/tailwind/theme-generator';
|
|
3
|
-
import themeConfig from './config/theme.json';
|
|
4
|
-
|
|
5
|
-
const theme = themeCreate(themeConfig.override);
|
|
6
|
-
|
|
7
|
-
/** @type {import('tailwindcss').Config} */
|
|
8
1
|
export default {
|
|
9
2
|
darkMode: 'class',
|
|
10
|
-
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}']
|
|
11
|
-
theme: {
|
|
12
|
-
extend: {
|
|
13
|
-
...root10px.themes,
|
|
14
|
-
colors: theme.colors
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
plugins: [root10px.plugin, theme.plugin]
|
|
3
|
+
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}']
|
|
18
4
|
};
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
"types": ["vite/client"],
|
|
21
21
|
"paths": {
|
|
22
22
|
"@/*": ["./src/*"],
|
|
23
|
-
"@config/*": ["./config/*"]
|
|
23
|
+
"@config/*": ["./config/*"],
|
|
24
|
+
"@lib/*": ["./lib/*"]
|
|
24
25
|
},
|
|
25
26
|
"experimentalDecorators": true
|
|
26
27
|
},
|
|
27
|
-
"include": ["src"],
|
|
28
|
+
"include": ["src", "lib/**/*.tsx"],
|
|
28
29
|
"references": [{ "path": "./tsconfig.node.json" }]
|
|
29
30
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { defineConfig } from 'vitest/config';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
|
-
import { envPrefix } from './config/common';
|
|
3
|
+
import { envPrefix, overrideAntdThemeMode } from './config/common';
|
|
4
4
|
import { name, version } from './package.json';
|
|
5
5
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
6
6
|
import envConfig from '@qlover/corekit-bridge/vite-env-config/index';
|
|
7
|
-
import ts2Locales from '@
|
|
7
|
+
import ts2Locales from '@brain-toolkit/ts2locales/vite';
|
|
8
8
|
import i18nConfig from './config/i18n';
|
|
9
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
10
|
+
import viteDeprecatedAntd from '@brain-toolkit/antd-theme-override/vite';
|
|
9
11
|
|
|
10
12
|
// https://vite.dev/config/
|
|
11
13
|
export default defineConfig({
|
|
12
14
|
plugins: [
|
|
15
|
+
tailwindcss(),
|
|
13
16
|
envConfig({
|
|
14
17
|
envPops: true,
|
|
15
18
|
envPrefix,
|
|
@@ -24,10 +27,19 @@ export default defineConfig({
|
|
|
24
27
|
locales: i18nConfig.supportedLngs as unknown as string[],
|
|
25
28
|
options: [
|
|
26
29
|
{
|
|
27
|
-
source: './config/
|
|
30
|
+
source: './config/Identifier.Error.ts',
|
|
31
|
+
target: './public/locales/{{lng}}/common.json'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
source: './config/Identifier.I18n.ts',
|
|
28
35
|
target: './public/locales/{{lng}}/common.json'
|
|
29
36
|
}
|
|
30
37
|
]
|
|
38
|
+
}),
|
|
39
|
+
viteDeprecatedAntd({
|
|
40
|
+
mode: overrideAntdThemeMode,
|
|
41
|
+
overriedCssFilePath: './src/styles/css/antd-themes/no-context.css',
|
|
42
|
+
targetPath: './src/base/types/deprecated-antd.d.ts'
|
|
31
43
|
})
|
|
32
44
|
],
|
|
33
45
|
envPrefix: envPrefix,
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import plugin from 'tailwindcss/plugin';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Tailwind CSS 配置 - 10px 根字体大小
|
|
5
|
-
*
|
|
6
|
-
* 注意事项:
|
|
7
|
-
* 1. 所有的 rem 值都基于 10px 计算
|
|
8
|
-
* 2. 16px = 1.6rem
|
|
9
|
-
* 3. spacing 中的值需要乘以 1.6 来保持与原来的单位一致
|
|
10
|
-
*
|
|
11
|
-
* 由于移动端开发需求,方便计算,重置像素 10px, 将默认 16px 变成 10px
|
|
12
|
-
*
|
|
13
|
-
* 但是 tailwind 中的单位间距都是有个 rem 做单位, 16px 变成 10px 基数改变, 需要在原来不变像素上用 10px 基数重写一遍
|
|
14
|
-
*
|
|
15
|
-
* @see https://redpixelthemes.com/blog/change-tailwindcss-base-font-size/
|
|
16
|
-
* @type {import('tailwindcss').Config['theme']}
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // 使用示例
|
|
20
|
-
* text-base -> 1.6rem -> 16px
|
|
21
|
-
* p-4 -> 1.6rem -> 16px
|
|
22
|
-
* w-40 -> 16rem -> 160px
|
|
23
|
-
*/
|
|
24
|
-
const root10pxThemes = {
|
|
25
|
-
lineHeight: {
|
|
26
|
-
3: '1.2rem',
|
|
27
|
-
4: '1.6rem',
|
|
28
|
-
5: '2.0rem',
|
|
29
|
-
6: '2.4rem',
|
|
30
|
-
7: '2.8rem',
|
|
31
|
-
8: '3.2rem',
|
|
32
|
-
9: '3.6rem',
|
|
33
|
-
10: '4.0rem',
|
|
34
|
-
none: 1,
|
|
35
|
-
tight: 1.25,
|
|
36
|
-
snug: 1.375,
|
|
37
|
-
normal: 1.5,
|
|
38
|
-
relaxed: 1.625,
|
|
39
|
-
loose: 2
|
|
40
|
-
},
|
|
41
|
-
maxWidth: {
|
|
42
|
-
xs: '32.0rem',
|
|
43
|
-
sm: '38.4rem',
|
|
44
|
-
md: '44.8rem',
|
|
45
|
-
lg: '51.2rem',
|
|
46
|
-
xl: '57.6rem',
|
|
47
|
-
'2xl': '67.2rem',
|
|
48
|
-
'3xl': '76.8rem',
|
|
49
|
-
'4xl': '89.6rem',
|
|
50
|
-
'5xl': '102.4rem',
|
|
51
|
-
'6xl': '115.2rem',
|
|
52
|
-
'7xl': '128.0rem'
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
// 为了兼容之前的写法,在10的倍数上以 16px 作为基准单位计算
|
|
57
|
-
// 默认是以 4的倍数作为基数计算间距,但是由于 html font-size 变为了 10px
|
|
58
|
-
// 现在版本从之前的16px -> 10px 整体缩小,所以,这里需要手动将间距放大,去适应以前的环境
|
|
59
|
-
// TODO: 后期将所有间距调整为基准值, 不使用放大值
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 因为之前版本 root size 为默认 16px, tailwind 默认就以 16px 为基准设置 spacing
|
|
63
|
-
*
|
|
64
|
-
* 而现在版本 root size 为 10px, 为了兼容以前代码, 将所有 spacing 重写
|
|
65
|
-
*
|
|
66
|
-
* @see https://tailwindcss.com/docs/customizing-spacing#default-spacing-scale
|
|
67
|
-
*
|
|
68
|
-
* 例如:
|
|
69
|
-
* 以前版本 1 -> 4px -> 0.25rem, 而现在 1 -> 4px -> 0.1rem
|
|
70
|
-
* 以前版本 4 -> 16px -> 1rem 而现在 4 -> 16px -> 1.6rem
|
|
71
|
-
*
|
|
72
|
-
* 注意只是 spaceing 使用这规则,也就是将默认的 px 间距用 10 重新换算一遍,间距并未改变
|
|
73
|
-
*/
|
|
74
|
-
spacing: {
|
|
75
|
-
0.5: '0.2rem',
|
|
76
|
-
1: '0.4rem',
|
|
77
|
-
1.5: '0.6rem',
|
|
78
|
-
2: '0.8rem',
|
|
79
|
-
2.5: '1rem',
|
|
80
|
-
3: '1.2rem',
|
|
81
|
-
3.5: '1.4rem',
|
|
82
|
-
4: '1.6rem',
|
|
83
|
-
5: '2rem',
|
|
84
|
-
6: '2.4rem',
|
|
85
|
-
7: '2.8rem',
|
|
86
|
-
8: '3.2rem',
|
|
87
|
-
9: '3.6rem',
|
|
88
|
-
10: '4rem',
|
|
89
|
-
11: '4.4rem',
|
|
90
|
-
12: '4.8rem',
|
|
91
|
-
14: '5.6rem',
|
|
92
|
-
16: '6.4rem',
|
|
93
|
-
20: '8rem',
|
|
94
|
-
24: '9.6rem',
|
|
95
|
-
28: '11.2rem',
|
|
96
|
-
32: '12.8rem',
|
|
97
|
-
36: '14.4rem',
|
|
98
|
-
40: '16rem',
|
|
99
|
-
44: '17.6rem',
|
|
100
|
-
48: '19.2rem',
|
|
101
|
-
52: '20.8rem',
|
|
102
|
-
56: '22.4rem',
|
|
103
|
-
60: '24rem',
|
|
104
|
-
64: '25.6rem',
|
|
105
|
-
72: '28.8rem',
|
|
106
|
-
80: '32rem',
|
|
107
|
-
96: '38.4rem'
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* 字体对应 font-size 和 line-height
|
|
112
|
-
*
|
|
113
|
-
* @see https://tailwindcss.com/docs/font-size
|
|
114
|
-
*/
|
|
115
|
-
fontSize: {
|
|
116
|
-
xxs: ['2rem', '1.2rem'],
|
|
117
|
-
xs: ['1.2rem', '1.6rem'],
|
|
118
|
-
sm: ['1.4rem', '2rem'],
|
|
119
|
-
base: ['1.6rem', '2.4rem'],
|
|
120
|
-
lg: ['1.8rem', '2.8rem'],
|
|
121
|
-
xl: ['2rem', '2.8rem'],
|
|
122
|
-
'2xl': ['2.4rem', '3.2rem'],
|
|
123
|
-
'3xl': ['3rem', '3.6rem'],
|
|
124
|
-
'4xl': ['3.6rem', '4rem'],
|
|
125
|
-
'5xl': ['4.8rem', 1],
|
|
126
|
-
'6xl': ['6rem', 1],
|
|
127
|
-
'7xl': ['7.2rem', 1],
|
|
128
|
-
'8xl': ['9.6rem', 1],
|
|
129
|
-
'9xl': ['12.8rem', 1],
|
|
130
|
-
12: ['1.2rem'],
|
|
131
|
-
14: ['1.4rem'],
|
|
132
|
-
16: ['1.6rem'],
|
|
133
|
-
18: ['1.8rem'],
|
|
134
|
-
20: ['2rem'],
|
|
135
|
-
22: ['2.2rem'],
|
|
136
|
-
24: ['2.4rem'],
|
|
137
|
-
26: ['2.6rem'],
|
|
138
|
-
32: ['3.2rem'],
|
|
139
|
-
34: ['3.4rem'],
|
|
140
|
-
36: ['3.6rem'],
|
|
141
|
-
40: ['4rem'],
|
|
142
|
-
46: ['4.6rem'],
|
|
143
|
-
50: ['5rem'],
|
|
144
|
-
54: ['5.4rem'],
|
|
145
|
-
60: ['6rem'],
|
|
146
|
-
70: ['7rem'],
|
|
147
|
-
80: ['8rem'],
|
|
148
|
-
90: ['9rem'],
|
|
149
|
-
100: ['10rem']
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
screens: {
|
|
153
|
-
/** @media (min-width: 375px) { ... } */
|
|
154
|
-
xs: '375px',
|
|
155
|
-
/** @media (min-width: 640px) { ... } */
|
|
156
|
-
sm: '640px',
|
|
157
|
-
/** @media (min-width: 768px) { ... } */
|
|
158
|
-
md: '768px',
|
|
159
|
-
/** @media (min-width: 1024px) { ... } */
|
|
160
|
-
lg: '1024px',
|
|
161
|
-
/** @media (min-width: 1280px) { ... } */
|
|
162
|
-
xl: '1280px',
|
|
163
|
-
/** @media (min-width: 1536px) { ... } */
|
|
164
|
-
'2xl': '1536px',
|
|
165
|
-
/** @media (min-width: 1640px) { ... } */
|
|
166
|
-
'3xl': '1640px',
|
|
167
|
-
/** @media (min-width: 1920px) { ... } */
|
|
168
|
-
maxxl: '1920px'
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const root10pxPlugin = plugin(({ addBase }) => {
|
|
173
|
-
addBase({
|
|
174
|
-
html: { fontSize: '10px' }
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
export default { themes: root10pxThemes, plugin: root10pxPlugin };
|