From 39b596f4f3dd78993991fdf6d5a244afe3c2e568 Mon Sep 17 00:00:00 2001 From: pen <121443048+penginn-0@users.noreply.github.com> Date: Fri, 21 Jun 2024 01:24:11 +0900 Subject: [PATCH] =?UTF-8?q?enhance(frontend):=20=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=A8=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E6=99=82=E3=81=AB=E7=85=A7=E4=BC=9A=E3=82=92?= =?UTF-8?q?=E8=A1=8C=E3=81=86=E3=81=8B=E3=82=92=E9=81=B8=E6=8A=9E=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#89)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG_yojo.md | 4 ++ locales/en-US.yml | 5 +++ locales/index.d.ts | 14 +++++++ locales/ja-JP.yml | 5 +++ packages/frontend/src/pages/search.note.vue | 29 +++++++++----- packages/frontend/src/pages/search.user.vue | 44 +++++++++++++++------ 6 files changed, 79 insertions(+), 22 deletions(-) diff --git a/CHANGELOG_yojo.md b/CHANGELOG_yojo.md index 3706f167fc..ac97d88026 100644 --- a/CHANGELOG_yojo.md +++ b/CHANGELOG_yojo.md @@ -23,6 +23,10 @@ ### General - メディアプロキシurlと拡大画像urlを分割 +### Client +- enhance: ノートとユーザーの検索時に照会を行うかが選択できるようになりました + - @foo@example.com 形式でユーザ検索した場合に照会ができるようになりました + ### Server - remoteProxyエンドポイント設定を追加 diff --git a/locales/en-US.yml b/locales/en-US.yml index d207768c0f..86da03b340 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -2854,3 +2854,8 @@ _advancedSearch: endDate: "Until" _description: other: "Other settings" + +_searchOrApShow: + question: "Want to search?" + search: "Search" + lookup: "Lookup" diff --git a/locales/index.d.ts b/locales/index.d.ts index d01efadca7..f812123c7a 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -11208,6 +11208,20 @@ export interface Locale extends ILocale { "other": string; }; }; + "_searchOrApShow": { + /** + * 照会を行いますか? + */ + "question": string; + /** + * 検索 + */ + "search": string; + /** + * 照会 + */ + "lookup": string; + }; } declare const locales: { [lang: string]: Locale; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 7838a3e1a6..a476457aa0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2987,3 +2987,8 @@ _advancedSearch: endDate: "まで" _description: other: "その他の設定" + +_searchOrApShow: + question: "照会を行いますか?" + search: "検索" + lookup: "照会" diff --git a/packages/frontend/src/pages/search.note.vue b/packages/frontend/src/pages/search.note.vue index 2bc17cbaf4..b1794bbede 100644 --- a/packages/frontend/src/pages/search.note.vue +++ b/packages/frontend/src/pages/search.note.vue @@ -111,21 +111,30 @@ async function search() { if (query == null || query === '') return; if (query.startsWith('https://')) { - const promise = misskeyApi('ap/show', { - uri: query, + const { canceled } = await os.confirm({ + type: 'question', + text: i18n.ts._searchOrApShow.question, + okText: i18n.ts._searchOrApShow.lookup, + cancelText: i18n.ts._searchOrApShow.search, }); - os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); + if (!canceled) { + const promise = misskeyApi('ap/show', { + uri: query, + }); - const res = await promise; + os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); - if (res.type === 'User') { - router.push(`/@${res.object.username}@${res.object.host}`); - } else if (res.type === 'Note') { - router.push(`/notes/${res.object.id}`); - } + const res = await promise; + + if (res.type === 'User') { + router.push(`/@${res.object.username}@${res.object.host}`); + } else if (res.type === 'Note') { + router.push(`/notes/${res.object.id}`); + } - return; + return; + } } if (isAdvancedSearchAvailable === true && advancedSearch.value === true) { diff --git a/packages/frontend/src/pages/search.user.vue b/packages/frontend/src/pages/search.user.vue index 05bffda5ed..d98ec71bb1 100644 --- a/packages/frontend/src/pages/search.user.vue +++ b/packages/frontend/src/pages/search.user.vue @@ -42,28 +42,48 @@ const key = ref(0); const searchQuery = ref(''); const searchOrigin = ref('combined'); const userPagination = ref(); +const isApUserName = RegExp('^@[a-zA-Z0-9_.]+@[a-zA-Z0-9-_.]+[a-zA-Z]$'); async function search() { const query = searchQuery.value.toString().trim(); if (query == null || query === '') return; - if (query.startsWith('https://')) { - const promise = misskeyApi('ap/show', { - uri: query, + if (query.startsWith('https://') || isApUserName.test(query)) { + const { canceled } = await os.confirm({ + type: 'question', + text: i18n.ts._searchOrApShow.question, + okText: i18n.ts._searchOrApShow.lookup, + cancelText: i18n.ts._searchOrApShow.search, }); - os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); + if (!canceled) { + if (isApUserName.test(query)) { + const querys = query.split('@'); + const promise = misskeyApi('users/show', { + username: querys[1], + host: querys[2], + }); + os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); + const res = await promise; + if (typeof res.error === 'undefined') { + router.push(`/@${res.username}@${res.host}`); + } + } else { + const promise = misskeyApi('ap/show', { + uri: query, + }); + os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); + const res = await promise; - const res = await promise; - - if (res.type === 'User') { - router.push(`/@${res.object.username}@${res.object.host}`); - } else if (res.type === 'Note') { - router.push(`/notes/${res.object.id}`); + if (res.type === 'User') { + router.push(`/@${res.object.username}@${res.object.host}`); + } else if (res.type === 'Note') { + router.push(`/notes/${res.object.id}`); + } + } + return; } - - return; } userPagination.value = {