index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {createRouter,createWebHashHistory} from "vue-router";
  2. import FormHome from "../views/c-views/formPart/FormHome.vue";
  3. import VisualizationHome from "../views/c-views/visualizationPart/VisualizationHome.vue";
  4. import HouseBuilding from "@/views/c-views/visualizationPart/houseBuilding/HouseBuilding.vue";
  5. import MainPage from "@/views/c-views/visualizationPart/mainPage/MainPage.vue";
  6. import MunicipalFacilities from "@/views/c-views/visualizationPart/municipalFacilities/MunicipalFacilities.vue";
  7. import {ElMessageBox} from "element-plus";
  8. import {useUserStore} from "@/store/userStore.js";
  9. const router = createRouter({
  10. history:createWebHashHistory(import.meta.env.BASE_URL),
  11. routes:[
  12. {
  13. path:'/',
  14. redirect:'/visualizationHome/mainPage'
  15. },
  16. {
  17. path:'/visualizationHome',
  18. name:'visualizationHome',
  19. component:VisualizationHome,
  20. children:[
  21. {
  22. path:'houseBuilding',
  23. name:'houseBuilding',
  24. component:HouseBuilding,
  25. },
  26. {
  27. path:'municipalFacilities',
  28. name:'municipalFacilities',
  29. component:MunicipalFacilities,
  30. },
  31. {
  32. path:'mainPage',
  33. name:'mainPage',
  34. component:MainPage,
  35. },
  36. ]
  37. },
  38. {
  39. path:'/formHome',
  40. name:'formHome',
  41. component:FormHome
  42. }
  43. ]
  44. })
  45. router.beforeEach((to,from) =>{
  46. let userStore = useUserStore();
  47. let userInfo = localStorage.getItem('exchangeUserInfo');
  48. userStore.userInfo = JSON.parse(userInfo);
  49. if(!userInfo ||userInfo == "null"||userInfo == null||userInfo == ""){
  50. ElMessageBox.alert("请登录后操作",name,{
  51. type:"warning",
  52. confirmButtonText: "确定",
  53. })
  54. window.location.href='https://cimweb.zjw.sh.cegn.cn:2007/cim-home/#/login';
  55. }
  56. })
  57. export default router