generator-mico-cli 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +1 -1
  2. package/generators/micro-react/index.js +34 -10
  3. package/generators/micro-react/templates/.commitlintrc.js +1 -0
  4. package/generators/micro-react/templates/.cursor/rules/coding-conventions.mdc +1 -1
  5. package/generators/micro-react/templates/.cursor/rules/development-guide.mdc +1 -1
  6. package/generators/micro-react/templates/.cursor/rules/layout-app.mdc +2 -5
  7. package/generators/micro-react/templates/.cursor/rules/project-overview.mdc +2 -2
  8. package/generators/micro-react/templates/.cursor/rules/theme-system.mdc +10 -12
  9. package/generators/micro-react/templates/AGENTS.md +2 -2
  10. package/generators/micro-react/templates/CLAUDE.md +1 -2
  11. package/generators/micro-react/templates/README.md +2 -2
  12. package/generators/micro-react/templates/_npmrc +3 -0
  13. package/generators/micro-react/templates/apps/layout/config/config.dev.ts +15 -0
  14. package/generators/micro-react/templates/apps/layout/config/config.ts +4 -3
  15. package/generators/micro-react/templates/apps/layout/docs/common-intl.md +370 -0
  16. package/generators/micro-react/templates/apps/layout/docs/feature-404/351/241/265/351/235/242.md +2 -2
  17. 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
  18. 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
  19. 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
  20. package/generators/micro-react/templates/apps/layout/docs/utils-timezone.md +322 -0
  21. package/generators/micro-react/templates/apps/layout/mock/menus.ts +17 -1
  22. package/generators/micro-react/templates/apps/layout/package.json +5 -2
  23. package/generators/micro-react/templates/apps/layout/src/app.tsx +22 -10
  24. package/generators/micro-react/templates/apps/layout/src/common/auth/index.ts +3 -0
  25. package/generators/micro-react/templates/apps/layout/src/common/helpers.ts +177 -0
  26. package/generators/micro-react/templates/apps/layout/src/common/locale.ts +56 -4
  27. package/generators/micro-react/templates/apps/layout/src/common/menu/parser.ts +84 -5
  28. package/generators/micro-react/templates/apps/layout/src/common/menu/types.ts +13 -1
  29. package/generators/micro-react/templates/apps/layout/src/common/request/interceptors.ts +1 -1
  30. package/generators/micro-react/templates/apps/layout/src/common/request/sso.ts +7 -1
  31. package/generators/micro-react/templates/apps/layout/src/common/theme.ts +1 -1
  32. package/generators/micro-react/templates/apps/layout/src/common/upload/oss.ts +2 -3
  33. package/generators/micro-react/templates/apps/layout/src/components/AppTabs/index.less +8 -2
  34. package/generators/micro-react/templates/apps/layout/src/components/AppTabs/index.tsx +23 -6
  35. package/generators/micro-react/templates/apps/layout/src/components/HeaderDropdown/index.tsx +22 -0
  36. package/generators/micro-react/templates/apps/layout/src/components/IconFont/index.tsx +1 -1
  37. package/generators/micro-react/templates/apps/layout/src/components/MicroAppLoader/index.tsx +1 -1
  38. package/generators/micro-react/templates/apps/layout/src/components/RightContent/AvatarDropdown.tsx +388 -0
  39. package/generators/micro-react/templates/apps/layout/src/components/RightContent/avatar-dropdown.less +35 -0
  40. package/generators/micro-react/templates/apps/layout/src/components/RightContent/index.ts +2 -0
  41. package/generators/micro-react/templates/apps/layout/src/constants/index.ts +2 -0
  42. package/generators/micro-react/templates/apps/layout/src/global.less +3 -6
  43. package/generators/micro-react/templates/apps/layout/src/layouts/components/header/index.less +3 -1
  44. package/generators/micro-react/templates/apps/layout/src/layouts/components/header/index.tsx +9 -6
  45. package/generators/micro-react/templates/apps/layout/src/layouts/components/menu/index.less +3 -1
  46. package/generators/micro-react/templates/apps/layout/src/layouts/components/menu/index.tsx +4 -4
  47. package/generators/micro-react/templates/apps/layout/src/layouts/index.less +83 -13
  48. package/generators/micro-react/templates/apps/layout/src/layouts/index.tsx +40 -25
  49. package/generators/micro-react/templates/apps/layout/src/locales/en-US.ts +9 -0
  50. package/generators/micro-react/templates/apps/layout/src/locales/zh-CN.ts +9 -0
  51. package/generators/micro-react/templates/apps/layout/src/pages/403/index.tsx +2 -1
  52. package/generators/micro-react/templates/apps/layout/src/pages/404/index.tsx +1 -1
  53. package/generators/micro-react/templates/apps/layout/src/pages/Home/index.less +3 -0
  54. package/generators/micro-react/templates/apps/layout/src/pages/User/Login/index.less +1 -1
  55. package/generators/micro-react/templates/apps/layout/src/pages/User/Login/index.tsx +3 -3
  56. package/generators/micro-react/templates/apps/layout/src/requestErrorConfig.ts +1 -1
  57. package/generators/micro-react/templates/apps/layout/src/services/config/index.ts +63 -0
  58. package/generators/micro-react/templates/apps/layout/src/services/config/type.ts +32 -0
  59. package/generators/micro-react/templates/apps/layout/src/services/user.ts +23 -1
  60. package/generators/micro-react/templates/package.json +4 -1
  61. package/generators/micro-react/templates/packages/common-intl/.turbo/turbo-build.log +13 -0
  62. package/generators/micro-react/templates/packages/common-intl/README.md +428 -0
  63. package/generators/micro-react/templates/packages/common-intl/dist/index.d.ts +3 -0
  64. package/generators/micro-react/templates/packages/common-intl/dist/index.js +4388 -0
  65. package/generators/micro-react/templates/packages/common-intl/dist/indexedDBUtils.d.ts +13 -0
  66. package/generators/micro-react/templates/packages/common-intl/dist/intl.d.ts +1022 -0
  67. package/generators/micro-react/templates/packages/common-intl/dist/utils.d.ts +122 -0
  68. package/generators/micro-react/templates/packages/common-intl/package.json +34 -0
  69. package/generators/micro-react/templates/packages/common-intl/src/index.ts +7 -0
  70. package/generators/micro-react/templates/packages/common-intl/src/indexedDBUtils.ts +51 -0
  71. package/generators/micro-react/templates/packages/common-intl/src/intl.ts +5709 -0
  72. package/generators/micro-react/templates/packages/common-intl/src/utils.ts +481 -0
  73. package/generators/micro-react/templates/packages/common-intl/tsconfig.json +22 -0
  74. package/generators/micro-react/templates/packages/common-intl/vite.config.ts +25 -0
  75. package/generators/micro-react/templates/turbo.json +3 -0
  76. package/generators/subapp-react/index.js +13 -18
  77. package/generators/subapp-react/templates/homepage/README.md +3 -3
  78. package/generators/subapp-react/templates/homepage/config/config.dev.ts +8 -7
  79. package/generators/subapp-react/templates/homepage/config/config.prod.development.ts +2 -3
  80. package/generators/subapp-react/templates/homepage/config/config.prod.testing.ts +2 -3
  81. package/generators/subapp-react/templates/homepage/config/config.prod.ts +4 -5
  82. package/generators/subapp-react/templates/homepage/package.json +3 -2
  83. package/generators/subapp-react/templates/homepage/src/global.less +3 -3
  84. package/generators/subapp-react/templates/homepage/src/pages/index.less +2 -2
  85. package/generators/subapp-react/templates/homepage/src/pages/index.tsx +72 -33
  86. package/generators/subapp-react/templates/homepage/src/styles/theme.less +1 -1
  87. package/lib/utils.js +43 -0
  88. package/package.json +8 -11
  89. package/generators/micro-react/templates/packages/shared-styles/README.md +0 -124
  90. package/generators/micro-react/templates/packages/shared-styles/arco-design-mobile-override.less +0 -91
  91. package/generators/micro-react/templates/packages/shared-styles/arco-override.less +0 -119
  92. package/generators/micro-react/templates/packages/shared-styles/index.d.ts +0 -44
  93. package/generators/micro-react/templates/packages/shared-styles/index.less +0 -13
  94. package/generators/micro-react/templates/packages/shared-styles/package.json +0 -30
  95. package/generators/micro-react/templates/packages/shared-styles/theme-inject.less +0 -10
  96. package/generators/micro-react/templates/packages/shared-styles/themes/dark/custom-var.less +0 -290
  97. package/generators/micro-react/templates/packages/shared-styles/themes/normal/custom-var.less +0 -269
  98. package/generators/micro-react/templates/packages/shared-styles/variables-only.less +0 -433
  99. package/generators/micro-react/templates/packages/shared-styles/variables.less +0 -452
@@ -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 '@arco-design/web-react';
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
- }, [currentRoute, allRoutes, allowedRoutes, location.pathname, filterOptions]);
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 style={{
125
- position: 'absolute',
126
- top: 0,
127
- left: 0,
128
- right: 0,
129
- bottom: 0,
130
- display: 'flex',
131
- alignItems: 'center',
132
- justifyContent: 'center',
133
- background: 'var(--color-bg-1)',
134
- zIndex: 100,
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 <Spin dot style={{ width: '100%', marginTop: 100, textAlign: 'center' }} />;
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
- <Outlet />
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
- <AppTabs />
182
- <Content className="layout-content-outlet">
183
- <Suspense
184
- fallback={<Spin dot style={{ width: '100%', marginTop: 100 }} />}
185
- >
186
- {renderContent()}
187
- </Suspense>
188
- </Content>
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 '@arco-design/web-react';
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 '@arco-design/web-react';
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,3 +1,6 @@
1
+ @import '<%= packageScope %>/shared-styles/variables-only';
2
+
1
3
  .container {
2
4
  padding-top: 30px;
5
+ color: @color-text-1;
3
6
  }
@@ -1,4 +1,4 @@
1
- @import '<%= packageScope %>/shared-styles/variables-only';
1
+ @import '@mico-platform/theme/variables';
2
2
 
3
3
  .container {
4
4
  display: flex;
@@ -1,5 +1,5 @@
1
- import { Button, Form, Input, Message, Space, Typography } from '@arco-design/web-react';
2
- import { IconLock, IconUser } from '@arco-design/web-react/icon';
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 level={3} className={styles.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 '@arco-design/web-react';
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 response = await request<IUserInfoResponse>(USER_INFO_API, {
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
+ vite v7.3.1 building client environment for production...
7
+ transforming (1) src/index.ts✓ 4 modules transformed.
8
+ rendering chunks (1)...
9
+ [vite:dts] Start generate declaration files...
10
+ computing gzip size (0)...computing gzip size (1)...dist/index.js 155.52 kB │ gzip: 21.87 kB
11
+ [vite:dts] Declaration files built in 808ms.
12
+ 
13
+ ✓ built in 957ms