index.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. import { createWebHashHistory, RouteRecordRaw } from 'vue-router'
  2. import { useLoginStore } from '@/stores'
  3. import { clearPending } from '@/services/http/pending'
  4. import service from '@/services'
  5. import Page from '../components/layouts/page/index.vue'
  6. import animateRouter from './animateRouter'
  7. const loginStore = useLoginStore()
  8. const routes: Array<RouteRecordRaw> = [
  9. {
  10. path: '/:pathMatch(.*)*',
  11. name: 'error',
  12. component: () => import('../views/error/404.vue'),
  13. meta: {
  14. ignoreAuth: true,
  15. },
  16. },
  17. {
  18. path: '/boot',
  19. name: 'boot',
  20. component: () => import('../views/boot/Index.vue'),
  21. meta: {
  22. ignoreAuth: true,
  23. },
  24. },
  25. {
  26. path: '/',
  27. component: Page,
  28. children: [
  29. {
  30. path: '',
  31. name: 'home',
  32. component: () => import('../views/home/Index.vue'),
  33. children: [
  34. {
  35. path: '',
  36. name: 'home-index',
  37. component: () => import('../views/home/main/Index.vue'),
  38. meta: {
  39. ignoreAuth: true,
  40. },
  41. },
  42. {
  43. path: 'ballot',
  44. name: 'home-ballot',
  45. component: () => import('../views/ballot/list/Index.vue'),
  46. },
  47. {
  48. path: 'goods',
  49. name: 'home-goods',
  50. component: () => import('../views/goods/list/Index.vue'),
  51. props: {
  52. marketId: 50101
  53. }
  54. },
  55. // {
  56. // path: 'spot',
  57. // name: 'home-spot',
  58. // component: () => import('../views/spot/list/Index.vue'),
  59. // },
  60. {
  61. path: 'transfer',
  62. name: 'home-transfer',
  63. component: () => import('../views/transfer/list/Index.vue'),
  64. },
  65. // {
  66. // path: 'swap',
  67. // name: 'home-swap',
  68. // component: () => import('../views/swap/list/Index.vue'),
  69. // },
  70. {
  71. path: 'mine',
  72. name: 'home-mine',
  73. component: () => import('../views/mine/Index.vue'),
  74. }
  75. ]
  76. },
  77. ],
  78. },
  79. {
  80. path: '/user',
  81. component: Page,
  82. children: [
  83. {
  84. path: 'login',
  85. name: 'user-login',
  86. component: () => import('../views/user/login/Index.vue'),
  87. meta: {
  88. ignoreAuth: true,
  89. },
  90. },
  91. {
  92. path: 'register',
  93. name: 'user-register',
  94. component: () => import('../views/user/register/Index.vue'),
  95. meta: {
  96. ignoreAuth: true,
  97. },
  98. },
  99. {
  100. path: 'forget',
  101. name: 'user-forget',
  102. component: () => import('../views/user/forget/Index.vue'),
  103. meta: {
  104. ignoreAuth: true,
  105. },
  106. },
  107. {
  108. path: 'cancel',
  109. name: 'user-cancel',
  110. component: () => import('../views/user/cancel/Index.vue'),
  111. },
  112. {
  113. path: 'password',
  114. name: 'user-password',
  115. component: () => import('../views/user/password/Index.vue'),
  116. },
  117. {
  118. path: 'avatar',
  119. name: 'user-avatar',
  120. component: () => import('../views/user/avatar/Index.vue'),
  121. },
  122. ],
  123. },
  124. {
  125. path: '/account',
  126. component: Page,
  127. children: [
  128. {
  129. path: 'certification',
  130. name: 'account-certification',
  131. component: () => import('../views/account/certification/Index.vue'),
  132. },
  133. ],
  134. },
  135. {
  136. path: '/news',
  137. component: Page,
  138. children: [
  139. {
  140. path: '',
  141. name: 'news-list',
  142. component: () => import('../views/news/list/Index.vue'),
  143. meta: {
  144. ignoreAuth: true,
  145. },
  146. },
  147. {
  148. path: 'detail',
  149. name: 'news-detail',
  150. component: () => import('../views/news/detail/Index.vue'),
  151. meta: {
  152. ignoreAuth: true,
  153. },
  154. },
  155. ],
  156. },
  157. {
  158. path: '/market',
  159. component: Page,
  160. children: [
  161. {
  162. path: '',
  163. name: 'market-list',
  164. component: () => import('../views/market/list/Index.vue'),
  165. },
  166. {
  167. path: 'detail',
  168. name: 'market-detail',
  169. component: () => import('../views/market/detail/Index.vue'),
  170. },
  171. ],
  172. },
  173. {
  174. path: '/goods',
  175. component: Page,
  176. children: [
  177. {
  178. path: '',
  179. name: 'goods-list',
  180. component: () => import('../views/goods/list/Index.vue'),
  181. },
  182. {
  183. path: 'detail',
  184. name: 'goods-detail',
  185. component: () => import('../views/goods/detail/Index.vue'),
  186. },
  187. {
  188. path: 'trade',
  189. name: 'goods-trade',
  190. component: () => import('../views/goods/trade/index.vue'),
  191. },
  192. ],
  193. },
  194. {
  195. path: '/presale',
  196. component: Page,
  197. children: [
  198. {
  199. path: '',
  200. name: 'presale-list',
  201. component: () => import('../views/presale/list/Index.vue'),
  202. },
  203. {
  204. path: 'detail',
  205. name: 'presale-detail',
  206. component: () => import('../views/presale/detail/Index.vue'),
  207. },
  208. ],
  209. },
  210. {
  211. path: '/transfer',
  212. component: Page,
  213. children: [
  214. {
  215. path: 'detail',
  216. name: 'transfer-detail',
  217. component: () => import('../views/transfer/detail/Index.vue'),
  218. },
  219. {
  220. path: 'detail2',
  221. name: 'transfer-detail2',
  222. component: () => import('../views/transfer/detail2/index.vue'),
  223. },
  224. {
  225. path: 'delisting',
  226. name: 'transfer-delisting',
  227. component: () => import('../views/transfer/delisting/Index.vue'),
  228. },
  229. ],
  230. },
  231. {
  232. path: '/swap',
  233. component: Page,
  234. children: [
  235. {
  236. path: '',
  237. name: 'swap-list',
  238. component: () => import('../views/swap/list/Index.vue'),
  239. },
  240. {
  241. path: 'detail',
  242. name: 'swap-detail',
  243. component: () => import('../views/swap/detail/Index.vue'),
  244. },
  245. ],
  246. },
  247. {
  248. path: '/spot',
  249. component: Page,
  250. children: [
  251. {
  252. path: '',
  253. name: 'spot-list',
  254. component: () => import('../views/spot/list/Index.vue'),
  255. },
  256. {
  257. path: 'detail',
  258. name: 'spot-detail',
  259. component: () => import('../views/spot/detail/Index.vue'),
  260. },
  261. {
  262. path: 'add',
  263. name: 'spot-add',
  264. component: () => import('../views/spot/add/index.vue'),
  265. },
  266. ],
  267. },
  268. {
  269. path: '/pricing',
  270. component: Page,
  271. children: [
  272. {
  273. path: '',
  274. name: 'pricing-list',
  275. component: () => import('../views/pricing/list/Index.vue'),
  276. },
  277. {
  278. path: 'detail',
  279. name: 'pricing-detail',
  280. component: () => import('../views/pricing/detail/Index.vue'),
  281. },
  282. ],
  283. },
  284. {
  285. path: '/ballot',
  286. component: Page,
  287. children: [
  288. {
  289. path: 'detail',
  290. name: 'ballot-detail',
  291. component: () => import('../views/ballot/detail/Index.vue'),
  292. },
  293. ],
  294. },
  295. {
  296. path: '/bank',
  297. component: Page,
  298. children: [
  299. {
  300. path: 'wallet',
  301. name: 'bank-wallet',
  302. component: () => import('../views/bank/wallet/Index.vue'),
  303. },
  304. {
  305. path: 'sign',
  306. name: 'bank-sign',
  307. component: () => import('../views/bank/sign/Index.vue'),
  308. },
  309. {
  310. path: 'statement',
  311. name: 'bank-statement',
  312. component: () => import('../views/bank/statement/Index.vue'),
  313. },
  314. {
  315. path: 'statement/history',
  316. name: 'bank-statement-history',
  317. component: () => import('../views/bank/statement/history/Index.vue'),
  318. },
  319. ],
  320. },
  321. {
  322. path: '/order',
  323. component: Page,
  324. children: [
  325. {
  326. path: 'list',
  327. name: 'order-list',
  328. component: () => import('../views/order/list/Index.vue'),
  329. },
  330. {
  331. path: 'position',
  332. name: 'order-position',
  333. component: () => import('../views/order/position/Index.vue'),
  334. },
  335. {
  336. path: 'delivery',
  337. name: 'order-delivery',
  338. component: () => import('../views/order/delivery/Index.vue'),
  339. },
  340. {
  341. path: 'performance',
  342. name: 'order-performance',
  343. component: () => import('../views/order/performance/Index.vue'),
  344. },
  345. ],
  346. },
  347. {
  348. path: '/forward',
  349. component: Page,
  350. children: [
  351. {
  352. path: '',
  353. name: 'forward-list',
  354. component: () => import('../views/goods/list/Index.vue'),
  355. props: {
  356. marketId: 50102
  357. }
  358. },
  359. ],
  360. },
  361. {
  362. path: '/fullpayment',
  363. component: Page,
  364. children: [
  365. {
  366. path: '',
  367. name: 'fullpayment-list',
  368. component: () => import('../views/goods/list/Index.vue'),
  369. props: {
  370. marketId: 16201
  371. }
  372. },
  373. ],
  374. },
  375. {
  376. path: '/mine',
  377. component: Page,
  378. children: [
  379. {
  380. path: 'address',
  381. name: 'mine-address',
  382. component: () => import('../views/mine/address/Index.vue'),
  383. },
  384. {
  385. path: 'invoice',
  386. name: 'mine-invoice',
  387. component: () => import('../views/mine/invoice/Index.vue'),
  388. },
  389. {
  390. path: 'profile',
  391. name: 'mine-profile',
  392. component: () => import('../views/mine/profile/Index.vue'),
  393. },
  394. {
  395. path: 'setting',
  396. name: 'mine-setting',
  397. component: () => import('../views/mine/setting/Index.vue'),
  398. },
  399. ],
  400. },
  401. {
  402. path: '/notice',
  403. component: Page,
  404. children: [
  405. {
  406. path: '',
  407. name: 'notice-list',
  408. component: () => import('../views/notice/list/index.vue'),
  409. },
  410. ],
  411. },
  412. {
  413. path: '/rules',
  414. component: Page,
  415. children: [
  416. {
  417. path: "ptgz",
  418. name: "rules-ptgz",
  419. component: () => import("../views/rules/ptgz/Index.vue"),
  420. meta: {
  421. ignoreAuth: true,
  422. },
  423. },
  424. {
  425. path: "myrz",
  426. name: "rules-myrz",
  427. component: () => import("../views/rules/myrz/Index.vue"),
  428. meta: {
  429. ignoreAuth: true,
  430. },
  431. },
  432. {
  433. path: "ccwl",
  434. name: "rules-ccwl",
  435. component: () => import("../views/rules/ccwl/Index.vue"),
  436. meta: {
  437. ignoreAuth: true,
  438. },
  439. },
  440. {
  441. path: "zcxy",
  442. name: "rules-zcxy",
  443. component: () => import("../views/rules/zcxy/Index.vue"),
  444. meta: {
  445. ignoreAuth: true,
  446. },
  447. },
  448. {
  449. path: "yhkhfxgzs",
  450. name: "rules-yhkhfxgzs",
  451. component: () => import("../views/rules/fxgzs/Index.vue"),
  452. meta: {
  453. ignoreAuth: true,
  454. },
  455. },
  456. {
  457. path: "yszc",
  458. name: "rules-yszc",
  459. component: () => import("../views/rules/yszc/Index.vue"),
  460. meta: {
  461. ignoreAuth: true,
  462. },
  463. },
  464. {
  465. path: "gywm",
  466. name: "rules-gywm",
  467. component: () => import("../views/rules/gywm/Index.vue"),
  468. meta: {
  469. ignoreAuth: true,
  470. },
  471. },
  472. {
  473. path: "fpsm",
  474. name: "rules-fpsm",
  475. component: () => import("../views/rules/fpsm/Index.vue"),
  476. meta: {
  477. ignoreAuth: true,
  478. },
  479. },
  480. {
  481. path: "fwrx",
  482. name: "rules-fwrx",
  483. component: () => import("../views/rules/fwrx/Index.vue"),
  484. meta: {
  485. ignoreAuth: true,
  486. },
  487. },
  488. {
  489. path: "buyrule",
  490. name: "rules-buyrule",
  491. component: () => import("../views/rules/buyrule/Index.vue"),
  492. meta: {
  493. ignoreAuth: true,
  494. },
  495. },
  496. {
  497. path: "sellrule",
  498. name: "rules-sellrule",
  499. component: () => import("../views/rules/sellrule/Index.vue"),
  500. meta: {
  501. ignoreAuth: true,
  502. },
  503. },
  504. {
  505. path: "djgz",
  506. name: "rules-dj",
  507. component: () => import("../views/rules/djgz/Index.vue"),
  508. meta: {
  509. ignoreAuth: true,
  510. },
  511. },
  512. {
  513. path: "jfgz",
  514. name: "rules-jf",
  515. component: () => import("../views/rules/jfgz/Index.vue"),
  516. meta: {
  517. ignoreAuth: true,
  518. },
  519. },
  520. {
  521. path: "cght",
  522. name: "rules-cght",
  523. component: () => import("../views/rules/cght/Index.vue"),
  524. meta: {
  525. ignoreAuth: true,
  526. },
  527. },
  528. {
  529. path: "zrht",
  530. name: "rules-zrht",
  531. component: () => import("../views/rules/zrht/Index.vue"),
  532. meta: {
  533. ignoreAuth: true,
  534. },
  535. },
  536. {
  537. path: "xhht",
  538. name: "rules-xhht",
  539. component: () => import("../views/rules/xhht/Index.vue"),
  540. meta: {
  541. ignoreAuth: true,
  542. },
  543. },
  544. ],
  545. },
  546. ]
  547. const router = animateRouter.create({
  548. history: createWebHashHistory(),
  549. routes,
  550. })
  551. // 路由跳转拦截
  552. router.beforeEach((to, from, next) => {
  553. clearPending()
  554. // 判断服务是否加载完成
  555. if (service.isReady) {
  556. if (to.meta.ignoreAuth || loginStore.token) {
  557. next()
  558. } else {
  559. next({
  560. name: 'user-login',
  561. query: { redirect: to.fullPath },
  562. })
  563. }
  564. } else {
  565. if (to.name === 'boot' || to.name === 'user-login') {
  566. next()
  567. } else {
  568. next({
  569. name: 'boot',
  570. query: { redirect: to.fullPath },
  571. })
  572. }
  573. }
  574. })
  575. export default router