| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- import { createRouter, createWebHistory } from 'vue-router'
- import { useUserStore } from '@/stores/modules/user'
- import { useBreadCrumb } from '@/stores/modules/breadCrumb'
- const router = createRouter({
- history: createWebHistory(`${import.meta.env.VITE_BASE_URL}`),
- routes: [
- {
- path: '/',
- name: 'Home',
- redirect: '/dashboard',
- component: () => import('../views/Layout'),
- children: [
- {
- path: '/dashboard',
- name: 'Dashboard',
- component: () => import('../views/Dashboard')
- },
- {
- path: '/booking',
- name: 'Booking',
- component: () => import('../views/Booking')
- },
- {
- path: '/booking/detail',
- name: 'Booking Detail',
- component: () => import('../views/Booking/src/components/BookingDetail'),
- meta: {
- activeMenu: '/booking'
- }
- },
- {
- path: '/tracking',
- name: 'Tracking',
- component: () => import('../views/Tracking')
- },
- {
- path: '/tracking/detail',
- name: 'Tracking Detail',
- component: () => import('../views/Tracking/src/components/TrackingDetail'),
- meta: {
- activeMenu: '/tracking'
- }
- },
- {
- path: '/shipment/detail',
- name: 'Shipment Detail',
- component: () => import('../views/Tracking/src/components/TrackingDetail'),
- meta: {
- activeMenu: '/tracking'
- }
- },
- {
- path: '/tracking/add-vgm',
- name: 'Add VGM',
- component: () =>
- import('../views/Tracking/src/components/TrackingTable/src/components/VGMView.vue'),
- meta: {
- activeMenu: '/tracking'
- }
- },
- {
- path: '/public-tracking',
- name: 'Public Tracking',
- component: () => import('../views/Tracking/src/components/PublicTracking'),
- meta: {
- activeMenu: '/tracking'
- }
- },
- {
- path: '/public-tracking/detail',
- name: 'Public Tracking Detail',
- component: () =>
- import(
- '../views/Tracking/src/components/PublicTracking/src/components/PublicTrackingDetail.vue'
- ),
- meta: {
- activeMenu: '/tracking'
- }
- },
- {
- path: '/login',
- name: 'Login',
- component: () => import('../views/Login'),
- meta: {
- activeMenu: '/tracking'
- }
- },
- {
- path: '/reset-password',
- name: 'Reset Password',
- component: () => import('../views/Login/src/components/ChangePasswordCard.vue')
- },
- {
- path: '/Operationlog',
- name: 'Operationlog',
- component: () => import('../views/OperationLog')
- },
- {
- path: '/chat-log',
- name: 'Chat Log',
- component: () => import('../views/ChatLog')
- },
- {
- path: '/ai-api-log',
- name: 'AI API Log',
- component: () => import('../views/AIApiLog')
- },
- {
- path: '/PromptConfiguration',
- name: 'PromptConfiguration',
- component: () => import('../views/PromptConfiguration')
- },
- {
- path: '/system-message',
- name: 'System Message',
- component: () => import('../views/SystemMessage')
- },
- {
- path: '/system-message-detail',
- name: 'System Message Detail',
- meta: {
- breadName: 'Detail',
- activeMenu: '/system-message'
- },
- component: () => import('../views/SystemMessage/src/components/SystemMessageDetail.vue')
- },
- {
- path: '/SystemSettings',
- name: 'Monitoring Settings',
- component: () => import('../views/SystemSettings')
- },
- {
- path: '/SystemSettings',
- name: 'System Settings',
- component: () => import('../views/SystemSettings')
- },
- {
- path: '/SystemSettings/createnewrule',
- name: 'Create New Rule',
- component: () => import('../views/SystemSettings/src/components/CreateNewrule'),
- meta: {
- activeMenu: '/SystemSettings'
- }
- },
- {
- path: '/destination-delivery',
- name: 'Destination Delivery',
- component: () => import('../views/DestinationDelivery')
- },
- {
- path: '/destination-delivery/CreateNewBooking',
- name: 'Create New Booking',
- component: () => import('../views/DestinationDelivery/src/components/CreateNewBooking')
- },
- {
- path: '/destination-delivery/ConfiguRations',
- name: 'Configurations',
- component: () => import('../views/DestinationDelivery/src/components/ConfiguRations')
- },
- {
- path: '/destination-delivery/ConfiguRations/CreateNewRule',
- name: 'Destination Create New Rule',
- component: () => import('../views/DestinationDelivery/src/components/ConfiguRations/src/components/CreateNewRule.vue')
- },
- {
- path: '/destination-delivery/modify-booking',
- name: 'Modify Booking',
- component: () => import('../views/DestinationDelivery/src/components/ModifyBooking'),
- meta: {
- breadName: 'Modify Booking',
- activeMenu: '/destination-delivery'
- }
- }
- ]
- }
- ]
- })
- // * 路由拦截 beforeEach
- router.beforeEach(async (to, from, next) => {
- useBreadCrumb().setRouteList(to)
- const userStore = useUserStore()
- // 如果手动跳转登录页,清除登录信息
- if (to.path === '/login') {
- if (userStore.isLogin) {
- await userStore.logout()
- }
- sessionStorage.removeItem('trackingTablePageInfo')
- sessionStorage.removeItem('bookingTablePageInfo')
- }
- // 判断是否从systemMessage详情页跳转到systemMessage列表页,或者从systemMessage列表页跳转到systemMessage详情页
- if (
- !(
- from.name === 'System Message Detail' ||
- from.name === 'System Message' ||
- !from.name ||
- from.name === 'Tracking Detail'
- ) ||
- !(
- to.name === 'System Message' ||
- to.name === 'System Message Detail' ||
- to.name === 'Tracking Detail'
- )
- ) {
- sessionStorage.removeItem('activeCardTypeName')
- }
- // 未登录白名单
- const whiteList = ['/login', '/public-tracking', '/public-tracking/detail', '/reset-password']
- // 判断是否登录
- if (!whiteList.includes(to.path) && !userStore.isLogin) {
- const userStore = useUserStore()
- await userStore.logout()
- if (whiteList.includes(from.path)) {
- ElMessage.warning({
- message: 'Please log in to use this feature.',
- grouping: true
- })
- next(false)
- return
- } else {
- next('/login')
- }
- }
- next()
- })
- export default router
|