From 657697ab937a5201ff8815bbe6c062f8c0c39ff2 Mon Sep 17 00:00:00 2001 From: taiy <53635909+taiyme@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:39:28 +0900 Subject: [PATCH 1/5] =?UTF-8?q?enhance(frontend):=20=E6=A4=9C=E7=B4=A2?= =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=9B=E3=82=B9=E3=83=88?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=81=A8=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=82=92=E7=B5=B1=E5=90=88=E3=81=99=E3=82=8B?= =?UTF-8?q?=20(#273)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit c79392c88d6bf58ede39d8bba9ca2778c58521ef) --- locales/index.d.ts | 30 ++ locales/ja-JP.yml | 9 + packages/frontend/src/pages/search.note.vue | 305 ++++++++++++------ packages/frontend/src/pages/search.user.vue | 11 +- .../frontend/src/scripts/gen-search-query.ts | 35 -- 5 files changed, 254 insertions(+), 136 deletions(-) delete mode 100644 packages/frontend/src/scripts/gen-search-query.ts diff --git a/locales/index.d.ts b/locales/index.d.ts index b5af5909a324..060ea09aa53d 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -10471,6 +10471,36 @@ export interface Locale extends ILocale { */ "codeGeneratedDescription": string; }; + "_search": { + /** + * 全て + */ + "searchScopeAll": string; + /** + * ローカル + */ + "searchScopeLocal": string; + /** + * サーバー指定 + */ + "searchScopeServer": string; + /** + * ユーザー指定 + */ + "searchScopeUser": string; + /** + * サーバーのホストを入力してください + */ + "pleaseEnterServerHost": string; + /** + * ユーザーを選択してください + */ + "pleaseSelectUser": string; + /** + * 例: misskey.example.com + */ + "serverHostPlaceholder": string; + }; } declare const locales: { [lang: string]: Locale; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index c448d4d50a73..9c60bcefd371 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2789,3 +2789,12 @@ _embedCodeGen: generateCode: "埋め込みコードを作成" codeGenerated: "コードが生成されました" codeGeneratedDescription: "生成されたコードをウェブサイトに貼り付けてご利用ください。" + +_search: + searchScopeAll: "全て" + searchScopeLocal: "ローカル" + searchScopeServer: "サーバー指定" + searchScopeUser: "ユーザー指定" + pleaseEnterServerHost: "サーバーのホストを入力してください" + pleaseSelectUser: "ユーザーを選択してください" + serverHostPlaceholder: "例: misskey.example.com" diff --git a/packages/frontend/src/pages/search.note.vue b/packages/frontend/src/pages/search.note.vue index 105c947d2543..5a9b3231476f 100644 --- a/packages/frontend/src/pages/search.note.vue +++ b/packages/frontend/src/pages/search.note.vue @@ -6,67 +6,127 @@ SPDX-License-Identifier: AGPL-3.0-only diff --git a/packages/frontend/src/pages/search.user.vue b/packages/frontend/src/pages/search.user.vue index 724fbfdfbda1..faafcc9b2704 100644 --- a/packages/frontend/src/pages/search.user.vue +++ b/packages/frontend/src/pages/search.user.vue @@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -48,14 +48,16 @@ const props = withDefaults(defineProps<{ const router = useRouter(); -const key = ref(''); +const key = ref(0); +const userPagination = ref>(); + const searchQuery = ref(toRef(props, 'query').value); const searchOrigin = ref(toRef(props, 'origin').value); -const userPagination = ref(); async function search() { const query = searchQuery.value.toString().trim(); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (query == null || query === '') return; //#region AP lookup @@ -75,6 +77,7 @@ async function search() { if (res.type === 'User') { router.push(`/@${res.object.username}@${res.object.host}`); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition } else if (res.type === 'Note') { router.push(`/notes/${res.object.id}`); } @@ -117,6 +120,6 @@ async function search() { }, }; - key.value = query; + key.value++; } diff --git a/packages/frontend/src/scripts/gen-search-query.ts b/packages/frontend/src/scripts/gen-search-query.ts deleted file mode 100644 index a85ee01e26e5..000000000000 --- a/packages/frontend/src/scripts/gen-search-query.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and misskey-project - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import * as Misskey from 'misskey-js'; -import { host as localHost } from '@@/js/config.js'; - -export async function genSearchQuery(v: any, q: string) { - let host: string; - let userId: string; - if (q.split(' ').some(x => x.startsWith('@'))) { - for (const at of q.split(' ').filter(x => x.startsWith('@')).map(x => x.substring(1))) { - if (at.includes('.')) { - if (at === localHost || at === '.') { - host = null; - } else { - host = at; - } - } else { - const user = await v.api('users/show', Misskey.acct.parse(at)).catch(x => null); - if (user) { - userId = user.id; - } else { - // todo: show error - } - } - } - } - return { - query: q.split(' ').filter(x => !x.startsWith('/') && !x.startsWith('@')).join(' '), - host: host, - userId: userId, - }; -} From 2290bd7bb72bb2514a7a0ef73fe559bceb1a69cb Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:14:16 +0900 Subject: [PATCH 2/5] fix --- packages/frontend/src/pages/search.note.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/search.note.vue b/packages/frontend/src/pages/search.note.vue index 5a9b3231476f..295918d70605 100644 --- a/packages/frontend/src/pages/search.note.vue +++ b/packages/frontend/src/pages/search.note.vue @@ -332,7 +332,7 @@ async function search() { width: 100%; height: 100%; padding: 12px; - border: 2px dashed var(--fgTransparent); + border: 2px dashed var(--MI_THEME-fgTransparent); } .userSelectButtonInner { From 780ba5a18255e0cd5b64b66977246f36d0d864b0 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:23:04 +0900 Subject: [PATCH 3/5] :art: --- packages/frontend/src/pages/search.note.vue | 34 ++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/packages/frontend/src/pages/search.note.vue b/packages/frontend/src/pages/search.note.vue index 295918d70605..2f7d01b19793 100644 --- a/packages/frontend/src/pages/search.note.vue +++ b/packages/frontend/src/pages/search.note.vue @@ -26,22 +26,22 @@ SPDX-License-Identifier: AGPL-3.0-only - - - - - -
+
+ + + + +
+ +
{{ i18n.ts._search.pleaseSelectUser }}
-
+