@fmdeui/fmui 1.0.21 → 1.0.22

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.
@@ -78,7 +78,15 @@ function backEndComponent(routes) {
78
78
  function dynamicImport(dynamicViewsModules2, component) {
79
79
  const keys = Object.keys(dynamicViewsModules2);
80
80
  const matchKeys = keys.filter((key) => {
81
- const k = key.replace(/..\/views|../, "");
81
+ const REMOVE_PREFIXES = [
82
+ "../../../../packages/fmasyspage/views",
83
+ "../../../../packages/fmwlpage/views",
84
+ "../../../../packages/fmreliefpage/views",
85
+ "../views",
86
+ "./views",
87
+ ".."
88
+ ].map((p) => p.replace(/\./g, "\\.").replace(/\//g, "\\/")).join("|");
89
+ const k = key.replace(new RegExp(`^(${REMOVE_PREFIXES})/?`), "/");
82
90
  return k.startsWith(`${component}`) || k.startsWith(`/${component}`);
83
91
  });
84
92
  if ((matchKeys == null ? void 0 : matchKeys.length) === 1) {
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { ElMessage } from 'element-plus';
2
+ import { ElLoading, ElMessage } from 'element-plus';
3
3
  import { Local, Session } from './storage.mjs';
4
4
 
5
5
  const abortControllerMap = /* @__PURE__ */ new Map();
@@ -31,9 +31,35 @@ const clearTokens = () => {
31
31
  Session.clear();
32
32
  };
33
33
  const axiosInstance = axios;
34
+ let loadingCount = 0;
35
+ let loadingInstance = null;
36
+ function startLoading() {
37
+ if (loadingCount === 0) {
38
+ loadingInstance = ElLoading.service({
39
+ lock: true,
40
+ text: "\u52A0\u8F7D\u4E2D...",
41
+ background: "rgba(0, 0, 0, 0.7)"
42
+ });
43
+ }
44
+ loadingCount++;
45
+ }
46
+ function endLoading() {
47
+ if (loadingCount <= 0) return;
48
+ loadingCount--;
49
+ if (loadingCount === 0 && loadingInstance) {
50
+ setTimeout(() => {
51
+ loadingInstance == null ? void 0 : loadingInstance.close();
52
+ loadingInstance = null;
53
+ }, 200);
54
+ }
55
+ }
34
56
  service.interceptors.request.use(
35
57
  (config) => {
36
58
  var _a;
59
+ const customConfig = config;
60
+ if (customConfig.loading) {
61
+ startLoading();
62
+ }
37
63
  const controller = new AbortController();
38
64
  config.signal = controller.signal;
39
65
  const url = config.url || "";
@@ -59,11 +85,19 @@ service.interceptors.request.use(
59
85
  return config;
60
86
  },
61
87
  (error) => {
88
+ const customConfig = error.config;
89
+ if ((customConfig == null ? void 0 : customConfig.loading) === true) {
90
+ endLoading();
91
+ }
62
92
  return Promise.reject(error);
63
93
  }
64
94
  );
65
95
  service.interceptors.response.use(
66
96
  (res) => {
97
+ const customConfig = res.config;
98
+ if (customConfig.loading === true) {
99
+ endLoading();
100
+ }
67
101
  const url = res.config.url || "";
68
102
  abortControllerMap.delete(url);
69
103
  var status = res.status;
@@ -97,6 +131,10 @@ service.interceptors.response.use(
97
131
  return res;
98
132
  },
99
133
  (error) => {
134
+ const customConfig = error.config;
135
+ if (customConfig.loading === true) {
136
+ endLoading();
137
+ }
100
138
  if (error.response) {
101
139
  if (error.response.status === 401) {
102
140
  clearAccessTokens();
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! fmdeui-fmui v1.0.21 */
1
+ /*! fmdeui-fmui v1.0.22 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('pinia'), require('crypto-js'), require('xlsx-js-style'), require('element-plus'), require('vue'), require('@element-plus/icons-vue'), require('axios'), require('js-cookie'), require('@microsoft/signalr'), require('vxe-table'), require('@vxe-ui/plugin-render-element'), require('@vxe-ui/plugin-export-xlsx'), require('vxe-pc-ui'), require('vue-i18n'), require('exceljs'), require('lodash-es'), require('@vueuse/core'), require('mitt'), require('vue-router'), require('nprogress')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'pinia', 'crypto-js', 'xlsx-js-style', 'element-plus', 'vue', '@element-plus/icons-vue', 'axios', 'js-cookie', '@microsoft/signalr', 'vxe-table', '@vxe-ui/plugin-render-element', '@vxe-ui/plugin-export-xlsx', 'vxe-pc-ui', 'vue-i18n', 'exceljs', 'lodash-es', '@vueuse/core', 'mitt', 'vue-router', 'nprogress'], factory) :
@@ -1263,9 +1263,35 @@
1263
1263
  Session.clear();
1264
1264
  };
1265
1265
  const axiosInstance = axios;
1266
+ let loadingCount = 0;
1267
+ let loadingInstance = null;
1268
+ function startLoading() {
1269
+ if (loadingCount === 0) {
1270
+ loadingInstance = elementPlus.ElLoading.service({
1271
+ lock: true,
1272
+ text: "\u52A0\u8F7D\u4E2D...",
1273
+ background: "rgba(0, 0, 0, 0.7)"
1274
+ });
1275
+ }
1276
+ loadingCount++;
1277
+ }
1278
+ function endLoading() {
1279
+ if (loadingCount <= 0) return;
1280
+ loadingCount--;
1281
+ if (loadingCount === 0 && loadingInstance) {
1282
+ setTimeout(() => {
1283
+ loadingInstance == null ? void 0 : loadingInstance.close();
1284
+ loadingInstance = null;
1285
+ }, 200);
1286
+ }
1287
+ }
1266
1288
  service.interceptors.request.use(
1267
1289
  (config) => {
1268
1290
  var _a;
1291
+ const customConfig = config;
1292
+ if (customConfig.loading) {
1293
+ startLoading();
1294
+ }
1269
1295
  const controller = new AbortController();
1270
1296
  config.signal = controller.signal;
1271
1297
  const url = config.url || "";
@@ -1291,11 +1317,19 @@
1291
1317
  return config;
1292
1318
  },
1293
1319
  (error) => {
1320
+ const customConfig = error.config;
1321
+ if ((customConfig == null ? void 0 : customConfig.loading) === true) {
1322
+ endLoading();
1323
+ }
1294
1324
  return Promise.reject(error);
1295
1325
  }
1296
1326
  );
1297
1327
  service.interceptors.response.use(
1298
1328
  (res) => {
1329
+ const customConfig = res.config;
1330
+ if (customConfig.loading === true) {
1331
+ endLoading();
1332
+ }
1299
1333
  const url = res.config.url || "";
1300
1334
  abortControllerMap.delete(url);
1301
1335
  var status = res.status;
@@ -1329,6 +1363,10 @@
1329
1363
  return res;
1330
1364
  },
1331
1365
  (error) => {
1366
+ const customConfig = error.config;
1367
+ if (customConfig.loading === true) {
1368
+ endLoading();
1369
+ }
1332
1370
  if (error.response) {
1333
1371
  if (error.response.status === 401) {
1334
1372
  clearAccessTokens();
@@ -22824,7 +22862,15 @@
22824
22862
  function dynamicImport(dynamicViewsModules2, component) {
22825
22863
  const keys = Object.keys(dynamicViewsModules2);
22826
22864
  const matchKeys = keys.filter((key) => {
22827
- const k = key.replace(/..\/views|../, "");
22865
+ const REMOVE_PREFIXES = [
22866
+ "../../../../packages/fmasyspage/views",
22867
+ "../../../../packages/fmwlpage/views",
22868
+ "../../../../packages/fmreliefpage/views",
22869
+ "../views",
22870
+ "./views",
22871
+ ".."
22872
+ ].map((p) => p.replace(/\./g, "\\.").replace(/\//g, "\\/")).join("|");
22873
+ const k = key.replace(new RegExp(`^(${REMOVE_PREFIXES})/?`), "/");
22828
22874
  return k.startsWith(`${component}`) || k.startsWith(`/${component}`);
22829
22875
  });
22830
22876
  if ((matchKeys == null ? void 0 : matchKeys.length) === 1) {