generator-mico-cli 0.2.13 → 0.2.15
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 +1 -1
- package/generators/micro-react/index.js +34 -10
- package/generators/micro-react/templates/.commitlintrc.js +1 -0
- package/generators/micro-react/templates/.cursor/rules/coding-conventions.mdc +1 -1
- package/generators/micro-react/templates/.cursor/rules/development-guide.mdc +1 -1
- package/generators/micro-react/templates/.cursor/rules/layout-app.mdc +2 -5
- package/generators/micro-react/templates/.cursor/rules/project-overview.mdc +2 -2
- package/generators/micro-react/templates/.cursor/rules/theme-system.mdc +10 -12
- package/generators/micro-react/templates/AGENTS.md +2 -2
- package/generators/micro-react/templates/CLAUDE.md +1 -2
- package/generators/micro-react/templates/README.md +2 -2
- package/generators/micro-react/templates/_npmrc +3 -0
- package/generators/micro-react/templates/apps/layout/config/config.dev.ts +15 -0
- package/generators/micro-react/templates/apps/layout/config/config.ts +4 -3
- package/generators/micro-react/templates/apps/layout/docs/common-intl.md +370 -0
- package/generators/micro-react/templates/apps/layout/docs/feature-404/351/241/265/351/235/242.md +2 -2
- package/generators/micro-react/templates/apps/layout/docs/feature-/344/270/273/351/242/230/350/211/262/345/210/207/346/215/242.md +21 -25
- package/generators/micro-react/templates/apps/layout/docs/feature-/345/276/256/345/211/215/347/253/257/346/250/241/345/274/217.md +15 -16
- package/generators/micro-react/templates/apps/layout/docs/feature-/350/217/234/345/215/225/346/235/203/351/231/220/346/216/247/345/210/266.md +1 -1
- package/generators/micro-react/templates/apps/layout/docs/utils-timezone.md +322 -0
- package/generators/micro-react/templates/apps/layout/mock/menus.ts +39 -1
- package/generators/micro-react/templates/apps/layout/package.json +5 -2
- package/generators/micro-react/templates/apps/layout/src/app.tsx +22 -10
- package/generators/micro-react/templates/apps/layout/src/common/auth/index.ts +3 -0
- package/generators/micro-react/templates/apps/layout/src/common/helpers.ts +177 -0
- package/generators/micro-react/templates/apps/layout/src/common/locale.ts +56 -4
- package/generators/micro-react/templates/apps/layout/src/common/menu/parser.ts +84 -5
- package/generators/micro-react/templates/apps/layout/src/common/menu/types.ts +13 -1
- package/generators/micro-react/templates/apps/layout/src/common/request/interceptors.ts +1 -1
- package/generators/micro-react/templates/apps/layout/src/common/request/sso.ts +7 -1
- package/generators/micro-react/templates/apps/layout/src/common/theme.ts +1 -1
- package/generators/micro-react/templates/apps/layout/src/common/upload/oss.ts +2 -3
- package/generators/micro-react/templates/apps/layout/src/components/AppTabs/index.less +8 -2
- package/generators/micro-react/templates/apps/layout/src/components/AppTabs/index.tsx +23 -6
- package/generators/micro-react/templates/apps/layout/src/components/HeaderDropdown/index.tsx +22 -0
- package/generators/micro-react/templates/apps/layout/src/components/IconFont/index.tsx +1 -1
- package/generators/micro-react/templates/apps/layout/src/components/MicroAppLoader/index.tsx +1 -1
- package/generators/micro-react/templates/apps/layout/src/components/RightContent/AvatarDropdown.tsx +388 -0
- package/generators/micro-react/templates/apps/layout/src/components/RightContent/avatar-dropdown.less +35 -0
- package/generators/micro-react/templates/apps/layout/src/components/RightContent/index.ts +2 -0
- package/generators/micro-react/templates/apps/layout/src/constants/index.ts +2 -0
- package/generators/micro-react/templates/apps/layout/src/global.less +3 -6
- package/generators/micro-react/templates/apps/layout/src/layouts/components/header/index.less +3 -1
- package/generators/micro-react/templates/apps/layout/src/layouts/components/header/index.tsx +8 -53
- package/generators/micro-react/templates/apps/layout/src/layouts/components/menu/index.less +3 -1
- package/generators/micro-react/templates/apps/layout/src/layouts/components/menu/index.tsx +4 -4
- package/generators/micro-react/templates/apps/layout/src/layouts/index.less +83 -13
- package/generators/micro-react/templates/apps/layout/src/layouts/index.tsx +40 -25
- package/generators/micro-react/templates/apps/layout/src/locales/en-US.ts +9 -0
- package/generators/micro-react/templates/apps/layout/src/locales/zh-CN.ts +9 -0
- package/generators/micro-react/templates/apps/layout/src/pages/403/index.tsx +2 -1
- package/generators/micro-react/templates/apps/layout/src/pages/404/index.tsx +1 -1
- package/generators/micro-react/templates/apps/layout/src/pages/Home/index.less +3 -0
- package/generators/micro-react/templates/apps/layout/src/pages/User/Login/index.less +1 -1
- package/generators/micro-react/templates/apps/layout/src/pages/User/Login/index.tsx +3 -3
- package/generators/micro-react/templates/apps/layout/src/requestErrorConfig.ts +1 -1
- package/generators/micro-react/templates/apps/layout/src/services/config/index.ts +63 -0
- package/generators/micro-react/templates/apps/layout/src/services/config/type.ts +32 -0
- package/generators/micro-react/templates/apps/layout/src/services/user.ts +23 -1
- package/generators/micro-react/templates/package.json +4 -1
- package/generators/micro-react/templates/packages/common-intl/.turbo/turbo-build.log +13 -0
- package/generators/micro-react/templates/packages/common-intl/README.md +427 -0
- package/generators/micro-react/templates/packages/common-intl/dist/index.d.ts +3 -0
- package/generators/micro-react/templates/packages/common-intl/dist/index.js +4388 -0
- package/generators/micro-react/templates/packages/common-intl/dist/indexedDBUtils.d.ts +13 -0
- package/generators/micro-react/templates/packages/common-intl/dist/intl.d.ts +1022 -0
- package/generators/micro-react/templates/packages/common-intl/dist/utils.d.ts +122 -0
- package/generators/micro-react/templates/packages/common-intl/package.json +34 -0
- package/generators/micro-react/templates/packages/common-intl/src/index.ts +7 -0
- package/generators/micro-react/templates/packages/common-intl/src/indexedDBUtils.ts +51 -0
- package/generators/micro-react/templates/packages/common-intl/src/intl.ts +5709 -0
- package/generators/micro-react/templates/packages/common-intl/src/utils.ts +481 -0
- package/generators/micro-react/templates/packages/common-intl/tsconfig.json +22 -0
- package/generators/micro-react/templates/packages/common-intl/vite.config.ts +25 -0
- package/generators/micro-react/templates/turbo.json +3 -0
- package/generators/subapp-react/index.js +13 -18
- package/generators/subapp-react/templates/homepage/README.md +3 -3
- package/generators/subapp-react/templates/homepage/config/config.dev.ts +8 -7
- package/generators/subapp-react/templates/homepage/config/config.prod.development.ts +2 -3
- package/generators/subapp-react/templates/homepage/config/config.prod.testing.ts +2 -3
- package/generators/subapp-react/templates/homepage/config/config.prod.ts +4 -5
- package/generators/subapp-react/templates/homepage/package.json +3 -2
- package/generators/subapp-react/templates/homepage/src/global.less +3 -3
- package/generators/subapp-react/templates/homepage/src/pages/index.less +2 -2
- package/generators/subapp-react/templates/homepage/src/pages/index.tsx +72 -33
- package/generators/subapp-react/templates/homepage/src/styles/theme.less +1 -1
- package/lib/utils.js +43 -0
- package/package.json +8 -11
- package/generators/micro-react/templates/packages/shared-styles/README.md +0 -124
- package/generators/micro-react/templates/packages/shared-styles/arco-design-mobile-override.less +0 -91
- package/generators/micro-react/templates/packages/shared-styles/arco-override.less +0 -119
- package/generators/micro-react/templates/packages/shared-styles/index.d.ts +0 -44
- package/generators/micro-react/templates/packages/shared-styles/index.less +0 -13
- package/generators/micro-react/templates/packages/shared-styles/package.json +0 -30
- package/generators/micro-react/templates/packages/shared-styles/theme-inject.less +0 -10
- package/generators/micro-react/templates/packages/shared-styles/themes/dark/custom-var.less +0 -290
- package/generators/micro-react/templates/packages/shared-styles/themes/normal/custom-var.less +0 -269
- package/generators/micro-react/templates/packages/shared-styles/variables-only.less +0 -433
- package/generators/micro-react/templates/packages/shared-styles/variables.less +0 -452
|
@@ -1,32 +1,60 @@
|
|
|
1
|
-
@import '
|
|
1
|
+
@import '@mico-platform/theme/variables';
|
|
2
|
+
|
|
3
|
+
.arco-tree-node:hover {
|
|
4
|
+
background-color: @color-fill-2;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
// 防止触发mac浏览器的双指水平滑动触发后退前进
|
|
9
|
+
overscroll-behavior-x: none;
|
|
10
|
+
}
|
|
2
11
|
|
|
3
12
|
.layout-container {
|
|
4
|
-
min-width:
|
|
13
|
+
min-width: @size-base * 128;
|
|
5
14
|
background: @color-fill-1;
|
|
6
|
-
overflow-x: auto;
|
|
7
|
-
overflow-y: hidden;
|
|
15
|
+
// overflow-x: auto;s
|
|
16
|
+
// overflow-y: hidden;
|
|
8
17
|
display: flex;
|
|
9
18
|
flex-direction: column;
|
|
19
|
+
// 适配子元素高度,覆盖 arco-layout 默认的 flex: 1
|
|
20
|
+
flex: none;
|
|
21
|
+
width: 100%;
|
|
10
22
|
|
|
11
23
|
.layout-content {
|
|
12
|
-
overflow: hidden;
|
|
24
|
+
// overflow: hidden;
|
|
13
25
|
flex: 1;
|
|
14
|
-
|
|
15
|
-
flex-direction: row;
|
|
26
|
+
margin-top: @header-height;
|
|
16
27
|
|
|
17
28
|
.layout-content-right {
|
|
18
|
-
padding: @spacing-md @spacing-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
padding: @spacing-md @spacing-md;
|
|
30
|
+
margin-left: var(--sider-width, @sidebar-width);
|
|
31
|
+
// flex: 1;
|
|
32
|
+
// display: flex;
|
|
33
|
+
// flex-direction: column;
|
|
34
|
+
// min-height: calc(100vh - @header-height);
|
|
35
|
+
// 当菜单折叠时,自适应调整 marginLeft
|
|
36
|
+
transition: margin-left 0.2s ease;
|
|
37
|
+
// overflow-y: auto;
|
|
38
|
+
// overflow: hidden auto;
|
|
39
|
+
|
|
40
|
+
.layout-content-scroll-container {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
min-height: 100%;
|
|
44
|
+
}
|
|
23
45
|
|
|
24
46
|
.layout-content-outlet {
|
|
25
47
|
flex: 1;
|
|
48
|
+
// overflow-y: scroll;
|
|
26
49
|
overflow: hidden;
|
|
27
50
|
background: none;
|
|
28
51
|
border-radius: @border-radius-lg;
|
|
29
52
|
position: relative;
|
|
53
|
+
|
|
54
|
+
--layout-content-outlet-margin-top: 32px;
|
|
55
|
+
|
|
56
|
+
margin-top: var(--layout-content-outlet-margin-top);
|
|
57
|
+
height: calc(100% - var(--layout-content-outlet-margin-top));
|
|
30
58
|
}
|
|
31
59
|
}
|
|
32
60
|
}
|
|
@@ -34,6 +62,10 @@
|
|
|
34
62
|
.arco-spin-children::after {
|
|
35
63
|
background-color: color-mix(in srgb, var(--color-text-5) 60%, transparent);
|
|
36
64
|
}
|
|
65
|
+
|
|
66
|
+
.arco-layout-sider-trigger {
|
|
67
|
+
background-color: @color-text-5;
|
|
68
|
+
}
|
|
37
69
|
}
|
|
38
70
|
|
|
39
71
|
.arco-form {
|
|
@@ -47,8 +79,9 @@
|
|
|
47
79
|
}
|
|
48
80
|
}
|
|
49
81
|
|
|
50
|
-
|
|
82
|
+
.mico-cs-sider {
|
|
51
83
|
box-shadow: none;
|
|
84
|
+
background-color: @color-text-5;
|
|
52
85
|
|
|
53
86
|
.arco-layout-sider-trigger {
|
|
54
87
|
display: flex;
|
|
@@ -57,6 +90,7 @@
|
|
|
57
90
|
|
|
58
91
|
.click-trigger-btn {
|
|
59
92
|
cursor: pointer;
|
|
93
|
+
// width: 100%;
|
|
60
94
|
display: flex;
|
|
61
95
|
}
|
|
62
96
|
|
|
@@ -69,3 +103,39 @@
|
|
|
69
103
|
justify-content: center;
|
|
70
104
|
}
|
|
71
105
|
}
|
|
106
|
+
|
|
107
|
+
.arco-drawer-header {
|
|
108
|
+
border-bottom: 1px solid @color-line-2;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.arco-drawer-footer {
|
|
112
|
+
border-top: 1px solid @color-line-2;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.arco-dropdown-menu {
|
|
116
|
+
border-color: @color-line-2;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.arco-message-success,
|
|
120
|
+
.arco-message-error,
|
|
121
|
+
.arco-message-warning,
|
|
122
|
+
.arco-message-loading {
|
|
123
|
+
border-color: @color-line-2;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 按钮样式覆盖
|
|
127
|
+
.arco-btn-secondary:not(.arco-btn-disabled) {
|
|
128
|
+
background-color: @color-fill-2;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.arco-btn-secondary:not(.arco-btn-disabled):not(.arco-btn-loading):hover {
|
|
132
|
+
background-color: @color-fill-3;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.arco-btn-secondary:not(.arco-btn-disabled):not(.arco-btn-loading):active {
|
|
136
|
+
background-color: @color-fill-4;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.arco-btn-secondary.arco-btn-disabled {
|
|
140
|
+
background-color: @color-fill-1;
|
|
141
|
+
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '@/constants';
|
|
16
16
|
import { useRoutePermissionRefresh } from '@/hooks/useRoutePermissionRefresh';
|
|
17
17
|
import ForbiddenPage from '@/pages/403';
|
|
18
|
-
import { Layout, Spin } from '@
|
|
18
|
+
import { Layout, Spin } from '@mico-platform/ui';
|
|
19
19
|
import { Outlet, useLocation, useModel } from '@umijs/max';
|
|
20
20
|
import React, { Suspense, useMemo } from 'react';
|
|
21
21
|
import LayoutHeader from './components/header';
|
|
@@ -91,7 +91,13 @@ const BasicLayout: React.FC = () => {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
return forbidden;
|
|
94
|
-
}, [
|
|
94
|
+
}, [
|
|
95
|
+
currentRoute,
|
|
96
|
+
allRoutes,
|
|
97
|
+
allowedRoutes,
|
|
98
|
+
location.pathname,
|
|
99
|
+
filterOptions,
|
|
100
|
+
]);
|
|
95
101
|
|
|
96
102
|
// 判断是否需要显示布局
|
|
97
103
|
const showLayout = !isNoLayoutRoute(location.pathname);
|
|
@@ -121,18 +127,20 @@ const BasicLayout: React.FC = () => {
|
|
|
121
127
|
<>
|
|
122
128
|
{/* 权限刷新中显示覆盖层,但不卸载 MicroAppLoader,避免子应用被中断 */}
|
|
123
129
|
{isRefreshing && (
|
|
124
|
-
<div
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
<div
|
|
131
|
+
style={{
|
|
132
|
+
position: 'absolute',
|
|
133
|
+
top: 0,
|
|
134
|
+
left: 0,
|
|
135
|
+
right: 0,
|
|
136
|
+
bottom: 0,
|
|
137
|
+
display: 'flex',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
justifyContent: 'center',
|
|
140
|
+
background: 'var(--color-bg-1)',
|
|
141
|
+
zIndex: 100,
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
136
144
|
<Spin dot />
|
|
137
145
|
</div>
|
|
138
146
|
)}
|
|
@@ -154,20 +162,25 @@ const BasicLayout: React.FC = () => {
|
|
|
154
162
|
|
|
155
163
|
// 权限刷新中,显示 loading(仅对非微应用路由)
|
|
156
164
|
if (isRefreshing) {
|
|
157
|
-
return
|
|
165
|
+
return (
|
|
166
|
+
<Spin
|
|
167
|
+
dot
|
|
168
|
+
style={{ width: '100%', marginTop: 100, textAlign: 'center' }}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
158
171
|
}
|
|
159
172
|
|
|
160
173
|
// 默认:使用 Outlet 渲染内部路由
|
|
161
174
|
return <Outlet />;
|
|
162
175
|
};
|
|
163
176
|
|
|
164
|
-
//
|
|
177
|
+
// 不需要布局的页面(仍需检查权限)
|
|
165
178
|
if (!showLayout) {
|
|
166
179
|
return (
|
|
167
180
|
<Suspense
|
|
168
181
|
fallback={<Spin dot style={{ width: '100%', marginTop: 100 }} />}
|
|
169
182
|
>
|
|
170
|
-
<
|
|
183
|
+
{isForbidden ? <ForbiddenPage /> : renderContent()}
|
|
171
184
|
</Suspense>
|
|
172
185
|
);
|
|
173
186
|
}
|
|
@@ -178,14 +191,16 @@ const BasicLayout: React.FC = () => {
|
|
|
178
191
|
<Layout className="layout-content">
|
|
179
192
|
<LayoutMenu />
|
|
180
193
|
<Layout className="layout-content-right">
|
|
181
|
-
<
|
|
182
|
-
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
194
|
+
<div className="layout-content-scroll-container">
|
|
195
|
+
<AppTabs />
|
|
196
|
+
<Content className="layout-content-outlet">
|
|
197
|
+
<Suspense
|
|
198
|
+
fallback={<Spin dot style={{ width: '100%', marginTop: 100 }} />}
|
|
199
|
+
>
|
|
200
|
+
{renderContent()}
|
|
201
|
+
</Suspense>
|
|
202
|
+
</Content>
|
|
203
|
+
</div>
|
|
189
204
|
</Layout>
|
|
190
205
|
</Layout>
|
|
191
206
|
</Layout>
|
|
@@ -17,4 +17,13 @@ export default {
|
|
|
17
17
|
|
|
18
18
|
'loading.text': 'Loading...',
|
|
19
19
|
'loading.error': 'Failed to load',
|
|
20
|
+
|
|
21
|
+
// AvatarDropdown
|
|
22
|
+
'avatar.language': 'Language',
|
|
23
|
+
'avatar.language.zh_CN': 'Simplified Chinese',
|
|
24
|
+
'avatar.language.en': 'English',
|
|
25
|
+
'avatar.theme': 'Theme',
|
|
26
|
+
'avatar.theme.light': 'Light Mode',
|
|
27
|
+
'avatar.theme.dark': 'Dark Mode',
|
|
28
|
+
'avatar.logout': 'Logout',
|
|
20
29
|
};
|
|
@@ -16,4 +16,13 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
'loading.text': '加载中...',
|
|
18
18
|
'loading.error': '加载失败',
|
|
19
|
+
|
|
20
|
+
// AvatarDropdown
|
|
21
|
+
'avatar.language': '语言',
|
|
22
|
+
'avatar.language.zh_CN': '简体中文',
|
|
23
|
+
'avatar.language.en': 'English',
|
|
24
|
+
'avatar.theme': '主题',
|
|
25
|
+
'avatar.theme.light': '浅色模式',
|
|
26
|
+
'avatar.theme.dark': '深色模式',
|
|
27
|
+
'avatar.logout': '退出登录',
|
|
19
28
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Result } from '@
|
|
1
|
+
import { Button, Result } from '@mico-platform/ui';
|
|
2
2
|
import { history } from '@umijs/max';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
@@ -10,6 +10,7 @@ const ForbiddenPage: React.FC = () => {
|
|
|
10
10
|
alignItems: 'center',
|
|
11
11
|
height: '100%',
|
|
12
12
|
minHeight: 400,
|
|
13
|
+
margin: '0 auto',
|
|
13
14
|
}}>
|
|
14
15
|
<Result
|
|
15
16
|
status="403"
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
type MenuFilterOptions,
|
|
6
6
|
} from '@/common/menu';
|
|
7
7
|
import { isAuthDisabled } from '@/constants';
|
|
8
|
-
import { Button, Result, Space } from '@
|
|
8
|
+
import { Button, Result, Space } from '@mico-platform/ui';
|
|
9
9
|
import { history, useModel } from '@umijs/max';
|
|
10
10
|
import React, { useMemo } from 'react';
|
|
11
11
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Button, Form, Input, Message, Space, Typography } from '@
|
|
2
|
-
import { IconLock, IconUser } from '@
|
|
1
|
+
import { Button, Form, Input, Message, Space, Typography } from '@mico-platform/ui';
|
|
2
|
+
import { IconLock, IconUser } from '@mico-platform/ui/icon';
|
|
3
3
|
import { useLocation, useModel,useNavigate } from '@umijs/max';
|
|
4
4
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
5
5
|
import { loginStaff } from '@/services/auth';
|
|
@@ -92,7 +92,7 @@ const LoginPage: React.FC = () => {
|
|
|
92
92
|
</svg>
|
|
93
93
|
</div>
|
|
94
94
|
<div className={styles.titleBlock}>
|
|
95
|
-
<Title
|
|
95
|
+
<Title className={styles.title}>
|
|
96
96
|
{window.__MICO_WORKSPACE__?.name}
|
|
97
97
|
</Title>
|
|
98
98
|
<Text className={styles.subTitle}><%= ProjectName %> Management Center</Text>
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createBusinessError,
|
|
4
4
|
notifyHostError,
|
|
5
5
|
} from '@/common/micro';
|
|
6
|
-
import { Message, Notification } from '@
|
|
6
|
+
import { Message, Notification } from '@mico-platform/ui';
|
|
7
7
|
import type { RequestConfig } from '@umijs/max';
|
|
8
8
|
|
|
9
9
|
// 错误处理方案: 错误类型
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { request } from '@/common/request';
|
|
2
|
+
import type {
|
|
3
|
+
IGetTimezoneListRequest,
|
|
4
|
+
IGetTimezoneListResponse,
|
|
5
|
+
ITimezone,
|
|
6
|
+
} from './type';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 静态时区列表(兜底配置)
|
|
10
|
+
* 当未配置 timezoneListUrl 时使用此静态列表
|
|
11
|
+
* 覆盖 UTC-12 到 UTC+14 共 27 个时区
|
|
12
|
+
*/
|
|
13
|
+
const STATIC_TIMEZONE_LIST: ITimezone[] = [
|
|
14
|
+
{ region: 'AZ', utc_offset: 3 },
|
|
15
|
+
{ region: 'BR', utc_offset: -3 },
|
|
16
|
+
{ region: 'DE', utc_offset: 1 },
|
|
17
|
+
{ region: 'FJ', utc_offset: 15 },
|
|
18
|
+
{ region: 'FR', utc_offset: 1 },
|
|
19
|
+
{ region: 'Global', utc_offset: 8 },
|
|
20
|
+
{ region: 'ID', utc_offset: 7 },
|
|
21
|
+
{ region: 'IN', utc_offset: 5 },
|
|
22
|
+
{ region: 'JP', utc_offset: 9 },
|
|
23
|
+
{ region: 'MECA', utc_offset: 3 },
|
|
24
|
+
{ region: 'MY', utc_offset: 8 },
|
|
25
|
+
{ region: 'PH', utc_offset: 8 },
|
|
26
|
+
{ region: 'PK', utc_offset: 5 },
|
|
27
|
+
{ region: 'TH', utc_offset: 7 },
|
|
28
|
+
{ region: 'TR', utc_offset: 3 },
|
|
29
|
+
{ region: 'TW', utc_offset: 8 },
|
|
30
|
+
{ region: 'US', utc_offset: -5 },
|
|
31
|
+
{ region: 'UU', utc_offset: -8 },
|
|
32
|
+
{ region: 'VN', utc_offset: 7 },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 获取时区配置
|
|
37
|
+
* 获取系统支持的时区配置列表
|
|
38
|
+
*
|
|
39
|
+
* - 如果配置了 window.__MICO_CONFIG__.timezoneListUrl,则请求该 API
|
|
40
|
+
* - 如果未配置,则返回静态时区列表
|
|
41
|
+
*/
|
|
42
|
+
export async function getTimezoneList(
|
|
43
|
+
payload: IGetTimezoneListRequest = {},
|
|
44
|
+
): Promise<IGetTimezoneListResponse> {
|
|
45
|
+
const timezoneListUrl = window.__MICO_CONFIG__?.timezoneListUrl;
|
|
46
|
+
|
|
47
|
+
// 未配置 API 地址时,返回静态时区列表
|
|
48
|
+
if (!timezoneListUrl) {
|
|
49
|
+
return {
|
|
50
|
+
result: { code: 0 },
|
|
51
|
+
timezone_list: STATIC_TIMEZONE_LIST,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 配置了 API 地址时,请求接口
|
|
56
|
+
return await request<IGetTimezoneListResponse>(timezoneListUrl, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
data: payload,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 导出类型
|
|
63
|
+
export type { ITimezone, IGetTimezoneListResponse } from './type';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置管理相关类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 时区信息
|
|
7
|
+
*/
|
|
8
|
+
export interface ITimezone {
|
|
9
|
+
/** UTC偏移量 */
|
|
10
|
+
utc_offset: number;
|
|
11
|
+
/** 时区地区 */
|
|
12
|
+
region: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 获取时区配置请求
|
|
17
|
+
*/
|
|
18
|
+
export interface IGetTimezoneListRequest {
|
|
19
|
+
// 空请求体
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 获取时区配置响应
|
|
24
|
+
*/
|
|
25
|
+
export interface IGetTimezoneListResponse {
|
|
26
|
+
result: {
|
|
27
|
+
code: number;
|
|
28
|
+
message?: string;
|
|
29
|
+
};
|
|
30
|
+
/** 时区列表 */
|
|
31
|
+
timezone_list?: ITimezone[];
|
|
32
|
+
}
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { request } from '@/common/request';
|
|
2
2
|
import type { IUserInfo } from '@/common/auth/type';
|
|
3
|
+
import { getCurrentLocale, type SupportedLocale } from '@/common/locale';
|
|
3
4
|
|
|
4
5
|
const USER_INFO_API = '/api/user/info';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* 语言代码到接口 lang 参数的映射
|
|
9
|
+
* - zh_CN: 1 (中文)
|
|
10
|
+
* - en: 2 (英文)
|
|
11
|
+
*/
|
|
12
|
+
const LOCALE_TO_LANG: Partial<Record<SupportedLocale, number>> = {
|
|
13
|
+
zh_CN: 1,
|
|
14
|
+
en: 2,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取当前语言对应的 API lang 参数
|
|
19
|
+
*/
|
|
20
|
+
function getApiLangParam(): number {
|
|
21
|
+
const locale = getCurrentLocale();
|
|
22
|
+
return LOCALE_TO_LANG[locale] ?? 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
6
25
|
export interface IUserInfoResponse {
|
|
7
26
|
code: number;
|
|
8
27
|
data: IUserInfo;
|
|
@@ -15,7 +34,10 @@ export interface IUserInfoResponse {
|
|
|
15
34
|
* @throws 当接口返回非 200 code 时抛出错误
|
|
16
35
|
*/
|
|
17
36
|
export async function fetchUserInfo(): Promise<IUserInfo> {
|
|
18
|
-
const
|
|
37
|
+
const lang = getApiLangParam();
|
|
38
|
+
const url = `${USER_INFO_API}?lang=${lang}`;
|
|
39
|
+
|
|
40
|
+
const response = await request<IUserInfoResponse>(url, {
|
|
19
41
|
method: 'GET',
|
|
20
42
|
skipProxy: true,
|
|
21
43
|
});
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
"pnpm": {
|
|
7
7
|
"overrides": {
|
|
8
8
|
"@types/react": "^18.3.26",
|
|
9
|
-
"@types/react-dom": "^18.3.7"
|
|
9
|
+
"@types/react-dom": "^18.3.7",
|
|
10
|
+
"@mico-platform/hooks": "^0.0.1",
|
|
11
|
+
"@mico-platform/utils": "^0.0.1"
|
|
10
12
|
}
|
|
11
13
|
},
|
|
12
14
|
"scripts": {
|
|
@@ -18,6 +20,7 @@
|
|
|
18
20
|
"build:local": "dotenv -e .env -e .env.local -- turbo run build:local && node scripts/collect-dist.js",
|
|
19
21
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx && turbo run lint",
|
|
20
22
|
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix && turbo run lint:fix",
|
|
23
|
+
"check-types": "turbo run check-types",
|
|
21
24
|
"lint-staged": "pnpm exec lint-staged --quiet",
|
|
22
25
|
"prepare": "husky install",
|
|
23
26
|
"test": "dotenv -e .env -e .env.local -- turbo run test",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @portal-web/common-intl@0.0.1 build /Users/mico/projects/portal-web/packages/common-intl
|
|
4
|
+
> vite build && tsc --emitDeclarationOnly
|
|
5
|
+
|
|
6
|
+
[36mvite v7.3.1 [32mbuilding client environment for production...[36m[39m
|
|
7
|
+
[2K[1Gtransforming (1) [2msrc/index.ts[22m[2K[1G[32m✓[39m 4 modules transformed.
|
|
8
|
+
[2K[1Grendering chunks (1)...[2K[1G[32m
|
|
9
|
+
[36m[vite:dts][32m Start generate declaration files...[39m
|
|
10
|
+
[2K[1Gcomputing gzip size (0)...[2K[1Gcomputing gzip size (1)...[2K[1G[2mdist/[22m[36mindex.js [39m[1m[2m155.52 kB[22m[1m[22m[2m │ gzip: 21.87 kB[22m
|
|
11
|
+
[32m[36m[vite:dts][32m Declaration files built in 808ms.
|
|
12
|
+
[39m
|
|
13
|
+
[32m✓ built in 957ms[39m
|