From e6d5a37236855ab028a8bae1932c9b7f685fbfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Wed, 27 Nov 2024 10:53:50 +0800 Subject: [PATCH] fix: menuRef --- napcat.webui/src/components/Dashboard.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/napcat.webui/src/components/Dashboard.vue b/napcat.webui/src/components/Dashboard.vue index f8870cdd..8bd8a031 100644 --- a/napcat.webui/src/components/Dashboard.vue +++ b/napcat.webui/src/components/Dashboard.vue @@ -27,13 +27,13 @@ const menuItems = ref([ { value: 'item5', icon: 'system-log', label: '日志查看', route: '/dashboard/log-view' }, { value: 'item6', icon: 'info-circle', label: '关于我们', route: '/dashboard/about-us' }, ]); -const menuRef = ref(null); +const menuRef = ref(null); emitter.on('sendMenu', (event) => { - emitter.emit('sendWidth', menuRef.value.offsetWidth); - localStorage.setItem('menuWidth', menuRef.value.offsetWidth); + emitter.emit('sendWidth', menuRef.value?.offsetWidth); + localStorage.setItem('menuWidth', menuRef.value?.offsetWidth?.toString() || '0'); }); onMounted(() => { - localStorage.setItem('menuWidth', menuRef.value.offsetWidth); + localStorage.setItem('menuWidth', menuRef.value?.offsetWidth?.toString() || '0'); });