From 43fafc8d5751f0741cb6883cf2b9a06de0e02b53 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 30 Dec 2022 14:24:00 +0900 Subject: [PATCH] enhance(client): tweak url preview --- locales/ja-JP.yml | 1 + .../frontend/src/components/MkUrlPreview.vue | 42 +++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 598b888c36..2764a85abb 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -915,6 +915,7 @@ windowRestore: "元に戻す" caption: "キャプション" loggedInAsBot: "Botアカウントでログイン中" tools: "ツール" +cannotLoad: "読み込めません" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" diff --git a/packages/frontend/src/components/MkUrlPreview.vue b/packages/frontend/src/components/MkUrlPreview.vue index 8ebfbe58e8..f8484e38a5 100644 --- a/packages/frontend/src/components/MkUrlPreview.vue +++ b/packages/frontend/src/components/MkUrlPreview.vue @@ -7,22 +7,26 @@
- - -
-
-
-
-

{{ title }}

-
-

{{ description.length > 85 ? description.slice(0, 85) + '…' : description }}

-
- -

{{ sitename }}

-
-
-
-
+ +
+
+
+
+

{{ url }}

+

+

{{ title }}

+
+

{{ i18n.ts.cannotLoad }}

+

+

{{ description.length > 85 ? description.slice(0, 85) + '…' : description }}

+
+ +

?

+

+

{{ sitename }}

+
+
+
{{ i18n.ts.expandTweet }} @@ -78,6 +82,7 @@ let tweetId = $ref(null); let tweetExpanded = $ref(props.detail); const embedId = `embed${Math.random().toString().replace(/\D/, '')}`; let tweetHeight = $ref(150); +let unknownUrl = $ref(false); const requestUrl = new URL(props.url); @@ -96,7 +101,10 @@ requestUrl.hash = ''; window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${requestLang}`).then(res => { res.json().then(info => { - if (info.url == null) return; + if (info.url == null) { + unknownUrl = true; + return; + } title = info.title; description = info.description; thumbnail = info.thumbnail;