fix: blank pages on /register and /apply

This commit is contained in:
FrenchGithubUser
2025-11-28 23:13:39 +01:00
parent 24786507dc
commit 70dfa83b37
3 changed files with 10 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div id="app-container" v-if="isAppReady">
<Toast position="top-right" group="tr" />
<div class="navbars-container" v-if="isProtectedRoute()">
<div class="navbars-container" v-if="isRouteProtected(route.path)">
<TopBar />
<MenuBar class="menu-bar" />
<SearchBars class="search-bars" />
@@ -27,6 +27,7 @@ import { ref } from 'vue'
import { useRoute } from 'vue-router'
import FooterBar from './components/FooterBar.vue'
import { useNotificationsStore } from './stores/notifications'
import { isRouteProtected } from './services/helpers'
// enable dark mode by default
document.documentElement.classList.add('dark-theme')
@@ -36,15 +37,8 @@ const route = useRoute()
const router = useRouter()
const siteName = import.meta.env.VITE_SITE_NAME
const isProtectedRoute = (path?: string) => {
if (path === undefined) {
path = route.path
}
return ['/login', '/register', '/apply', '/home/index.html'].indexOf(path) < 0
}
router.beforeEach(async (to, from, next) => {
if (from.path === '/login' && isProtectedRoute(to.path)) {
if (from.path === '/login' && isRouteProtected(to.path)) {
await getAppReady(true)
}
if (to.meta.dynamicDocumentTitle) {
@@ -65,7 +59,7 @@ router.beforeEach(async (to, from, next) => {
})
router.afterEach(async (to) => {
if (to.path === '/login') {
if (!isRouteProtected(to.path)) {
isAppReady.value = true
}
})
@@ -73,7 +67,7 @@ router.afterEach(async (to) => {
const getAppReady = async (forceGetUser: boolean = false) => {
const token = localStorage.getItem('token')
if (isProtectedRoute() || forceGetUser) {
if (isRouteProtected(route.path) || forceGetUser) {
if (token) {
try {
// refresh user on page reload or fetch user after registration

View File

@@ -20,8 +20,8 @@ const menuItems = ref([
{ label: 'Collages', route: '/collages' },
{ label: 'Requests', route: '/torrent-requests' },
{ label: 'Forum', route: '/forum' },
{ label: 'IRC', route: '' },
{ label: 'Top', route: '' },
// { label: 'IRC', route: '' },
// { label: 'Top', route: '' },
{ label: 'Rules', route: '/wiki/article/1' },
{ label: 'Wiki', route: '/wiki/article/1' },
{ label: 'Tags', route: '/title-group-tags' },

View File

@@ -369,3 +369,6 @@ export const scrollToHash = () => {
export const getHostname = () => {
return window.location.hostname
}
export const isRouteProtected = (path: string) => {
return ['/login', '/register', '/apply', '/home/index.html'].indexOf(path) < 0
}