diff --git a/resources/views/Main.vue b/resources/views/Main.vue index 55ce07f..576b0a4 100644 --- a/resources/views/Main.vue +++ b/resources/views/Main.vue @@ -3,10 +3,14 @@ Вставьте ссылку: - - - Найти - Скачать + + + + {{ hint }} +
+ Найти + Скачать +
@@ -21,14 +25,31 @@ export default { name: "Main", data: () => ({ url: ref(''), - fetching: ref(false) + fetching: ref(false), + downloadAvailable: ref(false), + downloadLink: '', + hint: ref(''), + error: ref(false) }), methods: { startDownload(){ + this.error = false; this.fetching = true; axios.get(`/download_api?videourl=${this.url}`).then((responce)=>{ this.fetching = false; - console.log(responce); + if (responce.data.error){ + this.error = true; + this.hint = 'Возникла ошибка'; + console.log(responce.data.error); + } else if (responce.data.link){ + this.downloadAvailable = true; + this.downloadLink = `/download/${responce.data.link}`; + } + }).catch((error)=>{ + this.fetching = false; + console.log(error); + this.error = true; + this.hint = 'Возникла ошибка'; }) } }