import { EnumRouterName } from '@/common/constants/enumRouterName'; import { setLoadComplete } from '@/common/methods'; import { getLoadIsComplete } from '@/common/methods/mixin'; import Main from '@/layout/components/main.vue'; import Layout from '@/layout/index.vue'; import { globalDataRefresh } from '@/services/bus'; import { isLogin, login } from '@/services/bus/login'; import { localStorageUtil } from '@/utils/storage'; import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'; import eventBus from '../utils/eventBus'; const routes: Array = [ { 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/custom_info_normal', name: 'custom_info_normal', component: () => import('@/views/information/custom/list/normal-use/index.vue'), meta: { requireAuth: true, }, }, { path: '/custom_info/custom_info_disabled', name: 'custom_info_disabled', component: () => import('@/views/information/custom/list/stop-use/index.vue'), meta: { requireAuth: true, }, }, { path: '/custom_info/custom_info_checkpending', name: 'custom_info_checkpending', component: () => import('@/views/information/custom/list/checkpending/index.vue'), meta: { requireAuth: true, }, }, { path: '/custom_info/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/goods_info_spot', name: 'goods_info_spot', component: () => import('@/views/information/goods/list/spot-variety/index.vue'), meta: { requireAuth: true, }, }, { path: '/goods_info/goods_info_hedge', 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/spot_contract_unsubmitted', name: 'spot_contract_unsubmitted', component: () => import('@/views/information/spot-contract/list/unsubmitted/index.vue'), meta: { requireAuth: true, }, }, { path: '/spot_contract/spot_contract_checkpending', name: 'spot_contract_checkpending', component: () => import('@/views/information/spot-contract/list/checkpending/index.vue'), meta: { requireAuth: true, }, }, { path: '/spot_contract/spot_contract_performance', name: 'spot_contract_performance', component: () => import('@/views/information/spot-contract/list/performance/index.vue'), meta: { requireAuth: true, }, }, { path: '/spot_contract/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/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/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/account_info_manager', name: 'account_info_manager', component: () => import('@/views/information/account_info/list/account_info_manager/index.vue'), meta: { requireAuth: true, }, }, { path: '/account_info/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/warehouse_info_normal', name: 'warehouse_info_normal', component: () => import('@/views/information/warehouse-info/list/normal-use/index.vue'), meta: { requireAuth: true, }, }, { path: '/warehouse_info/warehouse_info_disabled', 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: Main, meta: { requireAuth: true, }, redirect: (to) => { return { name: 'inventory_current' }; }, children: [ { path: '/inventory/inventory_current', name: 'inventory_current', component: () => import('@/views/search/inventory/list/inventory_current/index.vue'), meta: { requireAuth: true, }, }, { path: '/inventory/inventory_applyrecord', name: 'inventory_applyrecord', component: () => import('@/views/search/inventory/list/inventory_applyrecord/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/purchase', name: 'purchase', component: Main, meta: { requireAuth: true, }, redirect: { name: 'purchase_pending' }, children: [ { path: '/purchase/purchase_pending', name: 'purchase_pending', component: () => import('@/views/business/purchase/list/pending/index.vue'), meta: { requireAuth: true, }, }, { path: '/purchase/purchase_performance', name: 'purchase_performance', component: () => import('@/views/business/purchase/list/performance/index.vue'), meta: { requireAuth: true, }, }, { path: '/purchase/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/sell_pending', name: 'sell_pending', component: () => import('@/views/business/sell/list/pending/index.vue'), meta: { requireAuth: true, }, }, { path: '/sell/sell_performance', name: 'sell_performance', component: () => import('@/views/business/sell/list/performance/index.vue'), meta: { requireAuth: true, }, }, { path: '/sell/sell_all', name: '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: 'exposure_realtime' }, children: [ { path: '/exposure/exposure_realtime', name: 'exposure_realtime', component: () => import('@/views/business/exposure/list/realTime/index.vue'), meta: { requireAuth: true, }, }, { path: '/exposure/exposure_spot', name: 'exposure_spot', component: () => import('@/views/business/exposure/list/spot/index.vue'), meta: { requireAuth: true, }, }, { path: '/exposure/exposure_futures', name: 'exposure_futures', component: () => import('@/views/business/exposure/list/futures/index.vue'), meta: { requireAuth: true, }, }, { path: '/exposure/exposure_history', name: '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/plan_uncommitted', name: 'plan_uncommitted', component: () => import('@/views/business/plan/list/uncommitted/index.vue'), meta: { requireAuth: true, }, }, { path: '/plan/plan_audit', name: 'plan_audit', component: () => import('@/views/business/plan/list/audit/index.vue'), meta: { requireAuth: true, }, }, { path: '/plan/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: '/business_review/business_review_someprice', name: 'business_review_someprice', component: () => import('@/views/manage/business-review/list/someprice/index.vue'), meta: { requireAuth: true, }, }, { path: '/business_review/business_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: '/finance_review/finance_review_funds', name: 'finance_review_funds', component: () => import('@/views/manage/finance-review/list/funds/index.vue'), meta: { requireAuth: true, }, }, { path: '/finance_review/finance_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/inventory_review_checkin', name: 'inventory_review_checkin', component: () => import('@/views/manage/inventory-review/list/checkin/index.vue'), meta: { requireAuth: true, }, }, { path: '/inventory_review/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: Main, meta: { requireAuth: true, }, redirect: { name: 'exposure_report_exposure' }, children: [ { path: '/exposure_report/exposure_report_exposure', name: 'exposure_report_exposure', component: () => import('@/views/report/exposure-report/list/exposure_report/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/finance_report', name: 'finance_report', component: Main, meta: { requireAuth: true, }, redirect: { name: 'finance_report_finance' }, children: [ { path: '/finance_report/finance_report_finance', name: 'finance_report_finance', component: () => import('@/views/report/finance-report/list/finance_report_finance/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/inventory_report', name: 'inventory_report', component: Main, meta: { requireAuth: true, }, redirect: { name: 'inventory_report_inventory_category' }, children: [ { path: '/inventory_report/inventory_report_inventory_category', name: 'inventory_report_inventory_category', component: () => import('@/views/report/inventory-report/list/category/index.vue'), meta: { requireAuth: true, }, }, { path: '/inventory_report/warehouse', name: 'inventory_report_warehouse', component: () => import('@/views/report/inventory-report/list/warehouse/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/spot_report', name: 'spot_report', component: Main, meta: { requireAuth: true, }, redirect: { name: 'spot_report_spot' }, children: [ { path: '/spot_report/spot_report_spot', name: 'spot_report_spot', component: () => import('@/views/report/spot-report/list/spot_report/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/sum_pl_report', name: 'sum_pl_report', component: Main, meta: { requireAuth: true, }, redirect: { name: 'sum_pl_report_sum_pl' }, children: [ { path: '/sum_pl_report/sum_pl_report_sum_pl', name: 'sum_pl_report_sum_pl', component: () => import('@/views/report/sum_pl_report/list/sum_pl_report/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/future_report', name: 'future_report', component: Main, meta: { requireAuth: true, }, redirect: { name: 'future_report_future' }, children: [ { path: '/future_report/future_report_future', name: 'future_report_future', component: () => import('@/views/report/future_report/list/future_report/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_customer_info', name: 'platinum_customer_info', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_custom_info_normal' }, children: [ { path: '/platinum_customer_info/platinum_custom_info_normal', name: 'platinum_custom_info_normal', component: () => import('@/views/platinum/platinum_customer_info/list/normal-use/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_customer_info/platinum_customer_info_unsubmit', name: 'platinum_customer_info_unsubmit', component: () => import('@/views/platinum/platinum_customer_info/list/unsubmit/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_customer_info/platinum_customer_info_stop', name: 'platinum_customer_info_stop', component: () => import('@/views/platinum/platinum_customer_info/list/stop-use/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_pick_query', name: 'platinum_pick_query', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_pick_query_tab' }, children: [ { path: '/platinum_pick_query/platinum_pick_query_tab', name: 'platinum_pick_query_tab', component: () => import('@/views/platinum/platinum_pick_query/list/tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_recharge_withdrawal_review', name: 'platinum_recharge_withdrawal_review', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_recharge_review_tab' }, children: [ { path: '/platinum_withdrawal_review_tab/platinum_recharge_review_tab', name: 'platinum_recharge_review_tab', component: () => import('@/views/platinum/platinum_recharge_withdrawal_review/list/recharge/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_withdrawal_review_tab/platinum_withdrawal_review_tab', name: 'platinum_withdrawal_review_tab', component: () => import('@/views/platinum/platinum_recharge_withdrawal_review/list/withdrawal/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_fixed_investment_price_query', name: 'platinum_fixed_investment_price_query', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_fixed_investment_price_query_tab' }, children: [ { path: '/platinum_fixed_investment_price_query/platinum_fixed_investment_price_query_tab', name: 'platinum_fixed_investment_price_query_tab', component: () => import('@/views/platinum/platinum_fixed_investment_price_query/list/tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_fixed_investment_query', name: 'platinum_fixed_investment_query', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_fixed_investment_plan_query' }, children: [ { path: '/platinum_fixed_investment_plan_query/platinum_fixed_investment_plan_query', name: 'platinum_fixed_investment_plan_query', component: () => import('@/views/platinum/platinum_fixed_investment_query/list/plan/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_fixed_investment_plan_query/platinum_fixed_investment_flow_query', name: 'platinum_fixed_investment_flow_query', component: () => import('@/views/platinum/platinum_fixed_investment_query/list/flow/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_document_query', name: 'platinum_document_query', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_document_query_position' }, children: [ { path: '/platinum_document_query/platinum_document_query_position', name: 'platinum_document_query_position', component: () => import('@/views/platinum/platinum_document_query/list/position/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_document_query/platinum_document_query_order', name: 'platinum_document_query_order', component: () => import('@/views/platinum/platinum_document_query/list/order/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_document_query/platinum_document_query_waiting', name: 'platinum_document_query_waiting', component: () => import('@/views/platinum/platinum_document_query/list/waiting/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_document_query/platinum_document_query_success', name: 'platinum_document_query_success', component: () => import('@/views/platinum/platinum_document_query/list/success/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_financing_information', name: 'platinum_financing_information', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_financing_information_tab' }, children: [ { path: '/platinum_financing_information/platinum_financing_information_tab', name: 'platinum_financing_information_tab', component: () => import('@/views/platinum/platinum_financing_information/list/tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_agents_and_stores', name: 'platinum_agents_and_stores', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_agents_and_stores_tab' }, children: [ { path: '/platinum_agents_and_stores/platinum_agents_and_stores_tab', name: 'platinum_agents_and_stores_tab', component: () => import('@/views/platinum/platinum_agents_and_stores/list/tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_agreement', name: 'platinum_agreement', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_agreement_tab' }, children: [ { path: '/platinum_agreement/platinum_agreement_tab', name: 'platinum_agreement_tab', component: () => import('@/views/platinum/platinum_agreement/list/tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_capital_flow', name: 'platinum_capital_flow', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_capital_flow_tab' }, children: [ { path: '/platinum_capital_flow_tab/platinum_capital_flow_tab', name: 'platinum_capital_flow_tab', component: () => import('@/views/platinum/platinum_capital_flow/platinum_capital_flow_tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_promotion_report', name: 'platinum_promotion_report', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_promotion_report_tab' }, children: [ { path: '/platinum_promotion_report/platinum_promotion_report_tab', name: 'platinum_promotion_report_tab', component: () => import('@/views/platinum/platinum_promotion_report/platinum_promotion_report_tab/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/platinum_broker_management', name: 'platinum_broker_management', component: Main, meta: { requireAuth: true, }, redirect: { name: 'platinum_broker_management_normal_tab' }, children: [ { path: '/platinum_broker_management/platinum_broker_management_normal_tab', name: 'platinum_broker_management_normal_tab', component: () => import('@/views/platinum/platinum_broker_management/normal/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_broker_management/platinum_broker_management_waiting_tab', name: 'platinum_broker_management_waiting_tab', component: () => import('@/views/platinum/platinum_broker_management/waiting/index.vue'), meta: { requireAuth: true, }, }, { path: '/platinum_broker_management/platinum_broker_management_refuse_tab', name: 'platinum_broker_management_refuse_tab', component: () => import('@/views/platinum/platinum_broker_management/refuse/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/spot_trade', name: EnumRouterName.spot_trade, component: Main, meta: { requireAuth: true, }, redirect: { name: EnumRouterName.warehouse_receipt_trade, }, children: [ { path: '/spot_trade/warehouse_receipt_trade', name: EnumRouterName.warehouse_receipt_trade, component: () => import('@/views/market/spot_trade/warehouse_receipt_trade/index.vue'), meta: { requireAuth: true, }, children: [ { path: '/spot_trade/warehouse_receipt_trade/warehouse_receipt_trade_floating_price', name: EnumRouterName.warehouse_receipt_trade_floating_price, component: () => import('@/views/market/spot_trade/warehouse_receipt_trade/warehouse_receipt_trade_floating_price/index.vue'), meta: { requireAuth: true, }, }, { path: '/spot_trade/warehouse_receipt_trade/warehouse_receipt_trade_price', name: EnumRouterName.warehouse_receipt_trade_price, component: () => import('@/views/market/spot_trade/warehouse_receipt_trade/warehouse_receipt_trade_price/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/spot_trade/warehouse_pre_sale', name: EnumRouterName.warehouse_pre_sale, component: () => import('@/views/market/spot_trade/warehouse_pre_sale/index.vue'), meta: { requireAuth: true, }, children: [ { path: '/spot_trade/warehouse_pre_sale/warehouse_pre_sale_floating_price', name: EnumRouterName.warehouse_pre_sale_floating_price, component: () => import('@/views/market/spot_trade/warehouse_pre_sale/warehouse_pre_sale_floating_price/index.vue'), meta: { requireAuth: true, }, }, { path: '/spot_trade/warehouse_pre_sale/warehouse_pre_sale_price', name: EnumRouterName.warehouse_pre_sale_price, component: () => import('@/views/market/spot_trade/warehouse_pre_sale/warehouse_pre_sale_price/index.vue'), meta: { requireAuth: true, }, }, ] }, ] }, { path: '/search_document_records', name: EnumRouterName.search_document_records, component: Main, meta: { requireAuth: true, }, // redirect: { name: EnumRouterName.search_document_records, }, children: [ { path: '/search_document_records/search_commodity_contract', name: EnumRouterName.search_commodity_contract, component: () => import('@/views/search/search_document_records/search_commodity_contract/index.vue'), meta: { requireAuth: true, }, children: [ { path: '/search_document_records/search_commodity_contract/search_document_records_contract_summary', name: EnumRouterName.search_document_records_contract_summary, component: () => import('@/views/search/search_document_records/search_commodity_contract/search_document_records_contract_summary/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_commodity_contract/search_document_records_commission_record', name: EnumRouterName.search_document_records_commission_record, component: () => import('@/views/search/search_document_records/search_commodity_contract/search_document_records_commission_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_commodity_contract/search_document_records_delivery_record', name: EnumRouterName.search_document_records_delivery_record, component: () => import('@/views/search/search_document_records/search_commodity_contract/search_document_records_delivery_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_document_records/search_document_records_transaction_record', name: EnumRouterName.search_document_records_transaction_record, component: () => import('@/views/search/search_document_records/search_commodity_contract/search_document_records_transaction_record/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/search_document_records/search_pre_sale_warehouse_receipt', name: EnumRouterName.search_pre_sale_warehouse_receipt, component: () => import('@/views/search/search_document_records/search_pre_sale_warehouse_receipt/index.vue'), meta: { requireAuth: true, }, children: [ { path: '/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_commission_record', name: EnumRouterName.search_pre_sale_warehouse_receipt_commission_record, component: () => import('@/views/search/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_commission_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_order_summary', name: EnumRouterName.search_pre_sale_warehouse_receipt_order_summary, component: () => import('@/views/search/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_order_summary/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_protocol_specified_record', name: EnumRouterName.search_pre_sale_warehouse_receipt_protocol_specified_record, component: () => import('@/views/search/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_protocol_specified_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_transaction_record', name: EnumRouterName.search_pre_sale_warehouse_receipt_transaction_record, component: () => import('@/views/search/search_document_records/search_pre_sale_warehouse_receipt/search_pre_sale_warehouse_receipt_transaction_record/index.vue'), meta: { requireAuth: true, }, }, ] }, { path: '/search_document_records/search_spot_warrant', name: EnumRouterName.search_spot_warrant, component: () => import('@/views/search/search_document_records/search_spot_warrant/index.vue'), meta: { requireAuth: true, }, children: [ { path: '/search_document_records/search_spot_warrant/search_spot_warrant_transaction_record', name: EnumRouterName.search_spot_warrant_transaction_record, component: () => import('@/views/search/search_document_records/search_spot_warrant/search_spot_warrant_transaction_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_spot_warrant/search_spot_warrant_protocol_specified_record', name: EnumRouterName.search_spot_warrant_protocol_specified_record, component: () => import('@/views/search/search_document_records/search_spot_warrant/search_spot_warrant_protocol_specified_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_spot_warrant/search_spot_warrant_listing_record', name: EnumRouterName.search_spot_warrant_listing_record, component: () => import('@/views/search/search_document_records/search_spot_warrant/search_spot_warrant_listing_record/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_document_records/search_spot_warrant/search_spot_warrant_warehouse_receipt_details', name: EnumRouterName.search_spot_warrant_warehouse_receipt_details, component: () => import('@/views/search/search_document_records/search_spot_warrant/search_spot_warrant_warehouse_receipt_details/index.vue'), meta: { requireAuth: true, }, }, ] }, ] }, { path: '/search_capital_flow', name: EnumRouterName.search_capital_flow, component: Main, meta: { requireAuth: true, }, children: [ { path: '/search_capital_flow/search_capital_flow_tab', name: EnumRouterName.search_capital_flow_tab, component: () => import('@/views/search/search_capital_flow/search_capital_flow_tab/index.vue'), meta: { requireAuth: true, }, } ] }, { path: '/search_financing_inquiry', name: EnumRouterName.search_financing_inquiry, component: Main, meta: { requireAuth: true, }, children: [ { path: '/search_financing_inquiry/search_financing_inquiry_apply_order', name: EnumRouterName.search_financing_inquiry_apply_order, component: () => import('@/views/search/search_financing_inquiry/search_financing_inquiry_apply_order/index.vue'), meta: { requireAuth: true, }, }, { path: '/search_financing_inquiry/search_financing_inquiry_contract', name: EnumRouterName.search_financing_inquiry_contract, component: () => import('@/views/search/search_financing_inquiry/search_financing_inquiry_contract/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(); } else { if (!getLoadIsComplete()) { // 没有加载对应的资料,表示第一次启动项目 console.log('to', to); const { ACCOUNT, PASSWORD } = to.query const name = to.name ? to.name : 'home' if (ACCOUNT && PASSWORD) { setLoadComplete(false) globalDataRefresh().then(() => { const { ACCOUNT, PASSWORD } = to.query login(ACCOUNT as string, PASSWORD as string, [], true).then(res => { setLoadComplete(true) localStorageUtil.setItem('loginAccount', ACCOUNT); // 缓存登录账号 eventBus.$emit('loginSuccess', true); next({ name }) }).catch(err => { // 异常需要跳转到错误页面,让用户手动重试 console.log('err', err); }) }) } else { // 跳转到登录页面 next() } } else { // next() } } } }); export default router;