generator-mico-cli 0.2.7 → 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/.eslintrc.js +1 -0
- package/generators/micro-react/templates/apps/layout/config/config.dev.ts +5 -5
- 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/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
|
@@ -43,15 +43,15 @@ const config: ReturnType<typeof defineConfig> = {
|
|
|
43
43
|
},
|
|
44
44
|
define: {
|
|
45
45
|
'process.env.NODE_ENV': 'development',
|
|
46
|
-
'process.env.APP_ID': '
|
|
46
|
+
'process.env.APP_ID': '<%= projectName %>',
|
|
47
47
|
'process.env.API_BASE_URL': '',
|
|
48
|
-
'process.env.PROXY_SUFFIX': '/',
|
|
48
|
+
'process.env.PROXY_SUFFIX': '/proxy/audit_svr',
|
|
49
49
|
'process.env.LOGIN_ENDPOINT':
|
|
50
|
-
'',
|
|
50
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/',
|
|
51
51
|
'process.env.REFRESH_ENDPOINT':
|
|
52
|
-
'',
|
|
52
|
+
'https://dashboard-api-test.micoplatform.com/api/yufu_login/refresh/',
|
|
53
53
|
'process.env.EXTERNAL_LOGIN_PATH':
|
|
54
|
-
'',
|
|
54
|
+
'https://micous-idp.cig.tencentcs.com/sso/xxxxxxx/cas',
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
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'],
|
|
@@ -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
|
|