From 9fa5ec051632dec8f3585061ec7b21ba8c01c83f Mon Sep 17 00:00:00 2001 From: Choejiwon <jiwon0929@ajou.ac.kr> Date: Wed, 11 Dec 2019 00:40:54 +0900 Subject: [PATCH] F5 Error Resolve! --- src/components/core/Drawer.vue | 1 + src/store/mutations.js | 7 +++++++ src/store/state.js | 1 + src/views/Login.vue | 2 ++ src/views/MyPage.vue | 2 +- src/views/ShowFindPost.vue | 26 +++++++++++++++++--------- src/views/ShowLostPost.vue | 30 +++++++++++++++++++----------- 7 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/components/core/Drawer.vue b/src/components/core/Drawer.vue index 128e5a6..62f8b25 100644 --- a/src/components/core/Drawer.vue +++ b/src/components/core/Drawer.vue @@ -122,6 +122,7 @@ export default { if(res.data.success==true){ this.$store.commit("setInitialize"); this.$store.commit('delToken'); + this.$store.commit('delu_ID'); } }) } diff --git a/src/store/mutations.js b/src/store/mutations.js index ee7910b..4e30bfc 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -30,5 +30,12 @@ export default { delToken (state) { localStorage.removeItem('token') state.token = null + }, + getu_ID (state) { + state.u_ID = localStorage.getItem('u_ID') + }, + delu_ID (state) { + localStorage.removeItem('u_ID') + state.u_ID = null } } diff --git a/src/store/state.js b/src/store/state.js index 36fc722..fa8de9f 100644 --- a/src/store/state.js +++ b/src/store/state.js @@ -11,5 +11,6 @@ export default { live: "", }, token: localStorage.getItem('token'), + u_ID: localStorage.getItem('u_ID'), isUserInfoGetted: false //유저 정보가 현재 사용 가능한지 나타내는 플래그 변수 } diff --git a/src/views/Login.vue b/src/views/Login.vue index b722236..83f8ebb 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -69,7 +69,9 @@ export default { }; this.$store.commit("setUserInfo", payload); localStorage.setItem('token', user._id) + localStorage.setItem('u_ID', user.ID) this.$store.commit('getToken'); + this.$store.commit('getu_ID'); // alert(this.$store.state.userInfo._id) this.$router.push('/'); } diff --git a/src/views/MyPage.vue b/src/views/MyPage.vue index cabad9a..39eb02b 100644 --- a/src/views/MyPage.vue +++ b/src/views/MyPage.vue @@ -201,7 +201,7 @@ export default { console.log("Token : " + localStorage.getItem('token')) console.log("User_id : " + this.$store.state.userInfo._id); - if(this.$store.state.userInfo._id != localStorage.getItem('token')){ + if(!localStorage.getItem('token')){ this.loginDialog = true; } else{ diff --git a/src/views/ShowFindPost.vue b/src/views/ShowFindPost.vue index d31585c..ea7a0d0 100644 --- a/src/views/ShowFindPost.vue +++ b/src/views/ShowFindPost.vue @@ -3,7 +3,12 @@ <v-layout justify-center wrap> <v-flex xs12 md8> <material-card color="green" v-bind:title="findpost.title" v-bind:text="findpost.created" display-2> - <v-form> + <v-card :elevation="20" width="300" :shaped="true" v-if="dataLoading" class="mx-auto"> + <v-card-text> + <strong class="display-3 center">LOADING....</strong> + </v-card-text> + </v-card> + <v-form v-if="!dataLoading"> <v-container py-0> <v-layout wrap column> <v-flex xs12 md4> @@ -55,7 +60,7 @@ <v-divider vertical></v-divider> <v-btn small - v-if="$store.state.userInfo.ID === item.id" + v-if="$store.state.u_ID === item.id" color="error" dark @click.stop="commentDeleteDialog = true, comment_id = item._id" @@ -118,13 +123,13 @@ class="mx-0 font-weight-light" color="success" @click="onPostChange(findpost._id)" - v-if="$store.state.userInfo.ID === findpost.id" + v-if="$store.state.u_ID === findpost.id" >게시글 수정</v-btn> <v-divider vertical></v-divider> <v-btn color="error" dark - v-if="$store.state.userInfo.ID === findpost.id" + v-if="$store.state.u_ID === findpost.id" @click.stop="postDeleteDialog = true" > 게시글 삭제 @@ -190,10 +195,12 @@ export default { const _id = this.$route.params._id; this.$http.get(`/finderboard/${_id}`) .then((response) => { - this.findpost = response.data.board; - this.items = this.findpost.comments; - var base64data=Buffer.from(this.findpost.image.data.data,'binary').toString('base64'); - this.image='data:image/jpeg;base64,'+base64data; + this.dataLoading = true; + this.findpost = response.data.board; + this.items = this.findpost.comments; + var base64data=Buffer.from(this.findpost.image.data.data,'binary').toString('base64'); + this.image='data:image/jpeg;base64,'+base64data; + this.dataLoading = false; }); }, data: () => { @@ -214,7 +221,8 @@ export default { commentDeleteDialog: false, commentSnackbar: false, postSnackbar: false, - comment_id: '' + comment_id: '', + dataLoading: true } }, methods:{ diff --git a/src/views/ShowLostPost.vue b/src/views/ShowLostPost.vue index 07cbe14..851f16b 100644 --- a/src/views/ShowLostPost.vue +++ b/src/views/ShowLostPost.vue @@ -3,7 +3,12 @@ <v-layout justify-center wrap> <v-flex xs12 md8> <material-card color="green" v-bind:title="lostpost.title" v-bind:text="lostpost.created"> - <v-form> + <v-card :elevation="20" width="300" :shaped="true" v-if="dataLoading" class="mx-auto"> + <v-card-text> + <strong class="display-3 center">LOADING....</strong> + </v-card-text> + </v-card> + <v-form v-if="!dataLoading"> <v-container py-0> <v-layout wrap column> <v-flex xs12 md4> @@ -50,7 +55,7 @@ <td class="text-xs-right" outlined>{{ item.created }}</td> <v-divider vertical></v-divider> <v-btn - v-if="$store.state.userInfo.ID === item.id" + v-if="$store.state.u_ID === item.id" small color="error" dark @@ -114,13 +119,13 @@ class="mx-0 font-weight-light" color="success" @ - v-if="$store.state.userInfo.ID === lostpost.id" + v-if="$store.state.u_ID === lostpost.id" >게시글 수정</v-btn> <v-divider vertical></v-divider> <v-btn color="error" dark - v-if="$store.state.userInfo.ID === lostpost.id" + v-if="$store.state.u_ID === lostpost.id" @click.stop="postDeleteDialog = true" > 게시글 삭제 @@ -186,10 +191,12 @@ export default { const _id = this.$route.params._id; this.$http.get(`/losterboard/${_id}`) .then((response) => { - this.lostpost = response.data.board; - this.items = this.lostpost.comments; - var base64data=Buffer.from(this.lostpost.image.data.data,'binary').toString('base64'); - this.image='data:image/jpeg;base64,'+base64data; + this.dataLoading = true; + this.lostpost = response.data.board; + this.items = this.lostpost.comments; + var base64data=Buffer.from(this.lostpost.image.data.data,'binary').toString('base64'); + this.image='data:image/jpeg;base64,'+base64data; + this.dataLoading = false; }); }, data: () => { @@ -211,7 +218,8 @@ export default { commentDeleteDialog: false, commentSnackbar: false, postSnackbar: false, - comment_id: '' + comment_id: '', + dataLoading: true, } }, methods:{ @@ -248,7 +256,7 @@ export default { const comment_idx = this.comment_id; const post_idx = this.$route.params._id; - const user_id = this.$store.state.userInfo.ID; + const user_id = this.$store.state.u_ID; const index = this.items.findIndex(function(item, i){ return item._id === comment_idx @@ -275,7 +283,7 @@ export default { onPostDelete: function(id){ const post_id = id; const user_id = this.$store.state.userInfo._id; - const user_ID = this.$store.state.userInfo.ID; + const user_ID = this.$store.state.u_ID; const post_writer_ID = this.lostpost.id; if(user_ID === post_writer_ID){ -- GitLab