update
This commit is contained in:
15
src/router/generateRouter.js
Normal file
15
src/router/generateRouter.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import routesMap from "./routes-map.js";
|
||||
|
||||
const generateRouter = (routes) => {
|
||||
return routes.map(v => ({
|
||||
path: v.path,
|
||||
name: v.name,
|
||||
component: routesMap[v.component],
|
||||
children: v.children && v.children.length > 0 && [
|
||||
{path: '', redirect: `/home/${v.name}/${v.children[0].name}`},
|
||||
...generateRouter(v.children)
|
||||
],
|
||||
}))
|
||||
}
|
||||
|
||||
export default generateRouter;
|
||||
@@ -1,6 +1,7 @@
|
||||
import {createRouter, createWebHashHistory} from 'vue-router';
|
||||
import routes from "./routes.js";
|
||||
import {useUserStore} from "../pinia/UserStore/index.js";
|
||||
import {useSystemStore} from "../pinia/SystemStore/index.js";
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
@@ -9,6 +10,7 @@ const router = createRouter({
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const {isLogin} = useUserStore();
|
||||
const SystemStore = useSystemStore();
|
||||
|
||||
if (!isLogin && !to.path.includes('loginSYS')) {
|
||||
next({ path: '/loginSYS' });
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// const merchant = [
|
||||
// {
|
||||
// path: '/task-center',
|
||||
// name: 'task-center',
|
||||
// title: '任务中心',
|
||||
// icon: '',
|
||||
// component: () => import('../pages/merchant/pages/task-center/index.vue'),
|
||||
// children: [
|
||||
// {
|
||||
// path: '/reward-mission',
|
||||
// name: 'reward-mission',
|
||||
// title: '悬赏任务',
|
||||
// icon: '',
|
||||
// component: () => import('../pages/merchant/pages/task-center/reward-mission.vue'),
|
||||
// },
|
||||
// {
|
||||
// path: '/appointed-task',
|
||||
// name: 'appointed-task',
|
||||
// title: '任务指派',
|
||||
// icon: '',
|
||||
// component: () => import('../pages/merchant/pages/task-center/appointed-task.vue'),
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// ]
|
||||
//
|
||||
// export default merchant;
|
||||
@@ -1,7 +1,7 @@
|
||||
const routesMap = {
|
||||
'task-center': import('../pages/merchant/pages/task-center/index.vue'),
|
||||
'reward-mission': import('../pages/merchant/pages/task-center/reward-mission.vue'),
|
||||
'appointed-task': import('../pages/merchant/pages/task-center/appointed-task.vue'),
|
||||
'task-center': () => import('../pages/merchant/pages/task-center/index.vue'),
|
||||
'reward-mission': () => import('../pages/merchant/pages/task-center/reward-mission.vue'),
|
||||
'appointed-task': () => import('../pages/merchant/pages/task-center/appointed-task.vue'),
|
||||
};
|
||||
|
||||
export default routesMap;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import routesMap from "./routes-map.js";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
@@ -7,6 +9,7 @@ const routes = [
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: () => import('../pages/layout/index.vue'),
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
path: '/loginSYS',
|
||||
|
||||
Reference in New Issue
Block a user