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">
|
2022-03-27 11:24:34 +00:00
|
|
|
<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>
|
2022-03-27 11:24:34 +00:00
|
|
|
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) {
|
2022-03-27 11:24:34 +00:00
|
|
|
return navEndpoint.webviewEndpoint.url;
|
2022-03-27 04:31:32 +00:00
|
|
|
} else if (navEndpoint.browseEndpoint) {
|
|
|
|
return navEndpoint.browseEndpoint.canonicalBaseUrl;
|
2022-03-27 11:24:34 +00:00
|
|
|
} 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
|
|
|
|
}
|
|
|
|
},
|
2022-03-27 11:24:34 +00:00
|
|
|
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>
|