67 行
4.1 KiB
JavaScript
67 行
4.1 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: () => import('../views/Login.vue'),
|
|
meta: { public: true },
|
|
},
|
|
{
|
|
path: '/',
|
|
component: () => import('../components/layout/AdminLayout.vue'),
|
|
children: [
|
|
{ path: '', name: 'Dashboard', component: () => import('../views/Dashboard.vue') },
|
|
{ path: 'brand', name: 'Brand', component: () => import('../views/brand/BrandEdit.vue') },
|
|
{ path: 'products', name: 'Products', component: () => import('../views/products/ProductList.vue') },
|
|
{ path: 'products/summer-camp', name: 'SummerCamp', component: () => import('../views/products/SummerCampEdit.vue') },
|
|
{ path: 'products/selection-guide', name: 'SelectionGuide', component: () => import('../views/products/SelectionGuideEdit.vue') },
|
|
{ path: 'products/autumn', name: 'AutumnProducts', component: () => import('../views/products/AutumnProductList.vue') },
|
|
{ path: 'products/winter', name: 'WinterProducts', component: () => import('../views/products/WinterProductList.vue') },
|
|
{ path: 'products/winter-camp', name: 'WinterCamp', component: () => import('../views/products/WinterCampEdit.vue') },
|
|
{ path: 'destinations', name: 'Destinations', component: () => import('../views/destinations/DestinationEdit.vue') },
|
|
{ path: 'faq', name: 'FAQ', component: () => import('../views/faq/FaqList.vue') },
|
|
{ path: 'reviews', name: 'Reviews', component: () => import('../views/reviews/ReviewList.vue') },
|
|
{ path: 'about', name: 'About', component: () => import('../views/about/AboutEdit.vue') },
|
|
{ path: 'contact', name: 'Contact', component: () => import('../views/contact/ContactList.vue') },
|
|
{ path: 'seo', name: 'SEO', component: () => import('../views/seo/SeoList.vue') },
|
|
{ path: 'navigation', name: 'Navigation', component: () => import('../views/navigation/NavigationEdit.vue') },
|
|
{ path: 'versions', name: 'Versions', component: () => import('../views/versions/VersionTimeline.vue') },
|
|
{ path: 'guides', name: 'Guides', component: () => import('../views/guides/GuideList.vue') },
|
|
{ path: 'site-images', name: 'SiteImages', component: () => import('../views/site-images/SiteImageList.vue') },
|
|
{ path: 'users', name: 'Users', component: () => import('../views/users/UserList.vue') },
|
|
{ path: 'export', name: 'Export', component: () => import('../views/export/ExportPanel.vue') },
|
|
{ path: 'blog', name: 'Blog', component: () => import('../views/blog/BlogList.vue') },
|
|
{ path: 'stories', name: 'Stories', component: () => import('../views/stories/StoryList.vue') },
|
|
{ path: 'news', name: 'News', component: () => import('../views/news/NewsList.vue') },
|
|
{ path: 'pricing', name: 'Pricing', component: () => import('../views/pricing/PricingList.vue') },
|
|
{ path: 'qualifications', name: 'Qualifications', component: () => import('../views/qualifications/QualificationList.vue') },
|
|
{ path: 'partners', name: 'Partners', component: () => import('../views/partners/PartnerList.vue') },
|
|
{ path: 'calendar', name: 'Calendar', component: () => import('../views/calendar/CalendarEdit.vue') },
|
|
{ path: 'destinations-detail', name: 'DestinationsDetail', component: () => import('../views/destinations-detail/DestinationsDetailList.vue') },
|
|
{ path: 'gallery', name: 'Gallery', component: () => import('../views/gallery/GalleryList.vue') },
|
|
{ path: 'courses', name: 'Courses', component: () => import('../views/courses/CoursesEdit.vue') },
|
|
{ path: 'selector', name: 'Selector', component: () => import('../views/selector/SelectorEdit.vue') },
|
|
{ path: 'customize/submissions', name: 'CustomizeSubmissions', component: () => import('../views/customize/CustomizeSubmissions.vue') },
|
|
],
|
|
},
|
|
{ path: '/:pathMatch(.*)*', redirect: '/' },
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes,
|
|
})
|
|
|
|
// Auth guard
|
|
router.beforeEach((to, from, next) => {
|
|
const token = localStorage.getItem('token')
|
|
if (!to.meta.public && !token) {
|
|
next('/login')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|