import { createRouter, createWebHistory } from "vue-router"; import store from "@/store"; /** * 说明 * meta中 * keepAlive表示是否要缓存 * isRoot代表是否为侧边栏组件用于处理面包屑数据 * hasBack 控制是否有返回按钮 */ const routes=[ { path: "/", name: "Layout", redirect:'/report/index', component: ()=>import("@/layout/Index.vue"), }, //活动模块 { path: "/activity", name: "Activity", redirect:'/activity/list', component: () => import("@/layout/Index.vue"), meta: { title:"活动" }, children: [ { path: "list", name: "ActivityList", component: () => import("@/views/activity/List.vue"), meta: { title: "活动", keepAlive:true, isRoot:true }, }, { path:'detail',//query: id(活动id) name:"ActivityDetail", component: () => import("@/views/activity/Detail.vue"), meta: { title: "活动详情", hasBack:true }, }, { path: "reportdetail", name: "ActivityReportDetail", component: () => import("@/views/activity/ReportDetail.vue"), meta: { title: "报告详情", hasBack:true } }, { path: "chapterdetail", name: "ActivityChapterReportDetail", component: () => import("@/views/activity/ChapterDetail.vue"), meta: { title: "报告详情", hasBack:true } } ] }, // 报告模块 { path:'/report', name:'Report', redirect: '/report/index', component: () => import("@/layout/Index.vue"), meta: { title:"研报" }, children:[ { path: "index", name: "ReportIndex", component: () => import("@/views/report/Index.vue"), meta: { title: "研报", keepAlive:true, isRoot:true }, }, { path: "classify", name: "ReportClassify", component: () => import("@/views/report/Classify.vue"), meta: { title: "FICC研报分类", keepAlive:false, isRoot:false, hasBack:true }, }, { path: "search", name: "ReportSearch", component: () => import("@/views/report/Search.vue"), meta: { title: "研报搜索", keepAlive:true, isRoot:false, hasBack:true }, }, { path: "detail", name: "ReportDetail", component: () => import("@/views/report/Detail.vue"), meta: { title: "报告详情", keepAlive:false, isRoot:false, hasBack:true }, }, { path: "chapterdetail", name: "ReportChapterDetail", component: () => import("@/views/report/ChapterDetail.vue"), meta: { title: "报告详情", keepAlive:false, isRoot:false, hasBack:true }, }, { path: "list", name: "ReportList", component: () => import("@/views/report/List.vue"), meta: { title: "报告列表", keepAlive:true, isRoot:false, hasBack:true }, }, { path: "specialcolumnlist", name: "ReportSpecialColumnList", component: () => import("@/views/report/specialColumn/List.vue"), meta: { title: "专栏列表", keepAlive:true, isRoot:false, hasBack:true }, }, { path: "specialcolumndetail", name: "ReportSpecialColumnDetail", component: () => import("@/views/report/specialColumn/Detail.vue"), meta: { title: "专栏详情", keepAlive:true, isRoot:false, hasBack:true }, }, { path: "ficcserveintro", name: "FiccServeIntro", component: () => import("@/views/report/FiccIntroduce.vue"), meta: { title: "FICC服务介绍", keepAlive:false, isRoot:false, hasBack:true }, }, ] }, { path: "/apply", name: "Apply", component: () => import("@/layout/Index.vue"), meta: { title:"申请试用" }, children: [ { path: "permission",// source来源(如:2) fromPage=来源页面(如:活动列表) name: "ApplyPermission", component: () => import("@/views/applyPermission/Apply.vue"), meta: { title: "申请试用", hasBack:true } }, { path: "result", name: "ApplyPermissionResult", component: () => import("@/views/applyPermission/Result.vue"), meta: { title: "申请结果", hasBack:true } } ] }, // 图库模块 { path:'/chart', name:"Chart", component: () => import("@/layout/Index.vue"), meta:{ title:"ETA图库" }, children:[ { path:"list", name:"ChartList", component:()=>import('@/views/chart/List.vue'), meta: { title: "ETA图库", keepAlive:true, isRoot:true } } ] }, // 沙盘推演模块 { path:'/sandBox', name:"sandBox", component: () => import("@/layout/Index.vue"), redirect:'/sandBox/list', meta:{ title:"沙盘推演" }, children:[ { path:"list", name:"sandBoxList", component:()=>import('@/views/sandBox/List.vue'), meta: { title: "沙盘推演", keepAlive:false, isRoot:true } } ] }, // 用户模块 { path:'/user', name:"User", component: () => import("@/layout/Index.vue"), meta:{ title:"用户" }, children:[ { path:"setinfo", name:"UserSetInfo", component:()=>import('@/views/user/SetUserInfo.vue'), meta: { title: "我的设置", keepAlive:false, isRoot:false, hasBack:true } } ] }, //价格驱动 { path: '/pricedriven', name: "priceDriven", component: () => import("@/layout/Index.vue"), meta: { title:"价格驱动" }, children: [ { path: "/pricedriven", name: "priceDrivenDeteail", component: () => import("@/views/priceDriven/detail.vue"), meta: { title: "价格驱动", keepAlive:false, isRoot:true }, }, ] }, //视频社区模块 { path:'/video', name:"Video", component: () => import("@/layout/Index.vue"), meta:{ title:"视频社区" }, children:[ { path:"list", name:"VideoList", component:()=>import('@/views/video/List.vue'), meta: { title: "视频社区", keepAlive:true, isRoot:true } } ] }, //语音播报模块 { path:'/voice', name:"Voice", component: () => import("@/layout/Index.vue"), meta:{ title:"语音播报" }, children:[ { path:"list", name:"VoiceList", component:()=>import('@/views/voice/List.vue'), meta: { title: "语音播报", keepAlive:true, isRoot:true } } ] }, { path: '/:pathMatch(.*)', name: 'error', component: () => import("@/views/404.vue"), meta: { title: '404' }, } ] const router=createRouter({ history:createWebHistory(import.meta.env.VITE_APP_BASE_URL), routes }) router.beforeEach((to, from, next) => { if (to.query.token) { store.commit('getToken', to.query.token) store.dispatch('getUserInfo') } if(to.meta.isRoot){ store.commit('setBreadCrumb', to) }else{ if(store.state.breadCrumbList.length==1){ store.commit('modifyBreadCrumb',to.meta.title) } } document.title=to.meta.title next(); }) export default router