@utogether/udp-core 1.0.1-beta.22 → 1.0.1-beta.24
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/dist/{403-B87JSuhn.js → 403-Dzcgpvp0.js} +1 -1
- package/dist/{404-BhiUKT1b.js → 404-BMtUBfzS.js} +1 -1
- package/dist/{500-2G6eyDeT.js → 500-BM0zxG1M.js} +1 -1
- package/dist/{AuthorityInfo-Bl4_zDot.js → AuthorityInfo-BmsB4SqO.js} +1 -1
- package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-92i5Oriz.js → AuthorityInfo.vue_vue_type_style_index_0_lang-CKcQbO7T.js} +1 -1
- package/dist/{Company-CbTh7_bX.js → Company-CwUC57TC.js} +3 -3
- package/dist/{CompanyPanel-BVEYMQKM.js → CompanyPanel-BAmnU8nv.js} +1 -1
- package/dist/{Department-Cu83Buy8.js → Department-BsXoz3BD.js} +3 -3
- package/dist/{DepartmentPanel-CO76buwO.js → DepartmentPanel-78TnO9Tu.js} +1 -1
- package/dist/{DesignPanel-DDgVNzYW.js → DesignPanel-CSL9uUNR.js} +1 -1
- package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-Bwernx0s.js → DesignPanel.vue_vue_type_style_index_0_lang-CZrUHBBj.js} +2 -2
- package/dist/{DictView-DJDg_Oem.js → DictView-BKqfJuJq.js} +1 -1
- package/dist/{InvOrganization-D9BMWweK.js → InvOrganization-2gn2zpSK.js} +1 -1
- package/dist/{Org-CcfRkpBY.js → Org-C_08akFc.js} +1 -1
- package/dist/{Preview-DGP1uIZU.js → Preview-CffizoOK.js} +1 -1
- package/dist/{ReportDefine-u7r-IVPD.js → ReportDefine-BmBcBFey.js} +1 -1
- package/dist/{ReportDesign-CLQRMIy3.js → ReportDesign-Dw5AZl_M.js} +2 -2
- package/dist/{ReportQuery-BNTCTpqI.js → ReportQuery-B4LyGqtT.js} +1 -1
- package/dist/{ReportQueryFrom-G7X1Fyf5.js → ReportQueryFrom-oBS0ClDQ.js} +1 -1
- package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-D5lDZFPM.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-DvayIk8Y.js} +1 -1
- package/dist/{ReportTemplate-QWAuFjaB.js → ReportTemplate-CNcUhJRf.js} +1 -1
- package/dist/{Role-Ba1OVGG0.js → Role-RUCpeqPj.js} +3 -3
- package/dist/{RoleAssign-DFiMYll8.js → RoleAssign-DYidK2md.js} +3 -3
- package/dist/{RolePanel-c-xitljX.js → RolePanel-BQuKAefI.js} +1 -1
- package/dist/{RolePanel-D6xKrLlM.js → RolePanel-BrtpMF69.js} +1 -1
- package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-BeZ1xNXU.js → RolePanel.vue_vue_type_script_setup_true_lang-CrzUrpzJ.js} +1 -1
- package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-DrBiLlBb.js → RolePanel.vue_vue_type_script_setup_true_lang-FAOBa5ds.js} +3 -3
- package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-D4eReGaK.js → ScrollPanel.vue_vue_type_style_index_0_lang-CmhAWJD4.js} +1 -1
- package/dist/{Staff-C-5TE1Yn.js → Staff-MnxrATUB.js} +3 -3
- package/dist/{StaffInfo-CwJlL_Nr.js → StaffInfo-CXNLmE3w.js} +1 -1
- package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-C2BsoQlr.js → StaffInfo.vue_vue_type_script_setup_true_lang-AsAikm4v.js} +1 -1
- package/dist/{StaffPanel-QOv1pq2Z.js → StaffPanel-BdhcAqQL.js} +1 -1
- package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-BGQSHjaQ.js → StaffPanel.vue_vue_type_script_setup_true_lang-B51ElICg.js} +2 -2
- package/dist/{SysUser-Byug_VNY.js → SysUser-Dh70yuNE.js} +2 -2
- package/dist/{SysUserPanel-B-M2Yxjj.js → SysUserPanel-DimcWXi5.js} +1 -1
- package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-5U-oqRaF.js +340 -0
- package/dist/{SystemMenu-Bs9a4BE0.js → SystemMenu-CH04ZC4Q.js} +39 -39
- package/dist/{UserInfo-Ipp00UAF.js → UserInfo--5jFxyNg.js} +1 -1
- package/dist/{UserInfo.vue_vue_type_style_index_0_lang-DIcWs6vj.js → UserInfo.vue_vue_type_style_index_0_lang-BpS2JUoM.js} +1 -1
- package/dist/{childView-N1PkzqQK.js → childView-1QhOOcjT.js} +1 -1
- package/dist/{childView-O-5baerB.js → childView-q4jq8JUU.js} +1 -1
- package/dist/{childView.vue_vue_type_style_index_0_lang--yGHgWVq.js → childView.vue_vue_type_style_index_0_lang-C1_CKaiz.js} +1 -1
- package/dist/{childView.vue_vue_type_style_index_0_lang-srudWvXc.js → childView.vue_vue_type_style_index_0_lang-_9frXYVo.js} +1 -1
- package/dist/{code-rule-CRunTGXH.js → code-rule-Cmc-zh3P.js} +1 -1
- package/dist/core.es.js +1 -1
- package/dist/{cron-task-IEuaI4Nt.js → cron-task-BJC8dKFZ.js} +1 -1
- package/dist/{frameView-vGVXV1ZG.js → frameView-rRbSPmqe.js} +1 -1
- package/dist/index-CU7HTsRe.js +6497 -0
- package/dist/{layoutView-BJO8Hm5d.js → layoutView-C5aVJcOn.js} +1 -1
- package/dist/{login-CZyenjQX.js → login-DGj6zzD2.js} +1 -1
- package/dist/{lov-view-6He1ZxGX.js → lov-view-CDYHJIbU.js} +2 -2
- package/dist/{menuInfo-CE5Cae2u.js → menuInfo-N2mUoR6P.js} +1 -1
- package/dist/{menuInfo.vue_vue_type_style_index_0_lang-BjshFg3S.js → menuInfo.vue_vue_type_style_index_0_lang-Y7Jg-MZO.js} +119 -99
- package/dist/{pda-app-DOiT57m1.js → pda-app-D0g-Ygcq.js} +1 -1
- package/dist/{resource-BdlOJOcz.js → resource-DPW5r_7h.js} +1 -1
- package/dist/{su-welcome-BxRhJD8X.js → su-welcome-GWIgWj_m.js} +1 -1
- package/dist/{sys-config-Csy-234G.js → sys-config-DwaGsVVu.js} +1 -1
- package/dist/udp-core.css +1 -1
- package/package.json +3 -3
- package/src/components/udp/grid/index.vue +514 -513
- package/src/plugins/i18n/zh.ts +6 -3
- package/src/router/utils.ts +2 -2
- package/src/style/button.scss +85 -85
- package/src/utils/udp/http/index.ts +294 -0
- package/src/utils/udp/http/types.d.ts +42 -0
- package/src/views/system/cron/cron-task.vue +2 -12
- package/src/views/system/menu/SystemMenu.vue +185 -183
- package/src/views/system/menu/menuInfo.vue +384 -363
- package/src/views/system/sysUser/SysUserPanel.vue +346 -279
- package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-Dm1YyUXX.js +0 -298
- package/dist/index-D_tU_u2l.js +0 -4640
package/src/plugins/i18n/zh.ts
CHANGED
|
@@ -109,7 +109,9 @@ export default {
|
|
|
109
109
|
organizationName: '组织名称',
|
|
110
110
|
organizationCode: '组织编码',
|
|
111
111
|
appupper: '已上架',
|
|
112
|
-
applower: '已下架'
|
|
112
|
+
applower: '已下架',
|
|
113
|
+
isApprovalPage: '审批页面',
|
|
114
|
+
showLink: '菜单可见'
|
|
113
115
|
},
|
|
114
116
|
btn: {
|
|
115
117
|
passwordReset: '密码重置',
|
|
@@ -334,7 +336,7 @@ export default {
|
|
|
334
336
|
imageCapacity: '图片大小{capacity}',
|
|
335
337
|
singleImg: '仅支持设置单张图',
|
|
336
338
|
emptyAuth: '无系统权限, 请先给用户分配角色重试',
|
|
337
|
-
initPassword: `初始密码为:【
|
|
339
|
+
initPassword: `初始密码为:【{code}】,请及时修改密码`,
|
|
338
340
|
loginFailure: '用户名或密码不能为空',
|
|
339
341
|
updatenow: '立即更新',
|
|
340
342
|
newVersion: '检测到新版本',
|
|
@@ -353,6 +355,7 @@ export default {
|
|
|
353
355
|
dictInfo: '【{name}】字典值',
|
|
354
356
|
lovView: '值集视图',
|
|
355
357
|
lovColConfig: '值集列配置',
|
|
356
|
-
sequenceInfo: '{name}单据序列配置'
|
|
358
|
+
sequenceInfo: '{name}单据序列配置',
|
|
359
|
+
userInfo: '用户信息'
|
|
357
360
|
}
|
|
358
361
|
};
|
package/src/router/utils.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: levi7754 levi7754@163.com
|
|
3
3
|
* @Date: 2024-08-01 21:42:39
|
|
4
4
|
* @LastEditors: levi7754 levi7754@163.com
|
|
5
|
-
* @LastEditTime: 2025-11-
|
|
5
|
+
* @LastEditTime: 2025-11-13 18:18:46
|
|
6
6
|
* @FilePath: \udp-front\packages\udp-core\src\router\utils.ts
|
|
7
7
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
8
8
|
*/
|
|
@@ -298,7 +298,7 @@ const addAsyncRoutes = (arrRoutes: Array<any>) => {
|
|
|
298
298
|
}
|
|
299
299
|
const { icon, permissionCode, extraIcon, frameSrc } = v;
|
|
300
300
|
// 流程菜单保存
|
|
301
|
-
v.
|
|
301
|
+
v.isApprovalPage === 'Y' && processMenus.push(v);
|
|
302
302
|
|
|
303
303
|
v.meta = {
|
|
304
304
|
keepAlive: true,
|
package/src/style/button.scss
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
.vxe-button.size--mini.type--button {
|
|
2
|
-
height: 25px;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.vxe-button.size--small.type--button {
|
|
6
|
-
height: 25px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.vxe-button.type--button.theme--u-cyan,
|
|
10
|
-
.vxe-button.type--button.theme--u-cyan:hover {
|
|
11
|
-
color: #fff;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.vxe-button.type--button.theme--u-cyan {
|
|
15
|
-
background-color: #1cbbb4;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.vxe-button.type--button.theme--u-cyan:active {
|
|
19
|
-
background-color: #39b54a;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// 禁用状态
|
|
23
|
-
.vxe-button.type--button.theme--u-cyan.is--disabled {
|
|
24
|
-
background-color: #69e4de;
|
|
25
|
-
border-color: #69e4de;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.vxe-button.type--button.theme--u-color-shallow,
|
|
29
|
-
.vxe-button.type--button.theme--u-color-shallow:hover {
|
|
30
|
-
color: #fff;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.vxe-button.type--button.theme--u-color-shallow {
|
|
34
|
-
background-color: #fbbd08;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.vxe-button.type--button.theme--u-color-shallow:active {
|
|
38
|
-
background-color: #fff;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.layout-theme-default .vxe-button.type--button.theme--u-cyan:not(.is--disabled):hover {
|
|
42
|
-
background-color: #40e0d0;
|
|
43
|
-
border-color: #40e0d0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.vxe-button.type--button:not(.is--disabled):hover {
|
|
47
|
-
color: inherit;
|
|
48
|
-
|
|
49
|
-
.vxe-button--icon,
|
|
50
|
-
.vxe-button--item {
|
|
51
|
-
color: inherit;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.vxe-button[name='favorite'].type--button:not(.is--disabled):hover {
|
|
56
|
-
.vxe-button--item {
|
|
57
|
-
color: var(--udp-theme-vxeColor);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.u-color-royalBlue {
|
|
62
|
-
color: #4169e1;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.u-color-turquoise {
|
|
66
|
-
color: #40e0d0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.el-dropdown {
|
|
70
|
-
.el-dropdown__caret-button {
|
|
71
|
-
margin-left: 0;
|
|
72
|
-
border-top-left-radius: 0;
|
|
73
|
-
border-bottom-left-radius: 0;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.el-button-group + .el-button {
|
|
77
|
-
border-top-right-radius: 0 !important;
|
|
78
|
-
border-bottom-right-radius: 0 !important;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.el-button:first-child {
|
|
82
|
-
border-top-right-radius: 0 !important;
|
|
83
|
-
border-bottom-right-radius: 0 !important;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
1
|
+
.vxe-button.size--mini.type--button {
|
|
2
|
+
height: 25px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.vxe-button.size--small.type--button {
|
|
6
|
+
height: 25px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.vxe-button.type--button.theme--u-cyan,
|
|
10
|
+
.vxe-button.type--button.theme--u-cyan:hover {
|
|
11
|
+
color: #fff !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.vxe-button.type--button.theme--u-cyan {
|
|
15
|
+
background-color: #1cbbb4;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.vxe-button.type--button.theme--u-cyan:active {
|
|
19
|
+
background-color: #39b54a;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 禁用状态
|
|
23
|
+
.vxe-button.type--button.theme--u-cyan.is--disabled {
|
|
24
|
+
background-color: #69e4de;
|
|
25
|
+
border-color: #69e4de;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.vxe-button.type--button.theme--u-color-shallow,
|
|
29
|
+
.vxe-button.type--button.theme--u-color-shallow:hover {
|
|
30
|
+
color: #fff;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.vxe-button.type--button.theme--u-color-shallow {
|
|
34
|
+
background-color: #fbbd08;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.vxe-button.type--button.theme--u-color-shallow:active {
|
|
38
|
+
background-color: #fff;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.layout-theme-default .vxe-button.type--button.theme--u-cyan:not(.is--disabled):hover {
|
|
42
|
+
background-color: #40e0d0;
|
|
43
|
+
border-color: #40e0d0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.vxe-button.type--button:not(.is--disabled):hover {
|
|
47
|
+
color: inherit;
|
|
48
|
+
|
|
49
|
+
.vxe-button--icon,
|
|
50
|
+
.vxe-button--item {
|
|
51
|
+
color: inherit;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.vxe-button[name='favorite'].type--button:not(.is--disabled):hover {
|
|
56
|
+
.vxe-button--item {
|
|
57
|
+
color: var(--udp-theme-vxeColor);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.u-color-royalBlue {
|
|
62
|
+
color: #4169e1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.u-color-turquoise {
|
|
66
|
+
color: #40e0d0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.el-dropdown {
|
|
70
|
+
.el-dropdown__caret-button {
|
|
71
|
+
margin-left: 0;
|
|
72
|
+
border-top-left-radius: 0;
|
|
73
|
+
border-bottom-left-radius: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.el-button-group + .el-button {
|
|
77
|
+
border-top-right-radius: 0 !important;
|
|
78
|
+
border-bottom-right-radius: 0 !important;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.el-button:first-child {
|
|
82
|
+
border-top-right-radius: 0 !important;
|
|
83
|
+
border-bottom-right-radius: 0 !important;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import Axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { SuHttpError, RequestMethods, SuHttpResponse, SuHttpRequestConfig } from './types.d';
|
|
3
|
+
import { NProgress, cookies, errorMessage } from '@utogether/utils';
|
|
4
|
+
import { isRef } from 'vue';
|
|
5
|
+
import { has } from 'xe-utils';
|
|
6
|
+
|
|
7
|
+
const kTOKENKEY = 'authorized-token';
|
|
8
|
+
const defaultConfig: AxiosRequestConfig = {
|
|
9
|
+
timeout: 180000,
|
|
10
|
+
headers: {
|
|
11
|
+
Accept: 'application/json, text/plain, */*',
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
'X-Requested-With': 'XMLHttpRequest'
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
class SuHttp {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.httpInterceptorsRequest();
|
|
19
|
+
this.httpInterceptorsResponse();
|
|
20
|
+
}
|
|
21
|
+
router = undefined;
|
|
22
|
+
baseUrl = 'http: //192.168.101.138.8099';
|
|
23
|
+
/** token过期后,暂存待执行的请求 */
|
|
24
|
+
private static requests = [];
|
|
25
|
+
|
|
26
|
+
/** 防止重复刷新token */
|
|
27
|
+
private static isRefreshing = false;
|
|
28
|
+
|
|
29
|
+
/** 设置router调整 */
|
|
30
|
+
setRouter(router) {
|
|
31
|
+
this.router = router;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setBaseUrl(baseUrl) {
|
|
35
|
+
this.baseUrl = baseUrl;
|
|
36
|
+
}
|
|
37
|
+
// 初始化配置对象
|
|
38
|
+
private static initConfig: SuHttpRequestConfig = {};
|
|
39
|
+
|
|
40
|
+
// 保存当前Axios实例对象
|
|
41
|
+
private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
|
|
42
|
+
|
|
43
|
+
/** 重连原始请求 */
|
|
44
|
+
private static retryOriginalRequest(config: SuHttpRequestConfig) {
|
|
45
|
+
return new Promise(resolve => {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
SuHttp.requests.push((token: string) => {
|
|
48
|
+
config.headers!['Authorization'] = 'Bearer ' + token;
|
|
49
|
+
resolve(config);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 请求拦截
|
|
55
|
+
private httpInterceptorsRequest(): void {
|
|
56
|
+
SuHttp.axiosInstance.interceptors.request.use(
|
|
57
|
+
(config: any) => {
|
|
58
|
+
if (has(config, 'loading') && isRef(config.loading)) {
|
|
59
|
+
config.loading.value = true;
|
|
60
|
+
}
|
|
61
|
+
// 开启进度条动画
|
|
62
|
+
NProgress.start();
|
|
63
|
+
// 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
|
|
64
|
+
if (typeof config.beforeRequestCallback === 'function') {
|
|
65
|
+
config.beforeRequestCallback(config);
|
|
66
|
+
return config;
|
|
67
|
+
}
|
|
68
|
+
if (SuHttp.initConfig.beforeRequestCallback) {
|
|
69
|
+
SuHttp.initConfig.beforeRequestCallback(config);
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
const whiteList = ['/refreshToken', '/login'];
|
|
73
|
+
if (whiteList.some(v => config.url.indexOf(v) > -1)) return config;
|
|
74
|
+
return new Promise(resolve => {
|
|
75
|
+
const token = cookies.get(kTOKENKEY);
|
|
76
|
+
if (token) {
|
|
77
|
+
const data = JSON.parse(token);
|
|
78
|
+
const now = new Date().getTime();
|
|
79
|
+
const expired = data.expires - now <= 0;
|
|
80
|
+
if (expired) {
|
|
81
|
+
if (!SuHttp.isRefreshing) {
|
|
82
|
+
SuHttp.isRefreshing = true;
|
|
83
|
+
// requests.push(() => SuHttp.axiosInstance(config));
|
|
84
|
+
this.get(this.baseUrl + '/uath/refreshToken', {
|
|
85
|
+
refreshToken: data.refreshToken
|
|
86
|
+
})
|
|
87
|
+
.then((res: any) => {
|
|
88
|
+
if (!res?.access_token) {
|
|
89
|
+
this.routeToLogin();
|
|
90
|
+
} else {
|
|
91
|
+
// 替换token
|
|
92
|
+
this.setToken(res);
|
|
93
|
+
config.headers['Authorization'] = 'Bearer ' + res.access_token;
|
|
94
|
+
// token 刷新后将数组的方法重新执行
|
|
95
|
+
SuHttp.requests.forEach(cb => cb(res.access_token));
|
|
96
|
+
SuHttp.requests = []; // 重新请求完清空
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
.catch(() => {
|
|
100
|
+
this.routeToLogin();
|
|
101
|
+
})
|
|
102
|
+
.finally(() => {
|
|
103
|
+
SuHttp.isRefreshing = false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
resolve(SuHttp.retryOriginalRequest(config));
|
|
108
|
+
} else {
|
|
109
|
+
config.headers['Authorization'] = 'Bearer ' + data.accessToken;
|
|
110
|
+
resolve(config);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
const sessionKey = cookies.get('kCookies_token') as string;
|
|
114
|
+
if (sessionKey) {
|
|
115
|
+
config.headers['X-Token'] = sessionKey;
|
|
116
|
+
}
|
|
117
|
+
resolve(config);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
error => {
|
|
122
|
+
return Promise.reject(error);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private setToken(token) {
|
|
128
|
+
const { access_token, expires_in, refresh_token } = token;
|
|
129
|
+
const cache = {
|
|
130
|
+
accessToken: access_token,
|
|
131
|
+
refreshToken: refresh_token,
|
|
132
|
+
expires: Date.now() + expires_in * 1000
|
|
133
|
+
};
|
|
134
|
+
cookies.set(kTOKENKEY, JSON.stringify(cache));
|
|
135
|
+
// cookies.set(kTOKENKEY, JSON.stringify(cache), { expires: expires_in });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private routeToLogin() {
|
|
139
|
+
SuHttp.requests = []; // 重新请求完清空
|
|
140
|
+
cookies.remove('kCookies_token');
|
|
141
|
+
cookies.remove('authorized-token');
|
|
142
|
+
cookies.remove('loginer');
|
|
143
|
+
this.router.push({ name: 'login' });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 响应拦截
|
|
147
|
+
private httpInterceptorsResponse(): void {
|
|
148
|
+
const instance = SuHttp.axiosInstance;
|
|
149
|
+
instance.interceptors.response.use(
|
|
150
|
+
(response: SuHttpResponse) => {
|
|
151
|
+
const $config = response.config;
|
|
152
|
+
if (has($config, 'loading') && isRef($config.loading)) {
|
|
153
|
+
$config.loading.value = false;
|
|
154
|
+
}
|
|
155
|
+
// 关闭进度条动画
|
|
156
|
+
NProgress.done();
|
|
157
|
+
// 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
|
|
158
|
+
if (typeof $config.beforeResponseCallback === 'function') {
|
|
159
|
+
$config.beforeResponseCallback(response);
|
|
160
|
+
return response.data;
|
|
161
|
+
}
|
|
162
|
+
if (SuHttp.initConfig.beforeResponseCallback) {
|
|
163
|
+
SuHttp.initConfig.beforeResponseCallback(response);
|
|
164
|
+
return response.data;
|
|
165
|
+
}
|
|
166
|
+
return response.data;
|
|
167
|
+
},
|
|
168
|
+
(error: SuHttpError) => {
|
|
169
|
+
const $error = error;
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
if (has(error.config, 'loading') && isRef(error?.config?.loading)) {
|
|
172
|
+
// @ts-ignore
|
|
173
|
+
error.config.loading.value = false;
|
|
174
|
+
}
|
|
175
|
+
$error.isCancelRequest = Axios.isCancel($error);
|
|
176
|
+
// 关闭进度条动画
|
|
177
|
+
NProgress.done();
|
|
178
|
+
// 所有的响应异常 区分来源为取消请求/非取消请求
|
|
179
|
+
return Promise.reject($error);
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private transformConfigByMethod(params: any, config: SuHttpRequestConfig): SuHttpRequestConfig {
|
|
185
|
+
const { method } = config;
|
|
186
|
+
const methods = ['get'];
|
|
187
|
+
const m = method!.toLocaleLowerCase();
|
|
188
|
+
const props = methods.includes(m) ? 'params' : 'data';
|
|
189
|
+
return {
|
|
190
|
+
...config,
|
|
191
|
+
[props]: params
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 通用请求工具函数
|
|
196
|
+
public request<T>(
|
|
197
|
+
method: RequestMethods,
|
|
198
|
+
url: string,
|
|
199
|
+
param?: AxiosRequestConfig,
|
|
200
|
+
axiosConfig?: SuHttpRequestConfig
|
|
201
|
+
): Promise<T> {
|
|
202
|
+
const config = this.transformConfigByMethod(param, {
|
|
203
|
+
method,
|
|
204
|
+
url,
|
|
205
|
+
...axiosConfig
|
|
206
|
+
} as SuHttpRequestConfig);
|
|
207
|
+
// 单独处理自定义请求/响应回掉
|
|
208
|
+
return new Promise((resolve, reject) => {
|
|
209
|
+
SuHttp.axiosInstance
|
|
210
|
+
.request(config)
|
|
211
|
+
.then((res: any) => {
|
|
212
|
+
if (res && res?.code === '0') {
|
|
213
|
+
resolve(res.data);
|
|
214
|
+
} else if (res.code === '500') {
|
|
215
|
+
errorMessage(res.msg, { duration: 8000 });
|
|
216
|
+
if (config.method === 'get') {
|
|
217
|
+
resolve(res);
|
|
218
|
+
} else {
|
|
219
|
+
reject(res.msg);
|
|
220
|
+
}
|
|
221
|
+
} else if (res?.code !== '-1') {
|
|
222
|
+
resolve(res);
|
|
223
|
+
} else {
|
|
224
|
+
const msg = res?.msg || '服务异常';
|
|
225
|
+
errorMessage(msg, { duration: 8000 });
|
|
226
|
+
reject(msg);
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
.catch(e => {
|
|
230
|
+
if (e?.code) {
|
|
231
|
+
if (e?.response?.status === 401) {
|
|
232
|
+
// @ts-ignore
|
|
233
|
+
return this.router?.push({ path: '/login' });
|
|
234
|
+
}
|
|
235
|
+
errorMessage(this.getNetworkError(e?.response?.status) || e?.message, { duration: 8000 });
|
|
236
|
+
}
|
|
237
|
+
if (e.config.method === 'get') {
|
|
238
|
+
resolve(e);
|
|
239
|
+
} else {
|
|
240
|
+
reject(e);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
getNetworkError = code => {
|
|
247
|
+
if (!code) return null;
|
|
248
|
+
const msgMap = {
|
|
249
|
+
400: '错误的请求',
|
|
250
|
+
401: '服务未授权,请重新登录',
|
|
251
|
+
403: '拒绝访问',
|
|
252
|
+
404: '请求错误,未找到该资源',
|
|
253
|
+
408: '请求超时',
|
|
254
|
+
500: '服务器端出差',
|
|
255
|
+
502: '网络超时',
|
|
256
|
+
503: '服务不可用',
|
|
257
|
+
504: '网络超时'
|
|
258
|
+
};
|
|
259
|
+
return msgMap[code];
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// 单独抽离的post工具函数
|
|
263
|
+
public post<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
return this.request<P>('post', url, params, config);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// 单独抽离的delete工具函数
|
|
269
|
+
public delete<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
270
|
+
// @ts-ignore
|
|
271
|
+
return this.request<P>('delete', url, params, config);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// 单独抽离的put工具函数
|
|
275
|
+
public put<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
276
|
+
// @ts-ignore
|
|
277
|
+
return this.request<P>('put', url, params, config);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// 单独抽离的get工具函数
|
|
281
|
+
public get<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
|
|
282
|
+
for (const key in params) {
|
|
283
|
+
if (!params[key]) delete params[key];
|
|
284
|
+
}
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
return this.request<P>('get', url, params, config);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
public postRouter<T>(params?: any): Promise<T> {
|
|
290
|
+
return this.request<T>('post', 'route/service', params);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export const http = new SuHttp();
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: wei.li
|
|
3
|
+
* @Date: 2022-03-08 15:17:39
|
|
4
|
+
* @LastEditors: levi7754 levi7754@163.com
|
|
5
|
+
* @LastEditTime: 2023-12-01 13:55:46
|
|
6
|
+
* @Description: SuHttp Axios 类型定义文件
|
|
7
|
+
*/
|
|
8
|
+
import type { Method, AxiosError, AxiosResponse, AxiosRequestConfig } from 'axios';
|
|
9
|
+
|
|
10
|
+
export type resultType = {
|
|
11
|
+
access_token: string;
|
|
12
|
+
refresh_token: string;
|
|
13
|
+
expires_in: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type RequestMethods = Extract<Method, 'get' | 'post' | 'put' | 'delete' | 'patch' | 'option' | 'head'>;
|
|
17
|
+
|
|
18
|
+
export interface SuHttpError extends AxiosError {
|
|
19
|
+
isCancelRequest?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SuHttpResponse extends AxiosResponse {
|
|
23
|
+
config: SuHttpRequestConfig;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SuHttpRequestConfig extends AxiosRequestConfig {
|
|
27
|
+
beforeRequestCallback?: (request: SuHttpRequestConfig) => void;
|
|
28
|
+
beforeResponseCallback?: (response: SuHttpResponse) => void;
|
|
29
|
+
loading?: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class SuHttp {
|
|
33
|
+
request<T>(
|
|
34
|
+
method: RequestMethods,
|
|
35
|
+
url: string,
|
|
36
|
+
param?: AxiosRequestConfig,
|
|
37
|
+
axiosConfig?: SuHttpRequestConfig
|
|
38
|
+
): Promise<T>;
|
|
39
|
+
post<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P>;
|
|
40
|
+
postRouter<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P>;
|
|
41
|
+
get<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P>;
|
|
42
|
+
}
|
|
@@ -88,18 +88,8 @@ const columns = [
|
|
|
88
88
|
return [
|
|
89
89
|
<>
|
|
90
90
|
{app}
|
|
91
|
-
<ut-button
|
|
92
|
-
|
|
93
|
-
status="danger"
|
|
94
|
-
icon="ri-close-line"
|
|
95
|
-
onTap={() => handleStop(row)}
|
|
96
|
-
/>
|
|
97
|
-
<ut-button
|
|
98
|
-
content="taskLog"
|
|
99
|
-
status="info"
|
|
100
|
-
icon="ri-file-line"
|
|
101
|
-
onTap={() => handleLog(row)}
|
|
102
|
-
/>
|
|
91
|
+
<ut-button content="stopTask" status="danger" icon="ri-close-line" onTap={() => handleStop(row)} />
|
|
92
|
+
<ut-button content="taskLog" status="info" icon="ri-file-line" onTap={() => handleLog(row)} />
|
|
103
93
|
</>
|
|
104
94
|
];
|
|
105
95
|
}
|