|
@@ -6,6 +6,11 @@ Vue.use(Router)
|
|
|
/* Layout */
|
|
|
import Layout from '@/layout'
|
|
|
|
|
|
+import supplierRoutes from './modules/supplier'
|
|
|
+import authRoutes from './modules/auth'
|
|
|
+import productRoutes from './modules/product'
|
|
|
+import reviewRoutes from './modules/review'
|
|
|
+
|
|
|
/**
|
|
|
* Note: sub-menu only appear when route children.length >= 1
|
|
|
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
|
|
@@ -28,24 +33,8 @@ import Layout from '@/layout'
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
-/**
|
|
|
- * 默认路由 全部用户都可以访问
|
|
|
- * constantRoutes
|
|
|
- * a base page that does not have permission requirements
|
|
|
- * all roles can be accessed
|
|
|
- */
|
|
|
+// 默认路由列表 全部用户都可以访问
|
|
|
export const constantRoutes = [
|
|
|
- {
|
|
|
- path: '/redirect',
|
|
|
- component: Layout,
|
|
|
- hidden: true,
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: '/redirect/:path(.*)',
|
|
|
- component: () => import('@/views/redirect/index')
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
// 登录
|
|
|
{
|
|
|
path: '/login',
|
|
@@ -92,145 +81,27 @@ export const constantRoutes = [
|
|
|
}
|
|
|
]
|
|
|
|
|
|
-/**
|
|
|
- * 需要权限访问的路由
|
|
|
- * asyncRoutes
|
|
|
- * the routes that need to be dynamically loaded based on user roles
|
|
|
- */
|
|
|
+// 需要权限访问的路由列表
|
|
|
export const asyncRoutes = [
|
|
|
+ ...supplierRoutes,
|
|
|
+ ...authRoutes,
|
|
|
+ ...productRoutes,
|
|
|
+ ...reviewRoutes,
|
|
|
|
|
|
- // 供应商管理页面
|
|
|
- {
|
|
|
- path: '/supplier',
|
|
|
- component: Layout,
|
|
|
- alwaysShow: true,
|
|
|
- name: 'Supplier',
|
|
|
- redirect: '/supplier/list',
|
|
|
- meta: { title: '供应商管理', icon: 'el-icon-s-custom', roles: ['admin'], noCache: true },
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'list',
|
|
|
- component: () => import('@/views/supplier/user/index'),
|
|
|
- name: 'SupplierList',
|
|
|
- meta: { title: '供应商列表', icon: 'el-icon-menu', affix: true, roles: ['admin'], noCache: true }
|
|
|
- },
|
|
|
- {
|
|
|
- hidden: true,
|
|
|
- path: 'add',
|
|
|
- component: () => import('@/views/supplier/user/add'),
|
|
|
- name: 'SupplierAdd',
|
|
|
- meta: { title: '添加供应商', icon: 'el-icon-menu', roles: ['admin'], noCache: true }
|
|
|
- },
|
|
|
- {
|
|
|
- hidden: true,
|
|
|
- path: 'edit',
|
|
|
- component: () => import('@/views/supplier/user/edit'),
|
|
|
- name: 'SupplierEdit',
|
|
|
- meta: { title: '修改供应商', icon: 'el-icon-menu', roles: ['admin'], noCache: true }
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- // 授权管理页面
|
|
|
- {
|
|
|
- path: '/auth',
|
|
|
- component: Layout,
|
|
|
- alwaysShow: true,
|
|
|
- redirect: '/auth/list',
|
|
|
- name: 'Auth',
|
|
|
- meta: { title: '授权管理', icon: 'el-icon-s-promotion', roles: ['admin', 'normal'], noCache: true, proxy: true },
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'list',
|
|
|
- component: () => import('@/views/supplier/auth/index'),
|
|
|
- name: 'AuthList',
|
|
|
- meta: { title: '授权列表', icon: 'el-icon-menu', roles: ['admin', 'normal'], affix: true, noCache: true, proxy: true }
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- // 商品管理
|
|
|
- {
|
|
|
- path: '/product',
|
|
|
- component: Layout,
|
|
|
- alwaysShow: true,
|
|
|
- redirect: '/product/list',
|
|
|
- hidden: true,
|
|
|
- name: 'Product',
|
|
|
- meta: { title: '商品管理', icon: 'el-icon-s-shop', roles: ['admin', 'normal'], noCache: true, proxy: true },
|
|
|
- children: [
|
|
|
- {
|
|
|
- hidden: true,
|
|
|
- path: 'list',
|
|
|
- component: () => import('@/views/supplier/product/index'),
|
|
|
- name: 'ProductList',
|
|
|
- meta: { title: '商品列表', icon: 'el-icon-menu', roles: ['admin', 'normal'], noCache: true, proxy: true }
|
|
|
- },
|
|
|
- {
|
|
|
- hidden: true,
|
|
|
- path: 'add',
|
|
|
- component: () => import('@/views/supplier/product/add'),
|
|
|
- name: 'AddProduct',
|
|
|
- meta: { title: '添加商品', icon: 'el-icon-menu', roles: ['admin', 'normal'], noCache: true, proxy: true }
|
|
|
- },
|
|
|
- {
|
|
|
- hidden: true,
|
|
|
- path: 'edit',
|
|
|
- component: () => import('@/views/supplier/product/edit'),
|
|
|
- name: 'EditProduct',
|
|
|
- meta: { title: '修改商品', icon: 'el-icon-menu', roles: ['admin', 'normal'], noCache: true, proxy: true }
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- // 审核页面
|
|
|
- {
|
|
|
- path: '/review',
|
|
|
- component: Layout,
|
|
|
- alwaysShow: true,
|
|
|
- redirect: '/review/list',
|
|
|
- name: 'Review',
|
|
|
- meta: { title: '品牌授权审核', icon: 'el-icon-s-check', roles: ['admin'], noCache: true },
|
|
|
- children: [
|
|
|
- {
|
|
|
- path: 'list',
|
|
|
- component: () => import('@/views/supplier/review/index'),
|
|
|
- name: 'ReviewList',
|
|
|
- meta: { title: '审核列表', icon: 'el-icon-menu', roles: ['admin'], noCache: true }
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'auth-list',
|
|
|
- hidden: true,
|
|
|
- component: () => import('@/views/supplier/review/authList'),
|
|
|
- name: 'ReviewAuthList',
|
|
|
- meta: { title: '授权机构审核列表', icon: 'el-icon-menu', roles: ['admin'], noCache: true }
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'shop-list',
|
|
|
- hidden: true,
|
|
|
- component: () => import('@/views/supplier/review/shopList'),
|
|
|
- name: 'ShopList',
|
|
|
- meta: { title: '商品审核列表', icon: 'el-icon-menu', roles: ['admin'], noCache: true }
|
|
|
- },
|
|
|
- {
|
|
|
- path: 'shop-detail',
|
|
|
- hidden: true,
|
|
|
- component: () => import('@/views/supplier/review/shopDetail'),
|
|
|
- name: 'ShopDetail',
|
|
|
- meta: { title: '商品审核详情', icon: 'el-icon-menu', roles: ['admin'], noCache: true }
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- // 404页面
|
|
|
+ // 404页面 放在最后面
|
|
|
{ path: '*', redirect: '/404', hidden: true }
|
|
|
]
|
|
|
|
|
|
+// 创建路由对象
|
|
|
const createRouter = () =>
|
|
|
new Router({
|
|
|
- // mode: 'history', // require service support
|
|
|
scrollBehavior: () => ({ y: 0 }),
|
|
|
routes: constantRoutes
|
|
|
})
|
|
|
|
|
|
const router = createRouter()
|
|
|
|
|
|
+// 重置路由
|
|
|
export function resetRouter() {
|
|
|
const newRouter = createRouter()
|
|
|
router.matcher = newRouter.matcher // reset router
|