From da66079c297c18f5628d262bf5d26662e5c25011 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:56:17 +0900 Subject: enhance(frontend): ノート検索ページのデザイン調整 (#14780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(frontend): 検索ページのホスト指定とユーザー指定を統合する (#273) (cherry picked from commit c79392c88d6bf58ede39d8bba9ca2778c58521ef) * fix * :art: * Update Changelog * Update Changelog * refactor --------- Co-authored-by: taiy <53635909+taiyme@users.noreply.github.com> --- packages/frontend/src/pages/search.note.vue | 315 +++++++++++++++------- packages/frontend/src/pages/search.user.vue | 11 +- packages/frontend/src/scripts/gen-search-query.ts | 35 --- 3 files changed, 222 insertions(+), 139 deletions(-) delete mode 100644 packages/frontend/src/scripts/gen-search-query.ts (limited to 'packages/frontend') diff --git a/packages/frontend/src/pages/search.note.vue b/packages/frontend/src/pages/search.note.vue index 14b9f7a741..a390e3fba1 100644 --- a/packages/frontend/src/pages/search.note.vue +++ b/packages/frontend/src/pages/search.note.vue @@ -6,69 +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 e8bc4cd6d3..2b8faf5465 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 - + @@ -49,14 +49,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 @@ -76,6 +78,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}`); } @@ -118,6 +121,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 a85ee01e26..0000000000 --- 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, - }; -} -- cgit v1.2.3-freya