fix
This commit is contained in:
@@ -8,12 +8,10 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useGlobalStore } from '@/stores'
|
import { useGlobalStore } from '@/stores'
|
||||||
const globalStore = useGlobalStore()
|
const globalStore = useGlobalStore()
|
||||||
const loading = computed(() => globalStore.state.loading)
|
const loading = computed(() => globalStore.state.loading || globalStore.state.view_loading)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
font-size: 1.6rem;
|
font-size: 1.6rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import router from './index'
|
import router from './index'
|
||||||
|
import { useGlobalStore } from '@/stores/global'
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
|
useGlobalStore().setViewLoading(true)
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
|
useGlobalStore().setViewLoading(false)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ import { ref, computed } from 'vue'
|
|||||||
export const useGlobalStore = defineStore('global', () => {
|
export const useGlobalStore = defineStore('global', () => {
|
||||||
const state = ref({
|
const state = ref({
|
||||||
loading: false,// 全局loading
|
loading: false,// 全局loading
|
||||||
|
view_loading: false,// 页面跳转loading
|
||||||
homeLeftNavCollapse: false,// 首页左侧导航是否折叠
|
homeLeftNavCollapse: false,// 首页左侧导航是否折叠
|
||||||
})
|
})
|
||||||
|
|
||||||
const setLoading = (v: boolean) => { state.value.loading = v }
|
const setLoading = (v: boolean) => { state.value.loading = v }
|
||||||
|
const setViewLoading = (v: boolean) => { state.value.view_loading = v }
|
||||||
const setHomeLeftNavCollapse = (v: boolean) => { state.value.homeLeftNavCollapse = v }
|
const setHomeLeftNavCollapse = (v: boolean) => { state.value.homeLeftNavCollapse = v }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
setLoading,
|
setLoading,
|
||||||
|
setViewLoading,
|
||||||
setHomeLeftNavCollapse,
|
setHomeLeftNavCollapse,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user