|
@@ -51,6 +51,9 @@
|
|
|
<el-container>
|
|
<el-container>
|
|
|
<el-header>
|
|
<el-header>
|
|
|
<div class="header-right">
|
|
<div class="header-right">
|
|
|
|
|
+ <el-badge :value="unreadMessageCount" :hidden="unreadMessageCount === 0" class="msg-badge">
|
|
|
|
|
+ <el-button type="text" class="msg-btn" @click="handleMessageClick" icon="el-icon-bell"></el-button>
|
|
|
|
|
+ </el-badge>
|
|
|
<el-button v-if="hasPerm('service:*')" type="text" class="invite-code-btn" @click="showInviteCode" icon="el-icon-share">
|
|
<el-button v-if="hasPerm('service:*')" type="text" class="invite-code-btn" @click="showInviteCode" icon="el-icon-share">
|
|
|
邀请码
|
|
邀请码
|
|
|
</el-button>
|
|
</el-button>
|
|
@@ -146,6 +149,7 @@
|
|
|
import { getAdminInfo, changePassword } from '@/api/auth'
|
|
import { getAdminInfo, changePassword } from '@/api/auth'
|
|
|
import { updateAdminInfo } from '@/api/admin'
|
|
import { updateAdminInfo } from '@/api/admin'
|
|
|
import { getMyInviteCode } from '@/api/guide'
|
|
import { getMyInviteCode } from '@/api/guide'
|
|
|
|
|
+import { getUnreadMessageCount } from '@/api/teacherMessage'
|
|
|
import { getEffectivePermissions, hasPermission, getRoleLabel } from '@/utils/permissions'
|
|
import { getEffectivePermissions, hasPermission, getRoleLabel } from '@/utils/permissions'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -237,10 +241,9 @@ export default {
|
|
|
children: [
|
|
children: [
|
|
|
{ path: '/teacher-assessment', label: 'DAN测评', icon: 'el-icon-edit', perm: 'assessment:dan' },
|
|
{ path: '/teacher-assessment', label: 'DAN测评', icon: 'el-icon-edit', perm: 'assessment:dan' },
|
|
|
{ path: '/teacher-consult', label: '家长咨询', icon: 'el-icon-chat-dot-round', perm: 'assessment:consult' },
|
|
{ path: '/teacher-consult', label: '家长咨询', icon: 'el-icon-chat-dot-round', perm: 'assessment:consult' },
|
|
|
|
|
+ { path: '/growth-records', label: '成长记录', icon: 'el-icon-document', perm: 'growth:records' },
|
|
|
|
|
+ { path: '/growth-plans', label: '成长计划', icon: 'el-icon-document', perm: 'growth:plans' },
|
|
|
]},
|
|
]},
|
|
|
- { path: '/growth-records', label: '成长记录', icon: 'el-icon-document', perm: 'growth:records' },
|
|
|
|
|
- { path: '/growth-plans', label: '成长计划', icon: 'el-icon-document', perm: 'growth:plans' },
|
|
|
|
|
- { path: '/teacher-messages', label: '消息中心', icon: 'el-icon-chat-dot-round', perm: 'messages' },
|
|
|
|
|
|
|
|
|
|
// ===== 9. 系统配置 (admin) =====
|
|
// ===== 9. 系统配置 (admin) =====
|
|
|
{ title: '系统配置', icon: 'el-icon-s-tools', perm: 'system:*',
|
|
{ title: '系统配置', icon: 'el-icon-s-tools', perm: 'system:*',
|
|
@@ -325,6 +328,7 @@ export default {
|
|
|
inviteCodeVisible: false,
|
|
inviteCodeVisible: false,
|
|
|
inviteCodeLoading: false,
|
|
inviteCodeLoading: false,
|
|
|
inviteCodeData: null,
|
|
inviteCodeData: null,
|
|
|
|
|
+ unreadMessageCount: 0,
|
|
|
passwordRules: {
|
|
passwordRules: {
|
|
|
oldPassword: [
|
|
oldPassword: [
|
|
|
{ required: true, message: '请输入原密码', trigger: 'blur' }
|
|
{ required: true, message: '请输入原密码', trigger: 'blur' }
|
|
@@ -380,6 +384,10 @@ export default {
|
|
|
mounted() {
|
|
mounted() {
|
|
|
// 清除可能的 beforeunload 处理,防止页面刷新弹出"离开网站?"提示
|
|
// 清除可能的 beforeunload 处理,防止页面刷新弹出"离开网站?"提示
|
|
|
window.onbeforeunload = null
|
|
window.onbeforeunload = null
|
|
|
|
|
+ // 有消息权限(老师角色)才加载未读数
|
|
|
|
|
+ if (hasPermission(this.effectivePerms, 'messages')) {
|
|
|
|
|
+ this.fetchUnreadCount()
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
hasPerm(required) {
|
|
hasPerm(required) {
|
|
@@ -496,6 +504,19 @@ export default {
|
|
|
document.body.removeChild(input)
|
|
document.body.removeChild(input)
|
|
|
this.$message.success('已复制邀请码')
|
|
this.$message.success('已复制邀请码')
|
|
|
},
|
|
},
|
|
|
|
|
+ async fetchUnreadCount() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await getUnreadMessageCount()
|
|
|
|
|
+ if (res.data !== undefined) {
|
|
|
|
|
+ this.unreadMessageCount = res.data || 0
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ // silent: not critical
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ handleMessageClick() {
|
|
|
|
|
+ this.$router.push('/teacher-messages')
|
|
|
|
|
+ },
|
|
|
handleLogout() {
|
|
handleLogout() {
|
|
|
// 不使用 modal 遮罩(全局 .v-modal { display:none } 会与 $confirm 的遮罩冲突)
|
|
// 不使用 modal 遮罩(全局 .v-modal { display:none } 会与 $confirm 的遮罩冲突)
|
|
|
this.$confirm('确定要退出登录吗?', '提示', {
|
|
this.$confirm('确定要退出登录吗?', '提示', {
|
|
@@ -601,6 +622,22 @@ export default {
|
|
|
color: #4F46E5;
|
|
color: #4F46E5;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.msg-badge {
|
|
|
|
|
+ margin-right: 4px;
|
|
|
|
|
+}
|
|
|
|
|
+.msg-badge .el-badge__content.is-fixed {
|
|
|
|
|
+ top: 10px;
|
|
|
|
|
+ right: 6px;
|
|
|
|
|
+}
|
|
|
|
|
+.msg-btn {
|
|
|
|
|
+ font-size: 18px;
|
|
|
|
|
+ color: #606266;
|
|
|
|
|
+ padding: 4px;
|
|
|
|
|
+}
|
|
|
|
|
+.msg-btn:hover {
|
|
|
|
|
+ color: #6366F1;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.invite-code-content {
|
|
.invite-code-content {
|
|
|
padding: 8px 0;
|
|
padding: 8px 0;
|
|
|
}
|
|
}
|