2020-11-12 20:42:02 +00:00
|
|
|
<template>
|
2020-11-17 05:15:35 +00:00
|
|
|
<div v-if="channel">
|
|
|
|
<h1 class="uk-text-center">
|
|
|
|
<img v-bind:src="channel.avatarUrl" />{{ channel.name }}
|
|
|
|
</h1>
|
2020-11-22 04:35:01 +00:00
|
|
|
<img
|
|
|
|
v-if="channel.bannerUrl"
|
|
|
|
v-bind:src="channel.bannerUrl"
|
|
|
|
style="width: 100%"
|
|
|
|
/>
|
2020-11-17 05:15:35 +00:00
|
|
|
<p v-html="this.channel.description.replaceAll('\n', '<br>')"></p>
|
2020-11-13 11:57:11 +00:00
|
|
|
|
2020-11-17 05:15:35 +00:00
|
|
|
<hr />
|
2020-11-13 11:57:11 +00:00
|
|
|
|
2020-11-22 04:35:01 +00:00
|
|
|
<div class="uk-grid-xl" uk-grid="parallax: 0">
|
2020-11-17 05:15:35 +00:00
|
|
|
<div
|
2020-11-22 04:35:01 +00:00
|
|
|
class="uk-width-1-2 uk-width-1-3@m uk-width-1-4@l uk-width-1-5@xl"
|
2020-11-17 05:15:35 +00:00
|
|
|
v-bind:key="item.url"
|
|
|
|
v-for="item in this.channel.relatedStreams"
|
|
|
|
>
|
|
|
|
<router-link
|
2020-11-22 04:35:01 +00:00
|
|
|
class="uk-link-muted uk-text-justify"
|
2020-11-17 05:15:35 +00:00
|
|
|
v-bind:to="item.url || '/'"
|
|
|
|
>
|
|
|
|
<img style="width: 100%" v-bind:src="item.thumbnail" />
|
|
|
|
<a>{{ item.title }}</a>
|
|
|
|
</router-link>
|
|
|
|
<br />
|
2020-11-22 04:35:01 +00:00
|
|
|
<div>
|
|
|
|
<b class="uk-text-small uk-align-left">
|
|
|
|
{{ timeFormat(item.duration) }}
|
|
|
|
</b>
|
|
|
|
<b class="uk-text-small uk-align-right">
|
|
|
|
<font-awesome-icon icon="eye"></font-awesome-icon>
|
|
|
|
{{ item.views }} views
|
|
|
|
</b>
|
|
|
|
</div>
|
2020-11-17 05:15:35 +00:00
|
|
|
</div>
|
2020-11-12 20:42:02 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Constants from "@/Constants.js";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2020-11-17 05:15:35 +00:00
|
|
|
channel: null
|
|
|
|
};
|
2020-11-12 20:42:02 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
2020-11-17 05:15:35 +00:00
|
|
|
this.getChannelData();
|
2020-11-25 05:18:14 +00:00
|
|
|
window.addEventListener("scroll", this.handleScroll);
|
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
window.removeEventListener("scroll", this.handleScroll);
|
2020-11-12 20:42:02 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async fetchChannel() {
|
|
|
|
return await (
|
2020-11-17 05:15:35 +00:00
|
|
|
await fetch(
|
|
|
|
Constants.BASE_URL +
|
|
|
|
"/channels/" +
|
|
|
|
this.$route.params.channelId
|
|
|
|
)
|
2020-11-12 20:42:02 +00:00
|
|
|
).json();
|
|
|
|
},
|
|
|
|
async getChannelData() {
|
2020-11-17 05:15:35 +00:00
|
|
|
this.fetchChannel()
|
|
|
|
.then(data => (this.channel = data))
|
|
|
|
.then(() => (document.title = this.channel.name + " - Piped"));
|
2020-11-12 20:42:02 +00:00
|
|
|
},
|
2020-11-22 04:35:01 +00:00
|
|
|
timeFormat(d) {
|
|
|
|
return require("@/utils/TimeUtils.js").default.timeFormat(d);
|
2020-11-25 05:18:14 +00:00
|
|
|
},
|
|
|
|
handleScroll() {
|
|
|
|
if (this.loading || !this.channel || !this.channel.nextpage) return;
|
|
|
|
if (
|
|
|
|
window.innerHeight + window.scrollY >=
|
|
|
|
document.body.offsetHeight - window.innerHeight / 2
|
|
|
|
) {
|
|
|
|
this.loading = true;
|
|
|
|
fetch(
|
|
|
|
Constants.BASE_URL +
|
|
|
|
"/nextpage/channels/" +
|
|
|
|
this.$route.params.channelId +
|
|
|
|
"?url=" +
|
|
|
|
encodeURIComponent(this.channel.nextpage)
|
|
|
|
)
|
|
|
|
.then(body => body.json())
|
|
|
|
.then(json => {
|
|
|
|
this.channel.relatedStreams.concat(json.relatedStreams);
|
|
|
|
this.channel.nextpage = json.nextpage;
|
|
|
|
this.loading = false;
|
|
|
|
json.relatedStreams.map(stream =>
|
|
|
|
this.channel.relatedStreams.push(stream)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
2020-11-12 20:42:02 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-17 05:15:35 +00:00
|
|
|
};
|
2020-11-12 20:42:02 +00:00
|
|
|
</script>
|