Texte + Auth discord en cours
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
import IndexView from '../views/IndexView.vue'
|
||||
import HomeView from '../views/Index/HomeView.vue'
|
||||
import AboutView from '../views/Index/AboutView.vue'
|
||||
|
||||
import DiscordView from '../views/DiscordView.vue'
|
||||
import DashboardView from '../views/Discord/DashboardView.vue'
|
||||
import ConfigView from '../views/Discord/ConfigView.vue'
|
||||
import { inject } from 'vue'
|
||||
import type { VueCookies } from 'vue-cookies'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
@@ -14,38 +8,50 @@ const router = createRouter({
|
||||
{
|
||||
path: '/',
|
||||
name: 'index',
|
||||
component: IndexView,
|
||||
component: () => import('../views/IndexView.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'home',
|
||||
component: HomeView
|
||||
component: () => import('../views/Index/HomeView.vue')
|
||||
},
|
||||
{
|
||||
path: '/about',
|
||||
name: 'about',
|
||||
component: AboutView
|
||||
component: () => import('../views/Index/AboutView.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/discord',
|
||||
name: 'discord',
|
||||
component: DiscordView,
|
||||
component: () => import('../views/DiscordView.vue'),
|
||||
meta: { discordAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'dashboard',
|
||||
component: DashboardView
|
||||
component: () => import('../views/Discord/DashboardView.vue')
|
||||
},
|
||||
{
|
||||
path: '/config',
|
||||
name: 'config',
|
||||
component: ConfigView
|
||||
component: () => import('../views/Discord/ConfigView.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const $cookies = inject<VueCookies>('$cookies')
|
||||
if (!$cookies) return console.log('Error: $cookies is not injected')
|
||||
|
||||
if (to.meta.discordAuth && !$cookies.isKey('DISCORD_CODE')) {
|
||||
window.location.href =
|
||||
'https://discord.com/oauth2/authorize?client_id=1274800564449841172&response_type=code&redirect_uri=https%3A%2F%2Fmainframe.zac.ovh%2Fdiscord&scope=identify'
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user