index.ts 11 KB

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