콘텐츠 수정
- 테마 수정 기능 추가
This commit is contained in:
		| @@ -59,6 +59,10 @@ async function updateCurationOrders(ids) { | |||||||
|     return Vue.axios.put('/admin/audio-content/curation/orders', {ids: ids}) |     return Vue.axios.put('/admin/audio-content/curation/orders', {ids: ids}) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | async function getAudioContentThemeList() { | ||||||
|  |     return Vue.axios.get("/admin/audio-content/theme") | ||||||
|  | } | ||||||
|  |  | ||||||
| export { | export { | ||||||
|     getAudioContentList, |     getAudioContentList, | ||||||
|     searchAudioContent, |     searchAudioContent, | ||||||
| @@ -70,5 +74,6 @@ export { | |||||||
|     getCurations, |     getCurations, | ||||||
|     saveCuration, |     saveCuration, | ||||||
|     modifyCuration, |     modifyCuration, | ||||||
|     updateCurationOrders |     updateCurationOrders, | ||||||
|  |     getAudioContentThemeList | ||||||
| } | } | ||||||
|   | |||||||
| @@ -295,6 +295,22 @@ | |||||||
|               </v-col> |               </v-col> | ||||||
|             </v-row> |             </v-row> | ||||||
|           </v-card-text> |           </v-card-text> | ||||||
|  |           <v-card-text> | ||||||
|  |             <v-row> | ||||||
|  |               <v-col cols="4"> | ||||||
|  |                 테마 | ||||||
|  |               </v-col> | ||||||
|  |               <v-col cols="8"> | ||||||
|  |                 <v-select | ||||||
|  |                   v-model="audio_content.theme_id" | ||||||
|  |                   :items="themeList" | ||||||
|  |                   item-text="title" | ||||||
|  |                   item-value="value" | ||||||
|  |                   label="테마 선택" | ||||||
|  |                 /> | ||||||
|  |               </v-col> | ||||||
|  |             </v-row> | ||||||
|  |           </v-card-text> | ||||||
|           <v-card-actions v-show="!is_loading"> |           <v-card-actions v-show="!is_loading"> | ||||||
|             <v-spacer /> |             <v-spacer /> | ||||||
|             <v-btn |             <v-btn | ||||||
| @@ -355,277 +371,299 @@ import * as dynamicLink from "@/api/firebase_dynamic_link"; | |||||||
| import VuetifyAudio from 'vuetify-audio' | import VuetifyAudio from 'vuetify-audio' | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|     name: "AudioContentList", |   name: "AudioContentList", | ||||||
|  |  | ||||||
|     components: {VuetifyAudio}, |   components: {VuetifyAudio}, | ||||||
|  |  | ||||||
|     data() { |   data() { | ||||||
|         return { |     return { | ||||||
|             is_loading: false, |       is_loading: false, | ||||||
|             show_modify_dialog: false, |       show_modify_dialog: false, | ||||||
|             show_delete_confirm_dialog: false, |       show_delete_confirm_dialog: false, | ||||||
|             page: 1, |       page: 1, | ||||||
|             total_page: 0, |       total_page: 0, | ||||||
|             search_word: '', |       search_word: '', | ||||||
|             audio_content: {}, |       audio_content: {}, | ||||||
|             audio_contents: [], |       audio_contents: [], | ||||||
|             curations: [], |       curations: [], | ||||||
|             selected_audio_content: {}, |       themeList: [], | ||||||
|             utm_source: '', |       selected_audio_content: {}, | ||||||
|             utm_medium: '', |       utm_source: '', | ||||||
|             utm_campaign: '', |       utm_medium: '', | ||||||
|         } |       utm_campaign: '', | ||||||
|     }, |  | ||||||
|  |  | ||||||
|     async created() { |  | ||||||
|         await this.getCurations() |  | ||||||
|         await this.getAudioContent() |  | ||||||
|     }, |  | ||||||
|  |  | ||||||
|     methods: { |  | ||||||
|         notifyError(message) { |  | ||||||
|             this.$dialog.notify.error(message) |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         notifySuccess(message) { |  | ||||||
|             this.$dialog.notify.success(message) |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         deleteConfirm(item) { |  | ||||||
|             this.selected_audio_content = item |  | ||||||
|             this.show_delete_confirm_dialog = true |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         deleteCancel() { |  | ||||||
|             this.selected_audio_content = {} |  | ||||||
|             this.show_delete_confirm_dialog = false |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         showModifyDialog(item) { |  | ||||||
|             this.selected_audio_content = item |  | ||||||
|  |  | ||||||
|             this.audio_content.id = item.audioContentId |  | ||||||
|             this.audio_content.title = item.title |  | ||||||
|             this.audio_content.detail = item.detail |  | ||||||
|             this.audio_content.curation_id = item.curationId |  | ||||||
|             this.audio_content.is_adult = item.isAdult |  | ||||||
|             this.audio_content.is_comment_available = item.isCommentAvailable |  | ||||||
|             this.audio_content.is_default_cover_image = false |  | ||||||
|  |  | ||||||
|             console.log(this.audio_content) |  | ||||||
|  |  | ||||||
|             this.show_modify_dialog = true |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         cancel() { |  | ||||||
|             this.selected_audio_content = {} |  | ||||||
|             this.audio_content = {} |  | ||||||
|             this.show_modify_dialog = false |  | ||||||
|             this.show_delete_confirm_dialog = false |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async modify() { |  | ||||||
|             if ( |  | ||||||
|                 this.audio_content.title === null || |  | ||||||
|                 this.audio_content.title === undefined || |  | ||||||
|                 this.audio_content.title.trim().length <= 0 |  | ||||||
|             ) { |  | ||||||
|                 this.notifyError("제목을 입력하세요") |  | ||||||
|                 return |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if ( |  | ||||||
|                 this.audio_content.detail === null || |  | ||||||
|                 this.audio_content.detail === undefined || |  | ||||||
|                 this.audio_content.detail.trim().length <= 0 |  | ||||||
|             ) { |  | ||||||
|                 this.notifyError("내용을 입력하세요") |  | ||||||
|                 return |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (this.is_loading) return; |  | ||||||
|  |  | ||||||
|             this.isLoading = true |  | ||||||
|  |  | ||||||
|             try { |  | ||||||
|                 const request = { |  | ||||||
|                     id: this.audio_content.id, |  | ||||||
|                     isDefaultCoverImage: this.audio_content.is_default_cover_image |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if ( |  | ||||||
|                     this.selected_audio_content.title !== this.audio_content.title && |  | ||||||
|                     this.audio_content.title.trim().length > 0 |  | ||||||
|                 ) { |  | ||||||
|                     request.title = this.audio_content.title |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if ( |  | ||||||
|                     this.selected_audio_content.detail !== this.audio_content.detail && |  | ||||||
|                     this.audio_content.detail.trim().length > 0 |  | ||||||
|                 ) { |  | ||||||
|                     request.detail = this.audio_content.detail |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if (this.selected_audio_content.curationId !== this.audio_content.curation_id) { |  | ||||||
|                     request.curationId = this.audio_content.curation_id |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if (this.selected_audio_content.isAdult !== this.audio_content.is_adult) { |  | ||||||
|                     request.isAdult = this.audio_content.is_adult |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if (this.selected_audio_content.isCommentAvailable !== this.audio_content.is_comment_available) { |  | ||||||
|                     request.isCommentAvailable = this.audio_content.is_comment_available |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 console.log(request) |  | ||||||
|                 const res = await api.modifyAudioContent(request) |  | ||||||
|                 if (res.status === 200 && res.data.success === true) { |  | ||||||
|                     this.cancel() |  | ||||||
|                     this.notifySuccess('수정되었습니다.') |  | ||||||
|  |  | ||||||
|                     this.audio_contents = [] |  | ||||||
|                     await this.getAudioContent() |  | ||||||
|                 } else { |  | ||||||
|                     this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                 } |  | ||||||
|             } catch (e) { |  | ||||||
|                 this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|             } finally { |  | ||||||
|                 this.is_loading = false |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async deleteAudioContent() { |  | ||||||
|             if (this.is_loading) return; |  | ||||||
|             this.is_loading = true |  | ||||||
|  |  | ||||||
|             try { |  | ||||||
|                 let request = {id: this.selected_audio_content.audioContentId, isActive: false} |  | ||||||
|  |  | ||||||
|                 const res = await api.modifyAudioContent(request) |  | ||||||
|                 if (res.status === 200 && res.data.success === true) { |  | ||||||
|                     this.cancel() |  | ||||||
|                     this.notifySuccess('삭제되었습니다.') |  | ||||||
|  |  | ||||||
|                     this.audio_contents = [] |  | ||||||
|                     await this.getAudioContent() |  | ||||||
|                 } else { |  | ||||||
|                     this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                 } |  | ||||||
|             } catch (e) { |  | ||||||
|                 this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|             } finally { |  | ||||||
|                 this.is_loading = false |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async next() { |  | ||||||
|             if (this.search_word.length < 2) { |  | ||||||
|                 this.search_word = '' |  | ||||||
|                 await this.getAudioContent() |  | ||||||
|             } else { |  | ||||||
|                 await this.searchAudioContent() |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async getCurations() { |  | ||||||
|             this.is_loading = true |  | ||||||
|             try { |  | ||||||
|                 const res = await api.getCurations() |  | ||||||
|                 if (res.status === 200 && res.data.success === true) { |  | ||||||
|                     this.curations = res.data.data.map((curation) => { |  | ||||||
|                         return {title: curation.title, value: curation.id} |  | ||||||
|                     }) |  | ||||||
|  |  | ||||||
|                     this.curations.unshift({title: '없음', value: 0}) |  | ||||||
|                 } else { |  | ||||||
|                     this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                 } |  | ||||||
|             } catch (e) { |  | ||||||
|                 this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|             } finally { |  | ||||||
|                 this.is_loading = false |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async getAudioContent() { |  | ||||||
|             this.is_loading = true |  | ||||||
|             try { |  | ||||||
|                 const res = await api.getAudioContentList(this.page) |  | ||||||
|                 if (res.status === 200 && res.data.success === true) { |  | ||||||
|                     const data = res.data.data |  | ||||||
|  |  | ||||||
|                     const total_page = Math.ceil(data.totalCount / 10) |  | ||||||
|                     this.audio_contents = data.items |  | ||||||
|  |  | ||||||
|                     if (total_page <= 0) |  | ||||||
|                         this.total_page = 1 |  | ||||||
|                     else |  | ||||||
|                         this.total_page = total_page |  | ||||||
|                 } else { |  | ||||||
|                     this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 this.is_loading = false |  | ||||||
|             } catch (e) { |  | ||||||
|                 this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                 this.is_loading = false |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async search() { |  | ||||||
|             this.page = 1 |  | ||||||
|             await this.searchAudioContent() |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async searchAudioContent() { |  | ||||||
|             if (this.search_word.length === 0) { |  | ||||||
|                 await this.getAudioContent() |  | ||||||
|             } else if (this.search_word.length < 2) { |  | ||||||
|                 this.notifyError('검색어를 2글자 이상 입력하세요.') |  | ||||||
|             } else { |  | ||||||
|                 this.is_loading = true |  | ||||||
|                 try { |  | ||||||
|                     const res = await api.searchAudioContent(this.search_word, this.page) |  | ||||||
|                     if (res.status === 200 && res.data.success === true) { |  | ||||||
|                         const data = res.data.data |  | ||||||
|  |  | ||||||
|                         const total_page = Math.ceil(data.totalCount / 10) |  | ||||||
|                         this.audio_contents = data.items |  | ||||||
|  |  | ||||||
|                         if (total_page <= 0) |  | ||||||
|                             this.total_page = 1 |  | ||||||
|                         else |  | ||||||
|                             this.total_page = total_page |  | ||||||
|                     } else { |  | ||||||
|                         this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     this.is_loading = false |  | ||||||
|                 } catch (e) { |  | ||||||
|                     this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') |  | ||||||
|                     this.is_loading = false |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         async shareAudioContent(item) { |  | ||||||
|             this.is_loading = true |  | ||||||
|             try { |  | ||||||
|                 const linkData = await dynamicLink.shareAudioContent(item, this.utm_source, this.utm_medium, this.utm_campaign); |  | ||||||
|                 if (linkData.status === 200) { |  | ||||||
|                   await navigator.clipboard.writeText(linkData.data.shortLink) |  | ||||||
|                   this.notifySuccess("링크가 복사되었습니다.") |  | ||||||
|                 } else { |  | ||||||
|                   this.notifyError("링크를 생성하지 못했습니다.") |  | ||||||
|                 } |  | ||||||
|             } finally { |  | ||||||
|                 this.is_loading = false |  | ||||||
|             } |  | ||||||
|         }, |  | ||||||
|     } |     } | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   async created() { | ||||||
|  |     await this.getAudioContentThemeList(); | ||||||
|  |     await this.getCurations() | ||||||
|  |     await this.getAudioContent() | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   methods: { | ||||||
|  |     notifyError(message) { | ||||||
|  |       this.$dialog.notify.error(message) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     notifySuccess(message) { | ||||||
|  |       this.$dialog.notify.success(message) | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     deleteConfirm(item) { | ||||||
|  |       this.selected_audio_content = item | ||||||
|  |       this.show_delete_confirm_dialog = true | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     deleteCancel() { | ||||||
|  |       this.selected_audio_content = {} | ||||||
|  |       this.show_delete_confirm_dialog = false | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     showModifyDialog(item) { | ||||||
|  |       this.selected_audio_content = item | ||||||
|  |  | ||||||
|  |       this.audio_content.id = item.audioContentId | ||||||
|  |       this.audio_content.title = item.title | ||||||
|  |       this.audio_content.detail = item.detail | ||||||
|  |       this.audio_content.curation_id = item.curationId | ||||||
|  |       this.audio_content.theme_id = item.themeId | ||||||
|  |       this.audio_content.is_adult = item.isAdult | ||||||
|  |       this.audio_content.is_comment_available = item.isCommentAvailable | ||||||
|  |       this.audio_content.is_default_cover_image = false | ||||||
|  |       this.show_modify_dialog = true | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     cancel() { | ||||||
|  |       this.selected_audio_content = {} | ||||||
|  |       this.audio_content = {} | ||||||
|  |       this.show_modify_dialog = false | ||||||
|  |       this.show_delete_confirm_dialog = false | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async modify() { | ||||||
|  |       if ( | ||||||
|  |         this.audio_content.title === null || | ||||||
|  |         this.audio_content.title === undefined || | ||||||
|  |         this.audio_content.title.trim().length <= 0 | ||||||
|  |       ) { | ||||||
|  |         this.notifyError("제목을 입력하세요") | ||||||
|  |         return | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       if ( | ||||||
|  |         this.audio_content.detail === null || | ||||||
|  |         this.audio_content.detail === undefined || | ||||||
|  |         this.audio_content.detail.trim().length <= 0 | ||||||
|  |       ) { | ||||||
|  |         this.notifyError("내용을 입력하세요") | ||||||
|  |         return | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       if (this.is_loading) return; | ||||||
|  |  | ||||||
|  |       this.isLoading = true | ||||||
|  |  | ||||||
|  |       try { | ||||||
|  |         const request = { | ||||||
|  |           id: this.audio_content.id, | ||||||
|  |           isDefaultCoverImage: this.audio_content.is_default_cover_image | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if ( | ||||||
|  |           this.selected_audio_content.title !== this.audio_content.title && | ||||||
|  |           this.audio_content.title.trim().length > 0 | ||||||
|  |         ) { | ||||||
|  |           request.title = this.audio_content.title | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if ( | ||||||
|  |           this.selected_audio_content.detail !== this.audio_content.detail && | ||||||
|  |           this.audio_content.detail.trim().length > 0 | ||||||
|  |         ) { | ||||||
|  |           request.detail = this.audio_content.detail | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (this.selected_audio_content.curationId !== this.audio_content.curation_id) { | ||||||
|  |           request.curationId = this.audio_content.curation_id | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (this.selected_audio_content.themeId !== this.audio_content.theme_id) { | ||||||
|  |           request.themeId = this.audio_content.theme_id | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (this.selected_audio_content.isAdult !== this.audio_content.is_adult) { | ||||||
|  |           request.isAdult = this.audio_content.is_adult | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if (this.selected_audio_content.isCommentAvailable !== this.audio_content.is_comment_available) { | ||||||
|  |           request.isCommentAvailable = this.audio_content.is_comment_available | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         const res = await api.modifyAudioContent(request) | ||||||
|  |         if (res.status === 200 && res.data.success === true) { | ||||||
|  |           this.cancel() | ||||||
|  |           this.notifySuccess('수정되었습니다.') | ||||||
|  |  | ||||||
|  |           this.audio_contents = [] | ||||||
|  |           await this.getAudioContent() | ||||||
|  |         } else { | ||||||
|  |           this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         } | ||||||
|  |       } catch (e) { | ||||||
|  |         this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |       } finally { | ||||||
|  |         this.is_loading = false | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async deleteAudioContent() { | ||||||
|  |       if (this.is_loading) return; | ||||||
|  |       this.is_loading = true | ||||||
|  |  | ||||||
|  |       try { | ||||||
|  |         let request = {id: this.selected_audio_content.audioContentId, isActive: false} | ||||||
|  |  | ||||||
|  |         const res = await api.modifyAudioContent(request) | ||||||
|  |         if (res.status === 200 && res.data.success === true) { | ||||||
|  |           this.cancel() | ||||||
|  |           this.notifySuccess('삭제되었습니다.') | ||||||
|  |  | ||||||
|  |           this.audio_contents = [] | ||||||
|  |           await this.getAudioContent() | ||||||
|  |         } else { | ||||||
|  |           this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         } | ||||||
|  |       } catch (e) { | ||||||
|  |         this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |       } finally { | ||||||
|  |         this.is_loading = false | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async next() { | ||||||
|  |       if (this.search_word.length < 2) { | ||||||
|  |         this.search_word = '' | ||||||
|  |         await this.getAudioContent() | ||||||
|  |       } else { | ||||||
|  |         await this.searchAudioContent() | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async getAudioContentThemeList() { | ||||||
|  |       this.is_loading = true | ||||||
|  |       try { | ||||||
|  |         const res = await api.getAudioContentThemeList() | ||||||
|  |         if (res.status === 200 && res.data.success === true) { | ||||||
|  |           this.themeList = res.data.data.map((item) => { | ||||||
|  |             return {title: item.theme, value: item.id} | ||||||
|  |           }) | ||||||
|  |         } else { | ||||||
|  |           this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.is_loading = false | ||||||
|  |       } catch (e) { | ||||||
|  |         this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         this.is_loading = false | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async getCurations() { | ||||||
|  |       this.is_loading = true | ||||||
|  |       try { | ||||||
|  |         const res = await api.getCurations() | ||||||
|  |         if (res.status === 200 && res.data.success === true) { | ||||||
|  |           this.curations = res.data.data.map((curation) => { | ||||||
|  |             return {title: curation.title, value: curation.id} | ||||||
|  |           }) | ||||||
|  |  | ||||||
|  |           this.curations.unshift({title: '없음', value: 0}) | ||||||
|  |         } else { | ||||||
|  |           this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         } | ||||||
|  |       } catch (e) { | ||||||
|  |         this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |       } finally { | ||||||
|  |         this.is_loading = false | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async getAudioContent() { | ||||||
|  |       this.is_loading = true | ||||||
|  |       try { | ||||||
|  |         const res = await api.getAudioContentList(this.page) | ||||||
|  |         if (res.status === 200 && res.data.success === true) { | ||||||
|  |           const data = res.data.data | ||||||
|  |  | ||||||
|  |           const total_page = Math.ceil(data.totalCount / 10) | ||||||
|  |           this.audio_contents = data.items | ||||||
|  |  | ||||||
|  |           if (total_page <= 0) | ||||||
|  |             this.total_page = 1 | ||||||
|  |           else | ||||||
|  |             this.total_page = total_page | ||||||
|  |         } else { | ||||||
|  |           this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.is_loading = false | ||||||
|  |       } catch (e) { | ||||||
|  |         this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |         this.is_loading = false | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async search() { | ||||||
|  |       this.page = 1 | ||||||
|  |       await this.searchAudioContent() | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async searchAudioContent() { | ||||||
|  |       if (this.search_word.length === 0) { | ||||||
|  |         await this.getAudioContent() | ||||||
|  |       } else if (this.search_word.length < 2) { | ||||||
|  |         this.notifyError('검색어를 2글자 이상 입력하세요.') | ||||||
|  |       } else { | ||||||
|  |         this.is_loading = true | ||||||
|  |         try { | ||||||
|  |           const res = await api.searchAudioContent(this.search_word, this.page) | ||||||
|  |           if (res.status === 200 && res.data.success === true) { | ||||||
|  |             const data = res.data.data | ||||||
|  |  | ||||||
|  |             const total_page = Math.ceil(data.totalCount / 10) | ||||||
|  |             this.audio_contents = data.items | ||||||
|  |  | ||||||
|  |             if (total_page <= 0) | ||||||
|  |               this.total_page = 1 | ||||||
|  |             else | ||||||
|  |               this.total_page = total_page | ||||||
|  |           } else { | ||||||
|  |             this.notifyError(res.data.message || '알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           this.is_loading = false | ||||||
|  |         } catch (e) { | ||||||
|  |           this.notifyError('알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.') | ||||||
|  |           this.is_loading = false | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     async shareAudioContent(item) { | ||||||
|  |       this.is_loading = true | ||||||
|  |       try { | ||||||
|  |         const linkData = await dynamicLink.shareAudioContent(item, this.utm_source, this.utm_medium, this.utm_campaign); | ||||||
|  |         if (linkData.status === 200) { | ||||||
|  |           await navigator.clipboard.writeText(linkData.data.shortLink) | ||||||
|  |           this.notifySuccess("링크가 복사되었습니다.") | ||||||
|  |         } else { | ||||||
|  |           this.notifyError("링크를 생성하지 못했습니다.") | ||||||
|  |         } | ||||||
|  |       } finally { | ||||||
|  |         this.is_loading = false | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |   } | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung