yxuse 3.0.91 → 3.0.92

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 (83) hide show
  1. package/lib/api.cjs.js +1 -1
  2. package/lib/api.es.js +2 -2
  3. package/lib/components.cjs.js +1 -1
  4. package/lib/components.es.js +11 -9
  5. package/lib/hooks.cjs.js +1 -1
  6. package/lib/hooks.es.js +6 -6
  7. package/lib/index.cjs.js +1 -1
  8. package/lib/index.cjs11.js +1 -1
  9. package/lib/index.cjs12.js +1 -1
  10. package/lib/index.cjs13.js +1 -1
  11. package/lib/index.cjs14.js +1 -1
  12. package/lib/index.cjs2.js +1 -1
  13. package/lib/index.cjs3.js +1 -1
  14. package/lib/index.cjs4.js +1 -1
  15. package/lib/index.cjs5.js +1 -1
  16. package/lib/index.cjs5.js.gz +0 -0
  17. package/lib/index.cjs6.js +1 -1
  18. package/lib/index.cjs7.js +1 -1
  19. package/lib/index.cjs8.js +1 -1
  20. package/lib/index.cjs9.js +1 -1
  21. package/lib/index.es.js +8 -9
  22. package/lib/index.es11.js +454 -15
  23. package/lib/index.es12.js +226 -423
  24. package/lib/index.es13.js +29 -202
  25. package/lib/index.es14.js +19 -34
  26. package/lib/index.es2.js +4 -3
  27. package/lib/index.es3.js +2 -2
  28. package/lib/index.es4.js +3 -3
  29. package/lib/index.es5.js +1751 -34
  30. package/lib/index.es5.js.gz +0 -0
  31. package/lib/index.es6.js +35 -841
  32. package/lib/index.es6.js.gz +0 -0
  33. package/lib/index.es7.js +1 -1
  34. package/lib/index.es8.js +1 -1
  35. package/lib/index.es9.js +4 -125
  36. package/lib/theme.cjs.js +1 -1
  37. package/lib/theme.es.js +12 -13
  38. package/lib/translate.cjs.js +1 -1
  39. package/lib/translate.es.js +9 -10
  40. package/lib/utils.cjs.js +1 -1
  41. package/lib/utils.es.js +5 -4
  42. package/lib/yxIcon.cjs.js +1 -1
  43. package/lib/yxIcon.es.js +2 -2
  44. package/lib/yxi18n.cjs.js +1 -1
  45. package/lib/yxi18n.es.js +1 -1
  46. package/lib/yxuse.css +1 -1
  47. package/lib/yxuse.css.gz +0 -0
  48. package/package.json +1 -1
  49. package/types/components/CommonPage/pagination.d.ts +2 -2
  50. package/types/components/CommonPage/props.d.ts +2 -2
  51. package/types/components/YxForm/index.vue.d.ts +1 -1
  52. package/types/components/YxForm/type.d.ts +14 -1
  53. package/types/components/YxNormalPage/config.d.ts +12 -0
  54. package/types/components/YxNormalPage/form.d.ts +7 -0
  55. package/types/components/YxNormalPage/index.d.ts +3 -0
  56. package/types/components/YxNormalPage/page.d.ts +83 -0
  57. package/types/components/YxNormalPage/pagination.d.ts +9 -0
  58. package/types/components/YxNormalPage/props.d.ts +40 -0
  59. package/types/components/YxNormalPage/search.d.ts +9 -0
  60. package/types/components/YxNormalPage/table.d.ts +5 -0
  61. package/types/components/YxNormalPage/type.d.ts +69 -0
  62. package/types/components/YxTable/index.vue.d.ts +4 -4
  63. package/types/components/YxTableBar/bar.d.ts +47 -0
  64. package/types/components/YxTableBar/config.d.ts +18 -0
  65. package/types/components/YxTableBar/index.d.ts +11 -0
  66. package/types/components/YxTableBar/props.d.ts +23 -0
  67. package/types/components/YxTableBar/type.d.ts +11 -0
  68. package/types/components/YxTablePro/index.d.ts +14 -14
  69. package/types/components/YxUpload/index.vue.d.ts +3 -3
  70. package/types/components/Yxbutton/index.vue.d.ts +6 -6
  71. package/types/components/index.d.ts +2 -0
  72. package/types/hooks/useConfirm/index.d.ts +1 -1
  73. package/types/hooks/useDialog/type.d.ts +1 -1
  74. package/types/theme/config.d.ts +1 -1
  75. package/types/theme/index.d.ts +1 -1
  76. package/types/utils/common/index.d.ts +7 -1
  77. package/types/utils/common/util.d.ts +1 -1
  78. package/types/utils/excel/index.d.ts +8 -8
  79. package/types/utils/subscribe/index.d.ts +1 -1
  80. package/lib/index.cjs15.js +0 -1
  81. package/lib/index.cjs6.js.gz +0 -0
  82. package/lib/index.es15.js +0 -22
  83. /package/lib/{index.es12.js.gz → index.es11.js.gz} +0 -0
package/lib/index.es12.js CHANGED
@@ -1,457 +1,260 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { a as axios } from "./vendor-axios.es.js";
5
- import { ElMessage, ElLoading, ElNotification } from "element-plus";
6
- import "element-plus/es/components/notification/style/index";
1
+ import { ElMessage, ElMessageBox } from "element-plus";
7
2
  import "element-plus/es/components/message/style/index";
8
- import "element-plus/es/components/message/style/css";
9
- import "element-plus/es/components/notification/style/css";
10
3
  import "element-plus/es/components/message-box/style/index";
11
- import "./vendor-dayjs.es.js";
12
- import "element-plus/es/components/loading/style/index";
13
- import "element-plus/es/components/loading/style/css";
14
- import "./vendor-mqtt.es.js";
15
- const ttc = {
16
- LOGIN_URL: `${window.location.origin}/ttc/cloud/#/login`,
17
- HOME_URL: `${window.location.origin}/ttc/cloud/#/cloud`,
18
- INTEGRATED_BASE_URL: `/gateway/integrated-management/api/v1`
4
+ import { d as dayjs } from "./vendor-dayjs.es.js";
5
+ const notifyMessageToSystems = (message) => {
6
+ const themeBc = new BroadcastChannel("YXUSE_BC");
7
+ themeBc.postMessage(message);
19
8
  };
20
- const URL = {
21
- ttc
9
+ const receiveMessage = (callback) => {
10
+ const themeBc = new BroadcastChannel("YXUSE_BC");
11
+ themeBc.onmessage = () => {
12
+ callback();
13
+ };
22
14
  };
23
- const BC_THEME_NAME = "THEME";
24
- const BC_LANG_NAME = "LANG";
25
- const getAuthRouteList = (systemName = "ttc") => {
26
- return http.get(`${URL[systemName].INTEGRATED_BASE_URL}/account/auth/route/list`);
27
- };
28
- const getHomeMenuList = (systemName = "ttc") => {
29
- return http.get(`${URL[systemName].INTEGRATED_BASE_URL}/account/home/menu`);
30
- };
31
- const removeToken = (systemName = "ttc") => {
32
- setSystemConfig({ token: "" });
33
- };
34
- const setSystemInfo = (key, data) => {
35
- const GlobalStateKey = `${key}GlobalState`;
36
- localStorage.setItem(GlobalStateKey, JSON.stringify(data));
37
- };
38
- const setUserInfo = (key, userInfo) => {
39
- const GlobalStateKey = `${key}GlobalState`;
40
- const GlobalState = localStorage.getItem(GlobalStateKey) ?? "{}";
41
- const newGlobalState = { ...JSON.parse(GlobalState), userInfo };
42
- localStorage.setItem(GlobalStateKey, JSON.stringify(newGlobalState));
43
- };
44
- const getToken = (systemName = "ttc") => {
45
- const GlobalStateKey = `${systemName}GlobalState`;
46
- const GlobalState = localStorage.getItem(GlobalStateKey) ?? "{}";
47
- const token = JSON.parse(GlobalState) ? JSON.parse(GlobalState).token : null;
48
- return token;
15
+ const getSelectOptions = (arr, labelKey, valueKey, isValueToNumber) => {
16
+ if (!Array.isArray(arr)) return [];
17
+ return arr.map((item) => {
18
+ return {
19
+ label: item == null ? void 0 : item[labelKey],
20
+ value: isValueToNumber ? +item[valueKey] : item[valueKey]
21
+ };
22
+ });
49
23
  };
50
- const autoLogin = async ({ userName, password }, systemName = "ttc") => {
51
- const loginApiUrl = getSystemConfig("loginApiUrl");
52
- const { data } = await http.post(loginApiUrl, { userName, password });
53
- if (data.tokenValue) {
54
- ElMessage.success("登录成功");
24
+ const enumToArray = (enumObject) => {
25
+ const result = [];
26
+ for (const key in enumObject) {
27
+ if (isNaN(Number(key))) {
28
+ result.push({ label: key, value: enumObject[key] });
29
+ }
55
30
  }
56
- setSystemConfig({ token: data.tokenValue, userInfo: data });
31
+ return result;
57
32
  };
58
- const getUserInfo = (systemName = "ttc") => {
59
- const GlobalStateKey = `${systemName}GlobalState`;
60
- const GlobalState = localStorage.getItem(GlobalStateKey) ?? "{}";
61
- const userInfo = JSON.parse(GlobalState) ? JSON.parse(GlobalState).userInfo : null;
62
- return userInfo;
63
- };
64
- const getUserRouteList = async () => {
65
- if (!getToken()) return [];
66
- const data = await getHomeMenuList();
67
- return data;
68
- };
69
- const jumpToLogin = () => {
70
- if (isProduction()) {
71
- removeToken();
72
- const curRoute = location.pathname;
73
- if (curRoute.includes(getLoginUrl())) {
74
- return;
33
+ const isDarkColor = (color) => {
34
+ const parseColor = (color2) => {
35
+ let r2 = 0, g2 = 0, b2 = 0, a = 1;
36
+ if (color2.startsWith("#")) {
37
+ color2 = color2.slice(1);
38
+ if (color2.length === 3) {
39
+ r2 = parseInt(color2[0] + color2[0], 16);
40
+ g2 = parseInt(color2[1] + color2[1], 16);
41
+ b2 = parseInt(color2[2] + color2[2], 16);
42
+ } else if (color2.length === 6) {
43
+ r2 = parseInt(color2.slice(0, 2), 16);
44
+ g2 = parseInt(color2.slice(2, 4), 16);
45
+ b2 = parseInt(color2.slice(4, 6), 16);
46
+ } else {
47
+ return null;
48
+ }
49
+ } else if (color2.startsWith("rgb")) {
50
+ const rgbaMatch = color2.match(/(\d+(\.\d+)?)/g);
51
+ if (rgbaMatch) {
52
+ r2 = parseFloat(rgbaMatch[0]);
53
+ g2 = parseFloat(rgbaMatch[1]);
54
+ b2 = parseFloat(rgbaMatch[2]);
55
+ if (rgbaMatch.length > 3) {
56
+ a = parseFloat(rgbaMatch[3]);
57
+ }
58
+ } else {
59
+ return null;
60
+ }
75
61
  } else {
76
- location.replace(getLoginUrl());
62
+ return null;
77
63
  }
78
- } else {
79
- const userName = window.prompt("当前系统处于开发环境,当前登录过期,请输入登录账号", "");
80
- if (userName !== null) {
81
- const password = window.prompt("请输入登录密码", "");
82
- if (password === null || password == "") window.prompt("请输入登录密码", "");
83
- autoLogin({ userName, password });
84
- }
85
- }
86
- };
87
- const jumpToHome = () => {
88
- window.location.replace(getHomeUrl());
89
- };
90
- const getLoginUrl = () => {
91
- return getSystemConfig("loginUrl");
92
- };
93
- const getHomeUrl = () => {
94
- return getSystemConfig("homeUrl");
95
- };
96
- const setSystemConfig = (config2, systemName = "ttc") => {
97
- const GlobalState = localStorage.getItem(`${systemName}GlobalState`) ?? "{}";
98
- const newGlobalState = { ...JSON.parse(GlobalState), ...config2 };
99
- localStorage.setItem(`${systemName}GlobalState`, JSON.stringify(newGlobalState));
100
- };
101
- const changeSystemConfig = (key, value, systemName = "ttc") => {
102
- const GlobalState = localStorage.getItem(`${systemName}GlobalState`) ?? "{}";
103
- const newGlobalState = { ...JSON.parse(GlobalState), [key]: value };
104
- localStorage.setItem(`${systemName}GlobalState`, JSON.stringify(newGlobalState));
105
- };
106
- const getSystemConfig = (key, systemName = "ttc") => {
107
- const GlobalState = JSON.parse(localStorage.getItem(`${systemName}GlobalState`) ?? "{}");
108
- return GlobalState[key] ?? "";
109
- };
110
- const isProduction = () => {
111
- return getSystemConfig("environment") === "production";
112
- };
113
- const getUserPermissions = async (systemName, isJumpLogin = true, serverName) => {
114
- if (!getToken() && isJumpLogin) return jumpToLogin();
115
- try {
116
- const { data } = await getAuthRouteList(serverName);
117
- const systemPermissionList = data.filter((route) => route.routeTag.startsWith(systemName));
118
- const userMenuList = systemPermissionList.filter((item) => item.routeType === "VIEW");
119
- const userBtnList = systemPermissionList.filter((item) => item.routeType === "BTN");
120
- sessionStorage.setItem("ttcUserBtnList", JSON.stringify(userBtnList.map((item) => item.routeTag)));
121
- return {
122
- userMenuList,
123
- userBtnList
124
- };
125
- } catch (err) {
64
+ return [r2, g2, b2, a];
65
+ };
66
+ const colorComponents = parseColor(color);
67
+ if (!colorComponents) {
68
+ return null;
126
69
  }
70
+ const [r, g, b, _] = colorComponents;
71
+ const normalizedR = r / 255;
72
+ const normalizedG = g / 255;
73
+ const normalizedB = b / 255;
74
+ const max = Math.max(normalizedR, normalizedG, normalizedB);
75
+ const min = Math.min(normalizedR, normalizedG, normalizedB);
76
+ let l = (max + min) / 2;
77
+ return l < 0.5;
127
78
  };
128
- const getUserRouter = (userMenuList, viewModules) => {
129
- let menuList = [];
130
- userMenuList.forEach((item) => {
131
- const viewKey = `/src/views${item.routeView}/index.vue`;
132
- if (viewModules[viewKey]) {
133
- const pageConfig = (item == null ? void 0 : item.reservedRouteInfo) && JSON.parse((item == null ? void 0 : item.reservedRouteInfo) ?? "{}");
134
- const routerObject = {
135
- path: item.routeView,
136
- name: item.routeView.split("/")[1],
137
- meta: {
138
- title: item.routeName,
139
- icon: pageConfig == null ? void 0 : pageConfig.routeIcon
140
- },
141
- component: viewModules[viewKey]
142
- };
143
- menuList.push(routerObject);
144
- }
145
- });
146
- return menuList;
147
- };
148
- const getUserIsHaveBtnPower = (routeTag) => {
149
- if (!routeTag) return false;
150
- const authButtonListGet = sessionStorage.getItem("ttcUserBtnList") ?? "[]";
151
- return JSON.parse(authButtonListGet).includes(routeTag);
152
- };
153
- let userConfig = null;
154
- const getUserConfig = async () => {
155
- if (userConfig) return userConfig;
156
- const data = await http.get(
157
- getSystemConfig("userConfigApiUrl"),
158
- {},
159
- {
160
- headers: { noLoading: true },
161
- customResHandler: (data2) => {
162
- return data2;
79
+ const areColorsSimilar = (color1, color2, threshold = 100) => {
80
+ const getColorComponents = (color) => {
81
+ let r, g, b, a = 1;
82
+ if (color.startsWith("#")) {
83
+ color = color.slice(1);
84
+ if (color.length === 3) {
85
+ r = parseInt(color[0] + color[0], 16);
86
+ g = parseInt(color[1] + color[1], 16);
87
+ b = parseInt(color[2] + color[2], 16);
88
+ } else if (color.length === 6) {
89
+ r = parseInt(color.slice(0, 2), 16);
90
+ g = parseInt(color.slice(2, 4), 16);
91
+ b = parseInt(color.slice(4, 6), 16);
92
+ } else {
93
+ return null;
163
94
  }
95
+ } else if (color.startsWith("rgb")) {
96
+ const rgbaMatch = color.match(/(\d+(\.\d+)?)/g);
97
+ r = parseFloat(rgbaMatch[0]);
98
+ g = parseFloat(rgbaMatch[1]);
99
+ b = parseFloat(rgbaMatch[2]);
100
+ if (rgbaMatch.length > 3) {
101
+ a = parseFloat(rgbaMatch[3]);
102
+ }
103
+ } else {
104
+ return null;
164
105
  }
106
+ return [r, g, b, a];
107
+ };
108
+ const color1Components = getColorComponents(color1);
109
+ const color2Components = getColorComponents(color2);
110
+ if (!color1Components || !color2Components) {
111
+ return false;
112
+ }
113
+ const euclideanDistance = Math.sqrt(
114
+ Math.pow(color1Components[0] - color2Components[0], 2) + Math.pow(color1Components[1] - color2Components[1], 2) + Math.pow(color1Components[2] - color2Components[2], 2) + Math.pow(color1Components[3] - color2Components[3], 2)
165
115
  );
166
- userConfig = data;
167
- return data;
168
- };
169
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
170
- __proto__: null,
171
- autoLogin,
172
- changeSystemConfig,
173
- getHomeUrl,
174
- getLoginUrl,
175
- getSystemConfig,
176
- getToken,
177
- getUserConfig,
178
- getUserInfo,
179
- getUserIsHaveBtnPower,
180
- getUserPermissions,
181
- getUserRouteList,
182
- getUserRouter,
183
- isProduction,
184
- jumpToHome,
185
- jumpToLogin,
186
- removeToken,
187
- setSystemConfig,
188
- setSystemInfo,
189
- setUserInfo
190
- }, Symbol.toStringTag, { value: "Module" }));
191
- let loadingInstance;
192
- const loadingOptions = {
193
- lock: true,
194
- text: "loading...",
195
- fullscreen: true,
196
- background: "rgba(0, 0, 0, 0.6)"
116
+ return euclideanDistance <= threshold;
197
117
  };
198
- const startLoading = () => {
199
- loadingInstance = ElLoading.service(loadingOptions);
200
- };
201
- const endLoading = () => {
202
- loadingInstance.close();
118
+ const isColorEqual = (color1, color2) => {
119
+ function toRGBA(color) {
120
+ if (color.toLowerCase().startsWith("rgba")) {
121
+ return color.toLowerCase();
122
+ } else if (color.toLowerCase().startsWith("rgb")) {
123
+ return color.replace("rgb", "rgba").replace(")", ", 1)");
124
+ } else if (color.length === 7) {
125
+ const r = parseInt(color.substring(1, 3), 16);
126
+ const g = parseInt(color.substring(3, 5), 16);
127
+ const b = parseInt(color.substring(5, 7), 16);
128
+ return `rgba(${r}, ${g}, ${b}, 1)`;
129
+ } else if (color.length === 9 && color.toLowerCase().startsWith("rrggbbaa")) {
130
+ const r = parseInt(color.substring(1, 3), 16);
131
+ const g = parseInt(color.substring(3, 5), 16);
132
+ const b = parseInt(color.substring(5, 7), 16);
133
+ const a = Math.round(parseInt(color.substring(7, 9), 16) / 255 * 100) / 100;
134
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
135
+ } else {
136
+ return null;
137
+ }
138
+ }
139
+ const rgbaColor1 = toRGBA(convertShortHexToLongHex(color1));
140
+ const rgbaColor2 = toRGBA(convertShortHexToLongHex(color2));
141
+ if (!rgbaColor1 || !rgbaColor2) {
142
+ return false;
143
+ }
144
+ return rgbaColor1 === rgbaColor2;
203
145
  };
204
- let needLoadingRequestCount = 0;
205
- const showFullScreenLoading = () => {
206
- if (needLoadingRequestCount === 0) {
207
- startLoading();
146
+ const convertShortHexToLongHex = (shortHex) => {
147
+ if (shortHex.length === 4 && shortHex[0] === "#") {
148
+ const r = shortHex[1];
149
+ const g = shortHex[2];
150
+ const b = shortHex[3];
151
+ const longHex = `#${r}${r}${g}${g}${b}${b}`;
152
+ return longHex;
153
+ } else {
154
+ return shortHex;
208
155
  }
209
- needLoadingRequestCount++;
210
156
  };
211
- const hideFullScreenLoading = () => {
212
- if (needLoadingRequestCount <= 0) return;
213
- needLoadingRequestCount--;
214
- if (needLoadingRequestCount === 0) {
215
- endLoading();
157
+ const yxMessage = (data, callback, isShowError = false) => {
158
+ if (data.isSuccess) {
159
+ ElMessage.success(data.resultMsg || "操作成功");
160
+ callback && callback();
161
+ } else {
162
+ if (isShowError) {
163
+ ElMessage.error(data.resultMsg || "操作失败");
164
+ }
216
165
  }
217
166
  };
218
- var ResultEnum = /* @__PURE__ */ ((ResultEnum2) => {
219
- ResultEnum2[ResultEnum2["SUCCESS"] = 200] = "SUCCESS";
220
- ResultEnum2[ResultEnum2["ERROR"] = 500] = "ERROR";
221
- ResultEnum2[ResultEnum2["OVERDUE"] = 401] = "OVERDUE";
222
- ResultEnum2[ResultEnum2["TIMEOUT"] = 3e4] = "TIMEOUT";
223
- return ResultEnum2;
224
- })(ResultEnum || {});
225
- const config = {
226
- // 默认地址请求地址,可在 .env.*** 文件中修改
227
- // 设置超时时间(30s)
228
- timeout: 3e4,
229
- // 跨域时候允许携带凭证
230
- withCredentials: true
167
+ const copyText = (text) => {
168
+ const textField = document.createElement("textarea");
169
+ textField.innerText = text;
170
+ document.body.appendChild(textField);
171
+ textField.select();
172
+ document.execCommand("copy");
173
+ textField.remove();
174
+ ElMessage.success("已成功复制到剪贴板");
231
175
  };
232
- const checkStatus = (status, msg) => {
233
- switch (status) {
234
- case 400:
235
- ElMessage.error(msg || "请求失败!请您稍后重试");
236
- break;
237
- case 401:
238
- ElMessage.error(msg || "登录失效!请您重新登录");
239
- if (!location.href.includes(getLoginUrl())) {
240
- jumpToLogin();
241
- }
242
- break;
243
- case 403:
244
- ElMessage.error(msg || "当前账号无权限访问!");
245
- break;
246
- case 404:
247
- ElMessage.error("你所访问的资源不存在");
248
- break;
249
- case 405:
250
- ElMessage.error(msg || "请求方式错误!请您稍后重试");
251
- break;
252
- case 408:
253
- ElMessage.error(msg || "请求超时!请您稍后重试");
254
- break;
255
- case 500:
256
- ElMessage.error(msg || "服务异常!");
257
- break;
258
- case 502:
259
- ElMessage.error(msg || "网关错误!");
260
- break;
261
- case 503:
262
- ElMessage.error(msg || "服务不可用");
263
- break;
264
- case 504:
265
- ElMessage.error(msg || "网关超时!");
266
- break;
267
- default:
268
- ElMessage.error(msg || "请求失败!请您稍后重试!");
176
+ const getCownDownTime = (time) => {
177
+ const diffTimeSecond = dayjs(time).diff(dayjs(), "second");
178
+ let formattedTime = "00:00:00";
179
+ if (diffTimeSecond > 0) {
180
+ const hours = Math.floor(diffTimeSecond / 3600);
181
+ const minutes = Math.floor(diffTimeSecond % 3600 / 60);
182
+ const seconds = diffTimeSecond % 60;
183
+ formattedTime = `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
269
184
  }
185
+ return formattedTime;
270
186
  };
271
- getSystemConfig("isTranslateApi");
272
- class YxHttp {
273
- constructor(config2) {
274
- __publicField(this, "service");
275
- /** 自定义响应处理map */
276
- __publicField(this, "customResMap");
277
- /**自定义请求拦截器逻辑 */
278
- __publicField(this, "customResquestInterceptors");
279
- /**自定义响应拦截器逻辑 */
280
- __publicField(this, "customResponseInterceptors");
281
- /** 自定义全局响应处理回调*/
282
- __publicField(this, "customGlobalResHandler");
283
- this.service = axios.create(config2);
284
- this.setupInterceptors();
285
- this.customResMap = {};
286
- }
287
- setupInterceptors() {
288
- this.service.interceptors.request.use(
289
- (config2) => {
290
- var _a;
291
- if (!((_a = config2.headers) == null ? void 0 : _a.noLoading)) {
292
- showFullScreenLoading();
293
- }
294
- config2.headers.token = getToken();
295
- if ((config2 == null ? void 0 : config2.customResHandler) && (config2 == null ? void 0 : config2.url)) {
296
- this.customResMap[config2 == null ? void 0 : config2.url] = config2.customResHandler;
297
- }
298
- this.customResquestInterceptors && this.customResquestInterceptors(config2);
299
- return config2;
300
- },
301
- (error) => {
302
- return Promise.reject(error);
303
- }
304
- );
305
- this.service.interceptors.response.use(
306
- async (response) => {
307
- const { config: config2 } = response;
308
- let data = response.data;
309
- hideFullScreenLoading();
310
- if (this.customResponseInterceptors) return this.customResponseInterceptors(response);
311
- if (this.customGlobalResHandler) {
312
- const isContinue = this.customGlobalResHandler(response);
313
- if (!isContinue) return;
314
- }
315
- const code = response.status;
316
- if (config2.url && this.customResMap[config2.url]) {
317
- return this.customResMap[config2.url](data, response);
318
- }
319
- if (code == ResultEnum.OVERDUE || data.code === ResultEnum.OVERDUE) {
320
- this.handleOverdueResponse(data);
321
- } else if (data.code !== ResultEnum.SUCCESS) {
322
- this.handleErrorResponse(data);
323
- }
324
- return data;
325
- },
326
- (error) => {
327
- hideFullScreenLoading();
328
- const response = error.response;
329
- const { config: config2 } = error;
330
- if (this.customResponseInterceptors) return this.customResponseInterceptors(response);
331
- if (this.customGlobalResHandler) {
332
- const isContinue = this.customGlobalResHandler(response);
333
- if (!isContinue) return;
334
- }
335
- if ((config2 == null ? void 0 : config2.url) && this.customResMap[config2.url]) {
336
- return this.customResMap[config2.url](error.response);
337
- }
338
- if (error.message.includes("timeout")) {
339
- ElMessage.error("请求超时!请稍后重试");
340
- } else if (error.message.includes("Network Error")) {
341
- ElMessage.error("网络错误!请稍后重试");
342
- }
343
- if (response) {
344
- checkStatus(response.status, this.getResMessage(response.data));
345
- }
346
- if (!window.navigator.onLine) {
347
- ElNotification({
348
- title: "提示",
349
- message: "当前网络似乎开小差了",
350
- type: "warning",
351
- duration: 5e3
352
- });
353
- }
354
- return Promise.reject(error);
355
- }
356
- );
357
- }
358
- getResMessage(data) {
359
- return (data == null ? void 0 : data.resultMsg) ?? (data == null ? void 0 : data.message) ?? (data == null ? void 0 : data.msg) ?? null;
360
- }
361
- handleOverdueResponse(data) {
362
- ElNotification({
363
- title: "登录过期提醒",
364
- message: this.getResMessage(data) || "当前登录失效",
365
- type: "warning",
366
- duration: 5e3
367
- });
368
- jumpToLogin();
369
- return Promise.reject(data);
370
- }
371
- handleErrorResponse(data) {
372
- if (this.getResMessage(data)) {
373
- ElMessage.error(this.getResMessage(data));
374
- } else {
375
- checkStatus(data.status);
187
+ const useConfirm = (content, confrmCallback, options = {}) => {
188
+ ElMessageBox.confirm(content, (options == null ? void 0 : options.title) || "提示", {
189
+ confirmButtonText: "确定",
190
+ cancelButtonText: "取消",
191
+ type: "warning",
192
+ ...options
193
+ }).then(() => {
194
+ confrmCallback();
195
+ }).catch(() => {
196
+ });
197
+ };
198
+ function deepClone(value, cache = /* @__PURE__ */ new WeakMap()) {
199
+ if (typeof value !== "object" || value === null) {
200
+ if (typeof value === "function") {
201
+ return function(...args) {
202
+ return value.apply(this, args);
203
+ };
376
204
  }
377
- return Promise.reject(data);
378
- }
379
- /**
380
- *
381
- * @param url
382
- * @param params
383
- * @param options : AxiosRequestConfig
384
- * @description get 请求
385
- */
386
- get(url, params, options = {}) {
387
- return this.service.get(url, { params, ...options });
205
+ return value;
388
206
  }
389
- /**
390
- *
391
- * @param url
392
- * @param params
393
- * @param options : AxiosRequestConfig
394
- * @description post 请求
395
- */
396
- post(url, params, options = {}) {
397
- return this.service.post(url, params, options);
207
+ if (cache.has(value)) {
208
+ return cache.get(value);
398
209
  }
399
- /**
400
- *
401
- * @param url
402
- * @param params
403
- * @param options : AxiosRequestConfig
404
- */
405
- put(url, params, options = {}) {
406
- return this.service.put(url, params, options);
210
+ if (value instanceof Date) {
211
+ return new Date(value);
407
212
  }
408
- /**
409
- *
410
- * @param url
411
- * @param params
412
- * @param options : AxiosRequestConfig
413
- */
414
- delete(url, params, options = {}) {
415
- return this.service.delete(url, { params, ...options });
213
+ if (value instanceof RegExp) {
214
+ return new RegExp(value.source, value.flags);
416
215
  }
417
- /**
418
- * 请求拦截器的回调
419
- * @param callback
420
- */
421
- interceptorsRequestCallback(callback) {
422
- this.customResquestInterceptors = callback;
216
+ if (value instanceof Map) {
217
+ const result2 = /* @__PURE__ */ new Map();
218
+ cache.set(value, result2);
219
+ value.forEach((v, k) => {
220
+ result2.set(deepClone(k, cache), deepClone(v, cache));
221
+ });
222
+ return result2;
423
223
  }
424
- /**
425
- * 全局响应拦截器回调
426
- * @param callback
427
- */
428
- interceptorsResponseCallback(callback) {
429
- this.customResponseInterceptors = callback;
224
+ if (value instanceof Set) {
225
+ const result2 = /* @__PURE__ */ new Set();
226
+ cache.set(value, result2);
227
+ value.forEach((v) => {
228
+ result2.add(deepClone(v, cache));
229
+ });
230
+ return result2;
430
231
  }
431
- /**
432
- * 自定义请求拦截器回调
433
- * @param url
434
- * @param callback
435
- */
436
- customGlobalResHandlerCallback(callback) {
437
- this.customGlobalResHandler = callback;
232
+ if (Array.isArray(value)) {
233
+ const result2 = [];
234
+ cache.set(value, result2);
235
+ value.forEach((item, index) => {
236
+ result2[index] = deepClone(item, cache);
237
+ });
238
+ return result2;
438
239
  }
240
+ const result = {};
241
+ cache.set(value, result);
242
+ Object.keys(value).forEach((key) => {
243
+ result[key] = deepClone(value[key], cache);
244
+ });
245
+ return result;
439
246
  }
440
- const http = new YxHttp(config);
441
247
  export {
442
- BC_LANG_NAME as B,
443
- URL as U,
444
- http as a,
445
- getUserConfig as b,
446
- checkStatus as c,
447
- getUserIsHaveBtnPower as d,
448
- changeSystemConfig as e,
449
- getSystemConfig as f,
450
- getToken as g,
451
- hideFullScreenLoading as h,
452
- BC_THEME_NAME as i,
453
- jumpToHome as j,
454
- setSystemConfig as k,
455
- index as l,
456
- showFullScreenLoading as s
248
+ areColorsSimilar as a,
249
+ getSelectOptions as b,
250
+ copyText as c,
251
+ deepClone as d,
252
+ enumToArray as e,
253
+ isDarkColor as f,
254
+ getCownDownTime as g,
255
+ isColorEqual as i,
256
+ notifyMessageToSystems as n,
257
+ receiveMessage as r,
258
+ useConfirm as u,
259
+ yxMessage as y
457
260
  };