From dd60f1a53381ab55cd82e0697da7e20eb252bd9b Mon Sep 17 00:00:00 2001 From: tamaina Date: Wed, 17 May 2023 20:00:28 +0000 Subject: [PATCH] =?UTF-8?q?fix(frontend/MkUrlPreview):=20summaly=E3=81=8C?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E9=9A=9B=E3=81=AE=E6=8C=99=E5=8B=95=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + locales/ja-JP.yml | 1 + .../frontend/src/components/MkUrlPreview.vue | 30 ++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a20120b483d6..2ea1c2842a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ ### Client - 開発者モードを追加 - AiScriptを0.13.3に更新 +- Fix: URLプレビューで情報が取得できなかった際の挙動を修正 ## 13.12.2 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 340698a12bcd..264908482c75 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1048,6 +1048,7 @@ preventAiLearning: "生成AIによる学習を拒否" preventAiLearningDescription: "外部の文章生成AIや画像生成AIに対して、投稿したノートや画像などのコンテンツを学習の対象にしないように要求します。これはnoaiフラグをHTMLレスポンスに含めることによって実現されますが、この要求に従うかはそのAI次第であるため、学習を完全に防止するものではありません。" options: "オプション" specifyUser: "ユーザー指定" +failedToPreviewUrl: "プレビューできません" _initialAccountSetting: accountCreated: "アカウントの作成が完了しました!" diff --git a/packages/frontend/src/components/MkUrlPreview.vue b/packages/frontend/src/components/MkUrlPreview.vue index 9c5622b1c586..23be8143225f 100644 --- a/packages/frontend/src/components/MkUrlPreview.vue +++ b/packages/frontend/src/components/MkUrlPreview.vue @@ -41,14 +41,14 @@

{{ title }}

-

{{ i18n.ts.cannotLoad }}

+

{{ i18n.ts.failedToPreviewUrl }}

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

@@ -128,17 +128,33 @@ if (requestUrl.hostname === 'music.youtube.com' && requestUrl.pathname.match('^/ requestUrl.hash = ''; -window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`).then(res => { - res.json().then((info: SummalyResult) => { +window.fetch(`/url?url=${encodeURIComponent(requestUrl.href)}&lang=${versatileLang}`) + .then(res => { + if (!res.ok) { + fetching = false; + unknownUrl = true; + return; + } + + return res.json(); + }) + .then((info: SummalyResult) => { + if (info.url == null) { + fetching = false; + unknownUrl = true; + return; + } + + fetching = false; + unknownUrl = false; + title = info.title; description = info.description; thumbnail = info.thumbnail; icon = info.icon; sitename = info.sitename; - fetching = false; player = info.player; }); -}); function adjustTweetHeight(message: any) { if (message.origin !== 'https://platform.twitter.com') return;