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/classManage/index.vue | 135 +++++++++++++++++++++++--------------------- 1 files changed, 70 insertions(+), 65 deletions(-) diff --git a/src/views/classManage/index.vue b/src/views/classManage/index.vue index 993f5a2..9a0405a 100644 --- a/src/views/classManage/index.vue +++ b/src/views/classManage/index.vue @@ -29,7 +29,7 @@ > <span :style="{ - fill: activeIndex == index ? '#fff' : '#000' + fill: activeIndex == index ? '#fff' : '#000', }" v-html="item.icon" > @@ -50,115 +50,120 @@ </template> <script setup lang="ts"> -import { ref, watch, provide, onMounted, inject } from 'vue' -import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router' -import Header from './components/headerPage.vue' -import { menu } from './config' -import { getPublicImage } from '@/assets/js/middleGround/tool.js' -import defaultImg from '@/assets/images/default-book-img.png' +import { ref, watch, provide, onMounted, inject } from "vue"; +import { useRoute, useRouter, onBeforeRouteUpdate } from "vue-router"; +import Header from "./components/headerPage.vue"; +import { menu } from "./config"; +import { getPublicImage } from "@/assets/js/middleGround/tool.js"; +import defaultImg from "@/assets/images/default-book-img.png"; -const router: any = useRouter() -const route: any = useRoute() -const MG: any = inject('MG') -const config: any = inject('config') -const routerVal = router.currentRoute.value -const path = ref(routerVal.path) -const label = ref('') -const classInfo: any = ref() -const classIcon: any = ref() -const listMenu = ref([]) -const activeIndex = ref(0) -const userData = ref() +const router: any = useRouter(); +const route: any = useRoute(); +const MG: any = inject("MG"); +const config: any = inject("config"); +const routerVal = router.currentRoute.value; +const path = ref(routerVal.path); +const label = ref(""); +const classInfo: any = ref(); +const classIcon: any = ref(); +const listMenu = ref([]); +const activeIndex = ref(0); +const userData = ref(); watch(router.currentRoute, (val) => { - path.value = val.path + path.value = val.path; if (val.query.classInfo) { - const data: any = val.query.classInfo - const routerInfo: any = JSON.parse(data) - activeIndex.value = routerInfo.index + const data: any = val.query.classInfo; + const routerInfo: any = JSON.parse(data); + activeIndex.value = routerInfo.index; } -}) +}); watch(classInfo, (val) => { if (val) { - activeIndex.value = val.index + activeIndex.value = val.index; } if (!val.index) { - activeIndex.value = 0 + activeIndex.value = 0; } -}) +}); onBeforeRouteUpdate(async (to, from) => { - path.value = to.path -}) + path.value = to.path; +}); onMounted(() => { - classInfo.value = JSON.parse(route.query.classInfo) - classIcon.value = classInfo.value.icon ? getPublicImage(classInfo.value.icon, 200) : defaultImg + classInfo.value = JSON.parse(route.query.classInfo); + classIcon.value = classInfo.value.icon + ? getPublicImage(classInfo.value.icon, 200) + : defaultImg; 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) - userData.value = userInfo + }); + const userCache: any = localStorage.getItem(config.userInfoKey); + const userInfo = JSON.parse(userCache); + userData.value = userInfo; if (!userInfo) { router.push({ - path: '/' - }) - return false + path: "/", + }); + return false; } - if (userInfo.role != 'Teacher') { + if (userInfo.role != "Teacher") { const data: any = menu.filter( - (item: any) => item.path != 'studentManage' && item.path != 'jobAnalysis' - ) - listMenu.value = data + (item: any) => item.path != "studentManage" && item.path != "jobAnalysis" + ); + listMenu.value = data; } else { - const data: any = menu + const data: any = menu; // if (!classInfo.bookRefCode) { // // 铻嶅獟浣撳浘涔︼紝鏃犳暟瀛楅槄璇伙紝鏃犳硶璺宠浆 // const list: any = menu.filter((item: any) => item.path != 'teachingPlan') // listMenu.value = list; // return false // } - listMenu.value = data + listMenu.value = data; } -}) +}); const goRouter = (item: any, index: number) => { - activeIndex.value = index - if (!localStorage.getItem('jsek-token') || localStorage.getItem('jsek-token') == null) { + activeIndex.value = index; + if ( + !localStorage.getItem(config.tokenKey) || + localStorage.getItem(config.tokenKey) == null + ) { router.push({ - path: '/home', + path: "/home", query: { - showLogin: '1' - } - }) + showLogin: "1", + }, + }); } else { - label.value = item.label - classInfo.value.index = index + label.value = item.label; + classInfo.value.index = index; if (item.key == 5) { router.push({ - path: userData.value.role != 'Teacher' ? '/studentJob' : '/jobManage', + path: userData.value.role != "Teacher" ? "/studentJob" : "/jobManage", query: { - classInfo: JSON.stringify(classInfo.value) - } - }) + classInfo: JSON.stringify(classInfo.value), + }, + }); } else { router.push({ path: item.path, query: { - classInfo: JSON.stringify(classInfo.value) - } - }) + classInfo: JSON.stringify(classInfo.value), + }, + }); } } -} +}; const goBack = () => { - router.go(-1) -} + router.go(-1); +}; </script> <style lang="less" scoped> -- Gitblit v1.9.1