ki-frontend/src/router/index.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-08-02 19:06:41 +02:00
// SPDX-License-Identifier: AGPL-3.0-or-later
2021-05-31 16:14:28 +02:00
import { createRouter, createWebHistory } from 'vue-router'
2021-06-07 17:41:25 +02:00
import Index from '@/views/Index.vue'
import Search from '@/views/Search.vue'
import Edit from '@/views/profile/Edit.vue'
import View from '@/views/profile/View.vue'
2021-05-31 16:14:28 +02:00
const routes = [
{
2021-06-07 17:41:25 +02:00
path: '/s',
name: 's',
component: {
template: "<router-view/>",
},
beforeEnter: (to, from, next) => {
if(localStorage.getItem('token') !== null){
next()
}else{
next({path: '/', query: {url: to.fullPath, access: false}})
}
2021-06-07 17:41:25 +02:00
},
children: [
{
path: 'search',
name: 'Search',
component: Search
},
{
2021-07-26 17:10:28 +02:00
path: 'profile/:memberId',
2021-06-07 17:41:25 +02:00
name: 'ProfileMember',
component: View
},
{
path: 'profile-edit',
2021-06-07 17:41:25 +02:00
name: 'ProfileEdit',
component: Edit
},
]
2021-05-31 16:14:28 +02:00
},
{
2021-06-07 17:41:25 +02:00
path: '/',
name: 'Index',
component: Index
},
2021-05-31 16:14:28 +02:00
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
2021-08-02 19:06:41 +02:00
export default router