diff --git a/f/web-kboss/src/components/MessageCenter/MessageCenter.vue b/f/web-kboss/src/components/MessageCenter/MessageCenter.vue index 6a98a2f..939b31d 100644 --- a/f/web-kboss/src/components/MessageCenter/MessageCenter.vue +++ b/f/web-kboss/src/components/MessageCenter/MessageCenter.vue @@ -271,7 +271,8 @@ export default { props: { userId: { type: [String, Number], - required: true + required: false, + default: null }, visible: { type: Boolean, @@ -375,6 +376,13 @@ export default { }, getUnreadmsg() { + // 检查用户是否登录 + const userId = sessionStorage.getItem('userId'); + if (!userId) { + console.log('用户未登录,跳过获取未读消息'); + return; + } + getUnreadmsgAPI().then(res => { if (res.status) { this.count = res.count; @@ -389,14 +397,24 @@ export default { } }).catch(error => { console.error('获取未读消息失败:', error); - this.$message({ - message: "获取未读消息失败", - type: "error", - }); + // 401错误不显示错误消息,因为用户未登录是正常情况 + if (error.response && error.response.status !== 401) { + this.$message({ + message: "获取未读消息失败", + type: "error", + }); + } }); }, getReadmsg() { + // 检查用户是否登录 + const userId = sessionStorage.getItem('userId'); + if (!userId) { + console.log('用户未登录,跳过获取已读消息'); + return; + } + getReadmsgAPI().then(res => { if (res.status) { this.readInformationList = res.msg; @@ -435,7 +453,14 @@ export default { }, getMsg() { - getMsgAPI({ userid: this.userId }).then(res => { + // 检查用户是否登录 + const userId = sessionStorage.getItem('userId'); + if (!userId) { + console.log('用户未登录,跳过获取消息'); + return; + } + + getMsgAPI({ userid: userId }).then(res => { if (res.status && res.msg) { this.alliInformationList = res.msg; } else { diff --git a/f/web-kboss/src/layout/components/Navbar.vue b/f/web-kboss/src/layout/components/Navbar.vue index 39297a0..1f27cb9 100644 --- a/f/web-kboss/src/layout/components/Navbar.vue +++ b/f/web-kboss/src/layout/components/Navbar.vue @@ -11,7 +11,7 @@ id="breadcrumb-container" class="breadcrumb-container" />