From da3ad7f43c7c9140422a40ee700897ffa8537c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E9=B9=8F?= <2916022834@qq.com> Date: Thu, 4 Jun 2026 10:47:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=88=9D=E5=A7=8B=E5=AE=BD?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/global.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/stores/global.ts b/src/stores/global.ts index 47002d5..ff0291f 100644 --- a/src/stores/global.ts +++ b/src/stores/global.ts @@ -3,7 +3,7 @@ import { ref, computed } from 'vue' export const useGlobalStore = defineStore('global', () => { const state = ref({ loading: false,// 全局loading - windowWidth: window.innerWidth,// 页面宽度 + windowWidth: 1920,// 页面宽度 }) const setLoading = (v: boolean) => { state.value.loading = v } @@ -13,6 +13,8 @@ export const useGlobalStore = defineStore('global', () => { setLoading, } }) -window.addEventListener('resize', () => { - useGlobalStore().state.windowWidth = window.innerWidth -}) \ No newline at end of file +function setWindowWidth() { + return useGlobalStore().state.windowWidth = window.innerWidth +} +window.addEventListener('resize', setWindowWidth) +window.addEventListener('load', setWindowWidth) \ No newline at end of file