index.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. import { createRouter, createWebHistory } from "vue-router";
  2. import AppLayout from "@/components/layout/AppLayout.vue";
  3. import { useTokenStore } from "@/stores/mytoken"; // 确保正确导入 useTokenStore
  4. // 定义路由配置
  5. const routes = [
  6. { path: "/login", name: "login", component: () => import("@/views/login/loginView.vue") },
  7. {
  8. path: "/",
  9. component: AppLayout,
  10. meta: { requiresAuth: true },
  11. children: [
  12. {
  13. path: "/:catchAll(.*)",
  14. redirect: "/404", // 确保重定向到有效页面
  15. },
  16. {
  17. path: '',
  18. redirect: '/irriSampleData'
  19. },
  20. {
  21. path: "select-city", // remove leading slash
  22. name: "selectCityAndCounty",
  23. component: () => import("@/views/User/selectCityAndCounty.vue"),
  24. meta: { title: "选择城市和县", fullScreen: true },
  25. },
  26. {
  27. path: "shuJuKanBan",
  28. name: "shuJuKanBan",
  29. component: () => import("@/views/User/shuJuKanBan/shuJuKanBan.vue"), // 修复路径
  30. meta: { title: "数据看板" },
  31. },
  32. {
  33. path: "SoilPro",
  34. name: "SoilPro",
  35. component: () => import("@/views/User/introduction/SoilPro.vue"), // 修复路径
  36. meta: { title: "软件简介" },
  37. },
  38. {
  39. path: "Overview",
  40. name: "Overview",
  41. component: () => import("@/views/User/introduction/Overview.vue"), // 修复路径
  42. meta: { title: "项目简介" },
  43. },
  44. {
  45. path: "ResearchFindings",
  46. name: "ResearchFindings",
  47. component: () =>
  48. import("@/views/User/introduction/ResearchFindings.vue"), // 修复路径
  49. meta: { title: "研究成果" },
  50. },
  51. {
  52. path: "Unit",
  53. name: "Unit",
  54. component: () => import("@/views/User/introduction/Unit.vue"), // 修复路径
  55. meta: { title: "团队信息" },
  56. },
  57. {
  58. path: "IntroductionUpdate",
  59. name: "IntroductionUpdate",
  60. component: () =>
  61. import("@/views/User/introduction/IntroductionUpdate.vue"), // 修复路径
  62. meta: { title: "更新介绍" },
  63. },
  64. //管理员
  65. // {
  66. // path: "HmOutFlux",
  67. // name: "HmOutFlux",
  68. // component: () => import("@/views/User/HmOutFlux"),
  69. // meta: { title: "重金属输出通量" },
  70. // },
  71. // {
  72. // path: "irrigationWater",
  73. // name: "irrigationWater",
  74. // component: () => import("@/views/User/HmOutFlux/irrigationWater"),
  75. // meta: { title: "灌溉水" },
  76. // },
  77. {
  78. path: "samplingMethodDevice1",
  79. name: "samplingMethodDevice1",
  80. component: () =>
  81. import(
  82. "@/views/User/HmOutFlux/irrigationWater/samplingMethodDevice1.vue"
  83. ),
  84. meta: { title: "采样方法和装置" },
  85. },
  86. {
  87. path: "irriSampleData",
  88. name: "irriSampleData",
  89. component: () =>
  90. import(
  91. "@/views/User/HmOutFlux/irrigationWater/irriWaterSampleData.vue"
  92. ),
  93. meta: { title: "灌溉水采样数据" },
  94. },
  95. {
  96. path: "csSampleData",
  97. name: "csSampleData",
  98. component: () =>
  99. import(
  100. "@/views/User/HmOutFlux/irrigationWater/crossSection.vue"
  101. ),
  102. meta: { title: "断面采样数据" },
  103. },
  104. {
  105. path: "irriInputFlux",
  106. name: "irriInputFlux",
  107. component: () =>
  108. import(
  109. "@/views/User/HmOutFlux/irrigationWater/irriWaterInputFlux.vue"
  110. ),
  111. meta: { title: "灌溉水输入通量" },
  112. },
  113. // {
  114. // path: "agriInput",
  115. // name: "agriInput",
  116. // component: () => import("@/views/User/HmOutFlux/agriInput"),
  117. // meta: { title: "农产品投入" },
  118. // },
  119. {
  120. path: "farmInputSamplingDesc",
  121. name: "farmInputSamplingDesc",
  122. component: () =>
  123. import("@/views/User/HmOutFlux/agriInput/farmInputSamplingDesc.vue"),
  124. meta: { title: "采样说明" },
  125. },
  126. {
  127. path: "prodInputFlux",
  128. name: "prodInputFlux",
  129. component: () =>
  130. import("@/views/User/HmOutFlux/agriInput/prodInputFlux.vue"),
  131. meta: { title: "农产品输入通量" },
  132. },
  133. // {
  134. // path: "atmosDeposition",
  135. // name: "atmosDeposition",
  136. // component: () => import("@/views/User/HmOutFlux/atmosDeposition"),
  137. // meta: { title: "大气干湿沉降" },
  138. // },
  139. {
  140. path: "AtmosDepositionSamplingDesc",
  141. name: "AtmosDepositionSamplingDesc",
  142. component: () =>
  143. import(
  144. "@/views/User/HmOutFlux/atmosDeposition/AtmosDepositionSamplingDesc.vue"
  145. ),
  146. meta: { title: "采样说明" },
  147. },
  148. {
  149. path: "heavyMetalEnterprise",
  150. name: "heavyMetalEnterprise",
  151. component: () =>
  152. import(
  153. "@/views/User/HmOutFlux/atmosDeposition/heavyMetalEnterprise.vue"
  154. ),
  155. meta: { title: "涉重企业" },
  156. },
  157. {
  158. path: "airSampleData",
  159. name: "airSampleData",
  160. component: () =>
  161. import("@/views/User/HmOutFlux/atmosDeposition/airSampleData.vue"),
  162. meta: { title: "大气采样数据" },
  163. },
  164. {
  165. path: "airInputFlux",
  166. name: "airInputFlux",
  167. component: () =>
  168. import("@/views/User/HmOutFlux/atmosDeposition/airInputFlux.vue"),
  169. meta: { title: "大气输入通量" },
  170. },
  171. {
  172. path: "totalInputFluxDesc",
  173. name: "totalInputFluxDesc",
  174. component: () =>
  175. import("@/views/User/HmOutFlux/totalInputFluxDesc.vue"),
  176. meta: { title: "输入总通量说明" },
  177. },
  178. {
  179. path: "totalOutputFluxDesc",
  180. name: "totalOutputFluxDesc",
  181. component: () =>
  182. import("@/views/User/hmInFlux/totalOutputFluxDesc.vue"),
  183. meta: { title: "输出总通量说明" },
  184. },
  185. // {
  186. // path: "hmInFlux",
  187. // name: "hmInFlux",
  188. // component: () => import("@/views/User/hmInFlux"),
  189. // meta: { title: "重金属输入通量" },
  190. // },
  191. // {
  192. // path: "grainRemoval",
  193. // name: "grainRemoval",
  194. // component: () => import("@/views/User/hmInFlux/grainRemoval"),
  195. // meta: { title: "籽粒移除" },
  196. // },
  197. {
  198. path: "samplingDesc1",
  199. name: "samplingDesc1",
  200. component: () =>
  201. import("@/views/User/hmInFlux/grainRemoval/samplingDesc1.vue"),
  202. meta: { title: "采样说明" },
  203. },
  204. {
  205. path: "grainRemovalInputFlux",
  206. name: "grainRemovalInputFlux",
  207. component: () =>
  208. import(
  209. "@/views/User/hmInFlux/grainRemoval/grainRemovalInputFlux.vue"
  210. ),
  211. meta: { title: "籽粒移除输出通量" },
  212. },
  213. // {
  214. // path: "strawRemoval",
  215. // name: "strawRemoval",
  216. // component: () => import("@/views/User/hmInFlux/strawRemoval"),
  217. // meta: { title: "秸秆移除" },
  218. // },
  219. {
  220. path: "samplingDesc2",
  221. name: "samplingDesc2",
  222. component: () =>
  223. import("@/views/User/hmInFlux/strawRemoval/samplingDesc2.vue"),
  224. meta: { title: "采样说明" },
  225. },
  226. {
  227. path: "strawRemovalInputFlux",
  228. name: "strawRemovalInputFlux",
  229. component: () =>
  230. import(
  231. "@/views/User/hmInFlux/strawRemoval/strawRemovalInputFlux.vue"
  232. ),
  233. meta: { title: "秸秆移除输出通量" },
  234. },
  235. // {
  236. // path: "subsurfaceLeakage",
  237. // name: "subsurfaceLeakage",
  238. // component: () => import("@/views/User/hmInFlux/subsurfaceLeakage"),
  239. // meta: { title: "地下渗漏" },
  240. // },
  241. {
  242. path: "samplingDesc3",
  243. name: "samplingDesc3",
  244. component: () =>
  245. import("@/views/User/hmInFlux/subsurfaceLeakage/samplingDesc3.vue"),
  246. meta: { title: "采样说明" },
  247. },
  248. {
  249. path: "subsurfaceLeakageInputFlux",
  250. name: "subsurfaceLeakageInputFlux",
  251. component: () =>
  252. import(
  253. "@/views/User/hmInFlux/subsurfaceLeakage/subsurfaceLeakageInputFlux.vue"
  254. ),
  255. meta: { title: "地下渗漏输出通量" },
  256. },
  257. // {
  258. // path: "surfaceRunoff",
  259. // name: "surfaceRunoff",
  260. // component: () => import("@/views/User/hmInFlux/surfaceRunoff"),
  261. // meta: { title: "地表径流" },
  262. // },
  263. {
  264. path: "samplingDesc4",
  265. name: "samplingDesc4",
  266. component: () =>
  267. import("@/views/User/hmInFlux/surfaceRunoff/samplingDesc4.vue"),
  268. meta: { title: "采样说明" },
  269. },
  270. {
  271. path: "surfaceRunoffInputFlux",
  272. name: "surfaceRunoffInputFlux",
  273. component: () =>
  274. import(
  275. "@/views/User/hmInFlux/surfaceRunoff/surfaceRunoffInputFlux.vue"
  276. ),
  277. meta: { title: "地表径流输出通量" },
  278. },
  279. {
  280. path: "Calculation",
  281. name: "Calculation",
  282. component: () => import("@/views/User/acidModel/Calculation.vue"), // 修复路径
  283. meta: { title: "反酸计算" },
  284. },
  285. {
  286. path: "AcidNeutralizationModel",
  287. name: "AcidNeutralizationModel",
  288. component: () =>
  289. import(
  290. "@/views/User/neutralizationModel/AcidNeutralizationModel.vue"
  291. ), // 修复路径
  292. meta: { title: "降酸计算" },
  293. },
  294. {
  295. path: "SoilAcidificationIterativeEvolution",
  296. name: "SoilAcidificationIterativeEvolution",
  297. component: () =>
  298. import(
  299. "@/views/User/neutralizationModel/SoilAcidificationIterativeEvolution.vue"
  300. ), // 修复路径
  301. meta: { title: "降酸模型显示" },
  302. },
  303. {
  304. path: "SoilAcidReductionIterativeEvolution",
  305. name: "SoilAcidReductionIterativeEvolution",
  306. component: () =>
  307. import(
  308. "@/views/User/acidModel/SoilAcidReductionIterativeEvolution.vue"
  309. ), // 修复路径
  310. meta: { title: "反酸模型显示" },
  311. },
  312. {
  313. path: "mapView",
  314. name: "mapView",
  315. component: () => import("@/views/User/mapView/leafletMapView.vue"), // 修复路径
  316. meta: { title: "地图展示" },
  317. },
  318. {
  319. path: "totalInputFlux",
  320. name: "totalInputFlux",
  321. component: () =>
  322. import("@/views/User/cadmiumPrediction/totalInputFlux.vue"),
  323. meta: { title: "输入总通量" },
  324. },
  325. {
  326. path: "totalOutputFlux",
  327. name: "totalOutputFlux",
  328. component: () =>
  329. import("@/views/User/cadmiumPrediction/totalOutputFlux.vue"), // 修复路径
  330. meta: { title: "输出总通量" },
  331. },
  332. {
  333. path: "netFlux",
  334. name: "netFlux",
  335. component: () => import("@/views/User/cadmiumPrediction/netFlux.vue"), // 修复路径
  336. meta: { title: "净通量" },
  337. },
  338. {
  339. path: "currentYearConcentration",
  340. name: "currentYearConcentration",
  341. component: () =>
  342. import("@/views/User/cadmiumPrediction/currentYearConcentration.vue"), // 修复路径
  343. meta: { title: "当年浓度" },
  344. },
  345. {
  346. path: "TotalCadmiumPrediction",
  347. name: "TotalCadmiumPrediction",
  348. component: () =>
  349. import("@/views/User/cadmiumPrediction/TotalCadmiumPrediction.vue"), // 修复路径
  350. meta: { title: "土壤镉的总含量预测" },
  351. },
  352. {
  353. path: "EffectiveCadmiumPrediction",
  354. name: "EffectiveCadmiumPrediction",
  355. component: () =>
  356. import(
  357. "@/views/User/cadmiumPrediction/EffectiveCadmiumPrediction.vue"
  358. ), // 修复路径
  359. meta: { title: "土壤镉有效态含量预测" },
  360. },
  361. {
  362. path: "CropCadmiumPrediction",
  363. name: "CropCadmiumPrediction",
  364. component: () =>
  365. import("@/views/User/cadmiumPrediction/CropCadmiumPrediction.vue"), // 修复路径
  366. meta: { title: "土壤镉作物态含量预测" },
  367. },
  368. // {
  369. // path: "cropRiskAssessment",
  370. // name: "cropRiskAssessment",
  371. // component: () =>
  372. // import("@/views/User/cropRiskAssessment/cropRiskAssessment.vue"), // 修复路径
  373. // meta: { title: "水稻镉污染风险" },
  374. // },
  375. {
  376. path: "farmlandQualityAssessment",
  377. name: "farmlandQualityAssessment",
  378. component: () =>
  379. import(
  380. "@/views/User/farmlandQualityAssessment/farmlandQualityAssessment.vue"
  381. ), // 修复路径
  382. meta: { title: "韶关" },
  383. },
  384. {
  385. path: "SoilAcidReboundPrediction",
  386. name: "SoilAcidReboundPrediction",
  387. component: () =>
  388. import(
  389. "@/views/User/soilAcidificationPrediction/SoilAcidReboundPrediction.vue"
  390. ), // 修复路径
  391. meta: { title: "土壤反酸预测" },
  392. },
  393. {
  394. path: "SoilAcidReductionPrediction",
  395. name: "SoilAcidReductionPrediction",
  396. component: () =>
  397. import(
  398. "@/views/User/soilAcidificationPrediction/SoilAcidReductionPrediction.vue"
  399. ), // 修复路径
  400. meta: { title: "土壤降酸预测" },
  401. },
  402. // {
  403. // path: "TraditionalFarmingRisk",
  404. // name: "TraditionalFarmingRisk",
  405. // component: () =>
  406. // import("@/views/User/scenarioSimulation/TraditionalFarmingRisk.vue"), // 修复路径
  407. // meta: { title: "传统耕种习惯风险趋势" },
  408. // },
  409. // {
  410. // path: "HeavyMetalCadmiumControl",
  411. // name: "HeavyMetalCadmiumControl",
  412. // component: () =>
  413. // import(
  414. // "@/views/User/scenarioSimulation/HeavyMetalCadmiumControl.vue"
  415. // ), // 修复路径
  416. // meta: { title: "重金属镉污染治理" },
  417. // },
  418. // {
  419. // path: "SoilAcidificationControl",
  420. // name: "SoilAcidificationControl",
  421. // component: () =>
  422. // import(
  423. // "@/views/User/scenarioSimulation/SoilAcidificationControl.vue"
  424. // ), // 修复路径
  425. // meta: { title: "土壤酸化治理" },
  426. // },
  427. {
  428. path: "DetectionStatistics",
  429. name: "DetectionStatistics",
  430. component: () =>
  431. import("@/views/User/dataStatistics/DetectionStatistics.vue"), // 修复路径
  432. meta: { title: "检测信息统计" },
  433. },
  434. {
  435. path: "FarmlandPollutionStatistics",
  436. name: "FarmlandPollutionStatistics",
  437. component: () =>
  438. import("@/views/User/dataStatistics/SoilCdStatistics.vue"), // 修复路径
  439. meta: { title: "土壤镉含量统计" },
  440. },
  441. {
  442. path: "LandClutivatesStatistics",
  443. name: "LandClutivatesStatistics",
  444. component: () =>
  445. import("@/views/User/dataStatistics/LandCultivatedStatistics.vue"), // 修复路径
  446. meta: { title: "作物风险评估系统" },
  447. },
  448. {
  449. path: "SoilacidificationStatistics",
  450. name: "SoilacidificationStatistics",
  451. component: () =>
  452. import("@/views/User/dataStatistics/SoilacidificationStatistics.vue"), // 修复路径
  453. meta: { title: "作物风险评估系统" },
  454. },
  455. {
  456. path: "AdminRegionData",
  457. name: "AdminRegionData",
  458. component: () =>
  459. import("@/views/Admin/dataManagement/AdminRegionData.vue"), // 修复路径
  460. meta: { title: "行政区域数据" },
  461. },
  462. {
  463. path: "irrigationWaterSampleData",
  464. name: "irrigationWaterSampleData",
  465. component: () =>
  466. import(
  467. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/irrigationWaterSampleData.vue"
  468. ),
  469. meta: { title: "灌溉水采样数据" },
  470. },
  471. {
  472. path: "crossSectionSampleData",
  473. name: "crossSectionSampleData",
  474. component: () =>
  475. import(
  476. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/crossSectionSampleData.vue"
  477. ),
  478. meta: { title: "断面采样数据" },
  479. },
  480. {
  481. path: "irrigationWaterInputFluxData",
  482. name: "irrigationWaterInputFluxData",
  483. component: () =>
  484. import(
  485. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/irrigationWaterInputFluxData.vue"
  486. ),
  487. meta: { title: "灌溉水输入通量数据" },
  488. },
  489. {
  490. path: "agriProductInputFluxData",
  491. name: "agriProductInputFluxData",
  492. component: () =>
  493. import(
  494. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/agriProductInputFluxData.vue"
  495. ),
  496. meta: { title: "农产品输入通量数据" },
  497. },
  498. {
  499. path: "heavyMetalEnterpriseData",
  500. name: "heavyMetalEnterpriseData",
  501. component: () =>
  502. import(
  503. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/heavyMetalEnterpriseData.vue"
  504. ),
  505. meta: { title: "涉重企业数据" },
  506. },
  507. {
  508. path: "atmosphericSampleData",
  509. name: "atmosphericSampleData",
  510. component: () =>
  511. import(
  512. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/atmosphericSampleData.vue"
  513. ),
  514. meta: { title: "大气采样数据" },
  515. },
  516. {
  517. path: "atmosphericInputFluxData",
  518. name: "atmosphericInputFluxData",
  519. component: () =>
  520. import(
  521. "@/views/Admin/dataManagement/HeavyMetalInputFluxManager/atmosphericInputFluxData.vue"
  522. ),
  523. meta: { title: "大气输入通量数据" },
  524. },
  525. {
  526. path: "SoilAssessmentUnitData",
  527. name: "SoilAssessmentUnitData",
  528. component: () =>
  529. import("@/views/Admin/dataManagement/SoilAssessmentUnitData.vue"),
  530. meta: { title: "土壤评估单元格数据" },
  531. },
  532. {
  533. path: "SoilHeavyMetalData",
  534. name: "SoilHeavyMetalData",
  535. component: () =>
  536. import("@/views/Admin/dataManagement/SoilHeavyMetalData.vue"),
  537. meta: { title: "土壤重金属采集数据" },
  538. },
  539. {
  540. path: "CropHeavyMetalData",
  541. name: "CropHeavyMetalData",
  542. component: () =>
  543. import("@/views/Admin/dataManagement/CropHeavyMetalData.vue"),
  544. meta: { title: "农作物重金属采集样数据" },
  545. },
  546. {
  547. path: "LandUseTypeData",
  548. name: "LandUseTypeData",
  549. component: () =>
  550. import("@/views/Admin/dataManagement/LandUseTypeData.vue"),
  551. meta: { title: "用地类型数据" },
  552. },
  553. {
  554. path: "SoilAcidificationData",
  555. name: "SoilAcidificationData",
  556. component: () =>
  557. import(
  558. "@/views/Admin/dataManagement/Soil Acidification and Acid Reduction Data Management/soilAcidificationData.vue"
  559. ),
  560. meta: { title: "土壤酸化采样数据" },
  561. },
  562. {
  563. path: "soilAcidReductionData",
  564. name: "soilAcidReductionData",
  565. component: () =>
  566. import(
  567. "@/views/Admin/dataManagement/Soil Acidification and Acid Reduction Data Management/soilAcidReductionData.vue"
  568. ),
  569. meta: { title: "土壤酸化采样数据" },
  570. },
  571. {
  572. path: "ClimateInfoData",
  573. name: "ClimateInfoData",
  574. component: () =>
  575. import("@/views/Admin/dataManagement/ClimateInfoData.vue"),
  576. meta: { title: "气候信息数据" },
  577. },
  578. {
  579. path: "GeographicEnvInfoData",
  580. name: "GeographicEnvInfoData",
  581. component: () =>
  582. import("@/views/Admin/dataManagement/GeographicEnvInfoData.vue"),
  583. meta: { title: "地理环境信息" },
  584. },
  585. {
  586. path: "ModelSelection",
  587. name: "ModelSelection",
  588. component: () =>
  589. import("@/views/Admin/parameterConfig/ModelSelection.vue"),
  590. meta: { title: "模型选择" },
  591. },
  592. {
  593. path: "thres",
  594. name: "thres",
  595. component: () => import("@/views/Admin/parameterConfig/thres.vue"),
  596. meta: { title: "阈值选择" },
  597. },
  598. {
  599. path: "ModelTrain",
  600. name: "ModelTrain",
  601. component: () => import("@/views/Admin/parameterConfig/ModelTrain.vue"),
  602. meta: { title: "模型训练" },
  603. },
  604. {
  605. path: "UserRegistration",
  606. name: "UserRegistration",
  607. component: () =>
  608. import("@/views/Admin/userManagement/UserRegistration.vue"),
  609. meta: { title: "普通用户" },
  610. },
  611. {
  612. path: "UserManagement",
  613. name: "UserManagement",
  614. component: () =>
  615. import("@/views/Admin/userManagement/UserManagement.vue"),
  616. meta: { title: "用户信息管理" },
  617. },
  618. {
  619. path: "CadmiumPredictionModel",
  620. name: "CadmiumPredictionModel",
  621. component: () =>
  622. import("@/views/Admin/modelManagement/CadmiumPredictionModel.vue"),
  623. meta: { title: "土壤镉含量预测模型" },
  624. },
  625. {
  626. path: "EffectiveCadmiumModel",
  627. name: "EffectiveCadmiumModel",
  628. component: () =>
  629. import("@/views/Admin/modelManagement/EffectiveCadmiumModel.vue"),
  630. meta: { title: "土壤有效态镉预测模型" },
  631. },
  632. {
  633. path: "RiceRiskModel",
  634. name: "RiceRiskModel",
  635. component: () =>
  636. import("@/views/Admin/modelManagement/RiceRiskModel.vue"),
  637. meta: { title: "水稻镉污染风险模型" },
  638. },
  639. {
  640. path: "AcidReductionModel",
  641. name: "AcidReductionModel",
  642. component: () =>
  643. import("@/views/Admin/modelManagement/AcidReductionModel.vue"),
  644. meta: { title: "反酸及降酸模型" },
  645. },
  646. {
  647. path: "WheatRiskModel",
  648. name: "WheatRiskModel",
  649. component: () =>
  650. import("@/views/Admin/modelManagement/WheatRiskModel.vue"),
  651. meta: { title: "小麦镉污染风险模型" },
  652. },
  653. {
  654. path: "VegetableRiskModel",
  655. name: "VegetableRiskModel",
  656. component: () =>
  657. import("@/views/Admin/modelManagement/VegetableRiskModel.vue"),
  658. meta: { title: "蔬菜镉污染风险模型" },
  659. },
  660. {
  661. path: "about",
  662. name: "about",
  663. component: () => import("@/views/AboutView.vue"),
  664. },
  665. {
  666. path: "/:pathMatch(.*)*",
  667. name: "ErrorPage",
  668. component: () => import("@/views/ErrorPage.vue"),
  669. },
  670. ],
  671. },
  672. ];
  673. const router = createRouter({
  674. history: createWebHistory(),
  675. routes,
  676. });
  677. router.beforeEach((to, from, next) => {
  678. const tokenStore = useTokenStore();
  679. const user = tokenStore.userInfo;
  680. const isSameRoute = (path: string) => to.fullPath === path;
  681. // 已登录用户访问 login 页面
  682. if (to.name === "login" && user?.userId) {
  683. return next("/select-city");
  684. }
  685. // 需要登录才能访问的页面
  686. if (to.matched.some(r => r.meta.requiresAuth)) {
  687. if (!user?.userId) {
  688. return next({ name: "login" });
  689. }
  690. // 管理员权限页面
  691. if (to.matched.some(r => r.meta.requiresAdmin)) {
  692. if (user.loginType !== "admin") {
  693. // 普通用户访问管理员页面,提示并重定向
  694. // Replace with your notification library, e.g. for naive-ui:
  695. // import { useMessage } from 'naive-ui' at the top of the file if not already imported
  696. // const message = useMessage();
  697. // message.error("登录失败:用户类型不匹配");
  698. // If using Element Plus:
  699. // import { ElMessage } from 'element-plus' at the top of the file
  700. // ElMessage.error("登录失败:用户类型不匹配");
  701. // Example using Element Plus:
  702. // ElMessage.error("登录失败:用户类型不匹配");
  703. if (!isSameRoute("/select-city")) return next({ name: "selectCityAndCounty" });
  704. return next();
  705. }
  706. }
  707. }
  708. next();
  709. });
  710. export default router;