enhance(frontend): 検索

This commit is contained in:
kakkokari-gtyih 2024-12-10 14:55:25 +09:00
parent 1d837c0e64
commit d5156dbfb9
2 changed files with 15 additions and 12 deletions

View File

@ -13,15 +13,17 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #header>{{ i18n.ts.options }}</template> <template #header>{{ i18n.ts.options }}</template>
<div class="_gaps_m"> <div class="_gaps_m">
<MkRadios v-model="hostSelect"> <template v-if="instance.federation !== 'none'">
<template #label>{{ i18n.ts.host }}</template> <MkRadios v-model="hostSelect">
<option value="all" default>{{ i18n.ts.all }}</option> <template #label>{{ i18n.ts.host }}</template>
<option value="local">{{ i18n.ts.local }}</option> <option value="all" default>{{ i18n.ts.all }}</option>
<option v-if="noteSearchableScope === 'global'" value="specified">{{ i18n.ts.specifyHost }}</option> <option value="local">{{ i18n.ts.local }}</option>
</MkRadios> <option v-if="noteSearchableScope === 'global'" value="specified">{{ i18n.ts.specifyHost }}</option>
<MkInput v-if="noteSearchableScope === 'global'" v-model="hostInput" :disabled="hostSelect !== 'specified'" :large="true" type="search"> </MkRadios>
<template #prefix><i class="ti ti-server"></i></template> <MkInput v-if="noteSearchableScope === 'global'" v-model="hostInput" :disabled="hostSelect !== 'specified'" :large="true" type="search">
</MkInput> <template #prefix><i class="ti ti-server"></i></template>
</MkInput>
</template>
<MkFolder :defaultOpen="true"> <MkFolder :defaultOpen="true">
<template #label>{{ i18n.ts.specifyUser }}</template> <template #label>{{ i18n.ts.specifyUser }}</template>
@ -102,7 +104,7 @@ setHostSelectWithInput(hostInput.value, undefined);
watch(hostInput, setHostSelectWithInput); watch(hostInput, setHostSelectWithInput);
const searchHost = computed(() => { const searchHost = computed(() => {
if (hostSelect.value === 'local') return '.'; if (hostSelect.value === 'local' || instance.federation === 'none') return '.';
if (hostSelect.value === 'specified') return hostInput.value; if (hostSelect.value === 'specified') return hostInput.value;
return null; return null;
}); });

View File

@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter.prevent="search"> <MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter.prevent="search">
<template #prefix><i class="ti ti-search"></i></template> <template #prefix><i class="ti ti-search"></i></template>
</MkInput> </MkInput>
<MkRadios v-model="searchOrigin" @update:modelValue="search()"> <MkRadios v-if="instance.federation !== 'none'" v-model="searchOrigin" @update:modelValue="search()">
<option value="combined">{{ i18n.ts.all }}</option> <option value="combined">{{ i18n.ts.all }}</option>
<option value="local">{{ i18n.ts.local }}</option> <option value="local">{{ i18n.ts.local }}</option>
<option value="remote">{{ i18n.ts.remote }}</option> <option value="remote">{{ i18n.ts.remote }}</option>
@ -33,6 +33,7 @@ import MkInput from '@/components/MkInput.vue';
import MkRadios from '@/components/MkRadios.vue'; import MkRadios from '@/components/MkRadios.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import MkFoldableSection from '@/components/MkFoldableSection.vue'; import MkFoldableSection from '@/components/MkFoldableSection.vue';
import { misskeyApi } from '@/scripts/misskey-api.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
@ -113,7 +114,7 @@ async function search() {
limit: 10, limit: 10,
params: { params: {
query: query, query: query,
origin: searchOrigin.value, origin: instance.federation === 'none' ? 'local' : searchOrigin.value,
}, },
}; };