VueTube/NUXT/pages/search.vue

63 lines
1.4 KiB
Vue
Raw Normal View History

2022-03-03 18:05:50 +00:00
<template>
2022-03-25 19:21:00 +00:00
<div class="background">
2022-03-24 11:47:13 +00:00
<!-- Video Loading Animation -->
<vid-load-renderer v-if="renderer.length <= 0" />
<sectionListRenderer :render="renderer" />
2022-03-03 18:05:50 +00:00
</div>
</template>
<script>
2022-03-24 20:46:17 +00:00
import sectionListRenderer from "~/components/ListRenderers/sectionListRenderer.vue";
import VidLoadRenderer from "~/components/vidLoadRenderer.vue";
2022-03-24 11:47:13 +00:00
2022-03-03 18:05:50 +00:00
export default {
2022-03-24 11:47:13 +00:00
components: {
sectionListRenderer,
VidLoadRenderer,
},
2022-03-03 18:05:50 +00:00
data() {
return {
2022-03-24 11:47:13 +00:00
renderer: [],
2022-03-21 05:13:21 +00:00
};
2022-03-03 18:05:50 +00:00
},
2022-03-22 08:23:23 +00:00
watch: {
// Watches for new searches while the current search page is active.
$route: {
deep: true,
handler(newSearch, oldSearch) {
if (newSearch.query.q != oldSearch.query.q) {
this.getSearch();
}
},
},
2022-03-21 05:13:21 +00:00
},
2022-03-25 03:25:51 +00:00
mounted() {
this.getSearch();
},
methods: {
getSearch() {
this.$store.commit("search/setLoading", true); // in case navigated to the page not from top bar
2022-03-25 03:25:51 +00:00
const searchQuestion = this.$route.query.q;
this.$youtube.search(searchQuestion).then((response) => {
this.$store.commit("search/setLoading", false);
2022-03-25 03:25:51 +00:00
this.renderer = response;
});
},
},
2022-03-21 05:13:21 +00:00
};
2022-03-03 18:05:50 +00:00
</script>
<style scoped>
.entry {
width: 100%; /* Prevent Loading Weirdness */
}
.videoRuntimeFloat {
position: absolute;
bottom: 10px;
right: 10px;
background: rgba(0, 0, 0, 0.5);
border-radius: 5px;
padding: 0px 4px 0px 4px;
}
</style>