init
This commit is contained in:
20
src/stores/global.ts
Normal file
20
src/stores/global.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
export const useGlobalStore = defineStore('global', () => {
|
||||
const state = ref({
|
||||
loading: false,// 全局loading
|
||||
view_loading: false,// 页面跳转loading
|
||||
homeLeftNavCollapse: false,// 首页左侧导航是否折叠
|
||||
})
|
||||
|
||||
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 }
|
||||
|
||||
return {
|
||||
state,
|
||||
setLoading,
|
||||
setViewLoading,
|
||||
setHomeLeftNavCollapse
|
||||
}
|
||||
})
|
||||
8
src/stores/index.ts
Normal file
8
src/stores/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createPinia } from 'pinia'
|
||||
import { createPersistedState } from 'pinia-persistedstate-plugin'
|
||||
// 创建store实例
|
||||
const store = createPinia()
|
||||
// 使用持久化插件(全局持久化)
|
||||
store.use(createPersistedState())
|
||||
export default store
|
||||
export * from './global'
|
||||
Reference in New Issue
Block a user