dataease-dm/frontend/src/utils/loading.js

27 lines
876 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import store from '@/store'
export const tryShowLoading = identification => {
if (!identification) return
// const count = store.getters.loadingMap[identification]
store.dispatch('request/addLoading', identification)
}
export const tryHideLoading = identification => {
if (!identification) return
const count = store.getters.loadingMap[identification]
if (count > 0) {
store.dispatch('request/reduceLoading', identification)
}
}
/**
* 说明
* 要在view中加loading只需要两个步骤
* 1.在vue页面文件中加 v-loading="$store.getters.loadingMap[$store.getters.currentPath]"
* 例如views/system/user/index.vue
* 2.在需要loading的api中添加config {loading: true}
* 例如api/system/user.js中userLists方法 需要配置loading: true
* 针对整个view页面需要局部loading请在对应页面中自己添加
*/