diff --git a/src/components/core/Drawer.vue b/src/components/core/Drawer.vue index 128e5a69810751359d3916d0d5d840d08b5806d4..62f8b25aa6ae41a1301ebf37b6878bd030a4916c 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 ee7910b989803711216f37a71c77954ea4f89f22..4e30bfc573656d103a7d98ff6982d479e237d838 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 36fc722a3f16bd02c7fe25a033d2ecee323d4e8a..fa8de9fd119f0e20e3a98c92d1808090b0db6dc4 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 b7222365124e5a3a54e920be2f0dd77e2bbfd618..83f8ebb25ae21a8341654edd8d2f6db97aa4fb22 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 cabad9a486b7faaa1a3cecfdacfdfc704ed0c6f5..39eb02becc160227cbf785a35647a3523e07805b 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 d31585c47d00ab086490cf88482aecae6f398fc8..ea7a0d0fd72fc43dc0b83b2a3c03ec390b6b659d 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 07cbe1429e62a29ba2e05eb86d640a0c070004a3..851f16b3326ea46c749baab2241bd971eb0b53f4 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){