Renamed the router/index.js to router/router.js to easy code review

This commit is contained in:
Jonathan Bourdon
2024-08-04 22:12:49 -04:00
parent 1b43f0434c
commit feb5f5003d
2 changed files with 1 additions and 1 deletions

145
src/router/router.js Normal file
View File

@@ -0,0 +1,145 @@
import { createRouter, createWebHistory } from 'vue-router'
import About from '@/views/documentation/About.vue'
import ContentPolicy from '@/views/documentation/ContentPolicy.vue'
import FAQ from '@/views/documentation/FAQ.vue'
import Pricing from '@/views/documentation/Pricing.vue'
import CreatorGuide from '@/views/documentation/CreatorGuide.vue'
import HelpAndContact from '@/views/documentation/HelpAndContact.vue'
import TermsAndConditions from '@/views/documentation/TermsAndConditions.vue'
import LoginView from '../views/LoginView.vue'
import PaymentCompleted from '../views/PayementCompleted.vue'
import SignupView from '../views/SignupView.vue'
import Join from '../views/main/Join.vue'
import Home from '../views/main/Home.vue'
import Wallet from '../views/main/Wallet.vue'
import Profile from '../views/main/Profile.vue'
import CreatorList from '../views/creators/CreatorList.vue'
import CreatorPage from "@/views/creators/CreatorPage.vue";
import ContentPage from "@/views/contents/ContentPage.vue";
import PostContent from "@/views/contents/PostContent.vue";
import {useAuthStore} from "@/stores/authStore.js";
const routes = [
{
path: '/',
component: Home,
meta: { hideSideBar: true }
},
{
path: '/browse',
component: CreatorList
},
{
path: '/content/:contentId',
component: ContentPage
},
{
path: '/@:creator',
component: CreatorPage
},
{
path: '/creators/@:creator',
component: Profile
},
{
path: '/content/post',
component: PostContent,
},
{
path: '/helpandcontact',
component: HelpAndContact,
meta: { hideSideBar: true }
},
{
path: '/termsandconditions',
name: 'termsandconditions',
component: TermsAndConditions,
meta: { hideSideBar: true }
},
{
path: '/contentpolicy',
name: 'contentpolicy',
component: ContentPolicy,
meta: { hideSideBar: true }
},
{
path: '/faq',
name: 'FAQ',
component: FAQ,
meta: { hideSideBar: true }
},
{
path: '/guideforcreators',
name: 'guideforcreators',
component: CreatorGuide,
meta: { hideSideBar: true }
},
{
path: '/about',
name: 'about',
component: About,
meta: { hideSideBar: true }
},
{
path: '/pricing',
name: 'pricing',
component: Pricing,
meta: { hideSideBar: true }
},
{
path: '/join',
name: 'join',
component: Join,
meta: { hideSideBar: true }
},
{
path: '/signup',
name: 'signup',
component: SignupView
},
{
path: '/login',
name: 'login',
component: LoginView
},
{
path: '/paymentcompleted',
name: 'PayementCompleted',
component: PaymentCompleted,
},
{
path: '/wallet',
name: 'wallet',
component: Wallet,
meta: { requiresAuth: true }
},
{
path: '/profile',
name: 'profile',
component: Profile,
meta: { requiresAuth: true }
},
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes
})
// Navigation gards
router.beforeEach((to, from, next) => {
const authStore = useAuthStore();
if (to.matched.some(record => record.meta.requiresAuth)) {
if (!authStore.isAuthenticated) {
next('/');
} else {
next();
}
} else {
next();
}
})
export default router;