index.js 35 KB

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