роуты для авторизованных пользователей больше не доступы без авторизации
This commit is contained in:
parent
24b41d9036
commit
838c14a4ff
|
|
@ -35,7 +35,7 @@
|
|||
</template>
|
||||
</span>
|
||||
</div>
|
||||
<template v-if="user?.id">
|
||||
<div @click="handleAuthRequired">
|
||||
<q-skeleton v-if="loaderPlay" class="player__favorites m--skeleton" />
|
||||
<div
|
||||
v-else
|
||||
|
|
@ -43,10 +43,10 @@
|
|||
:class="[isFavorites && 'm--active']"
|
||||
@click="handlerFavorites"
|
||||
></div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="player__tools">
|
||||
<q-skeleton v-if="loaderPlay" class="player__tools m--skeleton" />
|
||||
<div v-else @click="toggleMyMusic">
|
||||
<div v-else @click="handleAuthRequired">
|
||||
<FormKit
|
||||
v-model="isUserMusic"
|
||||
type="toggle"
|
||||
|
|
@ -365,14 +365,14 @@ export default {
|
|||
}
|
||||
},
|
||||
changeVolume() {
|
||||
console.log(this.songVolume);
|
||||
// console.log(this.songVolume);
|
||||
this.$store.dispatch('handlerPlayer', { volume: this.songVolume });
|
||||
},
|
||||
toggleVolume() {
|
||||
if (this.songVolume === 0) {
|
||||
this.songVolume = this.preToggleVol;
|
||||
// console.log(this.songVolume);
|
||||
this.$store.dispatch('handlerPlayer', { volume: this.songVolume });
|
||||
this.$store.dispatch('handlerPlayer', { volume: this.preToggleVol });
|
||||
} else {
|
||||
this.preToggleVol = this.songVolume;
|
||||
this.songVolume = 0.0;
|
||||
|
|
@ -380,7 +380,7 @@ export default {
|
|||
this.$store.dispatch('handlerPlayer', { volume: this.songVolume });
|
||||
}
|
||||
},
|
||||
toggleMyMusic(e) {
|
||||
handleAuthRequired(e) {
|
||||
if (this.user?.id) return;
|
||||
this.$store.dispatch('setModal', { auth: true });
|
||||
},
|
||||
|
|
|
|||
|
|
@ -49,15 +49,29 @@ export default route(function (/* { store, ssrContext } */) {
|
|||
});
|
||||
|
||||
Router.beforeEach((to, from, next) => {
|
||||
if (
|
||||
to.matched.some((record) => record.meta.requiresAuth) &&
|
||||
!process.env.SERVER
|
||||
) {
|
||||
if (store.state.user && store.state.user?.id) {
|
||||
// console.log(to);
|
||||
// console.log(process.env.SERVER);
|
||||
// if (
|
||||
// to.matched.some((record) => record.meta.requiresAuth) &&
|
||||
// !process.env.SERVER
|
||||
// ) {
|
||||
// if (store.state.user && store.state.user?.id) {
|
||||
// next();
|
||||
// } else {
|
||||
// next({ name: 'home' });
|
||||
// this.$store.dispatch('setShowAuthModal', true);
|
||||
// }
|
||||
// } else {
|
||||
// next();
|
||||
// }
|
||||
|
||||
// console.log(to);
|
||||
// console.log(from);
|
||||
if (to.meta.isAuth) {
|
||||
if (store.state.user) {
|
||||
next();
|
||||
} else {
|
||||
next({ name: 'home' });
|
||||
this.$store.dispatch('setShowAuthModal', true);
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ const routes = [
|
|||
component: profile,
|
||||
meta: {
|
||||
title: 'Личный кабинет',
|
||||
isAuth: false,
|
||||
isAuth: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue