feat: add frontend
This commit is contained in:
51
frontend/src/router/index.js
Normal file
51
frontend/src/router/index.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import HomeView from '../views/tabs/HomeView.vue'
|
||||
import TabView from '../views/TabView.vue'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: '/tab',
|
||||
name: 'tab',
|
||||
component: TabView,
|
||||
children: [
|
||||
{
|
||||
path: 'home',
|
||||
name: 'tab.home',
|
||||
component: HomeView,
|
||||
},
|
||||
{
|
||||
path: 'bought',
|
||||
name: 'tab.bought',
|
||||
component: () => import('../views/tabs/BoughtView.vue'),
|
||||
},
|
||||
{
|
||||
path: 'me',
|
||||
name: 'tab.me',
|
||||
// route level code-splitting
|
||||
// this generates a separate chunk (About.[hash].js) for this route
|
||||
// which is lazy-loaded when the route is visited.
|
||||
component: () => import('../views/tabs/MeView.vue'),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/play/{:id}',
|
||||
name: 'play',
|
||||
component: () => import('../views/PlayView.vue'),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to, from) => {
|
||||
console.log("from", from, "goto: ", to)
|
||||
|
||||
if (to.path === "/" && from.path === "/") {
|
||||
console.log("redirecting to tab.home")
|
||||
return { name: "tab.home" }
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user