0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-09 04:55:07 +00:00
VueTube/NUXT/components/UtilRenderers/slimVideoDescriptionRenderer.vue

62 lines
1.7 KiB
Vue
Raw Normal View History

2022-03-27 04:31:32 +00:00
<template>
2022-03-27 05:48:27 +00:00
<div class="description" style="white-space: pre-line">
<template v-for="(text, index) in render.description.runs">
<template
v-if="
text.navigationEndpoint && text.navigationEndpoint.webviewEndpoint
"
>
<a @click="openExternal(parseLinks(text))" :key="index" class="link">{{
text.text
}}</a>
</template>
<template v-else-if="checkInternal(text)">
<a @click="openInternal(parseLinks(text))" :key="index" class="link">{{
text.text
}}</a>
2022-03-27 05:48:27 +00:00
</template>
<template v-else> {{ text.text }} </template>
</template>
2022-03-27 04:31:32 +00:00
</div>
</template>
<style scoped></style>
<script>
import { Browser } from "@capacitor/browser";
2022-03-27 04:31:32 +00:00
export default {
props: ["render"],
methods: {
2022-03-27 04:49:12 +00:00
parseLinks(base) {
const navEndpoint = base.navigationEndpoint;
2022-03-27 04:31:32 +00:00
if (!navEndpoint) return;
2022-03-27 04:49:12 +00:00
if (navEndpoint.webviewEndpoint) {
return navEndpoint.webviewEndpoint.url;
2022-03-27 04:31:32 +00:00
} else if (navEndpoint.browseEndpoint) {
return navEndpoint.browseEndpoint.canonicalBaseUrl;
} else if (navEndpoint.watchEndpoint) {
return `/watch?v=${navEndpoint.watchEndpoint.videoId}`;
2022-03-27 04:31:32 +00:00
} else if (navEndpoint.navigationEndpoint) {
return; //for now
}
},
checkInternal(base) {
const navEndpoint = base.navigationEndpoint;
if (!navEndpoint) return false;
if (navEndpoint.browseEndpoint || navEndpoint.watchEndpoint) {
return true;
} else {
return false;
}
},
async openExternal(url) {
await Browser.open({ url: url });
},
async openInternal(url) {
await this.$router.push(url);
},
2022-03-27 04:31:32 +00:00
},
};
</script>