| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- import * as EnumType from '@/common/constants/routerName';
- import Main from '@/layout/components/main.vue';
- import Layout from '@/layout/index.vue';
- import { isLogin } from '@/services/bus/login';
- import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
- import eventBus from '../utils/eventBus';
- const routes: Array<RouteRecordRaw> = [
- {
- path: '/login',
- name: 'login',
- component: () => import('@/views/account/login.vue'),
- },
- {
- path: '/logon',
- name: 'logon',
- component: () => import('@/views/account/logon.vue'),
- },
- {
- path: '/resetPassword',
- name: 'resetPassword',
- component: () => import('@/views/account/resetPassword.vue'),
- },
- {
- path: '/',
- component: Layout,
- props: true,
- redirect: '/login',
- children: [
- {
- path: '/home',
- name: 'home',
- component: () => import('@/views/home.vue'),
- },
- {
- path: '/futures',
- name: 'forward',
- component: () => import('@/views/market/forward/index.vue'),
- },
- {
- path: '/warehouse-trade',
- name: 'warehouseTrade',
- component: () => import('@/views/market/warehouseTrade/index.vue'),
- },
- {
- path: 'custom_info',
- name: 'custom_info',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: (to) => {
- return { name: 'custom_info_unsubmit' };
- },
- children: [
- {
- path: '/custom_info/normal',
- name: 'custom_info_normal',
- component: () => import('@/views/information/custom/list/normal-use/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/custom_info/stop',
- name: 'custom_info_disabled',
- component: () => import('@/views/information/custom/list/stop-use/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/custom_info/checkpending',
- name: 'custom_info_checkpending',
- component: () => import('@/views/information/custom/list/checkpending/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/custom_info/unsubmit',
- name: 'custom_info_unsubmit',
- component: () => import('@/views/information/custom/list/unsubmit/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: 'goods_info',
- name: 'goods_info',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: (to) => {
- return { name: 'goods_info_spot' };
- },
- children: [
- {
- path: '/goods_info/spot',
- name: 'goods_info_spot',
- component: () => import('@/views/information/goods/list/spot-variety/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/goods_info/hedging',
- name: 'goods_info_hedge',
- component: () => import('@/views/information/goods/list/hedging-variety/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/spot_contract',
- name: 'spot_contract',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: (to) => {
- return { name: 'spot_contract_unsubmitted' };
- },
- children: [
- {
- path: '/spot_contract/unsubmitted',
- name: 'spot_contract_unsubmitted',
- component: () => import('@/views/information/spot-contract/list/unsubmitted/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/spot_contract/checkpending',
- name: 'spot_contract_checkpending',
- component: () => import('@/views/information/spot-contract/list/checkpending/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/spot_contract/performance',
- name: 'spot_contract_performance',
- component: () => import('@/views/information/spot-contract/list/performance/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/spot_contract/finished',
- name: 'spot_contract_finished',
- component: () => import('@/views/information/spot-contract/list/finished/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/account_info',
- name: 'account_info',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: (to) => {
- return { name: 'account_info_business' };
- },
- children: [
- {
- path: '/account_info/business',
- name: 'account_info_business',
- component: () => import('@/views/information/account_info/list/account_info_business/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/account_info/futures',
- name: 'account_info_futures',
- component: () => import('@/views/information/account_info/list/account_info_futures/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/account_info/managers',
- name: 'account_info_manager',
- component: () => import('@/views/information/account_info/list/account_info_manager/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/account_info/trade',
- name: 'account_info_trade',
- component: () => import('@/views/information/account_info/list/account_info_trade/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/warehouse_info',
- name: 'warehouse_info',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: (to) => {
- return { name: 'warehouse_info_normal' };
- },
- children: [
- {
- path: '/warehouse_info/normal',
- name: 'warehouse_info_normal',
- component: () => import('@/views/information/warehouse-info/list/normal-use/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/warehouse_info/stop',
- name: 'warehouse_info_disabled',
- component: () => import('@/views/information/warehouse-info/list/stop-use/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/outaccount_status',
- name: 'outaccount_status',
- component: () => import('@/views/search/outaccount_status/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/inventory',
- name: 'inventory',
- component: () => import('@/views/search/inventory/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/purchase',
- name: 'purchase',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: 'purchase_pending' },
- children: [
- {
- path: '/purchase/pending',
- name: 'purchase_pending',
- component: () => import('@/views/business/purchase/list/pending/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/purchase/performance',
- name: 'purchase_performance',
- component: () => import('@/views/business/purchase/list/performance/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/purchase/all',
- name: 'purchase_all',
- component: () => import('@/views/business/purchase/list/all/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/sell',
- name: 'sell',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: 'sell_pending' },
- children: [
- {
- path: '/sell/pending',
- name: 'sell_pending',
- component: () => import('@/views/business/sell/list/pending/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/sell/performance',
- name: EnumType.Sell.performance,
- component: () => import('@/views/business/sell/list/performance/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/sell/all',
- name: EnumType.Sell.all,
- component: () => import('@/views/business/sell/list/all/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/exposure',
- name: 'exposure',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: EnumType.Exposure.realTime },
- children: [
- {
- path: '/exposure/realTime',
- name: EnumType.Exposure.realTime,
- component: () => import('@/views/business/exposure/list/realTime/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/exposure/spot',
- name: EnumType.Exposure.spot,
- component: () => import('@/views/business/exposure/list/spot/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/exposure/futures',
- name: EnumType.Exposure.futures,
- component: () => import('@/views/business/exposure/list/futures/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/exposure/history',
- name: EnumType.Exposure.history,
- component: () => import('@/views/business/exposure/list/history/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/plan',
- name: 'plan',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: 'plan_uncommitted' },
- children: [
- {
- path: '/plan/uncommitted',
- name: 'plan_uncommitted',
- component: () => import('@/views/business/plan/list/uncommitted/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/plan/audit',
- name: 'plan_audit',
- component: () => import('@/views/business/plan/list/audit/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/plan/running',
- name: 'plan_running',
- component: () => import('@/views/business/plan/list/running/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: 'review',
- name: 'business_review',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: 'business_review_someprice' },
- children: [
- {
- path: '/review/someprice',
- name: 'business_review_someprice',
- component: () => import('@/views/manage/business-review/list/someprice/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/review/settlement',
- name: 'business_review_settlement',
- component: () => import('@/views/manage/business-review/list/settlement/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ]
- },
- {
- path: '/finance_review',
- name: 'finance_review',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: 'finance_review_funds' },
- children: [
- {
- path: '/review/funds',
- name: 'finance_review_funds',
- component: () => import('@/views/manage/finance-review/list/funds/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/review/invoice',
- name: 'finance_review_invoice',
- component: () => import('@/views/manage/finance-review/list/invoice/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ]
- },
- {
- path: '/inventory_review',
- name: 'inventory_review',
- component: Main,
- meta: {
- requireAuth: true,
- },
- redirect: { name: 'inventory_review_checkin' },
- children: [
- {
- path: '/inventory_review/checkin',
- name: 'inventory_review_checkin',
- component: () => import('@/views/manage/inventory-review/list/checkin/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/inventory_review/checkout',
- name: 'inventory_review_checkout',
- component: () => import('@/views/manage/inventory-review/list/checkout/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ]
- },
- {
- path: '/exposure_report',
- name: 'exposure_report',
- component: () => import('@/views/report/exposure-report/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/finance_report',
- name: 'finance_report',
- component: () => import('@/views/report/finance-report/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/inventory_report',
- name: 'inventory_report',
- component: () => import('@/views/report/inventory-report/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- {
- path: '/spot_report',
- name: 'spot_report',
- component: () => import('@/views/report/spot-report/index.vue'),
- meta: {
- requireAuth: true,
- },
- },
- ],
- },
- {
- path: '/test',
- name: 'test',
- component: () => import('@/views/test/index.vue'),
- },
- {
- // VueRouter 匹配规则是从上往下 建议把*放最后
- path: '/:pathMatch(.*)*',
- name: '404',
- component: () => import('@/views/error-page/404.vue'),
- },
- ];
- const router = createRouter({
- history: createWebHashHistory(),
- routes,
- });
- // 路由拦截
- router.beforeEach((to, from, next) => {
- // 前往登录页时 直接走登出流程
- if (to.fullPath === '/login') {
- eventBus.$emit('logout');
- next();
- } else {
- // 前往其他页 判断是否是登录状态
- if (isLogin()) return next();
- // 不是登录状态不能去'我的'页面,跳至首页
- // if (to.fullPath.indexOf('/mine') !== -1) next('/');
- else next();
- }
- });
- export default router;
|