diff --git a/src/http/rule/index.ts b/src/http/rule/index.ts new file mode 100644 index 0000000..e37657e --- /dev/null +++ b/src/http/rule/index.ts @@ -0,0 +1,15 @@ +/* + * @FilePath: \wwwd:\code\screenFront\src\http\realtimeSecurity\index.ts + * @Author: 王路平 + * @文件版本: V1.0.0 + * @Date: 2023-02-14 08:45:45 + * @Description: + * + * 版权信息 : 2023 by ${再登软件}, All Rights Reserved. + */ +import {get,post} from "@/utils/http" + +//气压 +export function selectPermission({address,hash}){ + return get('/manage/selectPermission',{address,hash}) +} \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index 7dd8d39..78e6d5f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -9,7 +9,8 @@ */ import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router"; - +import { selectPermission } from "@/http/rule/index" +import { ElMessage, ElMessageBox } from 'element-plus' const routes: Array = [ { path: "/child", @@ -60,13 +61,11 @@ const routes: Array = [ { path: "/energyConsume", name: "energyConsume", + component: () => import("../views/energyConsume/index.vue"), children: [ - { - path: "/energyConsume/", - component: () => import("../views/energyConsume/index.vue"), - }, { path: "/energyConsume/historyData", + name: 'historyData', component: () => import("../views/energyConsume/content/child/historyData.vue"), }, @@ -83,12 +82,12 @@ const routes: Array = [ children: [ { path: "/Offsite/", - name:"offSiteIndex", + name: "offSiteIndex", component: () => import("../views/Offsite/index.vue"), }, { path: "/Offsite/devList/:city", - name:"offSiteDevList", + name: "offSiteDevList", component: () => import("../views/Offsite/child/index.vue"), }, ], @@ -139,14 +138,11 @@ const routes: Array = [ { path: "/energyConsumejixie", name: "energyConsumejixie", + component: () => import("../views/energyConsumeJixiefenchang/index.vue"), children: [ - { - path: "/energyConsumejixie/", - component: () => - import("../views/energyConsumeJixiefenchang/index.vue"), - }, { path: "/energyConsumejixie/historyData", + name: "jixieHistoryData", component: () => import( "../views/energyConsumeJixiefenchang/content/child/historyData.vue" @@ -330,11 +326,36 @@ const router = createRouter({ routes, }); -router.beforeEach((to, from,next) => { +router.beforeEach(async (to: any, from, next) => { // ... + let address = to.name + let hash = to.query.hash + let arr = [ + 'legionProducts', 'devItem', 'tufting', 'Winding', 'Large_Format', + 'GetonAgain', 'OffsiteDevList', 'Mechanicschild', 'Mechanicsson', 'jixieHistoryData' + ] + // 返回 false 以取消导航 - //console.log(to,from); - - next() + if (to.path == "/") { + sessionStorage.setItem("screen_user_id", to.query.id); + + next(); + } else if (arr.includes(address)) { + next(); + } else { + let res: any = await selectPermission({ address, hash }) + if (res.data == true) { + next() + } else { + ElMessageBox.alert('没有该页面权限', '通知', { + // if you want to disable its autofocus + // autofocus: false, + confirmButtonText: '确认' + }) + return false + } + + } + }) export default router; diff --git a/src/views/index.vue b/src/views/index.vue index 63a8b19..27b1900 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -53,7 +53,9 @@ import { ref, onMounted, onUnmounted } from "vue"; import list from "@/components/assembly/indexList.vue"; import { useI18n } from "vue-i18n"; import { getStoredLanguage, saveStoredLanguage } from "@/utils/languageStorage"; +import { useRoute } from 'vue-router' let langicon=require("@/assets/svg/language.svg") +let route = useRoute() window.document.title = "大屏物联管理系统"; let { t } = useI18n(); let routerList = [ @@ -305,7 +307,10 @@ function changelang(val){ saveStoredLanguage(val) location.reload() } -onMounted(() => {}); +onMounted(() => { + console.log(route.query); + +}); onUnmounted(() => {});