youtube-download-service/resources/views/Main.vue

82 lines
2.5 KiB
Vue
Raw Normal View History

2024-06-17 10:13:49 +03:00
<template>
<v-card class="bg-gradient" style="height: 100%">
<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>
2024-06-18 10:47:48 +03:00
<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>
2024-06-17 10:13:49 +03:00
</v-card-text>
</v-card>
</v-card-text>
</v-card>
</template>
<script>
import {ref} from "vue";
import axios from "axios";
export default {
name: "Main",
data: () => ({
url: ref(''),
2024-06-18 10:47:48 +03:00
fetching: ref(false),
downloadAvailable: ref(false),
downloadLink: '',
hint: ref(''),
error: ref(false)
2024-06-17 10:13:49 +03:00
}),
methods: {
startDownload(){
2024-06-18 10:47:48 +03:00
this.error = false;
2024-06-18 06:21:52 +03:00
this.fetching = true;
2024-06-17 12:44:56 +03:00
axios.get(`/download_api?videourl=${this.url}`).then((responce)=>{
2024-06-18 09:55:50 +03:00
this.fetching = false;
2024-06-18 10:47:48 +03:00
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 = 'Возникла ошибка';
2024-06-17 10:13:49 +03:00
})
}
}
}
</script>
<style scoped>
.bg-gradient {
background: linear-gradient(-45deg, #f103b0, #f0a068, #4fdbfeff);
background-size: 200% 200%;
animation: gradient 15s ease infinite;
height: 100vh;
}
@keyframes gradient {
0% {
background-position: 0 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
</style>