Skip to content

Commit 82827c7

Browse files
author
allen
committed
feat: loading优化
1 parent b73eeaa commit 82827c7

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/@types/api.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare namespace GetTest {
22
interface params {
33
a: number
4+
isLoading?: boolean
45
}
56
interface data {
67
name: string

src/config/commonParams.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const commonParams = {
2-
isLoading: true,
2+
// ...
33
}
44

55
export function getCommonParams() {

src/shims.axios.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { AxiosRequestConfig } from 'axios'
22

33
declare module 'axios' {
44
export interface AxiosRequestConfig {
5-
isLoading?: boolean
65
[propName: string]: any
76
}
87
}

src/utils/axios.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ methods.forEach(
3434
}
3535

3636
return new Promise<any>((resolve) => {
37-
if (fullParams.isLoading) loadingShow()
37+
if (isLoading) loadingShow()
3838
axios(axiosOptions)
3939
.then(({ data }) => {
4040
const { fedLogout } = useStore('user')
@@ -64,7 +64,7 @@ methods.forEach(
6464
resolve(null)
6565
})
6666
.finally(() => {
67-
if (fullParams.isLoading) loadingClose()
67+
if (isLoading) loadingClose()
6868
})
6969
})
7070
}),

src/views/dashboard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const dateVal = ref(new Date())
2424
const icons = ['foundation-indent-more', 'foundation-indent-less']
2525
2626
async function getTest() {
27-
const res = await apiTest.getTest({ a: 1 })
27+
const res = await apiTest.getTest({ a: 1, isLoading: true })
2828
if (!res) return
2929
console.log(res, 111)
3030
// res.data.age

0 commit comments

Comments
 (0)