|
|
@@ -1,24 +1,30 @@
|
|
|
-import { createRouter, createWebHistory } from "vue-router";
|
|
|
+import {createRouter, createWebHistory} from "vue-router";
|
|
|
|
|
|
const router = createRouter({
|
|
|
history: createWebHistory(),
|
|
|
routes: [{
|
|
|
path: '/',
|
|
|
redirect: '/login',
|
|
|
- },{
|
|
|
+ }, {
|
|
|
path: '/login',
|
|
|
component: () => import('../components/Login.vue'),
|
|
|
- },{
|
|
|
+ }, {
|
|
|
path: '/register',
|
|
|
component: () => import('../components/Register.vue'),
|
|
|
}, {
|
|
|
path: '/home',
|
|
|
- component: () => import('../views/Home.vue'),
|
|
|
+ redirect: '/allStore',
|
|
|
+ component: () => import('../views/portal/Home.vue'),
|
|
|
children: [
|
|
|
+ {
|
|
|
+ path: '/allStore',
|
|
|
+ name: 'allStore',
|
|
|
+ component: () => import('../views/portal/AllStore.vue'),
|
|
|
+ },
|
|
|
{
|
|
|
path: '/dashboard',
|
|
|
name: 'Dashboard',
|
|
|
- component: () => import('../components/Dashboard.vue'),
|
|
|
+ component: () => import('../views/portal/Dashboard.vue'),
|
|
|
meta: {
|
|
|
title: '个人信息'
|
|
|
}
|
|
|
@@ -26,7 +32,7 @@ const router = createRouter({
|
|
|
]
|
|
|
}, {
|
|
|
path: '/manager/createStore',
|
|
|
- component: () => import('../views/store/CreateStore.vue'),
|
|
|
+ component: () => import('../views/Manager/CreateStore.vue'),
|
|
|
}]
|
|
|
})
|
|
|
|
|
|
@@ -35,11 +41,20 @@ router.beforeEach((to, from, next) => {
|
|
|
|
|
|
console.log(role);
|
|
|
|
|
|
- if (!role && to.path !== '/login') {
|
|
|
- next('/login');
|
|
|
- } else {
|
|
|
+ if (role) {
|
|
|
next();
|
|
|
+ } else {
|
|
|
+ if(to.path === '/login') {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ else if(to.path === '/register') {
|
|
|
+ next();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ next('/login');
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
export {router};
|