全局loding

This commit is contained in:
X1627315083
2025-10-23 14:14:25 +08:00
parent 02ae02acbf
commit 2d4096c466

View File

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