| | |
| | | > |
| | | <span |
| | | :style="{ |
| | | fill: activeIndex == index ? '#fff' : '#000' |
| | | fill: activeIndex == index ? '#fff' : '#000', |
| | | }" |
| | | v-html="item.icon" |
| | | > |
| | |
| | | </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> |