import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/home',
            name: 'home',
            component: () => import('../views/HomeView.vue')
        },
        {
            path: '/news',
            name: 'news',
            component: () => import('../views/NewsView.vue')
        },
        {
            path: '/newsDetail',
            name: 'newsDetail',
            component: () => import('../views/NewsDetailView.vue'),
            meta: {
                index: '/news'
            }
        },
        {
            path: '/about',
            name: 'about',
            component: () => import('../views/AboutView.vue')
        },
        {
            path: '/connect',
            name: 'connect',
            component: () => import('../views/ConnectView.vue')
        },
        {
            path: '/video',
            name: 'video',
            component: () => import('../views/VideoView.vue')
        }
    ]
})
router.beforeEach((to, from, next) => {
    document.getElementById('app').scrollTop = 0
    next()
})
export default router
