Quellcode durchsuchen

路由激活选中问题处理

canghailong vor 6 Monaten
Ursprung
Commit
a3ed0bcf40
2 geänderte Dateien mit 34 neuen und 27 gelöschten Zeilen
  1. 2 2
      src/router/student.js
  2. 32 25
      src/views/portal/components/Header.vue

+ 2 - 2
src/router/student.js

@@ -1,4 +1,4 @@
-const forum = [
+const routes = [
 	{
 		path: '/',
 		redirect: '/student/resourceCenter',
@@ -125,4 +125,4 @@ const forum = [
 		]
 	}
 ]
-export default forum
+export default routes

+ 32 - 25
src/views/portal/components/Header.vue

@@ -5,7 +5,7 @@
 	<div class="fcc headerBox">
 		<div class="fcbc box-width">
 			<div class="headerBtn">
-				<a-menu v-model:selectedKeys="current" mode="horizontal" @select="menuSelect">
+				<a-menu v-model:selectedKeys="current" mode="horizontal" @click="menuSelect">
 					<a-menu-item key="student/resourceCenter">资源中心</a-menu-item>
 					<a-menu-item key="student/courseCenter">课程中心</a-menu-item>
 					<a-sub-menu key="myList">
@@ -29,17 +29,17 @@
 						<DownOutlined />
 					</div>
 					<template #overlay>
-						<a-menu>
-							<a-menu-item key="1" @click="jump('/userInfo')">个人中心</a-menu-item>
-							<a-menu-item key="2">
+						<a-menu v-model:selectedKeys="current" @click="menuSelect">
+							<a-menu-item key="userInfo">个人中心</a-menu-item>
+							<a-menu-item key="1">
 								<router-link :to="{ path: '/forum' }" target="_blank">论坛</router-link>
 							</a-menu-item>
-							<a-menu-item key="3" @click="jump('/inSsiteMessage')">站内信</a-menu-item>
-							<a-menu-item key="4" @click="jump('/classNotice')">课程公告</a-menu-item>
-							<a-menu-item key="5" @click="jump('/learningFootprint')">学习足迹</a-menu-item>
-							<a-menu-item key="7" @click="jump('/passwordRetrieve')">密码找回</a-menu-item>
-							<a-menu-item key="7" @click="jump('/activate')">激活</a-menu-item>
-							<a-menu-item key="8" @click="outLogin()">退出登录</a-menu-item>
+							<a-menu-item key="inSsiteMessage">站内信</a-menu-item>
+							<a-menu-item key="classNotice">课程公告</a-menu-item>
+							<a-menu-item key="learningFootprint">学习足迹</a-menu-item>
+							<a-menu-item key="passwordRetrieve">密码找回</a-menu-item>
+							<a-menu-item key="activate">激活</a-menu-item>
+							<a-menu-item key="1" @click="outLogin()">退出登录</a-menu-item>
 						</a-menu>
 					</template>
 				</a-dropdown>
@@ -72,22 +72,29 @@
 		return store.userInfo
 	})
 
-	watch(route, (newValue) => {
-		current.value = []
-		nextTick(() => {
-			current.value = [newValue.path.slice(1)]
-		})
-	})
+	watch(
+		route,
+		(newValue) => {
+			current.value = []
+			nextTick(() => {
+				current.value = [newValue.path.slice(1)]
+				if (newValue.path == '/student/resourceDetails') {
+					current.value = ['student/resourceCenter']
+				}
+				if (newValue.path == '/student/classCentre') {
+					current.value = ['student/courseCenter']
+				}
+			})
+		},
+		{ immediate: true, deep: true }
+	)
 	const menuSelect = (obj) => {
-		const pathLength = obj.keyPath.length
-		const path = '/' + obj.keyPath[pathLength - 1]
-		router.push({ path })
-		current.value = obj.selectedKeys
-	}
-	const jump = (url) => {
-		router.push({
-			path: url
-		})
+		if (obj.key != '1') {
+			const pathLength = obj.keyPath.length
+			const path = '/' + obj.keyPath[pathLength - 1]
+			router.push({ path })
+			current.value = obj.selectedKeys
+		}
 	}
 	const outLogin = () => {
 		Modal.confirm({