VueTube/NUXT/pages/search.vue

59 lines
1.2 KiB
Vue
Raw Normal View History

2022-03-03 18:05:50 +00:00
<template>
<div>
2022-03-04 14:32:09 +00:00
<center style="padding-top: 3em;" v-if="videos == null">
<v-progress-circular
size="50"
indeterminate
color="primary"
/>
</center>
2022-03-03 23:13:14 +00:00
<v-list-item v-for="(video, index) in videos" :key="index">
2022-03-04 02:25:30 +00:00
<v-card class="entry">
2022-03-03 23:13:14 +00:00
<v-card-text>
<div style="position: relative;">
<v-img :src="video.thumbnails[video.thumbnails.length - 1].url" />
<p v-text="video.runtime" class="videoRuntimeFloat background--text" />
</div>
<p v-text="video.title" />
<p v-text="`${video.views} ${video.uploaded}`" />
<p v-text="video.id" />
2022-03-03 23:13:14 +00:00
</v-card-text>
</v-card>
</v-list-item>
2022-03-03 18:05:50 +00:00
</div>
</template>
2022-03-04 02:25:30 +00:00
<style scoped>
.entry {
2022-03-04 14:17:32 +00:00
margin-top: 1em;
2022-03-04 02:25:30 +00:00
}
.videoRuntimeFloat {
position: absolute;
bottom: 0;
right: 10px;
background: rgba(0, 0, 0, 0.5);
border-radius: 1em;
padding: 3px;
}
2022-03-04 02:25:30 +00:00
</style>
2022-03-03 18:05:50 +00:00
<script>
export default {
data() {
return {
2022-03-04 14:32:09 +00:00
videos: null
2022-03-03 18:05:50 +00:00
}
},
mounted() {
2022-03-04 02:25:30 +00:00
const searchQuestion = this.$route.query.q
2022-03-03 18:05:50 +00:00
const vm = this;
2022-03-04 02:25:30 +00:00
this.$youtube.search(searchQuestion, (data) => {
2022-03-04 14:32:09 +00:00
console.log(data)
2022-03-03 23:13:14 +00:00
vm.videos = data;
2022-03-03 18:05:50 +00:00
})
}
}
</script>