index.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. import {createWebHistory, createRouter, RouteRecordRaw} from 'vue-router';
  2. /* Layout */
  3. import Layout from '@/layout/index.vue';
  4. /**
  5. * Note: 路由配置项
  6. *
  7. * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
  8. * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
  9. * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
  10. * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
  11. * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
  12. * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
  13. * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
  14. * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
  15. * roles: ['admin', 'common'] // 访问路由的角色权限
  16. * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
  17. * meta : {
  18. noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
  19. title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
  20. icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
  21. breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
  22. activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
  23. }
  24. */
  25. // 公共路由
  26. export const constantRoutes: RouteRecordRaw[] = [
  27. {
  28. path: '/redirect',
  29. component: Layout,
  30. hidden: true,
  31. children: [
  32. {
  33. path: '/redirect/:path(.*)',
  34. component: () => import('@/views/redirect/index.vue')
  35. }
  36. ]
  37. },
  38. {
  39. path: '/social-callback',
  40. hidden: true,
  41. component: () => import('@/layout/components/SocialCallback/index.vue')
  42. },
  43. {
  44. path: '/login',
  45. component: () => import('@/views/login.vue'),
  46. hidden: true
  47. },
  48. {
  49. path: '/authredirect',
  50. component: () => import('@/views/redirect/authredirect.vue'),
  51. hidden: true
  52. },
  53. {
  54. path: '/ssoredirect',
  55. component: () => import('@/views/redirect/ssoredirect.vue'),
  56. hidden: true
  57. },
  58. {
  59. path: '/401',
  60. component: () => import('@/views/error/401.vue'),
  61. hidden: true
  62. },
  63. {
  64. path: '',
  65. component: Layout,
  66. redirect: '/index',
  67. children: [
  68. {
  69. path: '/index',
  70. component: () => import('@/views/index.vue'),
  71. name: 'Index',
  72. meta: {title: '首页', icon: 'dashboard', affix: true}
  73. },
  74. {
  75. path: '/clue/add',
  76. component: () => import('@/views/clue/add.vue'),
  77. name: 'addClue',
  78. meta: {title: '新增线索', icon: ''},
  79. hidden: true,
  80. },
  81. // {
  82. // path: '/clue/detail',
  83. // component: () => import('@/views/clue/detail.vue'),
  84. // name: '线索详情',
  85. // hidden: true,
  86. // meta: {title: '线索详情', icon: ''}
  87. // },
  88. // {
  89. // path: '/customer/customerDetail',
  90. // component: () => import('@/views/customer/customerDetail/index.vue'),
  91. // name: '概况信息',
  92. // hidden: true,
  93. // meta: {title: '概况信息', icon: ''}
  94. // },
  95. {
  96. path: '/customer/addCustomer',
  97. component: () => import('@/views/customer/addCustomer/index.vue'),
  98. name: 'addCustomer',
  99. hidden: true,
  100. meta: {title: '创建客户', icon: '', noCache: false}
  101. },
  102. {
  103. path: '/customer/liaison/add',
  104. component: () => import('@/views/customer/liaison/add.vue'),
  105. name: 'addliaison',
  106. hidden: true,
  107. meta: {title: '添加联系人', icon: '', noCache: false}
  108. },
  109. // {
  110. // path: '/customer/liaison/detail',
  111. // component: () => import('@/views/customer/liaison/detail.vue'),
  112. // name: '联系人详情',
  113. // hidden: true,
  114. // meta: {title: '联系人详情', icon: ''}
  115. // },
  116. // {
  117. // path: '/work_order/detail',
  118. // component: () => import('@/views/order/detail.vue'),
  119. // name: '工单详情',
  120. // hidden: true,
  121. // meta: {title: '工单详情', icon: ''}
  122. // },
  123. {
  124. path: '/order/add',
  125. component: () => import('@/views/orderForm/add.vue'),
  126. name: 'addOrderForm',
  127. hidden: true,
  128. meta: {title: '添加订单', icon: '', noCache: false}
  129. },
  130. // {
  131. // path: '/order/detail',
  132. // component: () => import('@/views/orderForm/detail.vue'),
  133. // name: '订单详情',
  134. // hidden: true,
  135. // meta: {title: '订单详情', icon: ''}
  136. // },
  137. {
  138. path: '/layout/notice',
  139. component: () => import('@/layout/components/notice/index.vue'),
  140. name: '内部消息',
  141. hidden: true,
  142. meta: {title: '内部消息', icon: ''}
  143. },
  144. {
  145. path: '/target/targetScheme/add',
  146. component: () => import('@/views/target/targetScheme/add.vue'),
  147. name: 'addtargetScheme',
  148. hidden: true,
  149. meta: {title: '目标方案创建', icon: '', noCache: false}
  150. },{
  151. path: '/refundRecord/detail',
  152. component: () => import('@/views/finance/refundRecord/detailRefund.vue'),
  153. name: '退款详情',
  154. hidden: true,
  155. meta: {title: '退款详情', icon: ''}
  156. },{
  157. path: '/customer/followPanel',
  158. component: () => import('@/views/customer/followPanel/index.vue'),
  159. name: '跟进面板',
  160. hidden: true,
  161. meta: {title: '跟进面板', icon: ''}
  162. },
  163. // {
  164. // path: '/statistics/custoverview',
  165. // component: () => import('@/views/statistics/dataAnalysis/customerAttributeAnalysis/overview.vue'),
  166. // name: 'statisticsCustoverview',
  167. // hidden: true,
  168. // meta: {title: '客户属性', icon: ''}
  169. // },
  170. // {
  171. // path: '/statistics/dataSummary/groupSummary',
  172. // component: () => import('@/views/statistics/dataSummary/groupSummary.vue'),
  173. // name: '集团简报',
  174. // hidden: true,
  175. // meta: {title: '集团简报', icon: ''}
  176. // },
  177. // {
  178. // path: '/statistics/dataSummary/companySummary',
  179. // component: () => import('@/views/statistics/dataSummary/companySummary.vue'),
  180. // name: '公司简报',
  181. // hidden: true,
  182. // meta: {title: '公司简报', icon: ''}
  183. // },
  184. // {
  185. // path: '/statistics/dataSummary/deptSummary',
  186. // component: () => import('@/views/statistics/dataSummary/deptSummary.vue'),
  187. // name: '部门简报',
  188. // hidden: true,
  189. // meta: {title: '部门简报', icon: ''}
  190. // },
  191. // {
  192. // path: '/statistics/dataSummary/userSummary',
  193. // component: () => import('@/views/statistics/dataSummary/userSummary.vue'),
  194. // name: '个人简报',
  195. // hidden: true,
  196. // meta: {title: '个人简报', icon: ''}
  197. // },
  198. ]
  199. },
  200. {
  201. path: '/user',
  202. component: Layout,
  203. hidden: true,
  204. redirect: 'noredirect',
  205. children: [
  206. {
  207. path: '/system/updatePwd',
  208. component: () => import('@/views/index.vue'),
  209. name: 'updatePwd',
  210. meta: {title: '更新密码', icon: 'dashboard'}
  211. },{
  212. path: '/user/profile',
  213. component: () => import('@/views/system/user/profile/index.vue'),
  214. name: 'Profile',
  215. meta: {title: '个人中心', icon: 'user'}
  216. },
  217. ]
  218. },
  219. {
  220. path: '/email',
  221. component: () => import('@/views/email/index.vue'),
  222. name: 'email',
  223. hidden: true,
  224. meta: {title: '邮件', icon: ''}
  225. },
  226. {
  227. path: '/email/send',
  228. component: () => import('@/views/email/send.vue'),
  229. name: 'send',
  230. hidden: true,
  231. meta: {title: '写邮件', icon: ''}
  232. },
  233. {
  234. path: '/email/settings',
  235. component: () => import('@/views/email/settings.vue'),
  236. name: 'settings',
  237. hidden: true,
  238. meta: {title: '邮件设置', icon: ''}
  239. },
  240. {
  241. path: '/email/preview',
  242. component: () => import('@/views/email/preview.vue'),
  243. name: 'preview',
  244. hidden: true,
  245. meta: {title: '邮件预览', icon: ''}
  246. },
  247. {
  248. path: '/customer/followPanel/detail',
  249. component: () => import('@/views/customer/followPanel/detail.vue'),
  250. name: '跟进详情',
  251. hidden: true,
  252. meta: {title: '跟进详情', icon: ''}
  253. },
  254. {
  255. path: '/:pathMatch(.*)*',
  256. component: () => import('@/views/error/404.vue'),
  257. hidden: true
  258. },
  259. ];
  260. // 动态路由,基于用户权限动态去加载
  261. export const dynamicRoutes: RouteRecordRaw[] = [
  262. // {
  263. // path: '/system/user-auth',
  264. // component: Layout,
  265. // hidden: true,
  266. // permissions: ['system:user:edit'],
  267. // children: [
  268. // {
  269. // path: 'role/:userId(\\d+)',
  270. // component: () => import('@/views/system/user/authRole.vue'),
  271. // name: 'AuthRole',
  272. // meta: { title: '分配角色', activeMenu: '/system/user', icon: '' }
  273. // }
  274. // ]
  275. // },
  276. // {
  277. // path: '/system/role-auth',
  278. // component: Layout,
  279. // hidden: true,
  280. // permissions: ['system:role:edit'],
  281. // children: [
  282. // {
  283. // path: 'user/:roleId(\\d+)',
  284. // component: () => import('@/views/system/role/authUser.vue'),
  285. // name: 'AuthUser',
  286. // meta: { title: '分配用户', activeMenu: '/system/role', icon: '' }
  287. // }
  288. // ]
  289. // },
  290. // {
  291. // path: '/system/dict-data',
  292. // component: Layout,
  293. // hidden: true,
  294. // permissions: ['system:dict:list'],
  295. // children: [
  296. // {
  297. // path: 'index/:dictId(\\d+)',
  298. // component: () => import('@/views/system/dict/data.vue'),
  299. // name: 'Data',
  300. // meta: { title: '字典数据', activeMenu: '/system/dict', icon: '' }
  301. // }
  302. // ]
  303. // },
  304. // {
  305. // path: '/system/oss-config',
  306. // component: Layout,
  307. // hidden: true,
  308. // permissions: ['system:ossConfig:list'],
  309. // children: [
  310. // {
  311. // path: 'index',
  312. // component: () => import('@/views/system/oss/config.vue'),
  313. // name: 'OssConfig',
  314. // meta: { title: '配置管理', activeMenu: '/system/oss', icon: '' }
  315. // }
  316. // ]
  317. // },
  318. // {
  319. // path: '/tool/gen-edit',
  320. // component: Layout,
  321. // hidden: true,
  322. // permissions: ['tool:gen:edit'],
  323. // children: [
  324. // {
  325. // path: 'index/:tableId(\\d+)',
  326. // component: () => import('@/views/tool/gen/editTable.vue'),
  327. // name: 'GenEdit',
  328. // meta: { title: '修改生成配置', activeMenu: '/tool/gen', icon: '' }
  329. // }
  330. // ]
  331. // }
  332. ];
  333. /**
  334. * 创建路由
  335. */
  336. const router = createRouter({
  337. history: createWebHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
  338. routes: constantRoutes,
  339. // 刷新时,滚动条位置还原
  340. scrollBehavior(to, from, savedPosition) {
  341. if (savedPosition) {
  342. return savedPosition;
  343. } else {
  344. return {top: 0};
  345. }
  346. }
  347. });
  348. // 添加自定义方法 pushTarget
  349. router.pushTarget = (url: string, query: Record<string, any> = {}) => {
  350. const origin = location.origin
  351. // 构造 query 字符串
  352. const queryStr = new URLSearchParams(query).toString()
  353. const fullUrl = origin + url + (queryStr ? '?' + queryStr : '')
  354. window.open(fullUrl, '_blank')
  355. }
  356. export default router;