|
@@ -1,6 +1,8 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-container class="layout-container">
|
|
<el-container class="layout-container">
|
|
|
- <el-aside width="200px">
|
|
|
|
|
|
|
+ <!-- Mobile overlay -->
|
|
|
|
|
+ <div v-if="isMobile && sidebarVisible" class="sidebar-overlay" @click="sidebarVisible = false"></div>
|
|
|
|
|
+ <el-aside :class="['el-aside', { 'sidebar-mobile': isMobile, 'sidebar-open': isMobile && sidebarVisible, 'sidebar-closed': isMobile && !sidebarVisible }]" :width="isMobile ? '200px' : '200px'">
|
|
|
<div class="logo">浠艾福</div>
|
|
<div class="logo">浠艾福</div>
|
|
|
<el-scrollbar wrap-class="sidebar-scrollbar-wrap">
|
|
<el-scrollbar wrap-class="sidebar-scrollbar-wrap">
|
|
|
<el-menu
|
|
<el-menu
|
|
@@ -50,6 +52,11 @@
|
|
|
</el-aside>
|
|
</el-aside>
|
|
|
<el-container>
|
|
<el-container>
|
|
|
<el-header>
|
|
<el-header>
|
|
|
|
|
+ <div class="header-left">
|
|
|
|
|
+ <el-button v-if="isMobile" type="text" class="hamburger-btn" @click="toggleSidebar">
|
|
|
|
|
+ <i :class="sidebarVisible ? 'el-icon-s-unfold' : 'el-icon-s-fold'"></i>
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
<div class="header-right">
|
|
<div class="header-right">
|
|
|
<el-badge :value="unreadMessageCount" :hidden="unreadMessageCount === 0" class="msg-badge">
|
|
<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-button type="text" class="msg-btn" @click="handleMessageClick" icon="el-icon-bell"></el-button>
|
|
@@ -323,6 +330,8 @@ export default {
|
|
|
inviteCodeLoading: false,
|
|
inviteCodeLoading: false,
|
|
|
inviteCodeData: null,
|
|
inviteCodeData: null,
|
|
|
unreadMessageCount: 0,
|
|
unreadMessageCount: 0,
|
|
|
|
|
+ isMobile: window.innerWidth <= 768,
|
|
|
|
|
+ sidebarVisible: window.innerWidth > 768,
|
|
|
passwordRules: {
|
|
passwordRules: {
|
|
|
oldPassword: [
|
|
oldPassword: [
|
|
|
{ required: true, message: '请输入原密码', trigger: 'blur' }
|
|
{ required: true, message: '请输入原密码', trigger: 'blur' }
|
|
@@ -375,14 +384,27 @@ export default {
|
|
|
return this.displayRoles
|
|
return this.displayRoles
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ '$route'() {
|
|
|
|
|
+ if (this.isMobile) {
|
|
|
|
|
+ this.sidebarVisible = false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
mounted() {
|
|
mounted() {
|
|
|
// 清除可能的 beforeunload 处理,防止页面刷新弹出"离开网站?"提示
|
|
// 清除可能的 beforeunload 处理,防止页面刷新弹出"离开网站?"提示
|
|
|
window.onbeforeunload = null
|
|
window.onbeforeunload = null
|
|
|
|
|
+ // 响应式监听
|
|
|
|
|
+ this.handleResize = this.handleResize.bind(this)
|
|
|
|
|
+ window.addEventListener('resize', this.handleResize)
|
|
|
// 有消息权限(老师/营养师角色)才加载未读数,管理员不调用
|
|
// 有消息权限(老师/营养师角色)才加载未读数,管理员不调用
|
|
|
if (hasPermission(this.effectivePerms, 'messages') && this.currentRole !== 'admin') {
|
|
if (hasPermission(this.effectivePerms, 'messages') && this.currentRole !== 'admin') {
|
|
|
this.fetchUnreadCount()
|
|
this.fetchUnreadCount()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ beforeDestroy() {
|
|
|
|
|
+ window.removeEventListener('resize', this.handleResize)
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
hasPerm(required) {
|
|
hasPerm(required) {
|
|
|
return hasPermission(this.effectivePerms, required)
|
|
return hasPermission(this.effectivePerms, required)
|
|
@@ -396,6 +418,23 @@ export default {
|
|
|
if (index && index.startsWith('/')) {
|
|
if (index && index.startsWith('/')) {
|
|
|
this.$router.push(index)
|
|
this.$router.push(index)
|
|
|
}
|
|
}
|
|
|
|
|
+ if (this.isMobile) {
|
|
|
|
|
+ this.sidebarVisible = false
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ toggleSidebar() {
|
|
|
|
|
+ this.sidebarVisible = !this.sidebarVisible
|
|
|
|
|
+ },
|
|
|
|
|
+ handleResize() {
|
|
|
|
|
+ const mobile = window.innerWidth <= 768
|
|
|
|
|
+ if (mobile !== this.isMobile) {
|
|
|
|
|
+ this.isMobile = mobile
|
|
|
|
|
+ if (!mobile) {
|
|
|
|
|
+ this.sidebarVisible = true
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.sidebarVisible = false
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
handleProfileCommand(command) {
|
|
handleProfileCommand(command) {
|
|
|
if (command === 'profile') {
|
|
if (command === 'profile') {
|
|
@@ -592,7 +631,7 @@ export default {
|
|
|
background-color: #fff;
|
|
background-color: #fff;
|
|
|
box-shadow: 0 1px 4px rgba(0,21,41,.08);
|
|
box-shadow: 0 1px 4px rgba(0,21,41,.08);
|
|
|
display: flex;
|
|
display: flex;
|
|
|
- justify-content: flex-end;
|
|
|
|
|
|
|
+ justify-content: space-between;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
padding: 0 20px;
|
|
padding: 0 20px;
|
|
|
}
|
|
}
|
|
@@ -738,4 +777,87 @@ export default {
|
|
|
min-height: 0;
|
|
min-height: 0;
|
|
|
padding: 20px;
|
|
padding: 20px;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/* ========== 响应式:侧边栏折叠 ========== */
|
|
|
|
|
+@media (max-width: 768px) {
|
|
|
|
|
+ .sidebar-overlay {
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ top: 0;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ right: 0;
|
|
|
|
|
+ bottom: 0;
|
|
|
|
|
+ background: rgba(0, 0, 0, 0.4);
|
|
|
|
|
+ z-index: 1001;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .sidebar-mobile {
|
|
|
|
|
+ position: fixed !important;
|
|
|
|
|
+ top: 0;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ height: 100vh !important;
|
|
|
|
|
+ z-index: 1002;
|
|
|
|
|
+ transition: transform 0.25s ease;
|
|
|
|
|
+ transform: translateX(-100%);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .sidebar-mobile.sidebar-open {
|
|
|
|
|
+ transform: translateX(0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .sidebar-mobile.sidebar-closed {
|
|
|
|
|
+ transform: translateX(-100%);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .header-left {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .hamburger-btn {
|
|
|
|
|
+ font-size: 20px;
|
|
|
|
|
+ color: #606266;
|
|
|
|
|
+ padding: 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .hamburger-btn:hover {
|
|
|
|
|
+ color: #6366F1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-header {
|
|
|
|
|
+ padding: 0 10px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-main {
|
|
|
|
|
+ padding: 12px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .admin-page > .el-card .el-card__body {
|
|
|
|
|
+ padding: 12px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .admin-page > div:only-child > .el-card .el-card__body {
|
|
|
|
|
+ padding: 12px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .username {
|
|
|
|
|
+ margin-right: 10px !important;
|
|
|
|
|
+ font-size: 13px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* el-table 小屏字号 */
|
|
|
|
|
+ .el-table {
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-table .cell {
|
|
|
|
|
+ padding-left: 4px !important;
|
|
|
|
|
+ padding-right: 4px !important;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 桌面端隐藏 header-left(无汉堡按钮) */
|
|
|
|
|
+@media (min-width: 769px) {
|
|
|
|
|
+ .header-left {
|
|
|
|
|
+ display: none;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|