|
@@ -4,6 +4,7 @@ import { local, download } from '@/utils/tool';
|
|
|
import { get, isEmpty } from 'lodash';
|
|
|
import qs from 'qs';
|
|
|
import { h } from 'vue';
|
|
|
+import { LoadingPlugin } from 'tdesign-vue-next';
|
|
|
function createService() {
|
|
|
// 创建一个 axios 实例
|
|
|
const service = axios.create();
|
|
@@ -11,6 +12,9 @@ function createService() {
|
|
|
// HTTP request 拦截器
|
|
|
service.interceptors.request.use(
|
|
|
(config) => {
|
|
|
+ if (config.loading) {
|
|
|
+ LoadingPlugin(true);
|
|
|
+ }
|
|
|
if (config.download) {
|
|
|
config.responseType ??= 'blob';
|
|
|
}
|
|
@@ -25,6 +29,9 @@ function createService() {
|
|
|
// HTTP response 拦截器
|
|
|
service.interceptors.response.use(
|
|
|
(response) => {
|
|
|
+ if (response.config.loading) {
|
|
|
+ LoadingPlugin(false);
|
|
|
+ }
|
|
|
// 以下代码看后端是否有统一在接口里增加外层code的规范
|
|
|
// if (response.data.code && response.data.code !== 200) {
|
|
|
// Message.error({
|