From 5f00696dfb25bc90034448ceb634ed1ef256681a Mon Sep 17 00:00:00 2001 From: qiyunfeng-create <1940665526@qq.com> Date: 星期四, 21 八月 2025 21:13:35 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/xiehe_website --- src/views/personalCenter/index.vue | 89 +++++++++++++++++++++++--------------------- 1 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/views/personalCenter/index.vue b/src/views/personalCenter/index.vue index 243c6b4..53e00c3 100644 --- a/src/views/personalCenter/index.vue +++ b/src/views/personalCenter/index.vue @@ -41,53 +41,58 @@ </template> <script setup lang="ts"> -import { ArrowRight } from '@element-plus/icons-vue' -import { menu } from './config.ts' -import { useRouter, onBeforeRouteUpdate } from 'vue-router' -import { ref, onMounted } from 'vue' -const router = useRouter() -const routerVal = router.currentRoute.value -const path = ref(routerVal.path) -const label = ref('') -const listMenu: any = ref([]) +import { ArrowRight } from "@element-plus/icons-vue"; +import { menu } from "./config.ts"; +import { useRouter, onBeforeRouteUpdate } from "vue-router"; +import { ref, onMounted, inject } from "vue"; +const router = useRouter(); +const routerVal = router.currentRoute.value; +const path = ref(routerVal.path); +const label = ref(""); +const listMenu: any = ref([]); +const MG: any = inject("MG"); +const config: any = inject("config"); onBeforeRouteUpdate(async (to, from) => { - path.value = to.fullPath -}) + path.value = to.fullPath; +}); onMounted(() => { menu.forEach((item) => { - if ('/' + item.path === path.value) { - label.value = item.label + if ("/" + item.path === path.value) { + label.value = item.label; } - }) - // const userCache: any = localStorage.getItem('jesk-userInfo') - // const userInfo = JSON.parse(userCache) - // if(!userInfo){ - // router.push({ - // path:'/' - // }) - // return false; - // } - // if (userInfo.role == 'Teacher') { - // const data: any = menu.filter((item) => item.path != 'class') - // listMenu.value = data - // } else { - const data: any = menu.filter((item) => item.path != 'course') - listMenu.value = data - // } -}) + }); + const userCache: any = localStorage.getItem(config.userInfoKey); + const userInfo = JSON.parse(userCache); + if (!userInfo) { + router.push({ + path: "/", + }); + return false; + } + if (userInfo.role == "Teacher") { + const data: any = menu.filter((item) => item.path != "myClass"); + listMenu.value = data; + } else { + const data: any = menu.filter((item) => item.path != "myCourse"); + listMenu.value = data; + } +}); const goRouter = (item: any) => { - // if (!localStorage.getItem('jsek-token') || localStorage.getItem('jsek-token') == null) { - // router.push({ - // path: '/home', - // query: { - // showLogin: '1' - // } - // }) - // } else { - label.value = item.label - router.push({ path: item.path }) - // } -} + if ( + !localStorage.getItem(config.tokenKey) || + localStorage.getItem(config.tokenKey) == null + ) { + router.push({ + path: "/home", + query: { + showLogin: "1", + }, + }); + } else { + label.value = item.label; + router.push({ path: item.path }); + } +}; </script> <style lang="less" scoped> .breadcrumbBox { -- Gitblit v1.9.1