refactor(frontend): 非推奨となったReactivity Transformを使わないように (#12539)
* 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: 対応漏れ
This commit is contained in:
parent
e42c91dee7
commit
406b4bdbe7
277 changed files with 3353 additions and 3441 deletions
|
@ -83,7 +83,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { defineAsyncComponent, onUnmounted } from 'vue';
|
||||
import { defineAsyncComponent, onUnmounted, ref } from 'vue';
|
||||
import type { summaly } from 'summaly';
|
||||
import { url as local } from '@/config.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
@ -107,36 +107,36 @@ const props = withDefaults(defineProps<{
|
|||
});
|
||||
|
||||
const MOBILE_THRESHOLD = 500;
|
||||
const isMobile = $ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
||||
const isMobile = ref(deviceKind === 'smartphone' || window.innerWidth <= MOBILE_THRESHOLD);
|
||||
|
||||
const self = props.url.startsWith(local);
|
||||
const attr = self ? 'to' : 'href';
|
||||
const target = self ? null : '_blank';
|
||||
let fetching = $ref(true);
|
||||
let title = $ref<string | null>(null);
|
||||
let description = $ref<string | null>(null);
|
||||
let thumbnail = $ref<string | null>(null);
|
||||
let icon = $ref<string | null>(null);
|
||||
let sitename = $ref<string | null>(null);
|
||||
let sensitive = $ref<boolean>(false);
|
||||
let player = $ref({
|
||||
const fetching = ref(true);
|
||||
const title = ref<string | null>(null);
|
||||
const description = ref<string | null>(null);
|
||||
const thumbnail = ref<string | null>(null);
|
||||
const icon = ref<string | null>(null);
|
||||
const sitename = ref<string | null>(null);
|
||||
const sensitive = ref<boolean>(false);
|
||||
const player = ref({
|
||||
url: null,
|
||||
width: null,
|
||||
height: null,
|
||||
} as SummalyResult['player']);
|
||||
let playerEnabled = $ref(false);
|
||||
let tweetId = $ref<string | null>(null);
|
||||
let tweetExpanded = $ref(props.detail);
|
||||
const playerEnabled = ref(false);
|
||||
const tweetId = ref<string | null>(null);
|
||||
const tweetExpanded = ref(props.detail);
|
||||
const embedId = `embed${Math.random().toString().replace(/\D/, '')}`;
|
||||
let tweetHeight = $ref(150);
|
||||
let unknownUrl = $ref(false);
|
||||
const tweetHeight = ref(150);
|
||||
const unknownUrl = ref(false);
|
||||
|
||||
const requestUrl = new URL(props.url);
|
||||
if (!['http:', 'https:'].includes(requestUrl.protocol)) throw new Error('invalid url');
|
||||
|
||||
if (requestUrl.hostname === 'twitter.com' || requestUrl.hostname === 'mobile.twitter.com' || requestUrl.hostname === 'x.com' || requestUrl.hostname === 'mobile.x.com') {
|
||||
const m = requestUrl.pathname.match(/^\/.+\/status(?:es)?\/(\d+)/);
|
||||
if (m) tweetId = m[1];
|
||||
if (m) tweetId.value = m[1];
|
||||
}
|
||||
|
||||
if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/(?:watch|channel)')) {
|
||||
|
@ -148,8 +148,8 @@ requestUrl.hash = '';
|
|||
window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`)
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
fetching = false;
|
||||
unknownUrl = true;
|
||||
fetching.value = false;
|
||||
unknownUrl.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -157,21 +157,21 @@ window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLa
|
|||
})
|
||||
.then((info: SummalyResult) => {
|
||||
if (info.url == null) {
|
||||
fetching = false;
|
||||
unknownUrl = true;
|
||||
fetching.value = false;
|
||||
unknownUrl.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
fetching = false;
|
||||
unknownUrl = false;
|
||||
fetching.value = false;
|
||||
unknownUrl.value = false;
|
||||
|
||||
title = info.title;
|
||||
description = info.description;
|
||||
thumbnail = info.thumbnail;
|
||||
icon = info.icon;
|
||||
sitename = info.sitename;
|
||||
player = info.player;
|
||||
sensitive = info.sensitive ?? false;
|
||||
title.value = info.title;
|
||||
description.value = info.description;
|
||||
thumbnail.value = info.thumbnail;
|
||||
icon.value = info.icon;
|
||||
sitename.value = info.sitename;
|
||||
player.value = info.player;
|
||||
sensitive.value = info.sensitive ?? false;
|
||||
});
|
||||
|
||||
function adjustTweetHeight(message: any) {
|
||||
|
@ -180,7 +180,7 @@ function adjustTweetHeight(message: any) {
|
|||
if (embed?.method !== 'twttr.private.resize') return;
|
||||
if (embed?.id !== embedId) return;
|
||||
const height = embed?.params[0]?.height;
|
||||
if (height) tweetHeight = height;
|
||||
if (height) tweetHeight.value = height;
|
||||
}
|
||||
|
||||
const openPlayer = (): void => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue