import { defineStore } from 'pinia' import { ref, computed } from 'vue' export const useGlobalStore = defineStore('global', () => { const state = ref({ loading: false,// 全局loading windowWidth: 1920,// 页面宽度 }) const setLoading = (v: boolean) => { state.value.loading = v } return { state, setLoading, } }) function setWindowWidth() { return useGlobalStore().state.windowWidth = window.innerWidth } window.addEventListener('resize', setWindowWidth) window.addEventListener('load', setWindowWidth)