import Vue from 'vue' import store from '@/store' import VueRouter from 'vue-router' import { publicPath, routerMode } from '@/config' Vue.use(VueRouter) // 通用路由 export const constantRoutes = [ { path: '/login', name: 'login', component: () => import('@/views/login/index'), hidden: true, }, { name: 'security', path: '/security', component: () => import('@/views/personal/security/index'), hidden: true, }, { name: 'tenantLogin', path: '/login/:tenant', component: () => import('@/views/login/index'), props: true, hidden: true, }, { path: '/loading', component: () => import('@/views/login/Loading.vue'), hidden: true, }, { path: '/401', name: '401', component: () => import('@/views/401'), hidden: true, }, { path: '/column/preview/:previewAlias', name: 'ColumnPreview', component: () => import('@/views/home/components/ColumnPreview.vue'), props: true, hidden: true, }, //表单预览菜单 { path: '/formPreview/:formId', name: 'formPreview', component: () => import('@/components/form/FormPreview'), props: true, hidden: true, }, { path: '/sysModulePreview/:id/:appName', name: 'sysModulePreview', component: () => import('@/components/sysModule'), props: true, hidden: true, }, { path: '/app/:id', name: 'app', component: () => import('@/views/app/index.vue'), props: true, hidden: true, meta: { title: '应用内容' }, }, { path: '/', component: () => import('@/components/layouts'), // redirect: 'index', children: [ { path: '/mapview', name: 'mapview', component: () => import('@/views/mapView/index'), hidden: true, meta: { title: '地图查看' }, }, { path: '/compare', name: 'compare', component: () => import('@/views/dbtj/compare.vue'), hidden: true, meta: { title: '详细对比' }, }, { path: '/personal/information', name: 'information', component: () => import('@/views/personal/index'), hidden: true, meta: { title: '个人中心' }, }, { path: '/templateForm/:templateKey/:action', component: () => import('@/components/dataTemplate/TemplateForm.vue'), name: 'templateForm', hidden: true, props: true, meta: { title: '表单详情' }, }, { path: '/templateForm/:templateKey/:action/:data', component: () => import('@/components/dataTemplate/TemplateForm.vue'), name: 'templateForm_withData', hidden: true, props: true, meta: { title: '表单列表' }, }, { path: '/templateDraftList/:tempAlias/:dataViewFlag', component: () => import('@/components/dataTemplate/TemplateForm.vue'), name: 'templateForm', hidden: true, props: true, meta: { title: '表单列表草稿' }, }, { path: '/appContent', name: 'appContent', component: () => import('@/views/appCenter/appContent/index.vue'), props: true, meta: { title: '应用内容' }, }, { path: '/templatePreview/:templateKey/:parameterqQuerys/:rkey', name: 'templatePreview', component: () => import('@/components/dataTemplate/TemplatePreview.vue'), hidden: true, props: true, meta: { title: '查询数据' }, }, ], }, { path: '/gasCylinderManage', component: () => import('@/components/layouts'), // redirect: 'index', children: [ { path: '/mapview', name: 'gasCylinderMap', component: () => import('@/views/pages/gasCylinderManage/gasCylinderMap/index'), hidden: true, meta: { title: '地图查看' }, }, ], }, { path: '/orderStatistics', component: () => import('@/components/layouts'), children: [ { path: '/mapview', name: 'orderStatistics', component: () => import('@/views/pages/orderStatistics/index'), meta: { title: '统计' }, }, ], }, { path: '/500', name: '500', component: () => import('@/views/500'), hidden: true, }, { path: '/404', name: '404', component: () => import('@/views/404'), hidden: true, }, { path: '/403', name: '403', component: () => import('@/views/403'), hidden: true, }, //企微钉钉路由 //钉钉 { path: '/dingTalk', name: 'dingTalk', component: () => import('@/components/jump/dt_jump.vue'), props: true, hidden: true, meta: { single: true, anonymous: true, }, }, //钉钉-租户 { path: '/login/:tenant/dingTalk', name: 'dingTalk', component: () => import('@/components/jump/dt_jump.vue'), props: true, hidden: true, meta: { single: true, anonymous: true, }, }, //飞书 { path: '/flyBook', name: 'flyBook', component: () => import('@/components/jump/flybook_jump.vue'), props: true, hidden: true, meta: { single: true, anonymous: true, }, }, //飞书-租户 { path: '/login/:tenant/flyBook', name: 'flyBook', component: () => import('@/components/jump/flybook_jump.vue'), props: true, hidden: true, meta: { single: true, anonymous: true, }, }, //企业微信 { path: '/weChat', name: 'weChat', component: () => import('@/components/jump/wcw_jump.vue'), props: true, hidden: true, meta: { single: true, anonymous: true, }, }, //企业微信-租户 { path: '/login/:tenant/weChat', name: 'weChat', component: () => import('@/components/jump/wcw_jump.vue'), props: true, hidden: true, meta: { single: true, anonymous: true, }, }, { path: '/lpg', component: () => import('@/components/layouts'), // redirect: 'index', children: [ { path: '/addOrder', name: 'addOrder', component: () => import('@/views/pages/newOrder/index'), hidden: true, meta: { title: '新增订单' }, }, ], }, ] const router = new VueRouter({ base: publicPath, mode: routerMode, scrollBehavior: () => ({ y: 0, }), routes: constantRoutes, }) const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location, onResolve, onReject) { if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) return originalPush.call(this, location).catch((err) => err) } export function resetRouter() { store.dispatch('routes/cleanRoutes') router.matcher = new VueRouter({ base: publicPath, mode: routerMode, scrollBehavior: () => ({ y: 0, }), routes: constantRoutes, }).matcher } export default router