@utogether/udp-core 2.0.0-beta.26 → 2.0.0-beta.27

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 (161) hide show
  1. package/dist/403-gdcH0-Bo.js +65 -0
  2. package/dist/404-Se2SF97M.js +65 -0
  3. package/dist/500-B6j9AqLo.js +67 -0
  4. package/dist/AuthorityInfo-CQ8ydZvr.js +4 -0
  5. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-C4NRvS8p.js +100 -0
  6. package/dist/AuthorityPanel-lVnZ5bce.js +4 -0
  7. package/dist/AuthorityPanel.vue_vue_type_style_index_0_lang-nsfhDlvV.js +113 -0
  8. package/dist/Company-BzSVBSC4.js +25 -0
  9. package/dist/CompanyPanel-DBjZB4aJ.js +204 -0
  10. package/dist/DataSet-iBHzs75s.js +147 -0
  11. package/dist/Department-BkgseHo8.js +25 -0
  12. package/dist/DepartmentPanel-Sen93_2M.js +249 -0
  13. package/dist/DesignPanel-pqDcwaFC.js +4 -0
  14. package/dist/DesignPanel.vue_vue_type_style_index_0_lang-BjtYyEw7.js +1013 -0
  15. package/dist/DictView-CJLG4LlE.js +110 -0
  16. package/dist/InvOrganization-D0Jq1IAa.js +74 -0
  17. package/dist/Org-CO_1WT39.js +39 -0
  18. package/dist/Preview-DLI4Bwel.js +48 -0
  19. package/dist/ReportDefine-Cw46OnJ_.js +10 -0
  20. package/dist/ReportDesign-D4sHTXT7.js +165 -0
  21. package/dist/ReportQuery-DtOCvQSN.js +74 -0
  22. package/dist/ReportQueryFrom-QjL-ETPq.js +4 -0
  23. package/dist/ReportQueryFrom.vue_vue_type_style_index_0_lang-Dj9ne87n.js +177 -0
  24. package/dist/ReportTemplate-BxAgc_Aj.js +161 -0
  25. package/dist/Role-Df77BBD-.js +25 -0
  26. package/dist/RoleAssign-BrunouML.js +26 -0
  27. package/dist/RolePanel-DSVwqhiD.js +4 -0
  28. package/dist/RolePanel-HLA7XBlN.js +4 -0
  29. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-CKlbqRa5.js +132 -0
  30. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-CN0rUxKz.js +152 -0
  31. package/dist/ScrollPanel.vue_vue_type_style_index_0_lang-D_FeSXKv.js +99 -0
  32. package/dist/Staff-BeL1xcRf.js +26 -0
  33. package/dist/StaffInfo-CIfnltyX.js +4 -0
  34. package/dist/StaffInfo.vue_vue_type_script_setup_true_lang-DbLFwWfG.js +107 -0
  35. package/dist/StaffPanel-BV2CHWac.js +4 -0
  36. package/dist/StaffPanel.vue_vue_type_script_setup_true_lang-CvT-Vp2G.js +153 -0
  37. package/dist/SysUser-DPfNvthk.js +15 -0
  38. package/dist/SysUserPanel-CoLKYlQE.js +4 -0
  39. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-lcO3Cjbq.js +353 -0
  40. package/dist/SystemMenu-sdj1dRDA.js +156 -0
  41. package/dist/UserInfo-CTX4hhFl.js +4 -0
  42. package/dist/UserInfo.vue_vue_type_style_index_0_lang-ClhCd_8z.js +160 -0
  43. package/dist/await-to-js.es5-Bv3Eu4mi.js +10 -0
  44. package/dist/childView-BDmWwJO5.js +4 -0
  45. package/dist/childView-Dx3ACtHa.js +4 -0
  46. package/dist/childView.vue_vue_type_style_index_0_lang-CfKq_0FN.js +183 -0
  47. package/dist/childView.vue_vue_type_style_index_0_lang-DxZNtkhd.js +143 -0
  48. package/dist/code-rule-cvN4gYC_.js +148 -0
  49. package/dist/core.es.js +24 -6
  50. package/dist/cron-task-B0TkxFdp.js +135 -0
  51. package/dist/flow-task-PoDnE_kE.js +10 -0
  52. package/dist/frameView-5cy5BSgS.js +43 -0
  53. package/dist/img/minicolors.png +0 -0
  54. package/dist/index-C5WRTwvI.js +3006 -0
  55. package/dist/layout-home-DrARg-3o.js +232 -0
  56. package/dist/layoutView-25v_ngk5.js +3191 -0
  57. package/dist/log-in-Bmz5Uhbt.js +116 -0
  58. package/dist/log-out-B-8m3oNj.js +130 -0
  59. package/dist/login-Cmp2RvvW.js +217 -0
  60. package/dist/login-log-CVvRgZSu.js +70 -0
  61. package/dist/lov-view-BATtzw2X.js +99 -0
  62. package/dist/menuInfo-BIvrE7nm.js +4 -0
  63. package/dist/menuInfo.vue_vue_type_style_index_0_lang-B6USomit.js +360 -0
  64. package/dist/pda-app-CzHVyeEa.js +707 -0
  65. package/dist/redirect-DTz8GSnv.js +15 -0
  66. package/dist/resource-Y5lGB38n.js +97 -0
  67. package/dist/su-welcome-CXA6OzBw.js +878 -0
  68. package/dist/sys-config-CqO03LeC.js +385 -0
  69. package/dist/udp-core.css +1 -2
  70. package/dist/useNav-C-rCgubt.js +84 -0
  71. package/dist/utogether-MlnyYtNS.js +4 -0
  72. package/dist/wecom-push-B75FLee5.js +70 -0
  73. package/index.ts +3 -2
  74. package/package.json +1 -1
  75. package/src/App.vue +79 -78
  76. package/src/api/index.ts +1 -1
  77. package/src/components/SuQrcode/src/index.tsx +231 -236
  78. package/src/layout/components/lay-panel/index.vue +2 -6
  79. package/src/layout/components/lay-search/components/SearchModal.vue +7 -3
  80. package/src/main.ts +25 -23
  81. package/src/router/index.ts +156 -187
  82. package/src/store/modules/system.ts +7 -0
  83. package/src/style/vxetable.scss +372 -364
  84. package/src/utils/authority/index.ts +46 -29
  85. package/src/utils/udp/http/index.ts +115 -64
  86. package/src/utils/udp/http/types.d.ts +15 -14
  87. package/src/views/login/login-view.vue +4 -21
  88. package/src/views/organization/department/DepartmentPanel.vue +3 -4
  89. package/src/views/system/sys/sys-config.vue +344 -344
  90. package/src/views/uhome/components/home-todo.vue +179 -178
  91. package/src/views/ulogin/login.vue +5 -9
  92. package/tsconfig.json +2 -3
  93. package/types/global.d.ts +234 -234
  94. package/vite.config.ts +2 -1
  95. package/dist/403-D6Wb3JJh.js +0 -72
  96. package/dist/404-B_HNbPNV.js +0 -72
  97. package/dist/500-BMemTTy1.js +0 -77
  98. package/dist/AuthorityInfo-6wHxwiFM.js +0 -91
  99. package/dist/AuthorityPanel-OqF_DvXA.js +0 -98
  100. package/dist/Company-BLXSfow0.js +0 -21
  101. package/dist/CompanyPanel-B4kRZ5Cg.js +0 -199
  102. package/dist/DataSet-CuGZcKC-.js +0 -141
  103. package/dist/Department-oFhsa7cd.js +0 -21
  104. package/dist/DepartmentPanel-B1UGpu-r.js +0 -242
  105. package/dist/DepartmentPanel-BL58AdoT.js +0 -2
  106. package/dist/DesignPanel-DmkFVw1N.js +0 -1196
  107. package/dist/DictView-CC5yMzOq.js +0 -100
  108. package/dist/File-WJXjGYxr.js +0 -89
  109. package/dist/InvOrganization-BwMmD8Ua.js +0 -76
  110. package/dist/Org-HgnOWubi.js +0 -76
  111. package/dist/Preview-CAzWxLmP.js +0 -45
  112. package/dist/ReIcon-DecitXmg.js +0 -413
  113. package/dist/ReportDefine-BgLM-Rjk.js +0 -10
  114. package/dist/ReportDesign-DwchGG2P.js +0 -158
  115. package/dist/ReportQuery-D5jaRJEn.js +0 -101
  116. package/dist/ReportQueryFrom-CNlmtYey.js +0 -198
  117. package/dist/ReportTemplate-CNcTmccs.js +0 -162
  118. package/dist/Role-Be8WfdCA.js +0 -21
  119. package/dist/RoleAssign-CtehGAUf.js +0 -22
  120. package/dist/RolePanel-CAwITg_q.js +0 -131
  121. package/dist/RolePanel-SN0FGFZ7.js +0 -176
  122. package/dist/ScrollPanel-DW30pGz1.js +0 -88
  123. package/dist/Staff-V2YsNKcj.js +0 -22
  124. package/dist/StaffInfo-CKRPW0r4.js +0 -149
  125. package/dist/StaffPanel-BxcgMg7u.js +0 -143
  126. package/dist/SysUser-Dxyj5w5m.js +0 -12
  127. package/dist/SysUserPanel-DI6CWcZo.js +0 -365
  128. package/dist/SystemMenu-BBHREM8T.js +0 -154
  129. package/dist/UserInfo-BMVQ0xwE.js +0 -194
  130. package/dist/_plugin-vue_export-helper-C6QCLu9I.js +0 -8
  131. package/dist/api-BFNxcxSN.js +0 -30
  132. package/dist/authority-BJFEUdrh.js +0 -20
  133. package/dist/await-to-js.es5-DkWYmPXW.js +0 -10
  134. package/dist/childView-BBjPEraB.js +0 -184
  135. package/dist/childView-DNqG2UVm.js +0 -181
  136. package/dist/code-rule-QFrhqFrW.js +0 -151
  137. package/dist/contant-Q77dU_V3.js +0 -4
  138. package/dist/cron-task-BpUDKEAU.js +0 -131
  139. package/dist/flow-task-DAc2NrDU.js +0 -11
  140. package/dist/frameView-Di0zJZUR.js +0 -39
  141. package/dist/layout-home-BVp7vYLR.js +0 -239
  142. package/dist/layoutView-B6Mx2ERA.js +0 -2662
  143. package/dist/log-in-BrNB0mLz.js +0 -117
  144. package/dist/log-out-dYfqvzy6.js +0 -111
  145. package/dist/login-D_Hjy3Jd.js +0 -231
  146. package/dist/login-log-CJak-ANA.js +0 -79
  147. package/dist/lov-view-DM5Nm5tW.js +0 -95
  148. package/dist/menuInfo-BlOY1KZW.js +0 -346
  149. package/dist/mitt-CQgI7DYU.js +0 -27
  150. package/dist/pda-app-CA7YI37u.js +0 -589
  151. package/dist/redirect-N0k4tImU.js +0 -16
  152. package/dist/resource-CfQTHFcs.js +0 -94
  153. package/dist/su-welcome-DVD3S_du.js +0 -799
  154. package/dist/sys-config-Ddb3vBpK.js +0 -316
  155. package/dist/system-Cm3lyBas.js +0 -1528
  156. package/dist/udp-core-DaQd5CF1.js +0 -2028
  157. package/dist/useDataThemeChange-DJ4K3VGp.js +0 -226
  158. package/dist/useNav-BhOJIdrJ.js +0 -106
  159. package/dist/utogether-l7JXs4Lv.js +0 -4
  160. package/dist/water-mark-WDQZ9YqB.js +0 -119
  161. package/dist/wecom-push-kWkAVRCj.js +0 -77
@@ -1,29 +1,46 @@
1
- /*
2
- * @Author: wei.li
3
- * @Date: 2021-11-17 16:26:34
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2024-04-14 20:43:50
6
- * @Description: file content
7
- */
8
- import { usePermissionStoreHook } from '../../store/modules/permission';
9
- import { isArray } from 'xe-utils';
10
- import { router } from '../../router';
11
- const hasAuthority = auth => {
12
- if (!auth) return true;
13
- const permissionCode = router.currentRoute.value.meta?.permissionCode;
14
- if (!permissionCode) return true;
15
- if (!isArray(auth)) {
16
- auth = [auth];
17
- }
18
- const buttonAuth = usePermissionStoreHook().getButtonAuth;
19
- if (!buttonAuth) return true;
20
- let hasAuth = false;
21
- auth.forEach(item => {
22
- if (!hasAuth) {
23
- const authRoles = `${permissionCode}.${item}`;
24
- hasAuth = buttonAuth.includes(authRoles);
25
- }
26
- });
27
- return hasAuth;
28
- };
29
- export default hasAuthority;
1
+ /*
2
+ * @Author: wei.li
3
+ * @Date: 2021-11-17 16:26:34
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2026-07-01 13:55:44
6
+ * @Description: file content
7
+ */
8
+ import { usePermissionStoreHook } from '../../store/modules/permission';
9
+ import { isArray } from 'xe-utils';
10
+ import { router } from '../../router';
11
+ export const hasAuthority = auth => {
12
+ if (!auth) return true;
13
+ const permissionCode = router.currentRoute.value.meta?.permissionCode;
14
+ if (!permissionCode) return true;
15
+ if (!isArray(auth)) {
16
+ auth = [auth];
17
+ }
18
+ const buttonAuth = usePermissionStoreHook().getButtonAuth;
19
+ if (!buttonAuth) return true;
20
+ let hasAuth = false;
21
+ auth.forEach(item => {
22
+ if (!hasAuth) {
23
+ const authRoles = `${permissionCode}.${item}`;
24
+ hasAuth = buttonAuth.includes(authRoles);
25
+ }
26
+ });
27
+ return hasAuth;
28
+ };
29
+ /**
30
+ * @description: 只能查看权限
31
+ * @param {*} queryAuth 查询权限
32
+ * @param {*} editAuth 编辑权限
33
+ * @return {*} 是否仅有查询权限
34
+ */
35
+ export const isViewonly = (queryAuth = 'fetch', editAuth = 'edit') => {
36
+ if (!queryAuth) return true;
37
+ const permissionCode = router.currentRoute.value.meta?.permissionCode;
38
+ if (!permissionCode) return true;
39
+ const buttonAuth = usePermissionStoreHook().getButtonAuth;
40
+ if (!buttonAuth) return true;
41
+
42
+ const fetchAuth = `${permissionCode}.${queryAuth}`;
43
+ const hasAuth = buttonAuth.includes(fetchAuth) && !buttonAuth.includes(`${permissionCode}.${editAuth}`);
44
+ return hasAuth;
45
+ };
46
+ export default hasAuthority;
@@ -1,25 +1,66 @@
1
1
  import Axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
2
- import type { SuHttpError, RequestMethods, SuHttpResponse, SuHttpRequestConfig } from './types.d';
2
+ import type { XHttpError, RequestMethods, XHttpRequestConfig } from './types.d';
3
3
  import { NProgress, cookies, errorMessage } from '@utogether/utils';
4
4
  import { isRef } from 'vue';
5
5
  import { has } from 'xe-utils';
6
6
 
7
7
  const kTOKENKEY = 'authorized-token';
8
8
  const defaultConfig: AxiosRequestConfig = {
9
- timeout: 180000,
9
+ timeout: 300000,
10
10
  headers: {
11
11
  Accept: 'application/json, text/plain, */*',
12
12
  'Content-Type': 'application/json',
13
13
  'X-Requested-With': 'XMLHttpRequest'
14
14
  }
15
15
  };
16
- class SuHttp {
16
+
17
+ // 存储pending中的请求
18
+ const pendingMap = new Map<string, (message?: string) => void>();
19
+
20
+ // 生成请求唯一标识
21
+ const getRequestKey = config => {
22
+ try {
23
+ const { method, url, params, data } = config;
24
+ const paramString = params ? JSON.stringify(params) : '';
25
+ const dataString = data ? JSON.stringify(data) : '';
26
+ return [method?.toUpperCase(), url, paramString, dataString].filter(Boolean).join('&');
27
+ } catch (error) {
28
+ console.warn('Failed to generate request key:', error);
29
+ return `${config.method || 'GET'}_${config.url || ''}_${Date.now()}`;
30
+ }
31
+ };
32
+
33
+ // 添加pending请求
34
+ const addPending = (config: any): void => {
35
+ const key = getRequestKey(config);
36
+ console.log(key, pendingMap.has(key));
37
+ if (pendingMap.has(key)) {
38
+ const cancel = pendingMap.get(key);
39
+ if (cancel) {
40
+ cancel(`Duplicate request canceled: ${key}`);
41
+ }
42
+ pendingMap.delete(key);
43
+ }
44
+ config.cancelToken = new Axios.CancelToken(cancel => {
45
+ pendingMap.set(key, cancel);
46
+ });
47
+ };
48
+
49
+ // 移除pending请求
50
+ const removePending = config => {
51
+ const key = getRequestKey(config);
52
+ if (pendingMap.has(key)) {
53
+ pendingMap.delete(key);
54
+ }
55
+ };
56
+
57
+ class XHttp {
17
58
  constructor() {
18
59
  this.httpInterceptorsRequest();
19
60
  this.httpInterceptorsResponse();
20
61
  }
21
62
  router = undefined;
22
- baseUrl = 'http: //192.168.101.138.8099';
63
+ baseUrl = null;
23
64
  /** token过期后,暂存待执行的请求 */
24
65
  private static requests = [];
25
66
 
@@ -34,17 +75,14 @@ class SuHttp {
34
75
  setBaseUrl(baseUrl) {
35
76
  this.baseUrl = baseUrl;
36
77
  }
37
- // 初始化配置对象
38
- private static initConfig: SuHttpRequestConfig = {};
39
78
 
40
79
  // 保存当前Axios实例对象
41
80
  private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
42
81
 
43
82
  /** 重连原始请求 */
44
- private static retryOriginalRequest(config: SuHttpRequestConfig) {
83
+ private static retryOriginalRequest(config: XHttpRequestConfig) {
45
84
  return new Promise(resolve => {
46
- // @ts-ignore
47
- SuHttp.requests.push((token: string) => {
85
+ XHttp.requests.push((token: string) => {
48
86
  config.headers!['Authorization'] = 'Bearer ' + token;
49
87
  resolve(config);
50
88
  });
@@ -53,34 +91,37 @@ class SuHttp {
53
91
 
54
92
  // 请求拦截
55
93
  private httpInterceptorsRequest(): void {
56
- SuHttp.axiosInstance.interceptors.request.use(
94
+ XHttp.axiosInstance.interceptors.request.use(
57
95
  (config: any) => {
58
96
  if (has(config, 'loading') && isRef(config.loading)) {
59
97
  config.loading.value = true;
60
98
  }
99
+
100
+ // 重复请求取消前一个
101
+ addPending(config);
102
+
61
103
  // 开启进度条动画
62
104
  NProgress.start();
105
+
63
106
  // 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
64
107
  if (typeof config.beforeRequestCallback === 'function') {
65
108
  config.beforeRequestCallback(config);
66
109
  return config;
67
110
  }
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 => {
111
+
112
+ // 服务白名单,判断是否需要token
113
+ const whiteList = [/\/refreshToken$/, /\/login$/];
114
+ if (whiteList.some(pattern => pattern.test(config.url))) return config;
115
+
116
+ return new Promise(async resolve => {
75
117
  const token = cookies.get(kTOKENKEY);
76
118
  if (token) {
77
119
  const data = JSON.parse(token);
78
120
  const now = new Date().getTime();
79
121
  const expired = data.expires - now <= 0;
80
122
  if (expired) {
81
- if (!SuHttp.isRefreshing) {
82
- SuHttp.isRefreshing = true;
83
- // requests.push(() => SuHttp.axiosInstance(config));
123
+ if (!XHttp.isRefreshing) {
124
+ XHttp.isRefreshing = true;
84
125
  this.get(this.baseUrl + '/uath/refreshToken', {
85
126
  refreshToken: data.refreshToken
86
127
  })
@@ -92,19 +133,18 @@ class SuHttp {
92
133
  this.setToken(res);
93
134
  config.headers['Authorization'] = 'Bearer ' + res.access_token;
94
135
  // token 刷新后将数组的方法重新执行
95
- SuHttp.requests.forEach(cb => cb(res.access_token));
96
- SuHttp.requests = []; // 重新请求完清空
136
+ XHttp.requests.forEach(cb => cb(res.access_token));
137
+ XHttp.requests = []; // 重新请求完清空
97
138
  }
98
139
  })
99
140
  .catch(() => {
100
141
  this.routeToLogin();
101
142
  })
102
143
  .finally(() => {
103
- SuHttp.isRefreshing = false;
144
+ XHttp.isRefreshing = false;
104
145
  });
105
146
  }
106
- // @ts-ignore
107
- resolve(SuHttp.retryOriginalRequest(config));
147
+ return XHttp.retryOriginalRequest(config);
108
148
  } else {
109
149
  config.headers['Authorization'] = 'Bearer ' + data.accessToken;
110
150
  resolve(config);
@@ -132,11 +172,10 @@ class SuHttp {
132
172
  expires: Date.now() + expires_in * 1000
133
173
  };
134
174
  cookies.set(kTOKENKEY, JSON.stringify(cache));
135
- // cookies.set(kTOKENKEY, JSON.stringify(cache), { expires: expires_in });
136
175
  }
137
176
 
138
177
  private routeToLogin() {
139
- SuHttp.requests = []; // 重新请求完清空
178
+ XHttp.requests = []; // 重新请求完清空
140
179
  cookies.remove('kCookies_token');
141
180
  cookies.remove('authorized-token');
142
181
  cookies.remove('loginer');
@@ -145,43 +184,58 @@ class SuHttp {
145
184
 
146
185
  // 响应拦截
147
186
  private httpInterceptorsResponse(): void {
148
- const instance = SuHttp.axiosInstance;
187
+ const instance = XHttp.axiosInstance;
149
188
  instance.interceptors.response.use(
150
- (response: SuHttpResponse) => {
151
- const $config = response.config;
189
+ (response: any) => {
190
+ const $config = response.config as XHttpRequestConfig;
191
+
152
192
  if (has($config, 'loading') && isRef($config.loading)) {
153
193
  $config.loading.value = false;
154
194
  }
195
+
196
+ // 请求完成,移除pending记录
197
+ removePending(response.config);
198
+
155
199
  // 关闭进度条动画
156
200
  NProgress.done();
201
+
157
202
  // 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
158
203
  if (typeof $config.beforeResponseCallback === 'function') {
159
204
  $config.beforeResponseCallback(response);
160
205
  return response.data;
161
206
  }
162
- if (SuHttp.initConfig.beforeResponseCallback) {
163
- SuHttp.initConfig.beforeResponseCallback(response);
164
- return response.data;
207
+
208
+ if (!response.data && response?.msg) {
209
+ return Promise.reject(response.msg);
165
210
  }
211
+
166
212
  return response.data;
167
213
  },
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;
214
+ (error: XHttpError) => {
215
+ // 被取消的请求不做错误提示
216
+ if (Axios.isCancel(error)) {
217
+ console.warn('请求已取消:', error.message);
218
+ return Promise.reject(error);
174
219
  }
175
- $error.isCancelRequest = Axios.isCancel($error);
220
+
221
+ // 移除pending记录
222
+ error.config && removePending(error.config);
223
+
224
+ const config = error.config as XHttpRequestConfig;
225
+
226
+ if (has(config, 'loading') && isRef(config?.loading)) {
227
+ config.loading.value = false;
228
+ }
229
+
176
230
  // 关闭进度条动画
177
231
  NProgress.done();
178
232
  // 所有的响应异常 区分来源为取消请求/非取消请求
179
- return Promise.reject($error);
233
+ return Promise.reject(error);
180
234
  }
181
235
  );
182
236
  }
183
237
 
184
- private transformConfigByMethod(params: any, config: SuHttpRequestConfig): SuHttpRequestConfig {
238
+ private transformConfigByMethod(params: any, config: XHttpRequestConfig): XHttpRequestConfig {
185
239
  const { method } = config;
186
240
  const methods = ['get'];
187
241
  const m = method!.toLocaleLowerCase();
@@ -197,27 +251,27 @@ class SuHttp {
197
251
  method: RequestMethods,
198
252
  url: string,
199
253
  param?: AxiosRequestConfig,
200
- axiosConfig?: SuHttpRequestConfig
254
+ axiosConfig?: XHttpRequestConfig
201
255
  ): Promise<T> {
202
256
  const config = this.transformConfigByMethod(param, {
203
257
  method,
204
258
  url,
205
259
  ...axiosConfig
206
- } as SuHttpRequestConfig);
260
+ } as XHttpRequestConfig);
207
261
  // 单独处理自定义请求/响应回掉
208
262
  return new Promise((resolve, reject) => {
209
- SuHttp.axiosInstance
263
+ XHttp.axiosInstance
210
264
  .request(config)
211
265
  .then((res: any) => {
212
- if (res && res?.code === '0') {
213
- resolve(res.data);
214
- } else if (res.code === '500') {
266
+ if (res.code === '500') {
215
267
  errorMessage(res.msg, { duration: 8000 });
216
268
  if (config.method === 'get') {
217
269
  resolve(res);
218
270
  } else {
219
271
  reject(res.msg);
220
272
  }
273
+ } else if (res?.code === '0') {
274
+ resolve(res.data);
221
275
  } else if (res?.code !== '-1') {
222
276
  resolve(res);
223
277
  } else {
@@ -229,12 +283,13 @@ class SuHttp {
229
283
  .catch(e => {
230
284
  if (e?.code) {
231
285
  if (e?.response?.status === 401) {
232
- // @ts-ignore
233
286
  return this.router?.push({ path: '/login' });
234
287
  }
235
- errorMessage(this.getNetworkError(e?.response?.status) || e?.message, { duration: 8000 });
288
+ if (e.code !== 'ERR_CANCELED') {
289
+ errorMessage(this.getNetworkError(e?.response?.status) || e?.message, { duration: 8000 });
290
+ }
236
291
  }
237
- if (e.config.method === 'get') {
292
+ if (e.config?.method === 'get') {
238
293
  resolve(e);
239
294
  } else {
240
295
  reject(e);
@@ -246,12 +301,12 @@ class SuHttp {
246
301
  getNetworkError = code => {
247
302
  if (!code) return null;
248
303
  const msgMap = {
249
- 400: '错误的请求',
250
- 401: '服务未授权,请重新登录',
251
- 403: '拒绝访问',
304
+ 400: '请求参数错误',
305
+ 401: '登录已过期,请重新登录',
306
+ 403: '没有权限访问',
252
307
  404: '请求错误,未找到该资源',
253
308
  408: '请求超时',
254
- 500: '服务器端出差',
309
+ 500: '服务器内部错误',
255
310
  502: '网络超时',
256
311
  503: '服务不可用',
257
312
  504: '网络超时'
@@ -260,29 +315,25 @@ class SuHttp {
260
315
  };
261
316
 
262
317
  // 单独抽离的post工具函数
263
- public post<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
264
- // @ts-ignore
318
+ public post<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
265
319
  return this.request<P>('post', url, params, config);
266
320
  }
267
321
 
268
322
  // 单独抽离的delete工具函数
269
- public delete<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
270
- // @ts-ignore
323
+ public delete<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
271
324
  return this.request<P>('delete', url, params, config);
272
325
  }
273
326
 
274
327
  // 单独抽离的put工具函数
275
- public put<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
276
- // @ts-ignore
328
+ public put<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
277
329
  return this.request<P>('put', url, params, config);
278
330
  }
279
331
 
280
332
  // 单独抽离的get工具函数
281
- public get<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
333
+ public get<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
282
334
  for (const key in params) {
283
335
  if (!params[key]) delete params[key];
284
336
  }
285
- // @ts-ignore
286
337
  return this.request<P>('get', url, params, config);
287
338
  }
288
339
 
@@ -291,4 +342,4 @@ class SuHttp {
291
342
  }
292
343
  }
293
344
 
294
- export const http = new SuHttp();
345
+ export const http = new XHttp();
@@ -2,8 +2,8 @@
2
2
  * @Author: wei.li
3
3
  * @Date: 2022-03-08 15:17:39
4
4
  * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2023-12-01 13:55:46
6
- * @Description: SuHttp Axios 类型定义文件
5
+ * @LastEditTime: 2026-05-18 10:46:33
6
+ * @Description: XHttp Axios 类型定义文件
7
7
  */
8
8
  import type { Method, AxiosError, AxiosResponse, AxiosRequestConfig } from 'axios';
9
9
 
@@ -15,28 +15,29 @@ export type resultType = {
15
15
 
16
16
  export type RequestMethods = Extract<Method, 'get' | 'post' | 'put' | 'delete' | 'patch' | 'option' | 'head'>;
17
17
 
18
- export interface SuHttpError extends AxiosError {
18
+ export interface XHttpError extends AxiosError {
19
19
  isCancelRequest?: boolean;
20
20
  }
21
21
 
22
- export interface SuHttpResponse extends AxiosResponse {
23
- config: SuHttpRequestConfig;
22
+ export interface XHttpResponse extends AxiosResponse {
23
+ config: XHttpRequestConfig;
24
+ msg: string;
24
25
  }
25
26
 
26
- export interface SuHttpRequestConfig extends AxiosRequestConfig {
27
- beforeRequestCallback?: (request: SuHttpRequestConfig) => void;
28
- beforeResponseCallback?: (response: SuHttpResponse) => void;
29
- loading?: any;
27
+ export interface XHttpRequestConfig extends AxiosRequestConfig {
28
+ beforeRequestCallback?: (request: XHttpRequestConfig) => void;
29
+ beforeResponseCallback?: (response: XHttpResponse) => void;
30
+ loading?: boolean;
30
31
  }
31
32
 
32
- export default class SuHttp {
33
+ export default class XHttp {
33
34
  request<T>(
34
35
  method: RequestMethods,
35
36
  url: string,
36
37
  param?: AxiosRequestConfig,
37
- axiosConfig?: SuHttpRequestConfig
38
+ axiosConfig?: XHttpRequestConfig
38
39
  ): 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>;
40
+ post<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P>;
41
+ postRouter<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P>;
42
+ get<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P>;
42
43
  }
@@ -91,7 +91,6 @@ import { ref, reactive, onMounted, onBeforeMount, onBeforeUnmount } from 'vue';
91
91
  import { useRouter } from 'vue-router';
92
92
  import type { FormInstance } from 'element-plus';
93
93
  import { storageLocal, cookies, successMessage, delay } from '@utogether/utils';
94
- import { toDateString } from 'xe-utils';
95
94
  import to from 'await-to-js';
96
95
 
97
96
  import Motion from './utils/motion';
@@ -100,15 +99,12 @@ import TypeIt from '@/components/SuTypeit';
100
99
  import { useRenderIcon } from '@/components/ReIcon/src/hooks';
101
100
  // import { useTranslationLang } from '@/layout/hooks/useTranslationLang';
102
101
  import { useLayout } from '@/layout/hooks/useLayout';
103
- // import { useNav } from '@/layout/hooks/useNav';
104
- // import { useDataThemeChange } from '@/layout/hooks/useDataThemeChange';
102
+
105
103
  import { useSystemStoreHook } from '@/store/modules/system';
106
104
 
107
105
  import { getServiceApi } from '../../api';
108
- import { getPlatform, getBrower } from '@/utils/browers';
109
- // import dayIcon from '@/assets/svg/day.svg?component';
110
- // import darkIcon from '@/assets/svg/dark.svg?component';
111
- // import globalization from '@/assets/svg/globalization.svg?component';
106
+ import { userMonitor } from '../../api/user';
107
+
112
108
  import Lock from '@iconify-icons/ri/lock-fill';
113
109
  import User from '@iconify-icons/ri/user-3-fill';
114
110
 
@@ -176,7 +172,7 @@ const onLogin = async (formEl: FormInstance | undefined) => {
176
172
  cookies.set('loginer', username);
177
173
  await delay(300);
178
174
  router.push('/');
179
- await insertLoginInfo(username);
175
+ userMonitor(username);
180
176
  })
181
177
  .finally(() => {
182
178
  loading.value = false;
@@ -204,19 +200,6 @@ const cacheToken = token => {
204
200
  expires_in > 0 ? cookies.set(kTOKENKEY, dataString) : cookies.set(kTOKENKEY, dataString);
205
201
  };
206
202
 
207
- const insertLoginInfo = username => {
208
- const userAgent = navigator.userAgent.toLowerCase();
209
- const { browser, browserVersion } = getBrower(userAgent);
210
- const obj = {
211
- userName: username,
212
- loginTime: toDateString(new Date()),
213
- browser,
214
- browserVersion,
215
- operatingSystem: getPlatform(userAgent)
216
- };
217
- serviceApi.post('/upfm/v1/userMonitor', obj);
218
- };
219
-
220
203
  /** 使用公共函数,避免`removeEventListener`失效 */
221
204
  function onkeypress({ code }: KeyboardEvent) {
222
205
  if (['Enter', 'NumpadEnter'].includes(code)) {
@@ -113,15 +113,14 @@
113
113
 
114
114
  <script setup lang="ts">
115
115
  import { useI18n } from 'vue-i18n';
116
- import { reactive, watch, inject } from 'vue';
117
- import { templateRef } from '@vueuse/core';
116
+ import { reactive, watch, inject, ref } from 'vue';
118
117
  import { clone } from 'xe-utils';
119
118
  import to from 'await-to-js';
120
119
  import { VxeUI } from 'vxe-table';
121
120
  import { successMessage, warnMessage } from '@utogether/utils';
122
121
  import { useSystemStoreHook } from '../../../store/modules/system';
123
122
  import { getServiceApi } from '../../../api';
124
- import hasAuthority from '../../../utils/authority';
123
+ import { hasAuthority } from '../../../utils/authority';
125
124
 
126
125
  const data = reactive<IRecord>({
127
126
  record: {},
@@ -186,7 +185,7 @@ const handleEdit = dataStatus => {
186
185
  data.dialogFormVisible = true;
187
186
  };
188
187
 
189
- const xForm = templateRef<any>('xForm', null);
188
+ const xForm = ref<any>('xForm');
190
189
  const handleComfirm = () => {
191
190
  xForm.value.validate(async valid => {
192
191
  if (!valid) {