diff --git a/locales/en-US.yml b/locales/en-US.yml index 0476484aa..28cabce03 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -167,7 +167,6 @@ general: "General" wallpaper: "Wallpaper" setWallpaper: "Set wallpaper" removeWallpaper: "Remove wallpaper" -searchWith: "Search: {q}" youHaveNoLists: "You don't have any lists" followConfirm: "Are you sure that you want to follow {name}?" proxyAccount: "Proxy account" diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts index 8d8b21238..e75fe0ef6 100644 --- a/packages/backend/src/server/api/endpoints/notes/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/search.ts @@ -50,6 +50,8 @@ export default define(meta, paramDef, async (ps, me) => { if (ps.userId) { query.andWhere('note.userId = :userId', { userId: ps.userId }); + } else if (ps.host) { + query.andWhere('note.userHost = :host', { host: ps.host }); } else if (ps.channelId) { query.andWhere('note.channelId = :channelId', { channelId: ps.channelId }); } diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index d428c9ceb..692617abd 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -30,8 +30,8 @@ import * as sound from '@/scripts/sound'; import { $i, refreshAccount, login, updateAccount, signout } from '@/account'; import { defaultStore, ColdDeviceStorage } from '@/store'; import { fetchInstance, instance } from '@/instance'; +import { mainRouter } from '@/router'; import { makeHotkey } from '@/scripts/hotkey'; -import { search } from '@/scripts/search'; import { deviceKind } from '@/scripts/device-kind'; import { initializeSw } from '@/scripts/initialize-sw'; import { reloadChannel } from '@/scripts/unison-reload'; @@ -332,7 +332,9 @@ import { getAccountFromId } from '@/scripts/get-account-from-id'; 'd': (): void => { defaultStore.set('darkMode', !defaultStore.state.darkMode); }, - 's': search, + 's': (): void => { + mainRouter.push('/search'); + }, }; if ($i) { diff --git a/packages/client/src/menu.ts b/packages/client/src/menu.ts index dbe85fe4f..b730fdd8e 100644 --- a/packages/client/src/menu.ts +++ b/packages/client/src/menu.ts @@ -1,7 +1,6 @@ import { computed, ref, reactive } from 'vue'; import { $i } from '@/account'; import { mainRouter } from '@/router'; -import { search } from '@/scripts/search'; import * as os from '@/os'; import { i18n } from '@/i18n'; import { ui } from '@/config'; @@ -49,7 +48,7 @@ export const menuDef = reactive({ search: { title: 'search', icon: 'fas fa-search', - action: () => search(), + to: '/search', }, lists: { title: 'lists', diff --git a/packages/client/src/pages/explore.vue b/packages/client/src/pages/explore.vue index d27c32885..35a5c75c4 100644 --- a/packages/client/src/pages/explore.vue +++ b/packages/client/src/pages/explore.vue @@ -11,57 +11,19 @@
-
-
- - - - - - - - - -
- - -
+ + diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index 037109455..6d3011688 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -73,10 +73,6 @@ export const routes = [{ }, { path: '/search', component: page(() => import('./pages/search.vue')), - query: { - q: 'query', - channel: 'channel', - }, }, { path: '/authorize-follow', component: page(() => import('./pages/follow.vue')), diff --git a/packages/client/src/scripts/search.ts b/packages/client/src/scripts/search.ts deleted file mode 100644 index 64914d3d6..000000000 --- a/packages/client/src/scripts/search.ts +++ /dev/null @@ -1,63 +0,0 @@ -import * as os from '@/os'; -import { i18n } from '@/i18n'; -import { mainRouter } from '@/router'; - -export async function search() { - const { canceled, result: query } = await os.inputText({ - title: i18n.ts.search, - }); - if (canceled || query == null || query === '') return; - - const q = query.trim(); - - if (q.startsWith('@') && !q.includes(' ')) { - mainRouter.push(`/${q}`); - return; - } - - if (q.startsWith('#')) { - mainRouter.push(`/tags/${encodeURIComponent(q.substr(1))}`); - return; - } - - // like 2018/03/12 - if (/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}/.test(q.replace(/-/g, '/'))) { - const date = new Date(q.replace(/-/g, '/')); - - // 日付しか指定されてない場合、例えば 2018/03/12 ならユーザーは - // 2018/03/12 のコンテンツを「含む」結果になることを期待するはずなので - // 23時間59分進める(そのままだと 2018/03/12 00:00:00 「まで」の - // 結果になってしまい、2018/03/12 のコンテンツは含まれない) - if (q.replace(/-/g, '/').match(/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$/)) { - date.setHours(23, 59, 59, 999); - } - - // TODO - //v.$root.$emit('warp', date); - os.alert({ - icon: 'fas fa-history', - iconOnly: true, autoClose: true, - }); - return; - } - - if (q.startsWith('https://')) { - const promise = os.api('ap/show', { - uri: q, - }); - - os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); - - const res = await promise; - - if (res.type === 'User') { - mainRouter.push(`/@${res.object.username}@${res.object.host}`); - } else if (res.type === 'Note') { - mainRouter.push(`/notes/${res.object.id}`); - } - - return; - } - - mainRouter.push(`/search?q=${encodeURIComponent(q)}`); -} diff --git a/packages/client/src/ui/visitor/b.vue b/packages/client/src/ui/visitor/b.vue index 7f8446bc2..e330e5a70 100644 --- a/packages/client/src/ui/visitor/b.vue +++ b/packages/client/src/ui/visitor/b.vue @@ -50,7 +50,6 @@ import { ComputedRef, onMounted, provide } from 'vue'; import XHeader from './header.vue'; import XKanban from './kanban.vue'; import { host, instanceName } from '@/config'; -import { search } from '@/scripts/search'; import * as os from '@/os'; import MkPagination from '@/components/ui/pagination.vue'; import XSigninDialog from '@/components/signin-dialog.vue'; @@ -87,7 +86,9 @@ const keymap = $computed(() => { if (ColdDeviceStorage.get('syncDeviceDarkMode')) return; defaultStore.set('darkMode', !defaultStore.state.darkMode); }, - 's': search, + 's': () => { + mainRouter.push('/search'); + }, }; }); diff --git a/packages/client/src/ui/visitor/header.vue b/packages/client/src/ui/visitor/header.vue index 71d393284..dc364e16e 100644 --- a/packages/client/src/ui/visitor/header.vue +++ b/packages/client/src/ui/visitor/header.vue @@ -18,7 +18,7 @@
- + {{ i18n.ts.search }}
@@ -46,7 +46,6 @@ import { onMounted, ref, Ref } from 'vue'; import XSigninDialog from '@/components/signin-dialog.vue'; import XSignupDialog from '@/components/signup-dialog.vue'; import * as os from '@/os'; -import { search } from '@/scripts/search'; import { i18n } from '@/i18n'; defineProps<{