Допиливаем

This commit is contained in:
p.belezov 2024-06-18 15:47:48 +08:00
parent 766f7d4f9d
commit 19d316221c

View File

@ -3,10 +3,14 @@
<v-card-text class="d-flex justify-center align-center">
<v-card class="align-center justify-center h-auto w-33">
<v-card-title>Вставьте ссылку:</v-card-title>
<v-card-text class="justify-center">
<v-text-field v-model="url" label="Ссылка"/>
<v-btn @click="startDownload">Найти</v-btn>
<v-btn>Скачать</v-btn>
<v-card-text class="d-flex flex-column justify-center">
<v-text-field v-model="url" label="Ссылка" :loading="fetching">
</v-text-field>
<v-label v-if="error" class="text-red">{{ hint }}</v-label>
<div class="d-flex align-center justify-center">
<v-btn class="mr-5 ml-5" variant="elevated" color="blue" @click="startDownload">Найти</v-btn>
<v-btn v-if="downloadAvailable" :href="downloadLink" target="_blank" class="mr-5 ml-5" variant="elevated" color="blue">Скачать</v-btn>
</div>
</v-card-text>
</v-card>
</v-card-text>
@ -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 = 'Возникла ошибка';
})
}
}