inspire.vue
1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
<v-layout>
<v-flex class="text-center">
<div
v-if="me">
<v-btn @click="logout">로그아웃</v-btn>
</div>
<div
v-else>
<div
v-if="tryLogin">
<login-component/>
<v-btn @click="changeTryLogin">회원가입</v-btn>
</div>
<div
v-else>
<sign-up-component/>
<v-btn @click="changeTryLogin">로그인</v-btn>
</div>
</div>
<v-btn @click="socialLogin">소셜로그인</v-btn>
</v-flex>
</v-layout>
</template>
<script>
import LoginComponent from "../components/LoginComponent";
import SignUpComponent from "../components/SignUpComponent";
export default {
data() {
return {
tryLogin: true,
}
},
computed: {
me() {
return this.$store.state.user.me
}
},
components: {
LoginComponent,
SignUpComponent,
},
methods: {
changeTryLogin() {
this.tryLogin = !this.tryLogin
},
async logout() {
try {
await this.$store.dispatch('user/logout');
await this.$router.replace('/');
} catch (e) {
console.error(e);
}
},
async socialLogin(){
try{
if(process.client){
console.log('zzz')
window.open('http://ec2-54-180-112-94.ap-northeast-2.compute.amazonaws.com:8080/accounts/google/login/')
}
console.log('z')
await this.$store.dispatch('user/socialLogin');
await this.$router.replace('/');
}catch(e){
console.error(e);
}
},
}
}
</script>