diff --git a/src/layouts/GlobalLayout.vue b/src/layouts/GlobalLayout.vue index f98df9f..77ccad3 100644 --- a/src/layouts/GlobalLayout.vue +++ b/src/layouts/GlobalLayout.vue @@ -33,8 +33,9 @@ const getGlobalNotify = async () => { .get() .json() - if (data.value && !error.value) { - if (data.value !== 200) { + if (data.value && !error.value && data.value.code === 200) { + // 安全检查:确保 data.data 和 notifications 存在 + if (data.value.data && data.value.data.notifications) { notify.value = data.value.data.notifications checkNotification() // 在获取数据后检查通知 }