|
@@ -6,40 +6,20 @@ import MainPage from "@/views/c-views/visualizationPart/mainPage/MainPage.vue";
|
|
import MunicipalFacilities from "@/views/c-views/visualizationPart/municipalFacilities/MunicipalFacilities.vue";
|
|
import MunicipalFacilities from "@/views/c-views/visualizationPart/municipalFacilities/MunicipalFacilities.vue";
|
|
import {ElMessageBox} from "element-plus";
|
|
import {ElMessageBox} from "element-plus";
|
|
import {useUserStore} from "@/store/userStore.js";
|
|
import {useUserStore} from "@/store/userStore.js";
|
|
|
|
+import {getTokenInterior} from "@/service/userInfo.js";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
const router = createRouter({
|
|
const router = createRouter({
|
|
history:createWebHashHistory(import.meta.env.BASE_URL),
|
|
history:createWebHashHistory(import.meta.env.BASE_URL),
|
|
routes:[
|
|
routes:[
|
|
{
|
|
{
|
|
- path:'/',
|
|
|
|
- redirect:'/visualizationHome/mainPage'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path:'/visualizationHome',
|
|
|
|
- name:'visualizationHome',
|
|
|
|
- component:VisualizationHome,
|
|
|
|
- children:[
|
|
|
|
- {
|
|
|
|
- path:'houseBuilding',
|
|
|
|
- name:'houseBuilding',
|
|
|
|
- component:HouseBuilding,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path:'municipalFacilities',
|
|
|
|
- name:'municipalFacilities',
|
|
|
|
- component:MunicipalFacilities,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- path:'mainPage',
|
|
|
|
- name:'mainPage',
|
|
|
|
- component:MainPage,
|
|
|
|
- },
|
|
|
|
- ]
|
|
|
|
|
|
+ path:'/login',
|
|
|
|
+ name:'login',
|
|
|
|
+ // component:() => import('../views/login/Login.vue')
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- path:'/formHome',
|
|
|
|
- name:'formHome',
|
|
|
|
- component:FormHome
|
|
|
|
|
|
+ path:'/index:ticket',
|
|
},
|
|
},
|
|
{
|
|
{
|
|
path:'/iotAnalysis',
|
|
path:'/iotAnalysis',
|
|
@@ -48,16 +28,32 @@ const router = createRouter({
|
|
}
|
|
}
|
|
]
|
|
]
|
|
})
|
|
})
|
|
-router.beforeEach((to,from) =>{
|
|
|
|
- let userStore = useUserStore();
|
|
|
|
- let userInfo = localStorage.getItem('exchangeUserInfo');
|
|
|
|
- userStore.userInfo = JSON.parse(userInfo);
|
|
|
|
- // if(!userInfo ||userInfo == "null"||userInfo == null||userInfo == ""){
|
|
|
|
- // ElMessageBox.alert("请登录后操作",name,{
|
|
|
|
- // type:"warning",
|
|
|
|
- // confirmButtonText: "确定",
|
|
|
|
- // })
|
|
|
|
- // // window.location.href='https://cimweb.zjw.sh.cegn.cn:2007/cim-home/#/login';
|
|
|
|
- // }
|
|
|
|
-})
|
|
|
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
|
+ // 外部跳转, 携带票据守卫请求后端服务校验
|
|
|
|
+ if (to.path === '/login') {
|
|
|
|
+ let param = to.query.ticket;
|
|
|
|
+ debugger
|
|
|
|
+ // 调用后端服务进行权限校验
|
|
|
|
+ getTokenInterior(param, import.meta.env.VITE_SYSTEM_ID)
|
|
|
|
+ .then(res => {
|
|
|
|
+ debugger
|
|
|
|
+ // 401状态码,重定向到登录页
|
|
|
|
+ if (res.data.code === '401') {
|
|
|
|
+ alert(res.data.msg);
|
|
|
|
+ window.location.href = res.data.data.backUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 200状态码,权限校验成功,跳转到 /main/home
|
|
|
|
+ if (res.data.code === '200') {
|
|
|
|
+ router.replace({ path: '/iotAnalysis' });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(err => {
|
|
|
|
+ console.error('校验请求失败:', err);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ // 继续执行下一步
|
|
|
|
+ next();
|
|
|
|
+ }
|
|
|
|
+});
|
|
export default router
|
|
export default router
|