Commit 87c753b3 authored by jiaxu.yan's avatar jiaxu.yan

feat : 路由更新

parent c33ffbf0
// 创建路由为历史 // 创建路由为历史
import { createRouter, createWebHistory } from "vue-router"; import { createRouter, createWebHistory } from "vue-router";
import LoginPage from '@/views/login/login.vue' import LoginPage from "@/views/login/login.vue";
import HomePage from '@/views/home.vue' import HomePage from "@/views/home.vue";
import AboutPage from '@/components/About.vue' import AboutPage from "@/components/About.vue";
import store from '@/store' import store from "@/store";
//import nProgress from 'nprogress' //import nProgress from 'nprogress'
import screenDisplay from '@/views/Gis/screenDisplay.vue' import screenDisplay from "@/views/Gis/screenDisplay.vue";
import iframe from '@/views/iframe.vue' import iframe from "@/views/iframe.vue";
//import remote from './remote' //import remote from './remote'
// 定义路由规则 // 定义路由规则
const routes = [ const routes = [
{ {
path: '/', path: "/",
component: HomePage component: HomePage,
}, },
{ {
path: '/screenDisplay', path: "/screenDisplay",
component: screenDisplay component: screenDisplay,
},{ },
path:'/iframe', {
name: 'iframe', path: "/iframe",
component: iframe name: "iframe",
}, component: iframe,
{ },
path: '/Login', {
name: "/Login", path: "/Login",
component: LoginPage name: "/Login",
}, component: LoginPage,
{ },
path: '/Home', {
name: "Home", path: "/Home",
component: HomePage, name: "Home",
children: [ component: HomePage,
// ...remote,//远程控制 children: [
{ // ...remote,//远程控制
path: '/RealSupply', {
name: 'RealSupplyPage', path: "/RealSupply",
component: () => import('@/views/RealPage/RealSupplyPage.vue'), name: "RealSupplyPage",
meta: { component: () => import("@/views/RealPage/RealSupplyPage.vue"),
title: '首页-实时热源' meta: {
} title: "首页-实时热源",
},{ },
path: '/RealTransfer', },
name: '/RealTransPage', {
component: () => import('@/views/RealPage/RealTransPage.vue'), path: "/RealTransfer",
meta: { name: "/RealTransPage",
title: '实时换热站' component: () => import("@/views/RealPage/RealTransPage.vue"),
} meta: {
},{ title: "实时换热站",
path: '/RealPipe', },
name: 'RealPipePage', },
component: () => import('@/views/RealPage/RealPipePage.vue'), {
meta: { path: "/RealPipe",
title: '实时总管' name: "RealPipePage",
} component: () => import("@/views/RealPage/RealPipePage.vue"),
},{ meta: {
path: '/RealBoiler', title: "实时总管",
name: 'RealBoilerPage', },
component: () => import('@/views/RealPage/RealBoilerPage.vue'), },
meta: { {
title: '实时锅炉' path: "/RealBoiler",
} name: "RealBoilerPage",
},{ component: () => import("@/views/RealPage/RealBoilerPage.vue"),
path: '/RealEnergy', meta: {
name: 'RealEnergyPage', title: "实时锅炉",
component: () => import('@/views/RealPage/RealEnergyPage.vue'), },
meta: { },
title: '实时能耗' {
} path: "/RealEnergy",
}, name: "RealEnergyPage",
// },{ component: () => import("@/views/RealPage/RealEnergyPage.vue"),
// path: '/RealGas', meta: {
// name: 'RealGasPage', title: "实时能耗",
// component: () => import('@/views/RealPage/RealGasPage.vue'), },
// meta: { },
// title: '实时燃气' // },{
// } // path: '/RealGas',
// },{ // name: 'RealGasPage',
// path: '/RealHeat', // component: () => import('@/views/RealPage/RealGasPage.vue'),
// name: 'RealHeatPage', // meta: {
// component: () => import('@/views/RealPage/RealHeatPage.vue'), // title: '实时燃气'
// meta: { // }
// title: '实时热表' // },{
// } // path: '/RealHeat',
// },{ // name: 'RealHeatPage',
// path: '/RealWater', // component: () => import('@/views/RealPage/RealHeatPage.vue'),
// name: 'RealWaterPage', // meta: {
// component: () => import('@/views/RealPage/RealWaterPage.vue'), // title: '实时热表'
// meta: { // }
// title: '实时水表' // },{
// } // path: '/RealWater',
// },{ // name: 'RealWaterPage',
// path: '/RealElec', // component: () => import('@/views/RealPage/RealWaterPage.vue'),
// name: 'RealElecPage', // meta: {
// component: () => import('@/views/RealPage/RealElecPage.vue'), // title: '实时水表'
// meta: { // }
// title: '实时电表' // },{
// } // path: '/RealElec',
// }, // name: 'RealElecPage',
{ // component: () => import('@/views/RealPage/RealElecPage.vue'),
path: '/PipeStatus', // meta: {
name: 'PipeStatusPage', // title: '实时电表'
component: () => import('@/views/StatusPage/PipeStatusPage.vue'), // }
meta: { // },
title: '总管状态' {
} path: "/PipeStatus",
},{ name: "PipeStatusPage",
path: '/BoilerStatus', component: () => import("@/views/StatusPage/PipeStatusPage.vue"),
name: 'BoilerStatusPage', meta: {
component: () => import('@/views/StatusPage/BoilerStatusPage.vue'), title: "总管状态",
meta: { },
title: '锅炉状态' },
} {
},{ path: "/BoilerStatus",
path: '/TransferStatus', name: "BoilerStatusPage",
name: 'TransferStatusPage', component: () => import("@/views/StatusPage/BoilerStatusPage.vue"),
component: () => import('@/views/StatusPage/TransferStatusPage.vue'), meta: {
meta: { title: "锅炉状态",
title: '换热站状态' },
} },
},{ {
path: '/BoilerArtwork', path: "/TransferStatus",
name: 'BoilerArtworkPage', name: "TransferStatusPage",
component: () => import('@/views/ArtworkPage/BoilerArtworkPage.vue'), component: () => import("@/views/StatusPage/TransferStatusPage.vue"),
meta: { meta: {
title: '锅炉工艺图' title: "换热站状态",
} },
},{ },
path: '/MeasurementArtwork', {
name: 'MeasurementArtworkPage', path: "/BoilerArtwork",
component: () => import('@/views/ArtworkPage/MeasurementArtworkPage.vue'), name: "BoilerArtworkPage",
meta: { component: () => import("@/views/ArtworkPage/BoilerArtworkPage.vue"),
title: '计量站工艺图' meta: {
} title: "锅炉工艺图",
},{ },
path: '/AllBoilerArtwork', },
name: 'AllBoilerArtworkPage', {
component: () => import('@/views/ArtworkPage/AllBoilerArtworkPage.vue'), path: "/MeasurementArtwork",
meta: { name: "MeasurementArtworkPage",
title: '全景工艺图' component: () =>
} import("@/views/ArtworkPage/MeasurementArtworkPage.vue"),
},{ meta: {
path: '/TransferArtwork', title: "计量站工艺图",
name: 'TransferArtworkPage', },
component: () => import('@/views/ArtworkPage/TransferArtworkPage.vue'), },
meta: { {
title: '换热站工艺图' path: "/AllBoilerArtwork",
} name: "AllBoilerArtworkPage",
},{ component: () => import("@/views/ArtworkPage/AllBoilerArtworkPage.vue"),
path: '/AlarmStatus', meta: {
name: 'AlarmStatusPage', title: "全景工艺图",
component: () => import('@/views/AlarmPage/AlarmStatusPage.vue'), },
meta: { },
title: '报警状态' {
} path: "/TransferArtwork",
},{ name: "TransferArtworkPage",
path: '/Alarm', component: () => import("@/views/ArtworkPage/TransferArtworkPage.vue"),
name: 'AlarmInfoPage', meta: {
component: () => import('@/views/AlarmPage/AlarmInfoPage.vue'), title: "换热站工艺图",
meta: { },
title: '报警信息' },
} {
},{ path: "/AlarmStatus",
path: '/DataAnalysis', name: "AlarmStatusPage",
name: 'DataAnalysisPage', component: () => import("@/views/AlarmPage/AlarmStatusPage.vue"),
component: () => import('@/views/HandlerPage/DataAnalysisPage.vue'), meta: {
meta: { title: "报警状态",
title: '能耗分析' },
} },
},{ {
path: '/EnergyConsumption', path: "/Alarm",
name: 'EnergyConsumptionPage', name: "AlarmInfoPage",
component: () => import('@/views/HandlerPage/EnergyConsumptionPage.vue'), component: () => import("@/views/AlarmPage/AlarmInfoPage.vue"),
meta: { meta: {
title: '能耗排名' title: "报警信息",
} },
},{ },
path: '/Handler/EnerpriseEnergyView', {
name: 'EnerpriseEnergyView', path: "/DataAnalysis",
component: () => import('@/views/HandlerPage/EnerpriseEnergyView.vue'), name: "DataAnalysisPage",
meta: { component: () => import("@/views/HandlerPage/DataAnalysisPage.vue"),
title: '企业趋势图' meta: {
} title: "能耗分析",
},{ },
path: '/Handler/TransferEnergyView', },
name: 'EnergyViewPage', {
component: () => import('@/views/HandlerPage/TransferEnergyView.vue'), path: "/EnergyConsumption",
meta: { name: "EnergyConsumptionPage",
title: '换热站趋势图' component: () =>
} import("@/views/HandlerPage/EnergyConsumptionPage.vue"),
},{ meta: {
path: '/Handler/QOQView', title: "能耗排名",
name: 'QOQView', },
component: () => import('@/views/HandlerPage/QOQ.vue'), },
meta: { {
title: '用量环比' path: "/Handler/EnerpriseEnergyView",
} name: "EnerpriseEnergyView",
},{ component: () => import("@/views/HandlerPage/EnerpriseEnergyView.vue"),
path: '/Handler/YOYView', meta: {
name: 'YOYView', title: "企业趋势图",
component: () => import('@/views/HandlerPage/YOY.vue'), },
meta: { },
title: '用量同比' {
} path: "/Handler/TransferEnergyView",
},{ name: "EnergyViewPage",
path: '/HeatAnalysis', component: () => import("@/views/HandlerPage/TransferEnergyView.vue"),
name: 'HeatAnalysisPage', meta: {
component: () => import('@/views/Report/HeatAnalysisPage.vue'), title: "换热站趋势图",
meta: { },
title: '热量分析' },
} {
},{ path: "/Handler/QOQView",
path: '/Forecast', name: "QOQView",
name: 'ForecastPage', component: () => import("@/views/HandlerPage/QOQ.vue"),
component: () => import('@/views/Report/ForecastPage.vue'), meta: {
meta: { title: "用量环比",
title: '明日预测' },
} },
},{ {
path: '/RealAnalysis', path: "/Handler/YOYView",
name: 'RealAnalysisPage', name: "YOYView",
component: () => import('@/views/Report/RealAnalysisPage.vue'), component: () => import("@/views/HandlerPage/YOY.vue"),
meta: { meta: {
title: '实时热量分析' title: "用量同比",
} },
},{ },
path: '/TransferEnergy', {
name: 'TransferEnergyPage', path: "/HeatAnalysis",
component: () => import('@/views/Report/TransferEnergyPage.vue'), name: "HeatAnalysisPage",
meta: { component: () => import("@/views/Report/HeatAnalysisPage.vue"),
title: '换热站能耗' meta: {
} title: "热量分析",
},{ },
path: '/AreaInfo', },
name: 'AreaInfoPage', {
component: () => import('@/views/Report/AreaInfoPage.vue'), path: "/Forecast",
meta: { name: "ForecastPage",
title: '面积统计' component: () => import("@/views/Report/ForecastPage.vue"),
} meta: {
},{ title: "明日预测",
path: '/TodayPatrol', },
name: 'PatrolPage', },
component: () => import('@/views/PatrolPage/TodayPatrolPage.vue'), {
meta: { path: "/RealAnalysis",
title: '今日巡更' name: "RealAnalysisPage",
} component: () => import("@/views/Report/RealAnalysisPage.vue"),
},{ meta: {
path: '/HisPatrol', title: "实时热量分析",
name: 'HisPatrolPage', },
component: () => import('@/views/PatrolPage/HisPatrolPage.vue'), },
meta: { {
title: '巡更历史' path: "/TransferEnergy",
} name: "TransferEnergyPage",
},{ component: () => import("@/views/Report/TransferEnergyPage.vue"),
path: '/HeatUser', meta: {
name: 'HeatUserPage', title: "换热站能耗",
component: () => import('@/views/HeatUserPage/HeatUserPage.vue'), },
meta: { },
title: '热用户' {
} path: "/AreaInfo",
},{ name: "AreaInfoPage",
path: '/HeatUser/Tap', component: () => import("@/views/Report/AreaInfoPage.vue"),
name: 'TapPage', meta: {
component: () => import('@/views/HeatUserPage/TapPage.vue'), title: "面积统计",
meta: { },
title: '阀门' },
} {
},{ path: "/TodayPatrol",
path: '/History/Pipe', name: "PatrolPage",
name: 'HisPipe', component: () => import("@/views/PatrolPage/TodayPatrolPage.vue"),
component: () => import('@/views/HistoryPage/HisPipePage.vue'), meta: {
meta: { title: "今日巡更",
title: '总管历史数据' },
} },
},{ {
path: '/History/Boiler', path: "/HisPatrol",
name: 'HisBoiler', name: "HisPatrolPage",
component: () => import('@/views/HistoryPage/HisBoilerPage.vue'), component: () => import("@/views/PatrolPage/HisPatrolPage.vue"),
meta: { meta: {
title: '锅炉历史数据' title: "巡更历史",
} },
},{ },
path: '/History/Transfer', {
name: 'HisTransfer', path: "/HeatUser",
component: () => import('@/views/HistoryPage/HisTransPage.vue'), name: "HeatUserPage",
meta: { component: () => import("@/views/HeatUserPage/HeatUserPage.vue"),
title: '换热站历史数据' meta: {
} title: "热用户",
},{ },
path: '/History/Gas', },
name: 'HisGas', {
component: () => import('@/views/HistoryPage/HisGasPage.vue'), path: "/HeatUser/Tap",
meta: { name: "TapPage",
title: '燃气历史数据' component: () => import("@/views/HeatUserPage/TapPage.vue"),
} meta: {
},{ title: "阀门",
path: '/History/Water', },
name: 'HisWater', },
component: () => import('@/views/HistoryPage/HisWaterPage.vue'), {
meta: { path: "/History/Pipe",
title: '水表历史数据' name: "HisPipe",
} component: () => import("@/views/HistoryPage/HisPipePage.vue"),
},{ meta: {
path: '/History/Heat', title: "总管历史数据",
name: 'HisHeat', },
component: () => import('@/views/HistoryPage/HisHeatPage.vue'), },
meta: { {
title: '热表历史数据' path: "/History/Boiler",
} name: "HisBoiler",
},{ component: () => import("@/views/HistoryPage/HisBoilerPage.vue"),
path: '/History/Electric', meta: {
name: 'HisElectric', title: "锅炉历史数据",
component: () => import('@/views/HistoryPage/HisElecPage.vue'), },
meta: { },
title: '电表历史数据' {
} path: "/History/Transfer",
},{ name: "HisTransfer",
path: '/Handler/Overview', component: () => import("@/views/HistoryPage/HisTransPage.vue"),
name: 'Overview', meta: {
component: () => import('@/views/HandlerPage/OverviewPage.vue'), title: "换热站历史数据",
meta: { },
title: '数据总览' },
} {
},{ path: "/History/Gas",
path: '/Handler/EnergyView', name: "HisGas",
name: 'EnergyView', component: () => import("@/views/HistoryPage/HisGasPage.vue"),
component: () => import('@/views/HandlerPage/QOQ.vue'),//EnergyViewPage meta: {
meta: { title: "燃气历史数据",
title: '趋势图' },
} },
},{ {
path: '/Remote/Boiler', path: "/History/Water",
name: 'BoilerRemotePage', name: "HisWater",
component: () => import('@/views/RemotePage/BoilerControlPage.vue'), component: () => import("@/views/HistoryPage/HisWaterPage.vue"),
meta: { meta: {
title: '锅炉远程控制' title: "水表历史数据",
} },
}, },
{ {
path: '/Remote/ZdlmSelfTest', path: "/History/Heat",
name: 'ZdlmSelfTestPage', name: "HisHeat",
component: () => import('@/views/RemotePage/ZdlmSelfTest.vue'), component: () => import("@/views/HistoryPage/HisHeatPage.vue"),
meta: { meta: {
title: '电动阀自检' title: "热表历史数据",
} },
}, },
{ {
path: '/Remote/Transfer', path: "/History/Electric",
name: 'TransferRemotePage', name: "HisElectric",
component: () => import('@/views/RemotePage/TransControlPage.vue'), component: () => import("@/views/HistoryPage/HisElecPage.vue"),
meta: { meta: {
title: '换热站远程控制' title: "电表历史数据",
} },
},{ },
path: '/Remote/TransferPump', {
name: 'TransferPumpPage', path: "/Handler/Overview",
component: () => import('@/views/RemotePage/TransferPumpPage.vue'), name: "Overview",
meta: { component: () => import("@/views/HandlerPage/OverviewPage.vue"),
title: '循环泵压差控制' meta: {
} title: "数据总览",
},{ },
path: '/Video', },
name: 'VideoPage', {
component: () => import('@/views/Video/VideoViewPage.vue'), path: "/Handler/EnergyView",
meta: { name: "EnergyView",
title: '视频监控' component: () => import("@/views/HandlerPage/QOQ.vue"), //EnergyViewPage
} meta: {
},{ title: "趋势图",
path: '/Scheduling/WeatherManage', },
name: 'WeatherManage', },
component: () => import('@/views/Scheduling/WeatherManage.vue'), {
meta: { path: "/Remote/Boiler",
title: '气象干预' name: "BoilerRemotePage",
} component: () => import("@/views/RemotePage/BoilerControlPage.vue"),
},{ meta: {
path: '/Scheduling/EnergyManage', title: "锅炉远程控制",
name: 'EnergyManage', },
component: () => import('@/views/Scheduling/EnergyManage.vue'), },
meta: { {
title: '能源消耗' path: "/Remote/ZdlmSelfTest",
} name: "ZdlmSelfTestPage",
},{ component: () => import("@/views/RemotePage/ZdlmSelfTest.vue"),
path: '/Scheduling/AnalysisManage', meta: {
name: 'AnalysisManage', title: "电动阀自检",
component: () => import('@/views/Scheduling/AnalysisManage.vue'), },
meta: { },
title: '生产与结算数据分析表' {
} path: "/Remote/Transfer",
},{ name: "TransferRemotePage",
path: '/Scheduling/ConfigBoiler', component: () => import("@/views/RemotePage/TransControlPage.vue"),
name: 'ConfigBoiler', meta: {
component: () => import('@/views/Scheduling/ConfigBoiler.vue'), title: "换热站远程控制",
meta: { },
title: '锅炉参数配置' },
} {
},{ path: "/Remote/TransferPump",
path: '/Scheduling/Phenomenon', name: "TransferPumpPage",
name: 'Phenomenon', component: () => import("@/views/RemotePage/TransferPumpPage.vue"),
component: () => import('@/views/Scheduling/Phenomenon.vue'), meta: {
meta: { title: "循环泵压差控制",
title: '天气工况' },
} },
},{ {
path: '/Scheduling/InstantHeat', path: "/Video",
name: 'InstantHeat', name: "VideoPage",
component: () => import('@/views/Scheduling/InstantHeat.vue'), component: () => import("@/views/Video/VideoViewPage.vue"),
meta: { meta: {
title: '瞬时热量对比配置' title: "视频监控",
} },
},{ },
path: '/Scheduling/WindManage', {
name: 'WindManage', path: "/Scheduling/EnergyManage",
component: () => import('@/views/Scheduling/WindManage.vue'), name: "EnergyManagePage",
meta: { component: () => import("@/views/SchedulingPage/EnergyManagePage.vue"),
title: '风力配置管理' meta: {
} title: "能源消耗",
},{ },
path: '/Scheduling/AnnualParam', },
name: 'AnnualParam', {
component: () => import('@/views/Scheduling/AnnualParam.vue'), path: "/Scheduling/WeatherManage",
meta: { name: "WeatherManagePage",
title: '年度参数管理' component: () => import("@/views/SchedulingPage/WeatherManagePage.vue"),
} meta: {
} title: "气象干预",
] },
}, },
{ {
path: '/About', path: "/Scheduling/AnnualParam",
name: "/About", name: "AnnualParamPage",
component: AboutPage component: () => import("@/views/SchedulingPage/AnnualParamPage.vue"),
}, meta: {
{ title: "年度参数",
path:'/GisHome', },
name:'/GisHome', },
component: () => import('@/views/Gis/screenDisplay.vue'), {
meta: { path: "/Scheduling/ConfigBoiler",
title: '地图' name: "ConfigBoiler",
} component: () => import("../views/SchedulingPage/ConfigBoilerPage.vue"),
meta: {
title: "参数配置",
},
},
{
path: "/Scheduling/WindManage",
name: "WindManage",
component: () => import("../views/SchedulingPage/WindManagePage.vue"),
meta: {
title: "风力配置管理",
},
},
{
path: "/Scheduling/Phenomenon",
name: "Phenomenon",
component: () => import("../views/SchedulingPage/PhenomenonPage.vue"),
meta: {
title: "天气工况管理",
},
},
{
path: "/Scheduling/InstantHeat",
name: "InstantHeatPage",
component: () => import("@/views/SchedulingPage/InstantHeatPage.vue"),
meta: {
title: "瞬时热量对比配置",
},
},
],
},
{
path: "/About",
name: "/About",
component: AboutPage,
},
{
path: "/GisHome",
name: "/GisHome",
component: () => import("@/views/Gis/screenDisplay.vue"),
meta: {
title: "地图",
}, },
//捕获404路由 },
{ //捕获404路由
path: '/:pathMatch(.*)*', {
name: 'NotFound', path: "/:pathMatch(.*)*",
component: () => import('@/views/404.vue') name: "NotFound",
component: () => import("@/views/404.vue"),
},
{
path: "/TransferArt",
name: "/TransferArt",
component: () => import("@/components/art/TransferArt.vue"),
meta: {
title: "换热站工艺图",
}, },
{ },
path:'/TransferArt', {
name:'/TransferArt', path: "/BoilerArt",
component: () => import('@/components/art/TransferArt.vue'), name: "/BoilerArt",
meta: { component: () => import("@/components/art/BoilerArt.vue"),
title: '换热站工艺图' meta: {
} title: "锅炉工艺图",
}, },
{ },
path:'/BoilerArt', {
name:'/BoilerArt', path: "/AllBoilerArt",
component: () => import('@/components/art/BoilerArt.vue'), name: "AllBoilerArt",
meta: { component: () => import("@/components/art/AllBoilerArt.vue"),
title: '锅炉工艺图' meta: {
} title: "锅炉全景工艺图",
}, },
{ },
path: '/AllBoilerArt', {
name: 'AllBoilerArt', path: "/MeasurementArt",
component: () => import('@/components/art/AllBoilerArt.vue'), name: "MeasurementArt",
meta: { component: () => import("@/components/art/MeasurementArt.vue"),
title: '锅炉全景工艺图' meta: {
} title: "计量站全景工艺图",
}, },
{ },
path: '/MeasurementArt', {
name: 'MeasurementArt', path: "/Visualizations",
component: () => import('@/components/art/MeasurementArt.vue'), name: "Visualizations",
meta: { component: () => import("@/views/Visualizations/index.vue"),
title: '计量站全景工艺图' meta: {
} title: "可视化",
}, },
{ },
path: '/Visualizations', ];
name: 'Visualizations',
component: () => import('@/views/Visualizations/index.vue'),
meta: {
title: '可视化'
}
}
]
//创建路由实例对象 //创建路由实例对象
const router = createRouter({ const router = createRouter({
routes, routes,
history: createWebHistory(import.meta.env.BASE_URL) history: createWebHistory(import.meta.env.BASE_URL),
}) });
// // 使用路由守卫来判断是否已经加载了Home页面 // // 使用路由守卫来判断是否已经加载了Home页面
// let homeLoaded = false // let homeLoaded = false
...@@ -507,46 +549,44 @@ const router = createRouter({ ...@@ -507,46 +549,44 @@ const router = createRouter({
// } // }
// }) // })
let isgetOrg = false;
let isgetOrg = false
//全局前置路由守卫 //全局前置路由守卫
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
//store.dispatch("onLoading", true); //store.dispatch("onLoading", true);
// //nProgress.start() // //nProgress.start()
//获取token //获取token
const userInfo = store.getters.getUserInfo(); const userInfo = store.getters.getUserInfo();
//console.log(userInfo); //console.log(userInfo);
const token = store.getters.getToken(); const token = store.getters.getToken();
//console.log(token); //console.log(token);
//如果未登录跳转到登录页面 //如果未登录跳转到登录页面
if (!userInfo && to.path !== '/login') return next('/login') if (!userInfo && to.path !== "/login") return next("/login");
//如果已登录避免重复登录 //如果已登录避免重复登录
if (userInfo && to.path == '/login') { if (userInfo && to.path == "/login") {
return next({ path: from.path ? from.path : '/' }) return next({ path: from.path ? from.path : "/" });
} }
let hasNewRoutes = false let hasNewRoutes = false;
//如果用户登录成功,调用Vuex方法,存储用户信息 //如果用户登录成功,调用Vuex方法,存储用户信息
if (userInfo && !isgetOrg) { if (userInfo && !isgetOrg) {
try try {
{ const res = await store.dispatch("getOrg");
const res = await store.dispatch('getOrg') isgetOrg = true;
isgetOrg = true } catch (error) {
} catch (error) { store.commit("clearUserInfo", "");
store.commit("clearUserInfo", ""); return next("/login");
return next('/login')
}
} }
}
//手动指定路由
//如果确实有新路由加入手动指定路由,否则直接放行 //手动指定路由
hasNewRoutes ? next(to.fullPath) : next() //如果确实有新路由加入手动指定路由,否则直接放行
//next() hasNewRoutes ? next(to.fullPath) : next();
}) //next()
});
// router.afterEach((to, from) => { // router.afterEach((to, from) => {
// store.dispatch("onLoading", false); // store.dispatch("onLoading", false);
// }) // })
// 共享路由实例对象 // 共享路由实例对象
export default router export default router;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment