최동원

.

...@@ -80,8 +80,12 @@ function downloadFile(fileData) { ...@@ -80,8 +80,12 @@ function downloadFile(fileData) {
80 }); 80 });
81 } 81 }
82 82
83 -function changeFavorite() { 83 +function delFavorite(folderData) {
84 - return axios.post(); 84 + return axios.post('api/favorites/delfolder', folderData);
85 +}
86 +
87 +function addFavorite(folderData) {
88 + return axios.post('api/favorites/addfolder', folderData);
85 } 89 }
86 90
87 export { 91 export {
...@@ -95,5 +99,6 @@ export { ...@@ -95,5 +99,6 @@ export {
95 uploadFile, 99 uploadFile,
96 deleteFile, 100 deleteFile,
97 downloadFile, 101 downloadFile,
98 - changeFavorite, 102 + delFavorite,
103 + addFavorite,
99 }; 104 };
......
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
28 <v-list-item-title v-text="item.folder_name"></v-list-item-title> 28 <v-list-item-title v-text="item.folder_name"></v-list-item-title>
29 </v-list-item-content> 29 </v-list-item-content>
30 <v-list-item-action> 30 <v-list-item-action>
31 - <v-icon v-if="item.favorite === 'false'" color="grey lighten-1"> 31 + <v-icon v-if="item.favorite === 0" color="grey lighten-1">
32 - star_border 32 + mdi-star-border
33 </v-icon> 33 </v-icon>
34 34
35 <v-icon v-else color="yellow"> 35 <v-icon v-else color="yellow">
36 - star 36 + mdi-star
37 </v-icon> 37 </v-icon>
38 </v-list-item-action> 38 </v-list-item-action>
39 </v-list-item> 39 </v-list-item>
...@@ -103,16 +103,12 @@ ...@@ -103,16 +103,12 @@
103 <v-list-item @click.prevent="deleteF"> 103 <v-list-item @click.prevent="deleteF">
104 <v-list-item-title>삭제</v-list-item-title> 104 <v-list-item-title>삭제</v-list-item-title>
105 </v-list-item> 105 </v-list-item>
106 - <template v-if="curfName.favorite === 'true'" @click="change_favorite"> 106 + <v-list-item v-if="curfName.favorite === 1" @click="delete_favorite">
107 - <v-list-item> 107 + <v-list-item-title>즐겨 찾기 삭제</v-list-item-title>
108 - <v-list-item-title>즐겨 찾기 삭제</v-list-item-title> 108 + </v-list-item>
109 - </v-list-item> 109 + <v-list-item v-if="curfName.favorite === 0" @click="add_favorite">
110 - </template> 110 + <v-list-item-title>즐겨 찾기 추가</v-list-item-title>
111 - <template v-if="curfName.favorite === 'false'" @click="change_favorite"> 111 + </v-list-item>
112 - <v-list-item>
113 - <v-list-item-title>즐겨 찾기 추가</v-list-item-title>
114 - </v-list-item>
115 - </template>
116 </v-list> 112 </v-list>
117 </v-menu> 113 </v-menu>
118 114
...@@ -162,6 +158,8 @@ import { ...@@ -162,6 +158,8 @@ import {
162 uploadFile, 158 uploadFile,
163 deleteFile, 159 deleteFile,
164 downloadFile, 160 downloadFile,
161 + delFavorite,
162 + addFavorite,
165 } from '../api/index'; 163 } from '../api/index';
166 import Axios from 'axios'; 164 import Axios from 'axios';
167 165
...@@ -388,7 +386,34 @@ export default { ...@@ -388,7 +386,34 @@ export default {
388 console.log(error); 386 console.log(error);
389 } 387 }
390 }, 388 },
391 - async change_favorite() {}, 389 + async delete_favorite() {
390 + try {
391 + const cData = {
392 + id: this.$store.state.id,
393 + cur: this.$store.state.cur,
394 + name: this.curfName.folder_name,
395 + };
396 + console.log(cData);
397 + const response = await delFavorite(cData);
398 + this.$store.commit('setFolder', response.data.folders);
399 + } catch (error) {
400 + console.log('에러');
401 + }
402 + },
403 + async add_favorite() {
404 + try {
405 + const cData = {
406 + id: this.$store.state.id,
407 + cur: this.$store.state.cur,
408 + name: this.curfName.folder_name,
409 + };
410 + console.log(cData);
411 + const response = await addFavorite(cData);
412 + this.$store.commit('setFolder', response.data.folders);
413 + } catch (error) {
414 + console.log('에러');
415 + }
416 + },
392 show(folderObj, e) { 417 show(folderObj, e) {
393 e.preventDefault(); 418 e.preventDefault();
394 this.curfName = folderObj; 419 this.curfName = folderObj;
......