2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-05-11 09:10:34 +00:00
|
|
|
<template>
|
|
|
|
<div class="_gaps">
|
|
|
|
<div class="_gaps">
|
2023-12-27 22:58:32 +00:00
|
|
|
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search">
|
2023-09-30 19:53:52 +00:00
|
|
|
<template #prefix><i class="ph-magnifying-glass ph-bold ph-lg"></i></template>
|
2023-05-11 09:10:34 +00:00
|
|
|
</MkInput>
|
2023-05-19 07:20:53 +00:00
|
|
|
<MkRadios v-model="searchOrigin" @update:modelValue="search()">
|
2023-05-11 09:10:34 +00:00
|
|
|
<option value="combined">{{ i18n.ts.all }}</option>
|
|
|
|
<option value="local">{{ i18n.ts.local }}</option>
|
|
|
|
<option value="remote">{{ i18n.ts.remote }}</option>
|
|
|
|
</MkRadios>
|
|
|
|
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<MkFoldableSection v-if="userPagination">
|
|
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
|
|
<MkUserList :key="key" :pagination="userPagination"/>
|
|
|
|
</MkFoldableSection>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-21 02:36:45 +00:00
|
|
|
import { ref } from 'vue';
|
2023-05-11 09:10:34 +00:00
|
|
|
import MkUserList from '@/components/MkUserList.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import * as os from '@/os.js';
|
2023-05-11 09:10:34 +00:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { useRouter } from '@/router.js';
|
2023-05-11 09:10:34 +00:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const key = ref('');
|
|
|
|
const searchQuery = ref('');
|
|
|
|
const searchOrigin = ref('combined');
|
|
|
|
const userPagination = ref();
|
2023-05-11 09:10:34 +00:00
|
|
|
|
|
|
|
async function search() {
|
2023-12-07 05:42:09 +00:00
|
|
|
const query = searchQuery.value.toString().trim();
|
2023-05-11 09:10:34 +00:00
|
|
|
|
|
|
|
if (query == null || query === '') return;
|
|
|
|
|
|
|
|
if (query.startsWith('https://')) {
|
|
|
|
const promise = os.api('ap/show', {
|
|
|
|
uri: query,
|
|
|
|
});
|
|
|
|
|
|
|
|
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-12-28 17:21:02 +00:00
|
|
|
if (query.match(/^@[a-z0-9_.-]+@[a-z0-9_.-]+$/i)) {
|
|
|
|
router.push(`/${query}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
userPagination.value = {
|
2023-05-11 09:10:34 +00:00
|
|
|
endpoint: 'users/search',
|
|
|
|
limit: 10,
|
|
|
|
params: {
|
2023-07-08 08:41:52 +00:00
|
|
|
query: query,
|
2023-12-07 05:42:09 +00:00
|
|
|
origin: searchOrigin.value,
|
2023-05-11 09:10:34 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
key.value = query;
|
2023-05-11 09:10:34 +00:00
|
|
|
}
|
|
|
|
</script>
|