mirror of
https://github.com/janishutz/MusicPlayer.git
synced 2026-09-10 14:25:24 +02:00
chore: more preparations
This commit is contained in:
+55
-1
@@ -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;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import {
|
||||
defineStore
|
||||
} from 'pinia';
|
||||
import {
|
||||
ref
|
||||
} from 'vue';
|
||||
|
||||
export const useAuthStore = defineStore( 'authstore', () => {
|
||||
const isAuth = ref( false );
|
||||
|
||||
return {
|
||||
isAuth
|
||||
};
|
||||
} );
|
||||
@@ -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 }
|
||||
})
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Player</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>MusicPlayer</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user