mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-11-15 20:06:54 +01:00
406b4bdbe7
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
79 lines
2 KiB
Vue
79 lines
2 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<MkWindow :initialWidth="640" :initialHeight="402" :canResize="true" :closeButton="true">
|
|
<template #header>
|
|
<i class="icon ti ti-brand-youtube" style="margin-right: 0.5em;"></i>
|
|
<span>{{ title ?? 'YouTube' }}</span>
|
|
</template>
|
|
|
|
<div class="poamfof">
|
|
<Transition :name="defaultStore.state.animation ? 'fade' : ''" mode="out-in">
|
|
<div v-if="player.url && (player.url.startsWith('http://') || player.url.startsWith('https://'))" class="player">
|
|
<iframe v-if="!fetching" :src="player.url + (player.url.match(/\?/) ? '&autoplay=1&auto_play=1' : '?autoplay=1&auto_play=1')" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen/>
|
|
</div>
|
|
<span v-else>invalid url</span>
|
|
</Transition>
|
|
<MkLoading v-if="fetching"/>
|
|
<MkError v-else-if="!player.url" @retry="ytFetch()"/>
|
|
</div>
|
|
</MkWindow>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref } from 'vue';
|
|
import MkWindow from '@/components/MkWindow.vue';
|
|
import { versatileLang } from '@/scripts/intl-const.js';
|
|
import { defaultStore } from '@/store.js';
|
|
|
|
const props = defineProps<{
|
|
url: string;
|
|
}>();
|
|
|
|
const requestUrl = new URL(props.url);
|
|
if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url');
|
|
|
|
const fetching = ref(true);
|
|
const title = ref<string | null>(null);
|
|
const player = ref({
|
|
url: null,
|
|
width: null,
|
|
height: null,
|
|
});
|
|
|
|
const ytFetch = (): void => {
|
|
fetching.value = true;
|
|
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`).then(res => {
|
|
res.json().then(info => {
|
|
if (info.url == null) return;
|
|
title.value = info.title;
|
|
fetching.value = false;
|
|
player.value = info.player;
|
|
});
|
|
});
|
|
};
|
|
|
|
ytFetch();
|
|
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.poamfof {
|
|
position: relative;
|
|
overflow: hidden;
|
|
height: 100%;
|
|
|
|
.player {
|
|
position: absolute;
|
|
inset: 0;
|
|
|
|
iframe {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
</style>
|