全局loding
This commit is contained in:
@@ -4,6 +4,7 @@ import { useUserInfoStore } from '@/stores/modules/userInfo'
|
|||||||
const store = useUserInfoStore()
|
const store = useUserInfoStore()
|
||||||
import { getLocal } from '@/utils/local'
|
import { getLocal } from '@/utils/local'
|
||||||
import router from '@/router/index'
|
import router from '@/router/index'
|
||||||
|
import { useOverallStore } from '@/stores'
|
||||||
|
|
||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
@@ -152,22 +153,18 @@ function removePending(config: any) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----------------------------------loading的函数-------------------------------
|
// ----------------------------------loading的函数-------------------------------
|
||||||
const LoadingInstance: { _target: any; _count: number } = {
|
const LoadingInstance: { _count: number } = {
|
||||||
_target: null, // 保存Loading实例
|
|
||||||
_count: 0
|
_count: 0
|
||||||
}
|
}
|
||||||
function openLoading(loadingDom: any) {
|
function openLoading(loadingDom: any) {
|
||||||
LoadingInstance._target = showNotify({
|
useOverallStore().setLoading(true)
|
||||||
message: '数据正在加载中',
|
|
||||||
background: 'rgba(25, 32, 53, 1)'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
function closeLoading() {
|
function closeLoading() {
|
||||||
if (LoadingInstance._count > 0) LoadingInstance._count--
|
if (LoadingInstance._count > 0) LoadingInstance._count--
|
||||||
if (LoadingInstance._count === 0) {
|
if (LoadingInstance._count === 0) {
|
||||||
LoadingInstance._target?.close()
|
useOverallStore().setLoading(false)
|
||||||
LoadingInstance._target = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default service
|
export default service
|
||||||
|
|||||||
Reference in New Issue
Block a user