@fmdevui/fm-dev 1.0.44 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/core/api/utils/request.d.ts +4 -1
- package/es/packages/core/api/utils/request.mjs +39 -1
- package/index.js +39 -1
- package/index.min.js +25 -25
- package/index.min.mjs +25 -25
- package/index.mjs +40 -2
- package/lib/core/api/utils/request.d.ts +4 -1
- package/lib/packages/core/api/utils/request.js +38 -0
- package/package.json +1 -1
- /package/es/{component.css → defaults.css} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
export interface CustomAxiosRequestConfig extends AxiosRequestConfig {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare const service: AxiosInstance;
|
|
3
6
|
export declare const accessTokenKey: string;
|
|
4
7
|
export declare const refreshAccessTokenKey: string;
|
|
@@ -32,5 +35,5 @@ export declare function getJWTDate(timestamp: number): Date;
|
|
|
32
35
|
* @config AxiosRequestConfig 请求参数
|
|
33
36
|
* @returns 返回对象
|
|
34
37
|
*/
|
|
35
|
-
export declare function request2(config:
|
|
38
|
+
export declare function request2(config: CustomAxiosRequestConfig): any;
|
|
36
39
|
export default service;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import '../../utils/index.mjs';
|
|
3
|
-
import { ElMessage } from 'element-plus';
|
|
3
|
+
import { ElLoading, ElMessage } from 'element-plus';
|
|
4
4
|
import { PUB } from '../../utils/const/index.mjs';
|
|
5
5
|
import { Local, Session } from '../../utils/storage/index.mjs';
|
|
6
6
|
|
|
@@ -25,8 +25,34 @@ const clearAccessTokens = () => {
|
|
|
25
25
|
window.location.reload();
|
|
26
26
|
};
|
|
27
27
|
const axiosInstance = axios;
|
|
28
|
+
let loadingCount = 0;
|
|
29
|
+
let loadingInstance = null;
|
|
30
|
+
function startLoading() {
|
|
31
|
+
if (loadingCount === 0) {
|
|
32
|
+
loadingInstance = ElLoading.service({
|
|
33
|
+
lock: true,
|
|
34
|
+
text: "\u52A0\u8F7D\u4E2D...",
|
|
35
|
+
background: "rgba(0, 0, 0, 0.7)"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
loadingCount++;
|
|
39
|
+
}
|
|
40
|
+
function endLoading() {
|
|
41
|
+
if (loadingCount <= 0) return;
|
|
42
|
+
loadingCount--;
|
|
43
|
+
if (loadingCount === 0 && loadingInstance) {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
loadingInstance?.close();
|
|
46
|
+
loadingInstance = null;
|
|
47
|
+
}, 200);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
28
50
|
service.interceptors.request.use(
|
|
29
51
|
(config) => {
|
|
52
|
+
const customConfig = config;
|
|
53
|
+
if (customConfig.loading) {
|
|
54
|
+
startLoading();
|
|
55
|
+
}
|
|
30
56
|
const controller = new AbortController();
|
|
31
57
|
config.signal = controller.signal;
|
|
32
58
|
const url = config.url || "";
|
|
@@ -52,11 +78,19 @@ service.interceptors.request.use(
|
|
|
52
78
|
return config;
|
|
53
79
|
},
|
|
54
80
|
(error) => {
|
|
81
|
+
const customConfig = error.config;
|
|
82
|
+
if (customConfig?.loading === true) {
|
|
83
|
+
endLoading();
|
|
84
|
+
}
|
|
55
85
|
return Promise.reject(error);
|
|
56
86
|
}
|
|
57
87
|
);
|
|
58
88
|
service.interceptors.response.use(
|
|
59
89
|
(res) => {
|
|
90
|
+
const customConfig = res.config;
|
|
91
|
+
if (customConfig.loading === true) {
|
|
92
|
+
endLoading();
|
|
93
|
+
}
|
|
60
94
|
const url = res.config.url || "";
|
|
61
95
|
abortControllerMap.delete(url);
|
|
62
96
|
var status = res.status;
|
|
@@ -95,6 +129,10 @@ service.interceptors.response.use(
|
|
|
95
129
|
return res;
|
|
96
130
|
},
|
|
97
131
|
(error) => {
|
|
132
|
+
const customConfig = error.config;
|
|
133
|
+
if (customConfig?.loading === true) {
|
|
134
|
+
endLoading();
|
|
135
|
+
}
|
|
98
136
|
if (error.response) {
|
|
99
137
|
if (error.response.status === 401) {
|
|
100
138
|
clearAccessTokens();
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! fm-dev v1.0.
|
|
1
|
+
/*! fm-dev v1.0.45 */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('crypto'), require('url'), require('http'), require('https'), require('util'), require('stream'), require('assert'), require('zlib'), require('element-plus')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'vue', 'crypto', 'url', 'http', 'https', 'util', 'stream', 'assert', 'zlib', 'element-plus'], factory) :
|
|
@@ -29519,8 +29519,34 @@
|
|
|
29519
29519
|
window.location.reload();
|
|
29520
29520
|
};
|
|
29521
29521
|
const axiosInstance = axios;
|
|
29522
|
+
let loadingCount = 0;
|
|
29523
|
+
let loadingInstance = null;
|
|
29524
|
+
function startLoading() {
|
|
29525
|
+
if (loadingCount === 0) {
|
|
29526
|
+
loadingInstance = elementPlus.ElLoading.service({
|
|
29527
|
+
lock: true,
|
|
29528
|
+
text: "\u52A0\u8F7D\u4E2D...",
|
|
29529
|
+
background: "rgba(0, 0, 0, 0.7)"
|
|
29530
|
+
});
|
|
29531
|
+
}
|
|
29532
|
+
loadingCount++;
|
|
29533
|
+
}
|
|
29534
|
+
function endLoading() {
|
|
29535
|
+
if (loadingCount <= 0) return;
|
|
29536
|
+
loadingCount--;
|
|
29537
|
+
if (loadingCount === 0 && loadingInstance) {
|
|
29538
|
+
setTimeout(() => {
|
|
29539
|
+
loadingInstance?.close();
|
|
29540
|
+
loadingInstance = null;
|
|
29541
|
+
}, 200);
|
|
29542
|
+
}
|
|
29543
|
+
}
|
|
29522
29544
|
service.interceptors.request.use(
|
|
29523
29545
|
(config) => {
|
|
29546
|
+
const customConfig = config;
|
|
29547
|
+
if (customConfig.loading) {
|
|
29548
|
+
startLoading();
|
|
29549
|
+
}
|
|
29524
29550
|
const controller = new AbortController();
|
|
29525
29551
|
config.signal = controller.signal;
|
|
29526
29552
|
const url = config.url || "";
|
|
@@ -29546,11 +29572,19 @@
|
|
|
29546
29572
|
return config;
|
|
29547
29573
|
},
|
|
29548
29574
|
(error) => {
|
|
29575
|
+
const customConfig = error.config;
|
|
29576
|
+
if (customConfig?.loading === true) {
|
|
29577
|
+
endLoading();
|
|
29578
|
+
}
|
|
29549
29579
|
return Promise.reject(error);
|
|
29550
29580
|
}
|
|
29551
29581
|
);
|
|
29552
29582
|
service.interceptors.response.use(
|
|
29553
29583
|
(res) => {
|
|
29584
|
+
const customConfig = res.config;
|
|
29585
|
+
if (customConfig.loading === true) {
|
|
29586
|
+
endLoading();
|
|
29587
|
+
}
|
|
29554
29588
|
const url = res.config.url || "";
|
|
29555
29589
|
abortControllerMap.delete(url);
|
|
29556
29590
|
var status = res.status;
|
|
@@ -29589,6 +29623,10 @@
|
|
|
29589
29623
|
return res;
|
|
29590
29624
|
},
|
|
29591
29625
|
(error) => {
|
|
29626
|
+
const customConfig = error.config;
|
|
29627
|
+
if (customConfig?.loading === true) {
|
|
29628
|
+
endLoading();
|
|
29629
|
+
}
|
|
29592
29630
|
if (error.response) {
|
|
29593
29631
|
if (error.response.status === 401) {
|
|
29594
29632
|
clearAccessTokens();
|