generator-mico-cli 0.2.6 → 0.2.8
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/generators/micro-react/templates/.cursor/rules/development-guide.mdc +1 -2
- package/generators/micro-react/templates/.eslintrc.js +1 -0
- package/generators/micro-react/templates/apps/layout/config/config.dev.ts +7 -11
- package/generators/micro-react/templates/apps/layout/config/config.prod.development.ts +6 -30
- package/generators/micro-react/templates/apps/layout/config/config.prod.testing.ts +6 -6
- package/generators/micro-react/templates/apps/layout/config/config.prod.ts +6 -6
- package/generators/micro-react/templates/apps/layout/config/config.ts +1 -0
- package/generators/micro-react/templates/apps/layout/mock/menus.ts +126 -4
- package/generators/micro-react/templates/apps/layout/src/app.tsx +2 -2
- package/generators/micro-react/templates/apps/layout/src/constants/index.ts +1 -1
- package/generators/micro-react/templates/apps/layout/src/layouts/components/header/index.tsx +0 -1
- package/generators/micro-react/templates/apps/layout/tailwind.config.js +3 -0
- package/generators/subapp-react/templates/homepage/src/common/request.ts +27 -0
- package/package.json +1 -1
- package/generators/micro-react/templates/apps/layout/mock/menus.json +0 -100
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// https://umijs.org/config/
|
|
2
2
|
|
|
3
3
|
import { defineConfig } from '@umijs/max';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
fs.readFileSync(path.join(__dirname, '../mock/menus.json'), 'utf-8'),
|
|
10
|
-
);
|
|
5
|
+
|
|
6
|
+
import mockMenus from '../mock/menus';
|
|
11
7
|
|
|
12
8
|
const config: ReturnType<typeof defineConfig> = {
|
|
13
9
|
publicPath: '/',
|
|
@@ -47,15 +43,15 @@ const config: ReturnType<typeof defineConfig> = {
|
|
|
47
43
|
},
|
|
48
44
|
define: {
|
|
49
45
|
'process.env.NODE_ENV': 'development',
|
|
50
|
-
'process.env.APP_ID': '
|
|
46
|
+
'process.env.APP_ID': '<%= projectName %>',
|
|
51
47
|
'process.env.API_BASE_URL': '',
|
|
52
|
-
'process.env.PROXY_SUFFIX': '/',
|
|
48
|
+
'process.env.PROXY_SUFFIX': '/proxy/audit_svr',
|
|
53
49
|
'process.env.LOGIN_ENDPOINT':
|
|
54
|
-
'',
|
|
50
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/',
|
|
55
51
|
'process.env.REFRESH_ENDPOINT':
|
|
56
|
-
'',
|
|
52
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/refresh/',
|
|
57
53
|
'process.env.EXTERNAL_LOGIN_PATH':
|
|
58
|
-
'',
|
|
54
|
+
'https://micous-idp.cig.tencentcs.com/sso/xxxxxxx/cas',
|
|
59
55
|
},
|
|
60
56
|
};
|
|
61
57
|
|
|
@@ -1,43 +1,19 @@
|
|
|
1
1
|
// https://umijs.org/config/
|
|
2
2
|
|
|
3
3
|
import { defineConfig } from '@umijs/max';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
|
|
7
|
-
// 使用 fs 读取 JSON 避免成为配置依赖,修改 menus.json 不会触发服务器重启
|
|
8
|
-
const mockMenus = JSON.parse(
|
|
9
|
-
fs.readFileSync(path.join(__dirname, '../mock/menus.json'), 'utf-8'),
|
|
10
|
-
);
|
|
11
4
|
|
|
12
5
|
const config: ReturnType<typeof defineConfig> = {
|
|
13
|
-
publicPath: '/',
|
|
14
|
-
/**
|
|
15
|
-
* @name 注入到 HTML head 的脚本
|
|
16
|
-
* @description 开发环境注入 mock 菜单数据
|
|
17
|
-
* @doc https://umijs.org/docs/api/config#headscripts
|
|
18
|
-
*/
|
|
19
|
-
headScripts: [
|
|
20
|
-
{
|
|
21
|
-
content: `
|
|
22
|
-
window.__MICO_MENUS__ = ${JSON.stringify(mockMenus)};
|
|
23
|
-
window.__MICO_CONFIG__ = {
|
|
24
|
-
appName: 'Mico Center',
|
|
25
|
-
apiBaseUrl: '',
|
|
26
|
-
};
|
|
27
|
-
`,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
6
|
define: {
|
|
31
7
|
'process.env.NODE_ENV': 'development',
|
|
32
|
-
'process.env.APP_ID': '
|
|
33
|
-
'process.env.API_BASE_URL': '
|
|
34
|
-
'process.env.PROXY_SUFFIX': '/',
|
|
8
|
+
'process.env.APP_ID': '<%= projectName %>',
|
|
9
|
+
'process.env.API_BASE_URL': '',
|
|
10
|
+
'process.env.PROXY_SUFFIX': '/proxy/audit_svr',
|
|
35
11
|
'process.env.LOGIN_ENDPOINT':
|
|
36
|
-
'',
|
|
12
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/',
|
|
37
13
|
'process.env.REFRESH_ENDPOINT':
|
|
38
|
-
'',
|
|
14
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/refresh/',
|
|
39
15
|
'process.env.EXTERNAL_LOGIN_PATH':
|
|
40
|
-
'',
|
|
16
|
+
'https://micous-idp.cig.tencentcs.com/sso/xxxxxxx/cas',
|
|
41
17
|
},
|
|
42
18
|
};
|
|
43
19
|
|
|
@@ -5,15 +5,15 @@ import { defineConfig } from '@umijs/max';
|
|
|
5
5
|
const config: ReturnType<typeof defineConfig> = {
|
|
6
6
|
define: {
|
|
7
7
|
'process.env.NODE_ENV': 'testing',
|
|
8
|
-
'process.env.APP_ID': '
|
|
9
|
-
'process.env.API_BASE_URL': '
|
|
10
|
-
'process.env.PROXY_SUFFIX': '/',
|
|
8
|
+
'process.env.APP_ID': '<%= projectName %>',
|
|
9
|
+
'process.env.API_BASE_URL': '',
|
|
10
|
+
'process.env.PROXY_SUFFIX': '/proxy/audit_svr',
|
|
11
11
|
'process.env.LOGIN_ENDPOINT':
|
|
12
|
-
'',
|
|
12
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/',
|
|
13
13
|
'process.env.REFRESH_ENDPOINT':
|
|
14
|
-
'',
|
|
14
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/refresh/',
|
|
15
15
|
'process.env.EXTERNAL_LOGIN_PATH':
|
|
16
|
-
'',
|
|
16
|
+
'https://micous-idp.cig.tencentcs.com/sso/xxxxxxx/cas',
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -10,15 +10,15 @@ const PUBLIC_PATH: string = CDN_PUBLIC_PATH
|
|
|
10
10
|
const config: ReturnType<typeof defineConfig> = {
|
|
11
11
|
define: {
|
|
12
12
|
'process.env.NODE_ENV': 'production',
|
|
13
|
-
'process.env.APP_ID': '
|
|
14
|
-
'process.env.API_BASE_URL': '
|
|
15
|
-
'process.env.PROXY_SUFFIX': '/',
|
|
13
|
+
'process.env.APP_ID': '<%= projectName %>',
|
|
14
|
+
'process.env.API_BASE_URL': '',
|
|
15
|
+
'process.env.PROXY_SUFFIX': '/proxy/audit_svr',
|
|
16
16
|
'process.env.LOGIN_ENDPOINT':
|
|
17
|
-
'',
|
|
17
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/',
|
|
18
18
|
'process.env.REFRESH_ENDPOINT':
|
|
19
|
-
'',
|
|
19
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/refresh/',
|
|
20
20
|
'process.env.EXTERNAL_LOGIN_PATH':
|
|
21
|
-
'',
|
|
21
|
+
'https://micous-idp.cig.tencentcs.com/sso/xxxxxxx/cas',
|
|
22
22
|
},
|
|
23
23
|
// 生产环境:将所有代码打包到一个文件
|
|
24
24
|
extraBabelPlugins: ['babel-plugin-dynamic-import-node'],
|
|
@@ -2,10 +2,132 @@
|
|
|
2
2
|
* Mock 菜单数据
|
|
3
3
|
* 用于开发环境测试
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* 菜单结构说明:
|
|
6
|
+
* - id: 菜单唯一标识
|
|
7
|
+
* - name: 菜单名称
|
|
8
|
+
* - type: 'page' | 'group' (page: 页面, group: 分组)
|
|
9
|
+
* - path: 路由路径 (group 类型为 null)
|
|
10
|
+
* - icon: 图标名称
|
|
11
|
+
* - enabled: 是否启用
|
|
12
|
+
* - sortOrder: 排序权重
|
|
13
|
+
* - pageId: 关联的页面 ID
|
|
14
|
+
* - page: 页面配置 (微前端入口)
|
|
15
|
+
* - htmlUrl: 子应用入口地址
|
|
16
|
+
* - jsUrls: 额外 JS 资源
|
|
17
|
+
* - cssUrls: 额外 CSS 资源
|
|
18
|
+
* - children: 子菜单数组
|
|
7
19
|
*/
|
|
8
|
-
import mockMenusData from './menus.json';
|
|
9
20
|
|
|
10
|
-
|
|
21
|
+
import type { MenuItem, PageConfig } from '@/common/menu/types';
|
|
22
|
+
|
|
23
|
+
/** Mock 页面配置 - 只需要核心字段 */
|
|
24
|
+
type MockPageConfig = Pick<PageConfig, 'id' | 'name' | 'route' | 'enabled' | 'htmlUrl' | 'jsUrls' | 'cssUrls'>;
|
|
25
|
+
|
|
26
|
+
/** Mock 菜单项 - page 字段使用简化类型 */
|
|
27
|
+
type MockMenuItem = Omit<MenuItem, 'page' | 'children'> & {
|
|
28
|
+
page: MockPageConfig | null;
|
|
29
|
+
children: MockMenuItem[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const mockMenus: MockMenuItem[] = [
|
|
33
|
+
{
|
|
34
|
+
"id": 1,
|
|
35
|
+
"name": "首页",
|
|
36
|
+
"type": "page",
|
|
37
|
+
"path": null,
|
|
38
|
+
"icon": "Home",
|
|
39
|
+
"enabled": true,
|
|
40
|
+
"sortOrder": 0,
|
|
41
|
+
"pageId": 1,
|
|
42
|
+
"page": {
|
|
43
|
+
"id": 1,
|
|
44
|
+
"name": "home",
|
|
45
|
+
"route": "/",
|
|
46
|
+
"enabled": true,
|
|
47
|
+
"htmlUrl": "",
|
|
48
|
+
"jsUrls": [],
|
|
49
|
+
"cssUrls": []
|
|
50
|
+
},
|
|
51
|
+
"children": []
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": 2,
|
|
55
|
+
"name": "示例模块",
|
|
56
|
+
"type": "group",
|
|
57
|
+
"path": null,
|
|
58
|
+
"icon": "List",
|
|
59
|
+
"enabled": true,
|
|
60
|
+
"sortOrder": 1,
|
|
61
|
+
"pageId": null,
|
|
62
|
+
"page": null,
|
|
63
|
+
"children": [
|
|
64
|
+
{
|
|
65
|
+
"id": 3,
|
|
66
|
+
"name": "示例页面",
|
|
67
|
+
"type": "page",
|
|
68
|
+
"path": "/example/page",
|
|
69
|
+
"icon": "File",
|
|
70
|
+
"enabled": true,
|
|
71
|
+
"sortOrder": 1,
|
|
72
|
+
"pageId": 45,
|
|
73
|
+
"page": {
|
|
74
|
+
"id": 45,
|
|
75
|
+
"name": "example-page",
|
|
76
|
+
"route": "/example/page",
|
|
77
|
+
"enabled": true,
|
|
78
|
+
"htmlUrl": "",
|
|
79
|
+
"jsUrls": [],
|
|
80
|
+
"cssUrls": []
|
|
81
|
+
},
|
|
82
|
+
"children": []
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": 5,
|
|
88
|
+
"name": "微应用示例",
|
|
89
|
+
"type": "group",
|
|
90
|
+
"path": null,
|
|
91
|
+
"icon": "Apps",
|
|
92
|
+
"enabled": true,
|
|
93
|
+
"sortOrder": 2,
|
|
94
|
+
"pageId": null,
|
|
95
|
+
"page": null,
|
|
96
|
+
"children": [
|
|
97
|
+
{
|
|
98
|
+
"id": 6,
|
|
99
|
+
"name": "子应用页面",
|
|
100
|
+
"type": "page",
|
|
101
|
+
"path": null,
|
|
102
|
+
"icon": "Desktop",
|
|
103
|
+
"enabled": true,
|
|
104
|
+
"sortOrder": 1,
|
|
105
|
+
"pageId": 55,
|
|
106
|
+
"page": {
|
|
107
|
+
"id": 55,
|
|
108
|
+
"name": "subapp-example",
|
|
109
|
+
"route": "/subapp",
|
|
110
|
+
"enabled": true,
|
|
111
|
+
"htmlUrl": "//localhost:8010",
|
|
112
|
+
"jsUrls": [],
|
|
113
|
+
"cssUrls": []
|
|
114
|
+
},
|
|
115
|
+
"children": []
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": 7,
|
|
121
|
+
"name": "外部链接",
|
|
122
|
+
"type": "link",
|
|
123
|
+
"path": "https://github.com",
|
|
124
|
+
"icon": "Link",
|
|
125
|
+
"enabled": true,
|
|
126
|
+
"sortOrder": 3,
|
|
127
|
+
"pageId": null,
|
|
128
|
+
"page": null,
|
|
129
|
+
"children": []
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
|
|
11
133
|
export default mockMenus;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { history,
|
|
2
|
-
import { addGlobalUncaughtErrorHandler
|
|
1
|
+
import { history, type RequestConfig } from '@umijs/max';
|
|
2
|
+
import { addGlobalUncaughtErrorHandler } from 'qiankun';
|
|
3
3
|
import { errorConfig } from './requestErrorConfig';
|
|
4
4
|
// 解决「React19 中无法使用 Message/Notification」的问题。 @see https://github.com/arco-design/arco-design/issues/2900#issuecomment-2796571653
|
|
5
5
|
import * as arco from '@arco-design/web-react';
|
|
@@ -46,4 +46,31 @@ export function getRequestSource(): 'main-app' | 'umi' {
|
|
|
46
46
|
return getMainAppRequest() ? 'main-app' : 'umi';
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* 从错误对象中提取错误消息
|
|
51
|
+
* 优先使用后端返回的 msg,否则使用默认消息
|
|
52
|
+
*/
|
|
53
|
+
export function getErrorMessage(error: unknown, defaultMsg: string): string {
|
|
54
|
+
if (error && typeof error === 'object') {
|
|
55
|
+
// 尝试从 error.data.msg 获取(umi-request 格式)
|
|
56
|
+
const err = error as Record<string, any>;
|
|
57
|
+
if (err.data?.msg) {
|
|
58
|
+
return err.data.msg;
|
|
59
|
+
}
|
|
60
|
+
// 尝试从 error.response.data.msg 获取(axios 格式)
|
|
61
|
+
if (err.response?.data?.msg) {
|
|
62
|
+
return err.response.data.msg;
|
|
63
|
+
}
|
|
64
|
+
// 尝试从 error.msg 获取
|
|
65
|
+
if (err.msg) {
|
|
66
|
+
return err.msg;
|
|
67
|
+
}
|
|
68
|
+
// 尝试从 error.message 获取
|
|
69
|
+
if (err.message) {
|
|
70
|
+
return err.message;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return defaultMsg;
|
|
74
|
+
}
|
|
75
|
+
|
|
49
76
|
|
package/package.json
CHANGED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": 1,
|
|
4
|
-
"name": "首页",
|
|
5
|
-
"type": "page",
|
|
6
|
-
"path": null,
|
|
7
|
-
"icon": "Home",
|
|
8
|
-
"enabled": true,
|
|
9
|
-
"sortOrder": 0,
|
|
10
|
-
"pageId": 1,
|
|
11
|
-
"page": {
|
|
12
|
-
"id": 1,
|
|
13
|
-
"name": "home",
|
|
14
|
-
"route": "/",
|
|
15
|
-
"enabled": true,
|
|
16
|
-
"htmlUrl": null,
|
|
17
|
-
"jsUrls": [],
|
|
18
|
-
"cssUrls": []
|
|
19
|
-
},
|
|
20
|
-
"children": []
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"id": 2,
|
|
24
|
-
"name": "示例模块",
|
|
25
|
-
"type": "group",
|
|
26
|
-
"path": null,
|
|
27
|
-
"icon": "List",
|
|
28
|
-
"enabled": true,
|
|
29
|
-
"sortOrder": 1,
|
|
30
|
-
"pageId": null,
|
|
31
|
-
"page": null,
|
|
32
|
-
"children": [
|
|
33
|
-
{
|
|
34
|
-
"id": 3,
|
|
35
|
-
"name": "示例页面",
|
|
36
|
-
"type": "page",
|
|
37
|
-
"path": "/example/page",
|
|
38
|
-
"icon": "File",
|
|
39
|
-
"enabled": true,
|
|
40
|
-
"sortOrder": 1,
|
|
41
|
-
"pageId": 45,
|
|
42
|
-
"page": {
|
|
43
|
-
"id": 45,
|
|
44
|
-
"name": "example-page",
|
|
45
|
-
"route": "/example/page",
|
|
46
|
-
"enabled": true,
|
|
47
|
-
"htmlUrl": null,
|
|
48
|
-
"jsUrls": [],
|
|
49
|
-
"cssUrls": []
|
|
50
|
-
},
|
|
51
|
-
"children": []
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"id": 5,
|
|
57
|
-
"name": "微应用示例",
|
|
58
|
-
"type": "group",
|
|
59
|
-
"path": null,
|
|
60
|
-
"icon": "Apps",
|
|
61
|
-
"enabled": true,
|
|
62
|
-
"sortOrder": 2,
|
|
63
|
-
"pageId": null,
|
|
64
|
-
"page": null,
|
|
65
|
-
"children": [
|
|
66
|
-
{
|
|
67
|
-
"id": 6,
|
|
68
|
-
"name": "子应用页面",
|
|
69
|
-
"type": "page",
|
|
70
|
-
"path": null,
|
|
71
|
-
"icon": "Desktop",
|
|
72
|
-
"enabled": true,
|
|
73
|
-
"sortOrder": 1,
|
|
74
|
-
"pageId": 55,
|
|
75
|
-
"page": {
|
|
76
|
-
"id": 55,
|
|
77
|
-
"name": "subapp-example",
|
|
78
|
-
"route": "/subapp",
|
|
79
|
-
"enabled": true,
|
|
80
|
-
"htmlUrl": "//localhost:8010",
|
|
81
|
-
"jsUrls": [],
|
|
82
|
-
"cssUrls": []
|
|
83
|
-
},
|
|
84
|
-
"children": []
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"id": 7,
|
|
90
|
-
"name": "外部链接",
|
|
91
|
-
"type": "link",
|
|
92
|
-
"path": "https://github.com",
|
|
93
|
-
"icon": "Link",
|
|
94
|
-
"enabled": true,
|
|
95
|
-
"sortOrder": 3,
|
|
96
|
-
"pageId": null,
|
|
97
|
-
"page": null,
|
|
98
|
-
"children": []
|
|
99
|
-
}
|
|
100
|
-
]
|