index.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import Layout from '@/views/Layout.vue'
  4. import axios from 'axios'
  5. import { getEffectivePermissions, hasPermission, getRoleHomePage } from '@/utils/permissions'
  6. Vue.use(VueRouter)
  7. const routes = [
  8. {
  9. path: '/login',
  10. name: 'Login',
  11. component: () => import('@/views/Login.vue')
  12. },
  13. {
  14. path: '/403',
  15. name: 'Forbidden',
  16. component: { template: '<div style="text-align:center;padding:100px"><h1>403</h1><p>权限不足</p><router-link to="/">返回首页</router-link></div>' },
  17. meta: { title: '权限不足' }
  18. },
  19. {
  20. path: '/',
  21. component: Layout,
  22. redirect: '/dashboard',
  23. children: [
  24. {
  25. path: 'dashboard',
  26. name: 'Dashboard',
  27. component: () => import('@/views/Dashboard.vue'),
  28. meta: { title: '首页', perm: 'dashboard' }
  29. },
  30. {
  31. path: 'teacher-dashboard',
  32. name: 'TeacherDashboard',
  33. component: () => import('@/views/TeacherDashboard.vue'),
  34. meta: { title: '规划师首页', requiresTeacher: true, perm: 'dashboard' }
  35. },
  36. {
  37. path: 'admin/dashboard',
  38. name: 'AdminDashboard',
  39. component: () => import('@/views/admin/Dashboard'),
  40. meta: { title: '数据大屏', roles: ['admin'] }
  41. },
  42. // 家庭管理
  43. {
  44. path: 'families',
  45. name: 'Families',
  46. component: () => import('@/views/Families.vue'),
  47. meta: { title: '家庭列表', perm: 'family:list' }
  48. },
  49. {
  50. path: 'children',
  51. name: 'Children',
  52. component: () => import('@/views/Children.vue'),
  53. meta: { title: '孩子管理', perm: 'family:children' }
  54. },
  55. {
  56. path: 'points',
  57. name: 'Points',
  58. component: () => import('@/views/Points.vue'),
  59. meta: { title: '积分管理', perm: 'family:points' }
  60. },
  61. {
  62. path: 'points-log',
  63. name: 'PointsLog',
  64. component: () => import('@/views/admin/PointsLog.vue'),
  65. meta: { title: '积分记录', perm: 'family:points' }
  66. },
  67. {
  68. path: 'membership-center',
  69. name: 'MembershipCenter',
  70. component: () => import('@/views/admin/MembershipCenter.vue'),
  71. meta: { title: '会员中心', perm: 'config:member' }
  72. },
  73. // 方案中心
  74. {
  75. path: 'health-plan-manage',
  76. name: 'HealthPlanManage',
  77. component: () => import('@/views/admin/HealthPlanManage.vue'),
  78. meta: { title: '健康方案管理', perm: 'plan:health' }
  79. },
  80. {
  81. path: 'assessment-plan-manage',
  82. name: 'AssessmentPlanManage',
  83. component: () => import('@/views/admin/AssessmentPlanManage.vue'),
  84. meta: { title: '测评方案管理', perm: 'plan:assessment' }
  85. },
  86. // 任务管理
  87. {
  88. path: 'tasks',
  89. name: 'Tasks',
  90. component: () => import('@/views/Tasks.vue'),
  91. meta: { title: '任务列表', perm: 'task:list' }
  92. },
  93. {
  94. path: 'task-templates',
  95. name: 'TaskTemplates',
  96. component: () => import('@/views/TaskTemplates.vue'),
  97. meta: { title: '任务模板', perm: 'task:templates' }
  98. },
  99. {
  100. path: 'growth-task',
  101. name: 'GrowthTaskManagement',
  102. component: () => import('@/views/admin/GrowthTaskManagement'),
  103. meta: { title: '成长任务管理', perm: 'task:list' }
  104. },
  105. // 奖励管理
  106. {
  107. path: 'rewards',
  108. name: 'Rewards',
  109. component: () => import('@/views/Rewards.vue'),
  110. meta: { title: '奖励列表', perm: 'family:rewards' }
  111. },
  112. {
  113. path: 'wishes',
  114. name: 'Wishes',
  115. component: () => import('@/views/Wishes.vue'),
  116. meta: { title: '心愿管理', perm: 'family:wishes' }
  117. },
  118. // 成长规划师管理
  119. {
  120. path: 'guide-packages',
  121. name: 'GuidePackages',
  122. component: () => import('@/views/GuidePackages.vue'),
  123. meta: { title: '成长规划师任务模板', requiresTeacher: true, perm: 'biz:packages' }
  124. },
  125. {
  126. path: 'guide-family-task',
  127. name: 'GuideFamilyTask',
  128. component: () => import('@/views/GuideFamilyTask.vue'),
  129. meta: { title: '家庭任务管理', requiresTeacher: true, perm: 'service:families' }
  130. },
  131. {
  132. path: 'teacher-consult',
  133. name: 'TeacherConsult',
  134. component: () => import('@/views/TeacherConsult.vue'),
  135. meta: { title: '家长咨询', requiresTeacher: true, perm: 'assessment:consult' }
  136. },
  137. {
  138. path: 'teacher-families',
  139. name: 'TeacherFamilies',
  140. component: () => import('@/views/teacher/TeacherFamilies.vue'),
  141. meta: { title: '我的家庭', requiresTeacher: true, perm: 'service:families' }
  142. },
  143. {
  144. path: 'teacher-team',
  145. name: 'TeacherTeam',
  146. component: () => import('@/views/teacher/TeacherTeam.vue'),
  147. meta: { title: '我的团队', requiresTeacher: true, perm: 'service:team' }
  148. },
  149. {
  150. path: 'teacher-packages',
  151. name: 'TeacherPackages',
  152. component: () => import('@/views/teacher/TeacherPackages.vue'),
  153. meta: { title: '任务模板管理', requiresTeacher: true, perm: 'biz:packages' }
  154. },
  155. {
  156. path: 'teacher-orders',
  157. name: 'TeacherOrders',
  158. component: () => import('@/views/teacher/TeacherOrders.vue'),
  159. meta: { title: '订单与佣金', requiresTeacher: true, perm: 'biz:orders' }
  160. },
  161. // 系统管理
  162. {
  163. path: 'users',
  164. name: 'Users',
  165. component: () => import('@/views/Users.vue'),
  166. meta: { title: '用户管理', perm: 'system:users' }
  167. },
  168. {
  169. path: 'review-center',
  170. name: 'ReviewCenter',
  171. component: () => import('@/views/admin/ReviewCenter.vue'),
  172. meta: { title: '审核中心', perm: 'audit' }
  173. },
  174. {
  175. path: 'butler-assignments',
  176. name: 'ButlerAssignments',
  177. component: () => import('@/views/admin/ButlerAssignments.vue'),
  178. meta: { title: '管家分配管理', perm: 'audit' }
  179. },
  180. {
  181. path: 'operation-logs',
  182. name: 'OperationLogs',
  183. component: () => import('@/views/OperationLogs.vue'),
  184. meta: { title: '操作日志', perm: 'system:logs' }
  185. },
  186. {
  187. path: 'menu-manage',
  188. name: 'MenuManage',
  189. component: () => import('@/views/admin/MenuManage.vue'),
  190. meta: { title: '菜单管理', perm: 'system:menu' }
  191. },
  192. // 服务管理(管理员)
  193. {
  194. path: 'service-role-applications',
  195. name: 'ServiceRoleApplications',
  196. component: () => import('@/views/service/ServiceRoleApplications.vue'),
  197. meta: { title: '服务角色申请审核', perm: 'audit' }
  198. },
  199. {
  200. path: 'teacher-messages',
  201. name: 'TeacherMessages',
  202. component: () => import('@/views/teacher/TeacherMessages.vue'),
  203. meta: { title: '消息中心', requiresTeacher: true, perm: 'messages' }
  204. },
  205. {
  206. path: 'teacher-assessment',
  207. name: 'TeacherAssessment',
  208. component: () => import('@/views/teacher/TeacherAssessment.vue'),
  209. meta: { title: 'DAN测评管理', requiresTeacher: true, perm: 'assessment:dan' }
  210. },
  211. {
  212. path: 'teacher-proxy-report',
  213. name: 'TeacherProxyReport',
  214. component: () => import('@/views/teacher/ProxyReport.vue'),
  215. meta: { title: '代上传报告', requiresTeacher: true, perm: 'health:reports' }
  216. },
  217. {
  218. path: 'teacher-health-plan-review',
  219. name: 'TeacherHealthPlanReview',
  220. component: () => import('@/views/teacher/HealthPlanReview.vue'),
  221. meta: { title: '健康方案审核', requiresTeacher: true, perm: 'health:plan:review' }
  222. },
  223. {
  224. path: 'assessment-admin',
  225. name: 'AssessmentAdmin',
  226. component: () => import('@/views/admin/Assessment.vue'),
  227. meta: { title: '测评管理', perm: 'assessment:dan' }
  228. },
  229. {
  230. path: 'assessment-assign',
  231. name: 'AssessmentAssign',
  232. component: () => import('@/views/admin/AssessmentAssign.vue'),
  233. meta: { title: '待分配规划师', perm: 'assessment:dan' }
  234. },
  235. {
  236. path: 'assessment-orders',
  237. name: 'AssessmentOrders',
  238. component: () => import('@/views/admin/AssessmentOrders.vue'),
  239. meta: { title: '测评订单', perm: 'assessment:dan' }
  240. },
  241. {
  242. path: 'dan-execution',
  243. name: 'DanExecution',
  244. component: () => import('@/views/admin/DanExecution.vue'),
  245. meta: { title: 'DAN服务执行', perm: 'assessment:dan' }
  246. },
  247. {
  248. path: 'dan-settlement',
  249. name: 'DanSettlement',
  250. component: () => import('@/views/admin/DanSettlement.vue'),
  251. meta: { title: 'DAN结算管理', perm: 'assessment:dan' }
  252. },
  253. {
  254. path: 'product-manage',
  255. name: 'ProductManage',
  256. component: () => import('@/views/admin/ProductManage.vue'),
  257. meta: { title: '商品管理', perm: 'commerce:products,commerce:self' }
  258. },
  259. {
  260. path: 'inventory',
  261. name: 'InventoryManage',
  262. component: () => import('@/views/admin/InventoryManage.vue'),
  263. meta: { title: '库存管理', perm: 'commerce:products' }
  264. },
  265. {
  266. path: 'inventory/inbound-create',
  267. name: 'InventoryInboundCreate',
  268. component: () => import('@/views/admin/InventoryInboundCreate.vue'),
  269. meta: { title: '创建入库单', perm: 'commerce:products' }
  270. },
  271. {
  272. path: 'product-edit',
  273. name: 'ProductEdit',
  274. component: () => import('@/views/admin/ProductEdit.vue'),
  275. meta: { title: '商品编辑', perm: 'commerce:products' }
  276. },
  277. {
  278. path: 'assessment-products',
  279. name: 'AssessmentProducts',
  280. component: () => import('@/views/admin/AssessmentProducts.vue'),
  281. meta: { title: '测评商品管理', perm: 'commerce:products' }
  282. },
  283. {
  284. path: 'assessment-plan-rules',
  285. name: 'AssessmentPlanRules',
  286. component: () => import('@/views/admin/AssessmentPlanRules.vue'),
  287. meta: { title: '方案生成规则', perm: 'plan:rules' }
  288. },
  289. {
  290. path: 'plan-management',
  291. name: 'PlanManagement',
  292. component: () => import('@/views/admin/PlanManagement.vue'),
  293. meta: { title: '方案管理', perm: 'plan:manage' }
  294. },
  295. {
  296. path: 'category-manage',
  297. name: 'CategoryManage',
  298. component: () => import('@/views/admin/CategoryManage.vue'),
  299. meta: { title: '商品分类', perm: 'commerce:category' }
  300. },
  301. {
  302. path: 'order-manage',
  303. name: 'OrderManage',
  304. component: () => import('@/views/admin/OrderManage.vue'),
  305. meta: { title: '订单管理', perm: 'commerce:orders' }
  306. },
  307. {
  308. path: 'pending-refund',
  309. name: 'PendingRefund',
  310. component: () => import('@/views/admin/PendingRefund.vue'),
  311. meta: { title: '待退款管理', perm: 'commerce:orders' }
  312. },
  313. {
  314. path: 'order-detail/:orderNo',
  315. name: 'OrderDetail',
  316. component: () => import('@/views/admin/OrderDetail.vue'),
  317. meta: { title: '订单详情', perm: 'commerce:orders' }
  318. },
  319. {
  320. path: 'sys-config',
  321. name: 'SysConfig',
  322. component: () => import('@/views/admin/SysConfig.vue'),
  323. meta: { title: '系统配置', perm: 'system:base' }
  324. },
  325. {
  326. path: 'menu-manage',
  327. name: 'MenuManage',
  328. component: () => import('@/views/admin/MenuManage.vue'),
  329. meta: { title: '菜单管理', perm: 'system:menu' }
  330. },
  331. {
  332. path: 'energy-sandbox',
  333. name: 'EnergySandbox',
  334. component: () => import('@/views/admin/EnergySandbox.vue'),
  335. meta: { title: '五维能量', perm: 'energy' }
  336. },
  337. {
  338. path: 'energy-rule',
  339. name: 'EnergyRuleManagement',
  340. component: () => import('@/views/admin/EnergyRuleManagement.vue'),
  341. meta: { title: '能量规则管理', perm: 'energy' }
  342. },
  343. {
  344. path: 'energy-behavior-config',
  345. name: 'EnergyBehaviorConfig',
  346. component: () => import('@/views/admin/EnergyBehaviorConfig.vue'),
  347. meta: { title: '能量行为配置', perm: 'energy' }
  348. },
  349. {
  350. path: 'challenge-score-config',
  351. name: 'ChallengeScoreConfig',
  352. component: () => import('@/views/admin/ChallengeScoreConfig.vue'),
  353. meta: { title: '挑战评分配置', perm: 'energy' }
  354. },
  355. // ========== 文章管理 ==========
  356. {
  357. path: 'article-categories',
  358. name: 'ArticleCategory',
  359. component: () => import('@/views/admin/ArticleCategory.vue'),
  360. meta: { title: '文章分类', perm: 'articles:categories' }
  361. },
  362. {
  363. path: 'article-manage',
  364. name: 'ArticleManage',
  365. component: () => import('@/views/admin/ArticleManage.vue'),
  366. meta: { title: '文章管理', perm: 'articles:manage' }
  367. },
  368. {
  369. path: 'article-edit',
  370. name: 'ArticleEdit',
  371. component: () => import('@/views/admin/ArticleEdit.vue'),
  372. meta: { title: '文章编辑', perm: 'articles:manage' }
  373. },
  374. {
  375. path: 'comment-review',
  376. name: 'CommentReview',
  377. component: () => import('@/views/admin/CommentReview.vue'),
  378. meta: { title: '评论审核', perm: 'articles:manage' }
  379. },
  380. {
  381. path: 'notice-manage',
  382. name: 'NoticeManage',
  383. component: () => import('@/views/admin/NoticeManage.vue'),
  384. meta: { title: '公告管理', perm: 'admin' }
  385. },
  386. {
  387. path: 'periodic-service-config',
  388. name: 'PeriodicServiceConfig',
  389. component: () => import('@/views/admin/PeriodicServiceConfig.vue'),
  390. meta: { title: '周期性服务配置', perm: 'admin' }
  391. },
  392. {
  393. path: 'knowledge-tags',
  394. name: 'KnowledgeTag',
  395. component: () => import('@/views/admin/KnowledgeTag.vue'),
  396. meta: { title: '知识标签', perm: 'articles:categories' }
  397. },
  398. {
  399. path: 'vector-knowledge',
  400. name: 'VectorKnowledgeBase',
  401. component: () => import('@/views/admin/VectorKnowledgeBase.vue'),
  402. meta: { title: '向量知识库', perm: 'knowledge:base' }
  403. },
  404. {
  405. path: 'virtual-goods-config',
  406. name: 'VirtualGoodsConfig',
  407. component: () => import('@/views/admin/VirtualGoodsConfig.vue'),
  408. meta: { title: '虚拟支付道具', perm: 'config:member' }
  409. },
  410. {
  411. path: 'gates',
  412. name: 'Gates',
  413. component: () => import('@/views/admin/gates.vue'),
  414. meta: { title: '关卡配置', perm: 'system:base' }
  415. },
  416. {
  417. path: 'system-prompt',
  418. name: 'SystemPromptManagement',
  419. component: () => import('@/views/admin/SystemPromptManagement.vue'),
  420. meta: { title: '系统提示词', perm: 'system:base' }
  421. },
  422. // ========== 佣金推荐系统 ==========
  423. {
  424. path: 'product-profit-rate',
  425. name: 'ProductProfitRate',
  426. component: () => import('@/views/admin/ProductProfitRate.vue'),
  427. meta: { title: '产品利润率', perm: 'commerce:profit-rate' }
  428. },
  429. {
  430. path: 'product-ppoint',
  431. name: 'ProductPpointManage',
  432. component: () => import('@/views/admin/ProductPpointManage.vue'),
  433. meta: { title: 'P点配置', perm: 'commerce:ppoint' }
  434. },
  435. {
  436. path: 'cf-value',
  437. name: 'CfValueManage',
  438. component: () => import('@/views/admin/CfValueManage.vue'),
  439. meta: { title: 'CF值管理', perm: 'finance:cf-value' }
  440. },
  441. {
  442. path: 'supply-system',
  443. name: 'SupplySystemList',
  444. component: () => import('@/views/admin/supply-system/List.vue'),
  445. meta: { title: '供应商体系', perm: 'system:supply' }
  446. },
  447. {
  448. path: 'supply-system/create',
  449. name: 'SupplySystemCreate',
  450. component: () => import('@/views/admin/supply-system/Form.vue'),
  451. meta: { title: '新建体系', perm: 'system:supply' }
  452. },
  453. {
  454. path: 'supply-system/:id',
  455. name: 'SupplySystemDetail',
  456. component: () => import('@/views/admin/supply-system/Detail.vue'),
  457. meta: { title: '体系详情', perm: 'system:supply' },
  458. props: true
  459. },
  460. {
  461. path: 'supplier-products',
  462. name: 'SupplierProducts',
  463. component: () => import('@/views/admin/SupplierProductManage.vue'),
  464. meta: { title: '商品管理', perm: 'commerce:product' }
  465. },
  466. {
  467. path: 'supply-system/:id/edit',
  468. name: 'SupplySystemEdit',
  469. component: () => import('@/views/admin/supply-system/Form.vue'),
  470. meta: { title: '编辑体系', perm: 'system:supply' },
  471. props: true
  472. },
  473. {
  474. path: 'supply-hierarchy/change-requests',
  475. name: 'SupplyHierarchyChangeRequests',
  476. component: () => import('@/views/admin/supply-hierarchy/ChangeRequest.vue'),
  477. meta: { title: '更换上级审核', perm: 'system:supply' }
  478. },
  479. // ========== 供应商管理 (supplier_admin) ==========
  480. {
  481. path: 'supply-manage',
  482. name: 'SupplyManage',
  483. component: () => import('@/views/admin/supply-manage/List.vue'),
  484. meta: { title: '供应商管理', perm: 'supply:manage' }
  485. },
  486. {
  487. path: 'supply-manage/create',
  488. name: 'SupplyManageCreate',
  489. component: () => import('@/views/admin/supply-manage/Form.vue'),
  490. meta: { title: '新增供应商', perm: 'supply:manage' }
  491. },
  492. {
  493. path: 'supply-manage/:id',
  494. name: 'SupplyManageDetail',
  495. component: () => import('@/views/admin/supply-manage/Detail.vue'),
  496. meta: { title: '供应商详情', perm: 'supply:manage' },
  497. props: true
  498. },
  499. {
  500. path: 'supply-manage/:id/edit',
  501. name: 'SupplyManageEdit',
  502. component: () => import('@/views/admin/supply-manage/Form.vue'),
  503. meta: { title: '编辑供应商', perm: 'supply:manage' },
  504. props: true
  505. },
  506. {
  507. path: 'zodiac-configs',
  508. name: 'ZodiacConfigs',
  509. component: () => import('@/views/admin/ZodiacConfigs.vue'),
  510. meta: { title: '星座配置', perm: 'config:dimension' }
  511. },
  512. {
  513. path: 'bazi-configs',
  514. name: 'BaziConfigs',
  515. component: () => import('@/views/admin/BaziConfigs.vue'),
  516. meta: { title: '八字配置', perm: 'config:dimension' }
  517. },
  518. {
  519. path: 'blood-type-configs',
  520. name: 'BloodTypeConfigs',
  521. component: () => import('@/views/admin/BloodTypeConfigs.vue'),
  522. meta: { title: '血型配置', perm: 'config:dimension' }
  523. },
  524. {
  525. path: 'innate-portrait-config',
  526. name: 'InnatePortraitConfig',
  527. component: () => import('@/views/admin/InnatePortraitConfig.vue'),
  528. meta: { title: '先天画像权重配置', perm: 'config:dimension' }
  529. },
  530. {
  531. path: 'numsoul-detail-config',
  532. name: 'NumSoulDetailConfig',
  533. component: () => import('@/views/admin/NumSoulDetailConfig.vue'),
  534. meta: { title: '数字能量配置', perm: 'config:dimension' }
  535. },
  536. // ========== 饮食管理 (admin) ==========
  537. {
  538. path: 'foods',
  539. name: 'Foods',
  540. component: () => import('@/views/admin/Foods.vue'),
  541. meta: { title: '食材管理', perm: 'diet:foods' }
  542. },
  543. {
  544. path: 'recipes',
  545. name: 'Recipes',
  546. component: () => import('@/views/admin/Recipes.vue'),
  547. meta: { title: '食谱管理', perm: 'diet:recipes' }
  548. },
  549. {
  550. path: 'my-families',
  551. name: 'MyFamilies',
  552. component: () => import('@/views/teacher/FamilyList.vue'),
  553. meta: { title: '我的家庭', perm: 'service:family' }
  554. },
  555. {
  556. path: 'growth-records',
  557. name: 'GrowthRecords',
  558. component: () => import('@/views/teacher/GrowthRecords.vue'),
  559. meta: { title: '成长记录', perm: 'growth:records' }
  560. },
  561. {
  562. path: 'growth-plans',
  563. name: 'GrowthPlans',
  564. component: () => import('@/views/teacher/GrowthPlans.vue'),
  565. meta: { title: '成长计划', perm: 'growth:plans' }
  566. },
  567. {
  568. path: 'health-reports',
  569. name: 'HealthReports',
  570. component: () => import('@/views/admin/UnifiedHealthReports.vue'),
  571. meta: { title: '健康报告', perm: 'health:reports' }
  572. },
  573. {
  574. path: 'health-reports/:id/edit',
  575. name: 'HealthReportEdit',
  576. component: () => import('@/views/admin/HealthReportEdit.vue'),
  577. meta: { title: '编辑报告', perm: 'health:reports' },
  578. props: true
  579. },
  580. {
  581. path: 'health-indicators',
  582. name: 'HealthIndicators',
  583. component: () => import('@/views/nutritionist/HealthIndicators.vue'),
  584. meta: { title: '健康指标', perm: 'health:indicators' }
  585. },
  586. {
  587. path: 'health-checkins',
  588. name: 'HealthCheckinManage',
  589. component: () => import('@/views/admin/HealthCheckinManage.vue'),
  590. meta: { title: '健康打卡管理', perm: 'health:checkins' }
  591. },
  592. {
  593. path: 'emotion-alert',
  594. name: 'EmotionAlertManage',
  595. component: () => import('@/views/admin/EmotionAlertManage.vue'),
  596. meta: { title: '情绪告警管理', perm: 'health:checkins' }
  597. },
  598. {
  599. path: 'nutrition-mappings',
  600. name: 'NutritionMappings',
  601. component: () => import('@/views/nutritionist/NutritionMappings.vue'),
  602. meta: { title: '营养素映射管理', perm: 'health:mappings' }
  603. },
  604. {
  605. path: 'report-management',
  606. name: 'ReportManagement',
  607. component: () => import('@/views/admin/ReportManagement.vue'),
  608. meta: { title: '报告管理', perm: 'health:reports' }
  609. },
  610. {
  611. path: 'report-audit',
  612. name: 'HealthReportAudit',
  613. component: () => import('@/views/health/HealthReportAudit.vue'),
  614. meta: { title: '报告审核', perm: 'report:audit' }
  615. },
  616. {
  617. path: 'seasonal-foods',
  618. name: 'SeasonalFoods',
  619. component: () => import('@/views/admin/SeasonalFoods.vue'),
  620. meta: { title: '应季食材', perm: 'diet:foods' }
  621. },
  622. {
  623. path: 'activities',
  624. name: 'Activities',
  625. component: () => import('@/views/admin/Activities.vue'),
  626. meta: { title: '活动列表', perm: 'activity:list,activity:self' }
  627. },
  628. {
  629. path: 'activity-edit',
  630. name: 'ActivityEdit',
  631. component: () => import('@/views/admin/ActivityEdit.vue'),
  632. meta: { title: '活动编辑', perm: 'activity:list' }
  633. },
  634. {
  635. path: 'survey-templates',
  636. name: 'SurveyTemplates',
  637. component: () => import('@/views/admin/SurveyTemplates.vue'),
  638. meta: { title: '调研模板管理', perm: 'admin:all' }
  639. },
  640. {
  641. path: 'problem-domain-manage',
  642. name: 'ProblemDomainManage',
  643. component: () => import('@/views/admin/ProblemDomainManage.vue'),
  644. meta: { title: '问题域管理', perm: 'admin:all' }
  645. },
  646. {
  647. path: 'notification-template-manage',
  648. name: 'NotificationTemplateManage',
  649. component: () => import('@/views/admin/NotificationTemplateManage.vue'),
  650. meta: { title: '通知模板管理', perm: 'admin:all' }
  651. },
  652. {
  653. path: 'activity-review',
  654. name: 'ActivityReview',
  655. component: () => import('@/views/admin/ActivityReview.vue'),
  656. meta: { title: '活动审核', perm: 'activity:review' }
  657. },
  658. {
  659. path: 'activity-registration-review',
  660. name: 'ActivityRegistrationReview',
  661. component: () => import('@/views/admin/ActivityRegistrationReview.vue'),
  662. meta: { title: '活动报名审核', perm: 'activity:review' }
  663. },
  664. // ========== 维度配置 + 知识库管理 ==========
  665. {
  666. path: 'coupon',
  667. name: 'CouponManagement',
  668. component: () => import('@/views/admin/CouponManagement'),
  669. meta: { title: '优惠券管理', perm: 'marketing:coupon' }
  670. },
  671. {
  672. path: 'coupon-grant-log',
  673. name: 'CouponGrantLog',
  674. component: () => import('@/views/admin/CouponGrantLog.vue'),
  675. meta: { title: '发券记录', perm: 'marketing:coupon' }
  676. },
  677. {
  678. path: 'discount-rules',
  679. name: 'DiscountRuleManagement',
  680. component: () => import('@/views/admin/DiscountRuleManagement.vue'),
  681. meta: { title: '限时折扣管理', perm: 'marketing:discount' }
  682. },
  683. {
  684. path: 'promotion',
  685. name: 'PromotionManagement',
  686. component: () => import('@/views/admin/PromotionManagement'),
  687. meta: { title: '推广管理', perm: 'marketing:promotion' }
  688. },
  689. {
  690. path: 'family-earnings',
  691. name: 'FamilyEarnings',
  692. component: () => import('@/views/admin/FamilyEarnings.vue'),
  693. meta: { title: '家庭收益管理', perm: 'marketing:promotion' }
  694. },
  695. {
  696. path: 'family-earnings-withdraw',
  697. name: 'FamilyEarningsWithdraw',
  698. component: () => import('@/views/admin/FamilyEarningsWithdraw.vue'),
  699. meta: { title: '家庭收益提现审核', perm: 'audit:withdraw' }
  700. },
  701. {
  702. path: 'dimension-config',
  703. name: 'DimensionConfig',
  704. component: () => import('@/views/admin/dimension'),
  705. meta: { title: '维度配置', perm: 'config:dimension' }
  706. },
  707. {
  708. path: 'knowledge-base',
  709. name: 'KnowledgeBase',
  710. component: () => import('@/views/admin/knowledge'),
  711. meta: { title: '知识库管理', perm: 'knowledge:base' }
  712. },
  713. {
  714. path: 'health-knowledge',
  715. name: 'HealthKnowledge',
  716. component: () => import('@/views/admin/health-knowledge'),
  717. meta: { title: '健康知识库管理', perm: 'knowledge:base' }
  718. },
  719. // ========== 健康维度配置 ==========
  720. {
  721. path: 'health-norm-config',
  722. name: 'HealthNormConfig',
  723. component: () => import('@/views/admin/dimension-config'),
  724. meta: { title: '健康常模配置', perm: 'config:health' }
  725. },
  726. {
  727. path: 'health-data-source',
  728. name: 'HealthDataSource',
  729. component: () => import('@/views/admin/data-source-config'),
  730. meta: { title: '健康数据源配置', perm: 'config:health' }
  731. },
  732. {
  733. path: 'health-energy-config',
  734. name: 'HealthEnergyConfig',
  735. component: () => import('@/views/admin/HealthEnergyConfig'),
  736. meta: { title: '五维能量配置', perm: 'config:health' }
  737. },
  738. {
  739. path: 'energy-config',
  740. name: 'EnergyConfig',
  741. component: () => import('@/views/admin/energy-config/WuxingConfig'),
  742. meta: { title: '五行能量配置', perm: 'config:health' }
  743. },
  744. {
  745. path: 'indicators',
  746. name: 'IndicatorManage',
  747. component: () => import('@/views/admin/indicators'),
  748. meta: { title: '指标管理', perm: 'config:health' }
  749. },
  750. // ========== 虚拟服务商团队管理 ==========
  751. {
  752. path: 'virtual-teams',
  753. name: 'VirtualTeamList',
  754. component: () => import('@/views/admin/VirtualTeamList'),
  755. meta: { title: '虚拟团队管理', perm: 'system:base' }
  756. },
  757. {
  758. path: 'virtual-team-detail/:systemId',
  759. name: 'VirtualTeamDetail',
  760. component: () => import('@/views/admin/VirtualTeamDetail'),
  761. meta: { title: '团队成员管理', perm: 'system:base' },
  762. props: true
  763. },
  764. // ========== 电商供应商管理 ==========
  765. {
  766. path: 'ecom-supplier',
  767. name: 'EcomSupplierManage',
  768. component: () => import('@/views/admin/EcomSupplierManage'),
  769. meta: { title: '电商供应商管理', perm: 'ecom:supplier' }
  770. },
  771. {
  772. path: 'badge-manage',
  773. name: 'BadgeManage',
  774. component: () => import('@/views/admin/BadgeManage'),
  775. meta: { title: '勋章管理', perm: 'config:member' }
  776. },
  777. // ========== 报告指纹解析系统 ==========
  778. {
  779. path: 'report-types',
  780. name: 'ReportTypeManagement',
  781. component: () => import('@/views/admin/ReportTypeManagement.vue'),
  782. meta: { title: '报告类型管理', perm: 'config:report-parser' }
  783. },
  784. {
  785. path: 'report-parser-import',
  786. name: 'ReportParserImport',
  787. component: () => import('@/views/admin/ReportParserImport.vue'),
  788. meta: { title: '解析器导入管理', perm: 'config:report-parser' }
  789. },
  790. {
  791. path: 'report-collector-trainer',
  792. name: 'ReportCollectorTrainer',
  793. component: () => import('@/views/admin/ReportCollectorTrainer.vue'),
  794. meta: { title: '报告采集训练', perm: 'config:report-parser' }
  795. },
  796. {
  797. path: 'report-template',
  798. name: 'ReportTemplateManage',
  799. component: () => import('@/views/admin/ReportTemplateManage.vue'),
  800. meta: { title: '报告模板管理', perm: 'config:report-parser' }
  801. },
  802. {
  803. path: 'report-unknown-clusters',
  804. name: 'ReportUnknownCluster',
  805. component: () => import('@/views/admin/ReportUnknownCluster.vue'),
  806. meta: { title: '未知报告审核', perm: 'config:report-parser' }
  807. },
  808. {
  809. path: 'report-auto-learn',
  810. name: 'ReportAutoLearn',
  811. component: () => import('@/views/admin/ReportAutoLearn.vue'),
  812. meta: { title: '报告自学习', perm: 'config:report-parser' }
  813. },
  814. // ========== LangGraph AI 服务管理 ==========
  815. {
  816. path: 'langgraph-admin',
  817. name: 'LangGraphAdmin',
  818. component: () => import('@/views/admin/LangGraphAdmin.vue'),
  819. meta: { title: 'LangGraph 管理', perm: 'config:report-parser' }
  820. },
  821. // ========== 营养产品管理 ==========
  822. {
  823. path: 'nutrition-products',
  824. name: 'NutritionProducts',
  825. component: () => import('@/views/admin/NutritionProducts.vue'),
  826. meta: { title: '营养产品管理', perm: 'health:*' }
  827. },
  828. {
  829. path: 'file-manage',
  830. name: 'FileManage',
  831. component: () => import('@/views/admin/FileManage'),
  832. meta: { title: '文件管理', perm: 'system:base' }
  833. }
  834. ]
  835. }
  836. ]
  837. const router = new VueRouter({
  838. mode: 'history',
  839. base: process.env.BASE_URL,
  840. routes
  841. })
  842. // Token 验证缓存:避免 redirect 链中重复调用 /api/admin-auth/info
  843. let tokenValidationCache = { token: '', timestamp: 0 }
  844. const TOKEN_CACHE_TTL = 30000 // 30秒内不重复验证
  845. async function validateToken(token) {
  846. try {
  847. const baseURL = process.env.VUE_APP_BASE_API || ''
  848. const res = await axios.post(`${baseURL}/api/admin-auth/info`, {}, {
  849. headers: { Authorization: `Bearer ${token}` },
  850. validateStatus: () => true
  851. })
  852. return res.status === 200 && res.data?.code === 200
  853. } catch (e) {
  854. return false
  855. }
  856. }
  857. router.beforeEach(async (to, from, next) => {
  858. const token = localStorage.getItem('token')
  859. const role = localStorage.getItem('role')
  860. // 1. 登录页允许访问
  861. if (to.path === '/login') {
  862. // 如果已有token和role,直接跳转到对应角色首页
  863. if (token && role) {
  864. const rolesStr = localStorage.getItem('roles')
  865. const roleList = rolesStr ? JSON.parse(rolesStr) : [role]
  866. const home = getRoleHomePage(roleList)
  867. if (home !== '/') {
  868. return next(home)
  869. }
  870. }
  871. return next()
  872. }
  873. // 2. 无Token强制跳转
  874. if (!token) {
  875. return next('/login')
  876. }
  877. // 3. Token有效性验证 (使用缓存避免 redirect 链重复调用)
  878. const now = Date.now()
  879. let isValid = false
  880. if (tokenValidationCache.token === token && (now - tokenValidationCache.timestamp) < TOKEN_CACHE_TTL) {
  881. isValid = true
  882. } else {
  883. isValid = await validateToken(token)
  884. if (isValid) {
  885. tokenValidationCache = { token, timestamp: now }
  886. }
  887. }
  888. if (!isValid) {
  889. tokenValidationCache = { token: '', timestamp: 0 }
  890. localStorage.clear()
  891. return next('/login')
  892. }
  893. // 3.5 入驻角色访问 /dashboard → 跳转各自工作台(B-6 入驻角色默认首页)
  894. if (to.path === '/dashboard') {
  895. const rolesStr = localStorage.getItem('roles')
  896. const roleList = rolesStr ? JSON.parse(rolesStr) : [role]
  897. const home = getRoleHomePage(roleList)
  898. if (home !== '/') {
  899. return next(home)
  900. }
  901. }
  902. // 4. 权限检查:如果路由有 perm 要求,检查用户权限
  903. const requiredPerm = to.meta && to.meta.perm
  904. if (requiredPerm) {
  905. const rolesStr = localStorage.getItem('roles')
  906. const roles = rolesStr ? JSON.parse(rolesStr) : [localStorage.getItem('role')]
  907. const perms = getEffectivePermissions(roles)
  908. if (!hasPermission(perms, requiredPerm)) {
  909. console.warn('Access denied: insufficient permissions for', to.name)
  910. return next({ path: '/403', replace: true })
  911. }
  912. }
  913. return next()
  914. })
  915. // Suppress navigation guard redirect errors (teacher/admin route cross-access)
  916. const originalPush = VueRouter.prototype.push
  917. VueRouter.prototype.push = function push(location) {
  918. return originalPush.call(this, location).catch(err => err)
  919. }
  920. export default router