blob: 2ab4a5d7236ec6e914de1f1343b971d3b8811210 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Vue from 'vue'
import Router, { RouteConfig } from 'vue-router'
/* Layout */
import Layout from '@/layout/index.vue'
/* Router modules */
import SchemaRoutesRouter from './modules/schema/routes'
import SchemaConsumersRouter from './modules/schema/consumers'
import SchemaServicesRouter from './modules/schema/services'
import SchemaSSLRouter from './modules/schema/ssl'
import SchemaUpstreamRouter from './modules/schema/upstream'
Vue.use(Router)
export const constantRoutes: RouteConfig[] = [
{
path: '/login',
component: () => import('@/views/login/index.vue'),
meta: { hidden: true }
},
{
path: '/',
component: Layout,
redirect: '/schema/routes/list'
}
]
/**
* asyncRoutes
* the routes that need to be dynamically loaded based on user roles
*/
export const asyncRoutes: RouteConfig[] = [
SchemaRoutesRouter,
SchemaConsumersRouter,
SchemaServicesRouter,
SchemaSSLRouter,
SchemaUpstreamRouter,
{
path: '*',
redirect: '/404',
meta: { hidden: true }
}
]
const createRouter = () => new Router({
scrollBehavior: (to, from, savedPosition) => {
if (savedPosition) {
return savedPosition
} else {
return { x: 0, y: 0 }
}
},
base: process.env.BASE_URL,
routes: constantRoutes
})
const router = createRouter()
export function resetRouter() {
const newRouter = createRouter();
(router as any).matcher = (newRouter as any).matcher // reset router
}
export default router