| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- import { createWebHashHistory, RouteRecordRaw } from 'vue-router'
- import { useLoginStore } from '@/stores'
- import { clearPending } from '@/services/http/pending'
- import service from '@/services'
- import Page from '../components/layouts/page/index.vue'
- import animateRouter from './animateRouter'
- const loginStore = useLoginStore()
- const routes: Array<RouteRecordRaw> = [
- {
- path: '/:pathMatch(.*)*',
- name: 'error',
- component: () => import('../views/error/404.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: '/boot',
- name: 'boot',
- component: () => import('../views/boot/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: '/',
- component: Page,
- children: [
- {
- path: '',
- name: 'home',
- component: () => import('../views/home/Index.vue'),
- children: [
- {
- path: '',
- name: 'home-index',
- component: () => import('../views/home/main/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'ballot',
- name: 'home-ballot',
- component: () => import('../views/ballot/list/Index.vue'),
- },
- {
- path: 'goods',
- name: 'home-goods',
- component: () => import('../views/goods/list/Index.vue'),
- props: {
- marketId: 50101
- }
- },
- // {
- // path: 'spot',
- // name: 'home-spot',
- // component: () => import('../views/spot/list/Index.vue'),
- // },
- {
- path: 'transfer',
- name: 'home-transfer',
- component: () => import('../views/transfer/list/Index.vue'),
- },
- // {
- // path: 'swap',
- // name: 'home-swap',
- // component: () => import('../views/swap/list/Index.vue'),
- // },
- {
- path: 'mine',
- name: 'home-mine',
- component: () => import('../views/mine/Index.vue'),
- }
- ]
- },
- ],
- },
- {
- path: '/user',
- component: Page,
- children: [
- {
- path: 'login',
- name: 'user-login',
- component: () => import('../views/user/login/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'register',
- name: 'user-register',
- component: () => import('../views/user/register/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'forget',
- name: 'user-forget',
- component: () => import('../views/user/forget/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'cancel',
- name: 'user-cancel',
- component: () => import('../views/user/cancel/Index.vue'),
- },
- {
- path: 'password',
- name: 'user-password',
- component: () => import('../views/user/password/Index.vue'),
- },
- {
- path: 'avatar',
- name: 'user-avatar',
- component: () => import('../views/user/avatar/Index.vue'),
- },
- ],
- },
- {
- path: '/account',
- component: Page,
- children: [
- {
- path: 'certification',
- name: 'account-certification',
- component: () => import('../views/account/certification/Index.vue'),
- },
- ],
- },
- {
- path: '/news',
- component: Page,
- children: [
- {
- path: '',
- name: 'news-list',
- component: () => import('../views/news/list/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: 'detail',
- name: 'news-detail',
- component: () => import('../views/news/detail/Index.vue'),
- meta: {
- ignoreAuth: true,
- },
- },
- ],
- },
- {
- path: '/market',
- component: Page,
- children: [
- {
- path: '',
- name: 'market-list',
- component: () => import('../views/market/list/Index.vue'),
- },
- {
- path: 'detail',
- name: 'market-detail',
- component: () => import('../views/market/detail/Index.vue'),
- },
- ],
- },
- {
- path: '/goods',
- component: Page,
- children: [
- {
- path: '',
- name: 'goods-list',
- component: () => import('../views/goods/list/Index.vue'),
- },
- {
- path: 'detail',
- name: 'goods-detail',
- component: () => import('../views/goods/detail/Index.vue'),
- },
- {
- path: 'trade',
- name: 'goods-trade',
- component: () => import('../views/goods/trade/index.vue'),
- },
- ],
- },
- {
- path: '/presale',
- component: Page,
- children: [
- {
- path: '',
- name: 'presale-list',
- component: () => import('../views/presale/list/Index.vue'),
- },
- {
- path: 'detail',
- name: 'presale-detail',
- component: () => import('../views/presale/detail/Index.vue'),
- },
- ],
- },
- {
- path: '/transfer',
- component: Page,
- children: [
- {
- path: 'detail',
- name: 'transfer-detail',
- component: () => import('../views/transfer/detail/Index.vue'),
- },
- {
- path: 'detail2',
- name: 'transfer-detail2',
- component: () => import('../views/transfer/detail2/index.vue'),
- },
- {
- path: 'delisting',
- name: 'transfer-delisting',
- component: () => import('../views/transfer/delisting/Index.vue'),
- },
- ],
- },
- {
- path: '/swap',
- component: Page,
- children: [
- {
- path: '',
- name: 'swap-list',
- component: () => import('../views/swap/list/Index.vue'),
- },
- {
- path: 'detail',
- name: 'swap-detail',
- component: () => import('../views/swap/detail/Index.vue'),
- },
- ],
- },
- {
- path: '/spot',
- component: Page,
- children: [
- {
- path: '',
- name: 'spot-list',
- component: () => import('../views/spot/list/Index.vue'),
- },
- {
- path: 'detail',
- name: 'spot-detail',
- component: () => import('../views/spot/detail/Index.vue'),
- },
- {
- path: 'add',
- name: 'spot-add',
- component: () => import('../views/spot/add/index.vue'),
- },
- ],
- },
- {
- path: '/pricing',
- component: Page,
- children: [
- {
- path: '',
- name: 'pricing-list',
- component: () => import('../views/pricing/list/Index.vue'),
- },
- {
- path: 'detail',
- name: 'pricing-detail',
- component: () => import('../views/pricing/detail/Index.vue'),
- },
- ],
- },
- {
- path: '/ballot',
- component: Page,
- children: [
- {
- path: 'detail',
- name: 'ballot-detail',
- component: () => import('../views/ballot/detail/Index.vue'),
- },
- ],
- },
- {
- path: '/bank',
- component: Page,
- children: [
- {
- path: 'wallet',
- name: 'bank-wallet',
- component: () => import('../views/bank/wallet/Index.vue'),
- },
- {
- path: 'sign',
- name: 'bank-sign',
- component: () => import('../views/bank/sign/Index.vue'),
- },
- {
- path: 'statement',
- name: 'bank-statement',
- component: () => import('../views/bank/statement/Index.vue'),
- },
- {
- path: 'statement/history',
- name: 'bank-statement-history',
- component: () => import('../views/bank/statement/history/Index.vue'),
- },
- ],
- },
- {
- path: '/order',
- component: Page,
- children: [
- {
- path: 'list',
- name: 'order-list',
- component: () => import('../views/order/list/Index.vue'),
- },
- {
- path: 'position',
- name: 'order-position',
- component: () => import('../views/order/position/Index.vue'),
- },
- {
- path: 'delivery',
- name: 'order-delivery',
- component: () => import('../views/order/delivery/Index.vue'),
- },
- {
- path: 'performance',
- name: 'order-performance',
- component: () => import('../views/order/performance/Index.vue'),
- },
- ],
- },
- {
- path: '/forward',
- component: Page,
- children: [
- {
- path: '',
- name: 'forward-list',
- component: () => import('../views/goods/list/Index.vue'),
- props: {
- marketId: 50102
- }
- },
- ],
- },
- {
- path: '/fullpayment',
- component: Page,
- children: [
- {
- path: '',
- name: 'fullpayment-list',
- component: () => import('../views/goods/list/Index.vue'),
- props: {
- marketId: 16201
- }
- },
- ],
- },
- {
- path: '/mine',
- component: Page,
- children: [
- {
- path: 'address',
- name: 'mine-address',
- component: () => import('../views/mine/address/Index.vue'),
- },
- {
- path: 'invoice',
- name: 'mine-invoice',
- component: () => import('../views/mine/invoice/Index.vue'),
- },
- {
- path: 'profile',
- name: 'mine-profile',
- component: () => import('../views/mine/profile/Index.vue'),
- },
- {
- path: 'setting',
- name: 'mine-setting',
- component: () => import('../views/mine/setting/Index.vue'),
- },
- ],
- },
- {
- path: '/notice',
- component: Page,
- children: [
- {
- path: '',
- name: 'notice-list',
- component: () => import('../views/notice/list/index.vue'),
- },
- ],
- },
- {
- path: '/rules',
- component: Page,
- children: [
- {
- path: "ptgz",
- name: "rules-ptgz",
- component: () => import("../views/rules/ptgz/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "myrz",
- name: "rules-myrz",
- component: () => import("../views/rules/myrz/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "ccwl",
- name: "rules-ccwl",
- component: () => import("../views/rules/ccwl/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "zcxy",
- name: "rules-zcxy",
- component: () => import("../views/rules/zcxy/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "yhkhfxgzs",
- name: "rules-yhkhfxgzs",
- component: () => import("../views/rules/fxgzs/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "yszc",
- name: "rules-yszc",
- component: () => import("../views/rules/yszc/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "gywm",
- name: "rules-gywm",
- component: () => import("../views/rules/gywm/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "fpsm",
- name: "rules-fpsm",
- component: () => import("../views/rules/fpsm/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "fwrx",
- name: "rules-fwrx",
- component: () => import("../views/rules/fwrx/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "buyrule",
- name: "rules-buyrule",
- component: () => import("../views/rules/buyrule/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "sellrule",
- name: "rules-sellrule",
- component: () => import("../views/rules/sellrule/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "djgz",
- name: "rules-dj",
- component: () => import("../views/rules/djgz/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "jfgz",
- name: "rules-jf",
- component: () => import("../views/rules/jfgz/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "cght",
- name: "rules-cght",
- component: () => import("../views/rules/cght/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "zrht",
- name: "rules-zrht",
- component: () => import("../views/rules/zrht/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- {
- path: "xhht",
- name: "rules-xhht",
- component: () => import("../views/rules/xhht/Index.vue"),
- meta: {
- ignoreAuth: true,
- },
- },
- ],
- },
- ]
- const router = animateRouter.create({
- history: createWebHashHistory(),
- routes,
- })
- // 路由跳转拦截
- router.beforeEach((to, from, next) => {
- clearPending()
- // 判断服务是否加载完成
- if (service.isReady) {
- if (to.meta.ignoreAuth || loginStore.token) {
- next()
- } else {
- next({
- name: 'user-login',
- query: { redirect: to.fullPath },
- })
- }
- } else {
- if (to.name === 'boot' || to.name === 'user-login') {
- next()
- } else {
- next({
- name: 'boot',
- query: { redirect: to.fullPath },
- })
- }
- }
- })
- export default router
|