Skip to content

Commit

Permalink
state 수정 중
Browse files Browse the repository at this point in the history
  • Loading branch information
WickiesHub committed Mar 26, 2019
1 parent 38c70a2 commit 1e2a491
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 75 deletions.
49 changes: 23 additions & 26 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ import animals from './data/animals.json'
export default {
name: 'App',
created(){
this.getAPIs()
this.$EventBus.$on('goBeforePage', this.goBeforePage)
this.$EventBus.$on('goAfterPage', this.goAfterPage)
this.$EventBus.$on('goLoadingPage', this.goLoadingPage)
this.$EventBus.$on('setSearchHistory', this.setSearchHistory)
this.$EventBus.$on('refreshMember', this.refreshMember)
this.$EventBus.$on('search', this.search)
const token = this.getToken()
this.backImg = localStorage.getItem("theme") != null ? localStorage.getItem("theme") : this.backImg
if(token !== null){
this.$http.get(`http://52.79.204.244/member?email=${token.email}`).then(res => {
this.$store.dispatch('SETMEMBER', res.data)
this.setCustomKeywords(res.data.email)
this.setSearchHistory(res.data.email)
})
} else {
// TODO anonymous@NAM 고치기
this.setMemberState('anonymous@NAM', '익명의 ' + animals[Math.floor(Math.random() * animals.length)] , null)
this.setCustomKeywords(`anonymous@NAM`)
this.setSearchHistory(`anonymous@NAM`)
}
},
components: {
'BottomPanel' : BottomPanel,
'Start' : Start,
Expand Down Expand Up @@ -79,6 +102,7 @@ export default {
methods: {
setState(){
const token = this.getToken()
console.log(token)
this.backImg = localStorage.getItem("theme") != null ? localStorage.getItem("theme") : this.backImg
if(token !== null){
this.$http.get(`http://52.79.204.244/member?email=${token.email}`).then(res => {
Expand Down Expand Up @@ -249,30 +273,6 @@ export default {
}
},
created(){
this.getAPIs()
this.$EventBus.$on('goBeforePage', this.goBeforePage)
this.$EventBus.$on('goAfterPage', this.goAfterPage)
this.$EventBus.$on('goLoadingPage', this.goLoadingPage)
this.$EventBus.$on('setSearchHistory', this.setSearchHistory)
this.$EventBus.$on('refreshMember', this.refreshMember)
this.$EventBus.$on('search', this.search)
const token = this.getToken()
this.backImg = localStorage.getItem("theme") != null ? localStorage.getItem("theme") : this.backImg
if(token !== null){
this.$http.get(`http://52.79.204.244/member?email=${token.email}`).then(res => {
this.$store.dispatch('SETMEMBER', res.data)
this.setCustomKeywords(res.data.email)
this.setSearchHistory(res.data.email)
})
} else {
// TODO anonymous@NAM 고치기
this.setMemberState('anonymous@NAM', '익명의 ' + animals[Math.floor(Math.random() * animals.length)] , null)
this.setCustomKeywords(`anonymous@NAM`)
this.setSearchHistory(`anonymous@NAM`)
}
},
}
</script>

Expand Down
38 changes: 17 additions & 21 deletions frontend/src/components/before/MyPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class='MyPage' v-if="ready">
<div class='MyPage'>
<div class="compHead">
MYPAGE
</div>
Expand Down Expand Up @@ -157,9 +157,6 @@
import animals from '../../data/animals.json'
export default {
created(){
this.ready = true
},
data(){
return{
memberInfo: this.$store.state,
Expand All @@ -172,7 +169,6 @@ export default {
edituser: false,
deluser: false,
editpw: false,
ready: false,
msg: "",
img1: 'https://image.flaticon.com/icons/svg/1283/1283214.svg',
img2: 'https://image.flaticon.com/icons/svg/1283/1283222.svg',
Expand All @@ -193,15 +189,15 @@ export default {
if(keyword.split(' ').join('').length != 0) tmp.push(keyword)
})
return tmp;
return tmp
},
replies(){
let memberInfo = this.$store.state;
let memberInfo = this.$store.state
if(memberInfo.sortedQuestionReplies == null && memberInfo.unsolvedQuestionReplies == null) return [];
if(memberInfo.sortedQuestionReplies != null && memberInfo.unsolvedQuestionReplies == null) return memberInfo.sortedQuestionReplies;
if(memberInfo.sortedQuestionReplies == null && memberInfo.unsolvedQuestionReplies != null) return memberInfo.unsolvedQuestionReplies;
return memberInfo.sortedQuestionReplies.concat(memberInfo.unsolvedQuestionReplies);
if(memberInfo.sortedQuestionReplies == null && memberInfo.unsolvedQuestionReplies == null) return []
if(memberInfo.sortedQuestionReplies != null && memberInfo.unsolvedQuestionReplies == null) return memberInfo.sortedQuestionReplies
if(memberInfo.sortedQuestionReplies == null && memberInfo.unsolvedQuestionReplies != null) return memberInfo.unsolvedQuestionReplies
return memberInfo.sortedQuestionReplies.concat(memberInfo.unsolvedQuestionReplies)
},
alerts(){
let memberInfo = this.$store.state
Expand All @@ -225,7 +221,7 @@ export default {
this.contentsshow = !this.contentsshow
},
showAlert(){
this.alertshow = true;
this.alertshow = true
},
closeInfo(){
this.contentsshow = false
Expand All @@ -239,7 +235,7 @@ export default {
this.$http.get(link).then(response => {
if(link.includes('sorted')) this.clickSth(response.data, 1)
else if(link.includes('unsolved')) this.clickSth(response.data, 0)
});
})
},
removeScrap(scrap){
this.$http({
Expand All @@ -252,8 +248,8 @@ export default {
}).then(response => {
}).finally(() => {
this.$EventBus.$emit('refreshMember');
});
this.$EventBus.$emit('refreshMember')
})
},
signUpAction(){
this.$EventBus.$emit('showSignUp')
Expand All @@ -264,7 +260,7 @@ export default {
editNickname(){
if(document.querySelector('#mypage-nick').value.length == 0){
this.msg = '변경할 닉네임을 입력해주세요.'
return;
return
}
this.$http({
method: 'post',
Expand All @@ -277,7 +273,7 @@ export default {
this.$EventBus.$emit('refreshMember')
this.edituser = false
this.msg = ''
});
})
},
checkPW(){
let pw = document.querySelector('#mypage-newPw').value
Expand Down Expand Up @@ -328,7 +324,7 @@ export default {
this.msg = ''
this.$store.dispatch('LOGOUT').then(console.log('로그아웃 완료'))
}
});
})
},
randomNick(){
this.$store.state.nickname = '익명의 ' + animals[Math.floor(Math.random() * animals.length)]
Expand All @@ -342,7 +338,7 @@ export default {
let ok = window.confirm("정말 삭제 하시겠습니까?")
if(!ok) return;
if(!ok) return
if(type === 0) url = 'http://52.79.204.244/question/unsolved'
else if(type === 1) url = 'http://52.79.204.244/question/sorted'
Expand All @@ -366,8 +362,8 @@ export default {
},
editQ(question, type){
question.content = question.content.split('<br/>').join('\n');
question.type = type;
question.content = question.content.split('<br/>').join('\n')
question.type = type
this.$EventBus.$emit('showWrite', question)
},
readAlert(...question){
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/etc/SignIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
</div>
<div class="sign-in-api">
<a :href=kakaoLoginURL><img src="../../../static/kakao.png" alt="" class="icon-image"></a>
<a :href=naverLoginURL><img src="../../../static/naver.png" alt="" class="icon-image"></a>
<a :href=githubLoginURL><img src="../../../static/github.png" alt="" class="icon-image"></a>
</div>
</div>
Expand All @@ -29,7 +28,6 @@ export default {
}
},
computed:{
naverLoginURL(){return `https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=${this.$store.getters.apis.naver[0]}&redirect_uri=http%3a%2f%2f52.79.204.244%2fapi%2fnaver%2fcallback&state=123`},
kakaoLoginURL(){return `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${this.$store.getters.apis.kakao[0]}&redirect_uri=http%3a%2f%2f52.79.204.244%2fapi%2fkakao%2fcallback`},
githubLoginURL(){return `https://github.com/login/oauth/authorize?client_id=${this.$store.getters.apis.github[0]}&redirect_uri=http://52.79.204.244/api/github/callback`}
},
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/etc/SignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</div>
<div class="sign-up-api">
<a :href=kakaoLoginURL><img src="../../../static/kakao.png" alt="" class="icon-image"></a>
<a :href=naverLoginURL><img src="../../../static/naver.png" alt="" class="icon-image"></a>
<a :href=githubLoginURL><img src="../../../static/github.png" alt="" class="icon-image"></a>
</div>
</div>
Expand All @@ -34,7 +33,6 @@ export default {
}
},
computed:{
naverLoginURL(){return `https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=${this.$store.getters.apis.naver[0]}&redirect_uri=http%3a%2f%2f52.79.204.244%2fapi%2fnaver%2fcallback&state=123`},
kakaoLoginURL(){return `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${this.$store.getters.apis.kakao[0]}&redirect_uri=http%3a%2f%2f52.79.204.244%2fapi%2fkakao%2fcallback`},
githubLoginURL(){return `https://github.com/login/oauth/authorize?client_id=${this.$store.getters.apis.github[0]}&redirect_uri=http://52.79.204.244/api/github/callback`}
},
Expand Down

0 comments on commit 1e2a491

Please sign in to comment.