chore: more preparations

This commit is contained in:
2026-08-21 17:48:39 +02:00
parent 494eef6cd2
commit d03fbe5e66
7 changed files with 87 additions and 62 deletions
+55 -1
View File
@@ -1,10 +1,64 @@
import {
useAuthStore
} from '@/stores/authstore';
import {
createRouter, createWebHistory
} from 'vue-router';
const router = createRouter( {
'history': createWebHistory( import.meta.env.BASE_URL ),
'routes': []
'routes': [
{
'path': '/',
'name': 'home',
'component': () => import( '@/views/StartPage.vue' ),
'meta': {
'title': 'Home',
'auth': false
}
},
{
'path': '/app',
'name': 'app',
'component': () => import( '@/views/AppView.vue' ),
'meta': {
'title': 'Player',
'auth': true
}
},
{
'path': '/:pathMatch(.*)*',
'name': 'NotFound',
'component': () => import( '@/views/404View.vue' ),
'meta': {
'title': '404 :: Page not found',
'transition': 'scale'
}
}
]
} );
router.beforeEach( ( to, from ) => {
const store = useAuthStore();
if ( to.meta.authRequired && !store.isAuth ) {
return {
'name': 'login'
};
} else if ( ( to.name === 'login' && store.isAuth ) || ( to.name === 'signup' && store.isAuth ) ) {
return {
'name': 'app-home'
};
}
} );
router.afterEach( to => {
window.scrollTo( {
'top': 0,
'behavior': 'smooth'
} );
document.title = to.meta.title ? to.meta.title + ' - MusicPlayer' : 'MusicPlayer';
// NProgress.done();
} );
export default router;
+14
View File
@@ -0,0 +1,14 @@
import {
defineStore
} from 'pinia';
import {
ref
} from 'vue';
export const useAuthStore = defineStore( 'authstore', () => {
const isAuth = ref( false );
return {
isAuth
};
} );
-12
View File
@@ -1,12 +0,0 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', () => {
const count = ref(0)
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
return { count, doubleCount, increment }
})
+6 -7
View File
@@ -1,7 +1,10 @@
<template>
<div class="home-view">
<img src="https://github.com/simplePCBuilding/MusicPlayerV2/raw/master/assets/logo.png" alt="MusicPlayer Logo" class="logo">
<div class="not-found-view">
<h1>404</h1>
<p>Page not found</p>
<RouterLink to="/" class="button primary">
Home
</RouterLink>
</div>
</template>
@@ -10,15 +13,11 @@
</script>
<style scoped>
.home-view {
.not-found-view {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.logo {
height: 50vh;
}
</style>
+5
View File
@@ -0,0 +1,5 @@
<template>
<div>
<h1>Player</h1>
</div>
</template>
+5
View File
@@ -0,0 +1,5 @@
<template>
<div>
<h1>MusicPlayer</h1>
</div>
</template>