| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- import { createRouter, createWebHistory } from "vue-router";
- import AppLayout from "@/components/layout/AppLayout.vue";
- import { useTokenStore } from "@/stores/mytoken"; // 确保正确导入 useTokenStore
- // 定义路由配置
- const routes = [
- {
- path: "/login",
- name: "login",
- component: () => import("@/views/login/loginView.vue"), // 修复路径
- },
- {
- path: "/",
- name: "home",
- component: AppLayout,
- meta: { requiresAuth: true, title: "模型" },
- redirect: { name: "login" }, // 修改默认重定向为 login
- children: [
- {
- path: "/:catchAll(.*)",
- redirect: "/404", // 确保重定向到有效页面
- },
- {
- path: "select-city", // remove leading slash
- name: "selectCityAndCounty",
- component: () => import("@/views/User/selectCityAndCounty.vue"),
- meta: { title: "选择城市和县", fullScreen: true },
- },
- {
- path: "shuJuKanBan",
- name: "shuJuKanBan",
- component: () => import("@/views/User/shuJuKanBan/shuJuKanBan.vue"), // 修复路径
- meta: { title: "数据看板" },
- },
- {
- path: "SoilPro",
- name: "SoilPro",
- component: () => import("@/views/User/introduction/SoilPro.vue"), // 修复路径
- meta: { title: "软件简介" },
- },
- {
- path: "Overview",
- name: "Overview",
- component: () => import("@/views/User/introduction/Overview.vue"), // 修复路径
- meta: { title: "项目简介" },
- },
- {
- path: "ResearchFindings",
- name: "ResearchFindings",
- component: () =>
- import("@/views/User/introduction/ResearchFindings.vue"), // 修复路径
- meta: { title: "研究成果" },
- },
- {
- path: "Unit",
- name: "Unit",
- component: () => import("@/views/User/introduction/Unit.vue"), // 修复路径
- meta: { title: "团队信息" },
- },
- {
- path: "IntroductionUpdate",
- name: "IntroductionUpdate",
- component: () =>
- import("@/views/User/introduction/IntroductionUpdate.vue"), // 修复路径
- meta: { title: "更新介绍" },
- },
- {
- path: "Calculation",
- name: "Calculation",
- component: () => import("@/views/User/acidModel/Calculation.vue"), // 修复路径
- meta: { title: "反酸计算" },
- },
- {
- path: "AcidNeutralizationModel",
- name: "AcidNeutralizationModel",
- component: () =>
- import(
- "@/views/User/neutralizationModel/AcidNeutralizationModel.vue"
- ), // 修复路径
- meta: { title: "降酸计算" },
- },
- {
- path: "SoilAcidificationIterativeEvolution",
- name: "SoilAcidificationIterativeEvolution",
- component: () =>
- import(
- "@/views/User/neutralizationModel/SoilAcidificationIterativeEvolution.vue"
- ), // 修复路径
- meta: { title: "降酸模型显示" },
- },
- {
- path: "SoilAcidReductionIterativeEvolution",
- name: "SoilAcidReductionIterativeEvolution",
- component: () =>
- import(
- "@/views/User/acidModel/SoilAcidReductionIterativeEvolution.vue"
- ), // 修复路径
- meta: { title: "反酸模型显示" },
- },
- {
- path: "mapView",
- name: "mapView",
- component: () => import("@/views/User/mapView/leafletMapView.vue"), // 修复路径
- meta: { title: "地图展示" },
- },
- {
- path: "TotalCadmiumPrediction",
- name: "TotalCadmiumPrediction",
- component: () =>
- import("@/views/User/cadmiumPrediction/TotalCadmiumPrediction.vue"), // 修复路径
- meta: { title: "土壤镉的总含量预测" },
- },
- {
- path: "EffectiveCadmiumPrediction",
- name: "EffectiveCadmiumPrediction",
- component: () =>
- import(
- "@/views/User/cadmiumPrediction/EffectiveCadmiumPrediction.vue"
- ), // 修复路径
- meta: { title: "土壤镉有效态含量预测" },
- },
- {
- path: "cropRiskAssessment",
- name: "cropRiskAssessment",
- component: () =>
- import("@/views/User/cropRiskAssessment/cropRiskAssessment.vue"), // 修复路径
- meta: { title: "水稻镉污染风险" },
- },
- {
- path: "farmlandQualityAssessment",
- name: "farmlandQualityAssessment",
- component: () =>
- import(
- "@/views/User/farmlandQualityAssessment/farmlandQualityAssessment.vue"
- ), // 修复路径
- meta: { title: "韶关" },
- },
- {
- path: "SoilAcidReboundPrediction",
- name: "SoilAcidReboundPrediction",
- component: () =>
- import(
- "@/views/User/soilAcidificationPrediction/SoilAcidReboundPrediction.vue"
- ), // 修复路径
- meta: { title: "土壤反酸预测" },
- },
- {
- path: "SoilAcidReductionPrediction",
- name: "SoilAcidReductionPrediction",
- component: () =>
- import(
- "@/views/User/soilAcidificationPrediction/SoilAcidReductionPrediction.vue"
- ), // 修复路径
- meta: { title: "土壤降酸预测" },
- },
- {
- path: "TraditionalFarmingRisk",
- name: "TraditionalFarmingRisk",
- component: () =>
- import("@/views/User/scenarioSimulation/TraditionalFarmingRisk.vue"), // 修复路径
- meta: { title: "传统耕种习惯风险趋势" },
- },
- {
- path: "HeavyMetalCadmiumControl",
- name: "HeavyMetalCadmiumControl",
- component: () =>
- import(
- "@/views/User/scenarioSimulation/HeavyMetalCadmiumControl.vue"
- ), // 修复路径
- meta: { title: "重金属镉污染治理" },
- },
- {
- path: "SoilAcidificationControl",
- name: "SoilAcidificationControl",
- component: () =>
- import(
- "@/views/User/scenarioSimulation/SoilAcidificationControl.vue"
- ), // 修复路径
- meta: { title: "土壤酸化治理" },
- },
- {
- path: "DetectionStatistics",
- name: "DetectionStatistics",
- component: () =>
- import("@/views/User/dataStatistics/DetectionStatistics.vue"), // 修复路径
- meta: { title: "检测信息统计" },
- },
- {
- path: "FarmlandPollutionStatistics",
- name: "FarmlandPollutionStatistics",
- component: () =>
- import("@/views/User/dataStatistics/FarmlandPollutionStatistics.vue"), // 修复路径
- meta: { title: "耕地污染信息统计" },
- },
- {
- path: "PlantingRiskStatistics",
- name: "PlantingRiskStatistics",
- component: () =>
- import("@/views/User/dataStatistics/PlantingRiskStatistics.vue"), // 修复路径
- meta: { title: "种植风险信息统计" },
- },
- {
- path: "Visualizatio",
- name: "Visualizatio",
- component: () =>
- import("@/views/Admin/dataManagement/Visualizatio.vue"), // 修复路径
- meta: { title: "降酸数据管理" },
- },
- {
- path: "Visualization",
- name: "Visualization",
- component: () =>
- import("@/views/Admin/dataManagement/Visualization.vue"), // 修复路径
- meta: { title: "反酸数据管理" },
- },
- {
- path: "AdminRegionData",
- name: "AdminRegionData",
- component: () =>
- import("@/views/Admin/dataManagement/AdminRegionData.vue"), // 修复路径
- meta: { title: "行政区域数据" },
- },
- {
- path: "SoilAssessmentUnitData",
- name: "SoilAssessmentUnitData",
- component: () =>
- import("@/views/Admin/dataManagement/SoilAssessmentUnitData.vue"),
- meta: { title: "土壤评估单元格数据" },
- },
- {
- path: "SoilHeavyMetalData",
- name: "SoilHeavyMetalData",
- component: () =>
- import("@/views/Admin/dataManagement/SoilHeavyMetalData.vue"),
- meta: { title: "土壤重金属采集数据" },
- },
- {
- path: "CropHeavyMetalData",
- name: "CropHeavyMetalData",
- component: () =>
- import("@/views/Admin/dataManagement/CropHeavyMetalData.vue"),
- meta: { title: "农作物重金属采集样数据" },
- },
- {
- path: "LandUseTypeData",
- name: "LandUseTypeData",
- component: () =>
- import("@/views/Admin/dataManagement/LandUseTypeData.vue"),
- meta: { title: "用地类型数据" },
- },
- {
- path: "SoilAcidificationData",
- name: "SoilAcidificationData",
- component: () =>
- import("@/views/Admin/dataManagement/SoilAcidificationData.vue"),
- meta: { title: "土壤酸化采样数据" },
- },
- {
- path: "ClimateInfoData",
- name: "ClimateInfoData",
- component: () =>
- import("@/views/Admin/dataManagement/ClimateInfoData.vue"),
- meta: { title: "气候信息数据" },
- },
- {
- path: "GeographicEnvInfoData",
- name: "GeographicEnvInfoData",
- component: () =>
- import("@/views/Admin/dataManagement/GeographicEnvInfoData.vue"),
- meta: { title: "地理环境信息" },
- },
- {
- path: "ModelSelection",
- name: "ModelSelection",
- component: () =>
- import("@/views/Admin/modelManagement/AcidReductionModel/ModelSelection.vue"),
- meta: { title: "模型选择" },
- },
- {
- path: "thres",
- name: "thres",
- component: () => import("@/views/Admin/modelManagement/AcidReductionModel/thres.vue"),
- meta: { title: "阈值选择" },
- },
- {
- path: "ModelTrain",
- name: "ModelTrain",
- component: () => import("@/views/Admin/modelManagement/AcidReductionModel/ModelTrain.vue"),
- meta: { title: "模型训练" },
- },
- {
- path: "UserRegistration",
- name: "UserRegistration",
- component: () =>
- import("../views/Admin/userManagement/UserRegistration.vue"),
- meta: { title: "普通用户" },
- },
- {
- path: "UserManagement",
- name: "UserManagement",
- component: () =>
- import("@/views/Admin/userManagement/UserManagement.vue"),
- meta: { title: "用户信息管理" },
- },
- {
- path: "CadmiumPredictionModel",
- name: "CadmiumPredictionModel",
- component: () =>
- import("@/views/Admin/modelManagement/CadmiumPredictionModel.vue"),
- meta: { title: "土壤镉含量预测模型" },
- },
- {
- path: "EffectiveCadmiumModel",
- name: "EffectiveCadmiumModel",
- component: () =>
- import("@/views/Admin/modelManagement/EffectiveCadmiumModel.vue"),
- meta: { title: "土壤有效态镉预测模型" },
- },
- {
- path: "RiceRiskModel",
- name: "RiceRiskModel",
- component: () =>
- import("@/views/Admin/modelManagement/RiceRiskModel.vue"),
- meta: { title: "水稻镉污染风险模型" },
- },
- {
- path: "WheatRiskModel",
- name: "WheatRiskModel",
- component: () =>
- import("@/views/Admin/modelManagement/WheatRiskModel.vue"),
- meta: { title: "小麦镉污染风险模型" },
- },
- {
- path: "VegetableRiskModel",
- name: "VegetableRiskModel",
- component: () =>
- import("@/views/Admin/modelManagement/VegetableRiskModel.vue"),
- meta: { title: "蔬菜镉污染风险模型" },
- },
- {
- path: "irrigationWater",
- name: "irrigationWater",
- component: () =>
- import(
- "@/views/User/heavyMetalFluxCalculation/inputFluxCalculation/irrigationWater.vue"
- ),
- meta: { title: "灌溉水" },
- },
- {
- path: "agriculturalProductInput",
- name: "agriculturalProductInput",
- component: () =>
- import(
- "@/views/User/heavyMetalFluxCalculation/inputFluxCalculation/agriculturalProductInput.vue"
- ),
- meta: { title: "农产品投入" },
- },
- {
- path: "atmosphericDryWetDeposition",
- name: "atmosphericDryWetDeposition",
- component: () =>
- import(
- "@/views/User/heavyMetalFluxCalculation/inputFluxCalculation/atmosphericDryWetDeposition.vue"
- ),
- meta: { title: "大气干湿沉降" },
- },
- {
- path: "surfaceRunoff",
- name: "surfaceRunoff",
- component: () =>
- import(
- "@/views/User/heavyMetalFluxCalculation/outputFluxCalculation/surfaceRunoff.vue"
- ),
- meta: { title: "地表径流" },
- },
- {
- path: "cropRemoval",
- name: "cropRemoval",
- component: () =>
- import(
- "@/views/User/heavyMetalFluxCalculation/outputFluxCalculation/cropRemoval.vue"
- ),
- meta: { title: "农作物移除" },
- },
- {
- path: "subsurfaceFlow",
- name: "subsurfaceFlow",
- component: () =>
- import(
- "@/views/User/heavyMetalFluxCalculation/outputFluxCalculation/subsurfaceFlow.vue"
- ),
- meta: { title: "地下渗流" },
- },
- {
- path: "about",
- name: "about",
- component: () => import("@/views/AboutView.vue"),
- },
- {
- path: "/:pathMatch(.*)*",
- name: "ErrorPage",
- component: () => import("@/views/ErrorPage.vue"),
- },
- ],
- },
- ];
- const router = createRouter({
- history: createWebHistory(import.meta.env.BASE_URL),
- routes,
- });
- router.beforeEach((to, from, next) => {
- const tokenStore = useTokenStore();
- if (to.name === "login" && tokenStore.token.userid) {
- next({ name: "selectCityAndCounty" });
- } else if (to.matched.some((r) => r.meta.requiresAuth)) {
- tokenStore.token.userid ? next() : next({ name: "login" });
- } else {
- next();
- }
- });
- export default router;
|