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

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 (183) hide show
  1. package/dist/403-CyoOD-Ik.js +65 -0
  2. package/dist/404-Ch_OHTw0.js +65 -0
  3. package/dist/500-Cf9am7HK.js +67 -0
  4. package/dist/AuthorityInfo-BJ427cqG.js +4 -0
  5. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-D9y7AwbB.js +99 -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-qo-lKPkv.js +25 -0
  9. package/dist/CompanyPanel-DkKWAKvY.js +204 -0
  10. package/dist/DataSet-iBHzs75s.js +147 -0
  11. package/dist/Department-CHUQByKX.js +25 -0
  12. package/dist/DepartmentPanel-C742dfOO.js +248 -0
  13. package/dist/DesignPanel-D9oE5R7m.js +4 -0
  14. package/dist/DesignPanel.vue_vue_type_style_index_0_lang-hYldVEbo.js +1097 -0
  15. package/dist/DictView-CrFXprP9.js +110 -0
  16. package/dist/InvOrganization-Cz8SzIgs.js +73 -0
  17. package/dist/Org-Bzt6yKox.js +38 -0
  18. package/dist/Preview-jonigfMQ.js +48 -0
  19. package/dist/ReportDefine-BpiM5Ovq.js +10 -0
  20. package/dist/ReportDesign-fp09cXJ7.js +164 -0
  21. package/dist/ReportQuery-52ZP1PYP.js +74 -0
  22. package/dist/ReportQueryFrom-DSYavJb1.js +4 -0
  23. package/dist/ReportQueryFrom.vue_vue_type_style_index_0_lang-DBGYEp0u.js +177 -0
  24. package/dist/ReportTemplate-CA_UW0eD.js +161 -0
  25. package/dist/Role-DqOt8Bk0.js +25 -0
  26. package/dist/RoleAssign-BdxhefhQ.js +26 -0
  27. package/dist/RolePanel-2gZ3H0ET.js +4 -0
  28. package/dist/RolePanel-BsNd0svJ.js +4 -0
  29. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DLOwgF99.js +152 -0
  30. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DmzD9kab.js +131 -0
  31. package/dist/ScrollPanel.vue_vue_type_style_index_0_lang-B9ptUMeI.js +99 -0
  32. package/dist/Staff-D3L8fEoY.js +26 -0
  33. package/dist/StaffInfo-DYRw6ZYJ.js +4 -0
  34. package/dist/StaffInfo.vue_vue_type_script_setup_true_lang-xqEOQnMs.js +107 -0
  35. package/dist/StaffPanel-DkrNH6Px.js +4 -0
  36. package/dist/StaffPanel.vue_vue_type_script_setup_true_lang-BPBMnliy.js +152 -0
  37. package/dist/SysUser-Bl1-cIpJ.js +15 -0
  38. package/dist/SysUserPanel-yxNLaBwt.js +4 -0
  39. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BDcsgSl5.js +352 -0
  40. package/dist/SystemMenu-C4_Arn12.js +155 -0
  41. package/dist/UserInfo-QcNwJCUR.js +4 -0
  42. package/dist/UserInfo.vue_vue_type_style_index_0_lang-DLIeUphX.js +159 -0
  43. package/dist/childView-B23DEO2u.js +4 -0
  44. package/dist/childView-saDZQv9x.js +4 -0
  45. package/dist/childView.vue_vue_type_style_index_0_lang-RsKR6CAC.js +182 -0
  46. package/dist/childView.vue_vue_type_style_index_0_lang-ZFEfavUY.js +142 -0
  47. package/dist/code-rule-2_Ihx_by.js +147 -0
  48. package/dist/core.es.js +26 -6
  49. package/dist/cron-task-BFOPJQIk.js +134 -0
  50. package/dist/flow-task-PoDnE_kE.js +10 -0
  51. package/dist/frameView-f7Ya0Knj.js +43 -0
  52. package/dist/index-BpdTDaTk.js +3213 -0
  53. package/dist/layout-home-v3DPJ7rB.js +231 -0
  54. package/dist/layoutView-DZHoQDH1.js +3190 -0
  55. package/dist/log-in-BPAMJTwH.js +115 -0
  56. package/dist/log-out-DZACF0jg.js +129 -0
  57. package/dist/login-B8cwozax.js +216 -0
  58. package/dist/login-log-CVvRgZSu.js +70 -0
  59. package/dist/lov-view-Ba7Y7xy0.js +98 -0
  60. package/dist/menuInfo-BpRKFYK8.js +4 -0
  61. package/dist/menuInfo.vue_vue_type_style_index_0_lang-DJ5sUC6m.js +359 -0
  62. package/dist/pda-app-C0jJecrL.js +706 -0
  63. package/dist/redirect-DTz8GSnv.js +15 -0
  64. package/dist/resource-BG22Cw4P.js +97 -0
  65. package/dist/su-welcome-DaxhbrC6.js +879 -0
  66. package/dist/sys-config-CG2fMtak.js +384 -0
  67. package/dist/udp-core.css +1 -2
  68. package/dist/useNav-_u2UAQWk.js +84 -0
  69. package/dist/utogether-MlnyYtNS.js +4 -0
  70. package/dist/wecom-push-B75FLee5.js +70 -0
  71. package/index.ts +54 -50
  72. package/package.json +21 -21
  73. package/src/App.vue +79 -78
  74. package/src/api/http.ts +10 -4
  75. package/src/api/index.ts +51 -51
  76. package/src/api/user.ts +64 -64
  77. package/src/components/SuQrcode/src/index.tsx +231 -236
  78. package/src/components/udp/content/index.vue +93 -93
  79. package/src/components/udp/form-upload/form-upload.vue +496 -496
  80. package/src/components/udp/grid/index.vue +643 -544
  81. package/src/components/udp/index.ts +2 -1
  82. package/src/components/udp/modal-form/index.vue +326 -0
  83. package/src/components/udp/utils.ts +420 -420
  84. package/src/layout/components/lay-navbar/index.vue +240 -240
  85. package/src/layout/components/lay-panel/index.vue +2 -6
  86. package/src/layout/components/lay-search/components/SearchModal.vue +185 -181
  87. package/src/layout/components/lay-sidebar/mixNav.vue +261 -261
  88. package/src/layout/components/lay-sidebar/sidebarItem.vue +199 -195
  89. package/src/layout/components/lay-sidebar/vertical.vue +92 -92
  90. package/src/layout/layoutView.vue +1 -0
  91. package/src/main.ts +111 -109
  92. package/src/plugins/i18n/zh.ts +5 -1
  93. package/src/plugins/vxe-table/index.ts +116 -116
  94. package/src/router/index.ts +5 -34
  95. package/src/router/utils.ts +434 -430
  96. package/src/store/modules/permission.ts +1 -1
  97. package/src/store/modules/system.ts +193 -186
  98. package/src/style/print-lock.css +380 -375
  99. package/src/style/suprint.css +990 -985
  100. package/src/style/vxetable.scss +372 -364
  101. package/src/utils/authority/index.ts +19 -2
  102. package/src/utils/dataFormat/index.ts +309 -222
  103. package/src/utils/udp/http/index.ts +126 -67
  104. package/src/utils/udp/http/types.d.ts +15 -14
  105. package/src/views/login/login-view.vue +4 -21
  106. package/src/views/organization/department/DepartmentPanel.vue +3 -4
  107. package/src/views/system/sys/sys-config.vue +344 -344
  108. package/src/views/uhome/components/home-todo.vue +191 -178
  109. package/src/views/uhome/dynamic-card.vue +31 -31
  110. package/src/views/uhome/su-welcome.vue +310 -310
  111. package/src/views/ulogin/login.vue +292 -296
  112. package/src/views/urpt/design/DesignPanel.vue +538 -507
  113. package/src/views/urpt/design/print-data.ts +39 -59
  114. package/tsconfig.json +2 -3
  115. package/types/global.d.ts +234 -234
  116. package/vite.config.ts +2 -1
  117. package/dist/403-D6Wb3JJh.js +0 -72
  118. package/dist/404-B_HNbPNV.js +0 -72
  119. package/dist/500-BMemTTy1.js +0 -77
  120. package/dist/AuthorityInfo-6wHxwiFM.js +0 -91
  121. package/dist/AuthorityPanel-OqF_DvXA.js +0 -98
  122. package/dist/Company-BLXSfow0.js +0 -21
  123. package/dist/CompanyPanel-B4kRZ5Cg.js +0 -199
  124. package/dist/DataSet-CuGZcKC-.js +0 -141
  125. package/dist/Department-oFhsa7cd.js +0 -21
  126. package/dist/DepartmentPanel-B1UGpu-r.js +0 -242
  127. package/dist/DepartmentPanel-BL58AdoT.js +0 -2
  128. package/dist/DesignPanel-DmkFVw1N.js +0 -1196
  129. package/dist/DictView-CC5yMzOq.js +0 -100
  130. package/dist/File-WJXjGYxr.js +0 -89
  131. package/dist/InvOrganization-BwMmD8Ua.js +0 -76
  132. package/dist/Org-HgnOWubi.js +0 -76
  133. package/dist/Preview-CAzWxLmP.js +0 -45
  134. package/dist/ReIcon-DecitXmg.js +0 -413
  135. package/dist/ReportDefine-BgLM-Rjk.js +0 -10
  136. package/dist/ReportDesign-DwchGG2P.js +0 -158
  137. package/dist/ReportQuery-D5jaRJEn.js +0 -101
  138. package/dist/ReportQueryFrom-CNlmtYey.js +0 -198
  139. package/dist/ReportTemplate-CNcTmccs.js +0 -162
  140. package/dist/Role-Be8WfdCA.js +0 -21
  141. package/dist/RoleAssign-CtehGAUf.js +0 -22
  142. package/dist/RolePanel-CAwITg_q.js +0 -131
  143. package/dist/RolePanel-SN0FGFZ7.js +0 -176
  144. package/dist/ScrollPanel-DW30pGz1.js +0 -88
  145. package/dist/Staff-V2YsNKcj.js +0 -22
  146. package/dist/StaffInfo-CKRPW0r4.js +0 -149
  147. package/dist/StaffPanel-BxcgMg7u.js +0 -143
  148. package/dist/SysUser-Dxyj5w5m.js +0 -12
  149. package/dist/SysUserPanel-DI6CWcZo.js +0 -365
  150. package/dist/SystemMenu-BBHREM8T.js +0 -154
  151. package/dist/UserInfo-BMVQ0xwE.js +0 -194
  152. package/dist/_plugin-vue_export-helper-C6QCLu9I.js +0 -8
  153. package/dist/api-BFNxcxSN.js +0 -30
  154. package/dist/authority-BJFEUdrh.js +0 -20
  155. package/dist/await-to-js.es5-DkWYmPXW.js +0 -10
  156. package/dist/childView-BBjPEraB.js +0 -184
  157. package/dist/childView-DNqG2UVm.js +0 -181
  158. package/dist/code-rule-QFrhqFrW.js +0 -151
  159. package/dist/contant-Q77dU_V3.js +0 -4
  160. package/dist/cron-task-BpUDKEAU.js +0 -131
  161. package/dist/flow-task-DAc2NrDU.js +0 -11
  162. package/dist/frameView-Di0zJZUR.js +0 -39
  163. package/dist/layout-home-BVp7vYLR.js +0 -239
  164. package/dist/layoutView-B6Mx2ERA.js +0 -2662
  165. package/dist/log-in-BrNB0mLz.js +0 -117
  166. package/dist/log-out-dYfqvzy6.js +0 -111
  167. package/dist/login-D_Hjy3Jd.js +0 -231
  168. package/dist/login-log-CJak-ANA.js +0 -79
  169. package/dist/lov-view-DM5Nm5tW.js +0 -95
  170. package/dist/menuInfo-BlOY1KZW.js +0 -346
  171. package/dist/mitt-CQgI7DYU.js +0 -27
  172. package/dist/pda-app-CA7YI37u.js +0 -589
  173. package/dist/redirect-N0k4tImU.js +0 -16
  174. package/dist/resource-CfQTHFcs.js +0 -94
  175. package/dist/su-welcome-DVD3S_du.js +0 -799
  176. package/dist/sys-config-Ddb3vBpK.js +0 -316
  177. package/dist/system-Cm3lyBas.js +0 -1528
  178. package/dist/udp-core-DaQd5CF1.js +0 -2028
  179. package/dist/useDataThemeChange-DJ4K3VGp.js +0 -226
  180. package/dist/useNav-BhOJIdrJ.js +0 -106
  181. package/dist/utogether-l7JXs4Lv.js +0 -4
  182. package/dist/water-mark-WDQZ9YqB.js +0 -119
  183. package/dist/wecom-push-kWkAVRCj.js +0 -77
@@ -1,25 +1,72 @@
1
1
  import Axios, { type AxiosInstance, type AxiosRequestConfig } from 'axios';
2
- import type { SuHttpError, RequestMethods, SuHttpResponse, SuHttpRequestConfig } from './types.d';
2
+ import type { RequestMethods, XHttpRequestConfig } from './types.d';
3
+ // import { NProgress, cookies, errorMessage } from "./index";
3
4
  import { NProgress, cookies, errorMessage } from '@utogether/utils';
5
+
4
6
  import { isRef } from 'vue';
5
7
  import { has } from 'xe-utils';
6
8
 
7
9
  const kTOKENKEY = 'authorized-token';
8
10
  const defaultConfig: AxiosRequestConfig = {
9
- timeout: 180000,
11
+ timeout: 300000,
10
12
  headers: {
11
13
  Accept: 'application/json, text/plain, */*',
12
14
  'Content-Type': 'application/json',
13
15
  'X-Requested-With': 'XMLHttpRequest'
14
16
  }
15
17
  };
16
- class SuHttp {
18
+
19
+ // 存储pending中的请求
20
+ const pendingMap = new Map<string, (message?: string) => void>();
21
+
22
+ // 生成请求唯一标识
23
+ const getRequestKey = config => {
24
+ try {
25
+ const { method, url, params, data } = config;
26
+ const paramString = params ? JSON.stringify(params) : '';
27
+ const dataString = data ? JSON.stringify(data) : '';
28
+ return [method?.toUpperCase(), url, paramString, dataString].filter(Boolean).join('&');
29
+ } catch (error) {
30
+ console.warn('Failed to generate request key:', error);
31
+ return `${config.method || 'GET'}_${config.url || ''}_${Date.now()}`;
32
+ }
33
+ };
34
+
35
+ // 添加pending请求
36
+ const addPending = (config: any): void => {
37
+ const key = getRequestKey(config);
38
+ console.log(key, pendingMap.has(key));
39
+ if (pendingMap.has(key)) {
40
+ const cancel = pendingMap.get(key);
41
+ if (cancel) {
42
+ cancel(`Duplicate request canceled: ${key}`);
43
+ }
44
+ pendingMap.delete(key);
45
+ }
46
+ config.cancelToken = new Axios.CancelToken(cancel => {
47
+ pendingMap.set(key, cancel);
48
+ });
49
+ };
50
+
51
+ // 移除pending请求
52
+ const removePending = config => {
53
+ const key = getRequestKey(config);
54
+ if (pendingMap.has(key)) {
55
+ pendingMap.delete(key);
56
+ }
57
+ };
58
+
59
+ class XHttp {
17
60
  constructor() {
18
61
  this.httpInterceptorsRequest();
19
62
  this.httpInterceptorsResponse();
20
63
  }
21
64
  router = undefined;
22
- baseUrl = 'http: //192.168.101.138.8099';
65
+ baseUrl = null;
66
+
67
+ // 服务白名单,判断是否需要token
68
+ whiteList = [/\/refreshToken$/, /\/login$/];
69
+
23
70
  /** token过期后,暂存待执行的请求 */
24
71
  private static requests = [];
25
72
 
@@ -34,17 +81,14 @@ class SuHttp {
34
81
  setBaseUrl(baseUrl) {
35
82
  this.baseUrl = baseUrl;
36
83
  }
37
- // 初始化配置对象
38
- private static initConfig: SuHttpRequestConfig = {};
39
84
 
40
85
  // 保存当前Axios实例对象
41
86
  private static axiosInstance: AxiosInstance = Axios.create(defaultConfig);
42
87
 
43
88
  /** 重连原始请求 */
44
- private static retryOriginalRequest(config: SuHttpRequestConfig) {
89
+ private static retryOriginalRequest(config: XHttpRequestConfig) {
45
90
  return new Promise(resolve => {
46
- // @ts-ignore
47
- SuHttp.requests.push((token: string) => {
91
+ XHttp.requests.push((token: string) => {
48
92
  config.headers!['Authorization'] = 'Bearer ' + token;
49
93
  resolve(config);
50
94
  });
@@ -53,37 +97,39 @@ class SuHttp {
53
97
 
54
98
  // 请求拦截
55
99
  private httpInterceptorsRequest(): void {
56
- SuHttp.axiosInstance.interceptors.request.use(
100
+ XHttp.axiosInstance.interceptors.request.use(
57
101
  (config: any) => {
58
102
  if (has(config, 'loading') && isRef(config.loading)) {
59
103
  config.loading.value = true;
60
104
  }
105
+
106
+ // 重复请求取消前一个
107
+ !config.url.includes('uath/refreshToken') && addPending(config);
108
+
61
109
  // 开启进度条动画
62
110
  NProgress.start();
111
+
63
112
  // 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
64
113
  if (typeof config.beforeRequestCallback === 'function') {
65
114
  config.beforeRequestCallback(config);
66
115
  return config;
67
116
  }
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 => {
117
+
118
+ if (this.whiteList.some(pattern => pattern.test(config.url))) return config;
119
+
120
+ return new Promise(async resolve => {
75
121
  const token = cookies.get(kTOKENKEY);
76
122
  if (token) {
77
123
  const data = JSON.parse(token);
78
124
  const now = new Date().getTime();
79
125
  const expired = data.expires - now <= 0;
80
126
  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
- })
127
+ if (!XHttp.isRefreshing) {
128
+ XHttp.isRefreshing = true;
129
+ XHttp.axiosInstance
130
+ .get(this.baseUrl + '/uath/refreshToken', {
131
+ params: { refreshToken: data.refreshToken }
132
+ })
87
133
  .then((res: any) => {
88
134
  if (!res?.access_token) {
89
135
  this.routeToLogin();
@@ -92,19 +138,20 @@ class SuHttp {
92
138
  this.setToken(res);
93
139
  config.headers['Authorization'] = 'Bearer ' + res.access_token;
94
140
  // token 刷新后将数组的方法重新执行
95
- SuHttp.requests.forEach(cb => cb(res.access_token));
96
- SuHttp.requests = []; // 重新请求完清空
141
+ XHttp.requests.forEach(cb => cb(res.access_token));
142
+ XHttp.requests = []; // 重新请求完清空
97
143
  }
98
144
  })
99
145
  .catch(() => {
100
146
  this.routeToLogin();
101
147
  })
102
148
  .finally(() => {
103
- SuHttp.isRefreshing = false;
149
+ XHttp.isRefreshing = false;
104
150
  });
105
151
  }
152
+ // 请求完成,移除pending记录
106
153
  // @ts-ignore
107
- resolve(SuHttp.retryOriginalRequest(config));
154
+ resolve(XHttp.retryOriginalRequest(config));
108
155
  } else {
109
156
  config.headers['Authorization'] = 'Bearer ' + data.accessToken;
110
157
  resolve(config);
@@ -129,14 +176,14 @@ class SuHttp {
129
176
  const cache = {
130
177
  accessToken: access_token,
131
178
  refreshToken: refresh_token,
132
- expires: Date.now() + expires_in * 1000
179
+ expires: Date.now() + expires_in
180
+ // expires: Date.now() + expires_in * 1000
133
181
  };
134
182
  cookies.set(kTOKENKEY, JSON.stringify(cache));
135
- // cookies.set(kTOKENKEY, JSON.stringify(cache), { expires: expires_in });
136
183
  }
137
184
 
138
185
  private routeToLogin() {
139
- SuHttp.requests = []; // 重新请求完清空
186
+ XHttp.requests = []; // 重新请求完清空
140
187
  cookies.remove('kCookies_token');
141
188
  cookies.remove('authorized-token');
142
189
  cookies.remove('loginer');
@@ -145,43 +192,58 @@ class SuHttp {
145
192
 
146
193
  // 响应拦截
147
194
  private httpInterceptorsResponse(): void {
148
- const instance = SuHttp.axiosInstance;
195
+ const instance = XHttp.axiosInstance;
149
196
  instance.interceptors.response.use(
150
- (response: SuHttpResponse) => {
151
- const $config = response.config;
197
+ (response: any) => {
198
+ const $config = response.config as XHttpRequestConfig;
199
+
152
200
  if (has($config, 'loading') && isRef($config.loading)) {
153
201
  $config.loading.value = false;
154
202
  }
203
+
204
+ // 请求完成,移除pending记录
205
+ removePending(response.config);
206
+
155
207
  // 关闭进度条动画
156
208
  NProgress.done();
209
+
157
210
  // 优先判断post/get等方法是否传入回掉,否则执行初始化设置等回掉
158
211
  if (typeof $config.beforeResponseCallback === 'function') {
159
212
  $config.beforeResponseCallback(response);
160
213
  return response.data;
161
214
  }
162
- if (SuHttp.initConfig.beforeResponseCallback) {
163
- SuHttp.initConfig.beforeResponseCallback(response);
164
- return response.data;
215
+
216
+ if (!response.data && response?.msg) {
217
+ return Promise.reject(response.msg);
165
218
  }
219
+
166
220
  return response.data;
167
221
  },
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;
222
+ (error: any) => {
223
+ // 被取消的请求不做错误提示
224
+ if (Axios.isCancel(error)) {
225
+ console.warn('请求已取消:', error.message);
226
+ return Promise.reject(error);
174
227
  }
175
- $error.isCancelRequest = Axios.isCancel($error);
228
+
229
+ // 移除pending记录
230
+ error.config && removePending(error.config);
231
+
232
+ const config = error.config as XHttpRequestConfig;
233
+
234
+ if (has(config, 'loading') && isRef(config?.loading)) {
235
+ config.loading.value = false;
236
+ }
237
+
176
238
  // 关闭进度条动画
177
239
  NProgress.done();
178
240
  // 所有的响应异常 区分来源为取消请求/非取消请求
179
- return Promise.reject($error);
241
+ return Promise.reject(error);
180
242
  }
181
243
  );
182
244
  }
183
245
 
184
- private transformConfigByMethod(params: any, config: SuHttpRequestConfig): SuHttpRequestConfig {
246
+ private transformConfigByMethod(params: any, config: XHttpRequestConfig): XHttpRequestConfig {
185
247
  const { method } = config;
186
248
  const methods = ['get'];
187
249
  const m = method!.toLocaleLowerCase();
@@ -197,27 +259,27 @@ class SuHttp {
197
259
  method: RequestMethods,
198
260
  url: string,
199
261
  param?: AxiosRequestConfig,
200
- axiosConfig?: SuHttpRequestConfig
262
+ axiosConfig?: XHttpRequestConfig
201
263
  ): Promise<T> {
202
264
  const config = this.transformConfigByMethod(param, {
203
265
  method,
204
266
  url,
205
267
  ...axiosConfig
206
- } as SuHttpRequestConfig);
268
+ } as XHttpRequestConfig);
207
269
  // 单独处理自定义请求/响应回掉
208
270
  return new Promise((resolve, reject) => {
209
- SuHttp.axiosInstance
271
+ XHttp.axiosInstance
210
272
  .request(config)
211
273
  .then((res: any) => {
212
- if (res && res?.code === '0') {
213
- resolve(res.data);
214
- } else if (res.code === '500') {
274
+ if (res.code === '500') {
215
275
  errorMessage(res.msg, { duration: 8000 });
216
276
  if (config.method === 'get') {
217
277
  resolve(res);
218
278
  } else {
219
279
  reject(res.msg);
220
280
  }
281
+ } else if (res?.code === '0') {
282
+ resolve(res.data);
221
283
  } else if (res?.code !== '-1') {
222
284
  resolve(res);
223
285
  } else {
@@ -229,12 +291,13 @@ class SuHttp {
229
291
  .catch(e => {
230
292
  if (e?.code) {
231
293
  if (e?.response?.status === 401) {
232
- // @ts-ignore
233
294
  return this.router?.push({ path: '/login' });
234
295
  }
235
- errorMessage(this.getNetworkError(e?.response?.status) || e?.message, { duration: 8000 });
296
+ if (e.code !== 'ERR_CANCELED') {
297
+ errorMessage(this.getNetworkError(e?.response?.status) || e?.message, { duration: 8000 });
298
+ }
236
299
  }
237
- if (e.config.method === 'get') {
300
+ if (e.config?.method === 'get') {
238
301
  resolve(e);
239
302
  } else {
240
303
  reject(e);
@@ -246,12 +309,12 @@ class SuHttp {
246
309
  getNetworkError = code => {
247
310
  if (!code) return null;
248
311
  const msgMap = {
249
- 400: '错误的请求',
250
- 401: '服务未授权,请重新登录',
251
- 403: '拒绝访问',
312
+ 400: '请求参数错误',
313
+ 401: '登录已过期,请重新登录',
314
+ 403: '没有权限访问',
252
315
  404: '请求错误,未找到该资源',
253
316
  408: '请求超时',
254
- 500: '服务器端出差',
317
+ 500: '服务器内部错误',
255
318
  502: '网络超时',
256
319
  503: '服务不可用',
257
320
  504: '网络超时'
@@ -260,29 +323,25 @@ class SuHttp {
260
323
  };
261
324
 
262
325
  // 单独抽离的post工具函数
263
- public post<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
264
- // @ts-ignore
326
+ public post<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
265
327
  return this.request<P>('post', url, params, config);
266
328
  }
267
329
 
268
330
  // 单独抽离的delete工具函数
269
- public delete<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
270
- // @ts-ignore
331
+ public delete<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
271
332
  return this.request<P>('delete', url, params, config);
272
333
  }
273
334
 
274
335
  // 单独抽离的put工具函数
275
- public put<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
276
- // @ts-ignore
336
+ public put<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
277
337
  return this.request<P>('put', url, params, config);
278
338
  }
279
339
 
280
340
  // 单独抽离的get工具函数
281
- public get<T, P>(url: string, params?: T, config?: SuHttpRequestConfig): Promise<P> {
341
+ public get<T, P>(url: string, params?: T, config?: XHttpRequestConfig): Promise<P> {
282
342
  for (const key in params) {
283
343
  if (!params[key]) delete params[key];
284
344
  }
285
- // @ts-ignore
286
345
  return this.request<P>('get', url, params, config);
287
346
  }
288
347
 
@@ -291,4 +350,4 @@ class SuHttp {
291
350
  }
292
351
  }
293
352
 
294
- export const http = new SuHttp();
353
+ 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) {