2024-10-22 19:28:45 +03:00
|
|
|
|
<template>
|
2024-10-28 12:59:00 +03:00
|
|
|
|
<v-card class="bg-gradient" style="height: 100%" :class="isWide ? '' : 'd-flex justify-center align-center'">
|
2024-10-22 19:28:45 +03:00
|
|
|
|
<v-card-text class="d-flex justify-center align-center">
|
2024-10-28 12:59:00 +03:00
|
|
|
|
<v-card class="align-center justify-center h-auto w-66 card-bg" :class="isWide ? 'w-66' : 'w-100'">
|
|
|
|
|
<v-card-title class="d-flex justify-space-between" :class="isWide ? '' : 'text-subtitle-1'">
|
|
|
|
|
<div v-if="isWide">
|
|
|
|
|
<!-- Добро пожаловать в <router-link :to="isAuthenticated ? '/wishlist' : '/auth_options'" class="link-no-decor">Wishlist</router-link>, {{ isAuthenticated ? user['name'] : 'Гость' }}! -->
|
2024-10-26 22:08:51 +03:00
|
|
|
|
<span>Добро пожаловать в </span>
|
|
|
|
|
<span><router-link :to="isAuthenticated ? '/wishlist' : '/auth_options'" class="link-no-decor">Wishlist</router-link>, </span>
|
|
|
|
|
<span v-if="isAuthenticated">{{ this.user['name'] }}!</span>
|
|
|
|
|
<span v-else>Гость!</span>
|
|
|
|
|
</div>
|
2024-10-28 12:59:00 +03:00
|
|
|
|
<div v-if="!isWide">
|
|
|
|
|
<p>Добро пожаловать в</p>
|
|
|
|
|
<p><router-link :to="isAuthenticated ? '/wishlist' : '/auth_options'" class="link-no-decor">Wishlist</router-link>, {{ isAuthenticated ? user['name'] : 'Гость' }}!</p>
|
|
|
|
|
</div>
|
2024-10-26 22:08:51 +03:00
|
|
|
|
<span v-if="isAuthenticated" class="link-no-decor align-end" @click="logout">Выйти</span>
|
|
|
|
|
</v-card-title>
|
|
|
|
|
<v-card-text class="d-flex justify-center align-center">
|
2024-10-28 11:36:45 +03:00
|
|
|
|
<v-skeleton-loader class="w-100" color="grey-darken-4" type="card" v-if="fetchingUser"></v-skeleton-loader>
|
|
|
|
|
<router-view v-else/>
|
2024-10-22 19:28:45 +03:00
|
|
|
|
</v-card-text>
|
|
|
|
|
</v-card>
|
|
|
|
|
</v-card-text>
|
|
|
|
|
</v-card>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-10-26 22:08:51 +03:00
|
|
|
|
import {useUserStore} from "../store/user.js";
|
|
|
|
|
import {watch} from "vue";
|
2024-10-22 19:28:45 +03:00
|
|
|
|
export default {
|
|
|
|
|
name: "Welcome",
|
|
|
|
|
data: () => ({
|
2024-10-26 22:08:51 +03:00
|
|
|
|
isAuthenticated: false,
|
2024-10-28 11:36:45 +03:00
|
|
|
|
userStore: useUserStore(),
|
2024-10-28 12:59:00 +03:00
|
|
|
|
fetchingUser: false,
|
|
|
|
|
isWide: window.innerWidth >= 800
|
2024-10-22 19:28:45 +03:00
|
|
|
|
}),
|
2024-10-26 22:08:51 +03:00
|
|
|
|
computed: {
|
|
|
|
|
user() {
|
2024-10-26 22:55:29 +03:00
|
|
|
|
return this.userStore.user;
|
2024-10-26 22:08:51 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async logout() {
|
2024-10-26 22:55:29 +03:00
|
|
|
|
this.userStore.logout();
|
|
|
|
|
this.$router.push('/auth_options');
|
|
|
|
|
}
|
2024-10-26 22:08:51 +03:00
|
|
|
|
},
|
2024-10-22 19:28:45 +03:00
|
|
|
|
mounted() {
|
2024-10-28 11:36:45 +03:00
|
|
|
|
this.fetchingUser = true;
|
2024-10-22 19:28:45 +03:00
|
|
|
|
this.$router.push('/auth_options');
|
2024-10-26 22:55:29 +03:00
|
|
|
|
watch(this.userStore, (newStore, oldStore)=>{
|
2024-10-26 22:08:51 +03:00
|
|
|
|
this.isAuthenticated = newStore.user !== null && newStore.user !== undefined;
|
2024-10-28 11:36:45 +03:00
|
|
|
|
this.fetchingUser = false;
|
2024-10-26 22:08:51 +03:00
|
|
|
|
if (this.isAuthenticated) {
|
|
|
|
|
this.$router.push('/wishlist');
|
|
|
|
|
} else {
|
|
|
|
|
this.$router.push('/auth_options');
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-10-26 22:55:29 +03:00
|
|
|
|
this.userStore.checkUser();
|
2024-10-22 19:28:45 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
.bg-gradient {
|
|
|
|
|
background: linear-gradient(-45deg, #000610, #000f25, #00152f);
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|