mirror of
https://github.com/talktao/Vue3-Vite-Vant-TS-H5.git
synced 2025-04-06 03:57:55 +08:00
test
This commit is contained in:
parent
a995aff153
commit
1d8b6097ab
@ -30,21 +30,21 @@ class HttpRequest {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
interceptors(instance: AxiosInstance) {
|
interceptors(instance: AxiosInstance) {
|
||||||
|
|
||||||
|
// 定义存放请求接口数组
|
||||||
let requestList = [];
|
let requestList = [];
|
||||||
const setLoadingToFalse = response => {
|
const setLoadingToFalse = response => {
|
||||||
|
|
||||||
requestList
|
requestList
|
||||||
.filter(item => item.url == response.config.url && item.method == response.config.method)
|
.filter(item => item.url == response.config.url && item.method == response.config.method)
|
||||||
.forEach(item => (item.isLoading = false));
|
.forEach(item => (item.isLoading = false));
|
||||||
|
|
||||||
//所有请求都加载完才让加载提示消失
|
//所有请求都加载完才让加载提示消失
|
||||||
if (requestList.every(item => !item.isLoading)) vuexStore.commit("changeIsLoading", false);
|
if (requestList.every(item => !item.isLoading)) vuexStore.commit("changeIsLoading", false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
instance.interceptors.request.use(
|
instance.interceptors.request.use(
|
||||||
(config: any) => {
|
(config: any) => {
|
||||||
|
// 不用判断请求loading的路由
|
||||||
let ignoreLoadingUrls = ["/login"];
|
let ignoreLoadingUrls = ["/login"];
|
||||||
|
|
||||||
if (!ignoreLoadingUrls.includes(config.url)) {
|
if (!ignoreLoadingUrls.includes(config.url)) {
|
||||||
@ -67,9 +67,7 @@ class HttpRequest {
|
|||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
if (error.response.status == 301) {
|
if (error.response.status == 301) { }
|
||||||
vuexStore.commit("changeLoginModalVisible", true);
|
|
||||||
}
|
|
||||||
setLoadingToFalse(error);
|
setLoadingToFalse(error);
|
||||||
return Promise.reject(error.response?.data);
|
return Promise.reject(error.response?.data);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref, toRefs } from "vue";
|
import { computed, onMounted, reactive, ref, toRefs } from "vue";
|
||||||
import { getList } from "@/api/home";
|
import { getTest } from "@/api/home";
|
||||||
import logo from "@/assets/logo.png";
|
import logo from "@/assets/logo.png";
|
||||||
|
|
||||||
const useShowList = () => {
|
const useShowList = () => {
|
||||||
@ -27,12 +27,15 @@ const useShowList = () => {
|
|||||||
const { list } = useShowList();
|
const { list } = useShowList();
|
||||||
|
|
||||||
// 请求真实数据
|
// 请求真实数据
|
||||||
const get = async () => {
|
const getTestData = async () => {
|
||||||
const result = await getList();
|
let params = {
|
||||||
|
modules: "statisGradeCityDetail",
|
||||||
|
};
|
||||||
|
const result = await getTest(params);
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
get();
|
getTestData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user