2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-05-11 11:10:34 +02:00
|
|
|
<template>
|
|
|
|
<div class="_gaps">
|
|
|
|
<div class="_gaps">
|
2023-12-27 23:58:32 +01:00
|
|
|
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search">
|
2023-05-11 11:10:34 +02:00
|
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
|
|
|
</MkInput>
|
|
|
|
<MkFolder>
|
|
|
|
<template #label>{{ i18n.ts.options }}</template>
|
|
|
|
|
2023-08-20 06:39:37 +02:00
|
|
|
<div class="_gaps_m">
|
|
|
|
<MkSwitch v-model="isLocalOnly">{{ i18n.ts.localOnly }}</MkSwitch>
|
|
|
|
|
2024-02-02 08:49:09 +01:00
|
|
|
<MkFolder :defaultOpen="true">
|
2023-08-20 06:39:37 +02:00
|
|
|
<template #label>{{ i18n.ts.specifyUser }}</template>
|
|
|
|
<template v-if="user" #suffix>@{{ user.username }}</template>
|
|
|
|
|
|
|
|
<div style="text-align: center;" class="_gaps">
|
|
|
|
<div v-if="user">@{{ user.username }}</div>
|
|
|
|
<div>
|
|
|
|
<MkButton v-if="user == null" primary rounded inline @click="selectUser">{{ i18n.ts.selectUser }}</MkButton>
|
|
|
|
<MkButton v-else danger rounded inline @click="user = null">{{ i18n.ts.remove }}</MkButton>
|
|
|
|
</div>
|
2023-05-11 11:10:34 +02:00
|
|
|
</div>
|
2023-08-20 06:39:37 +02:00
|
|
|
</MkFolder>
|
|
|
|
</div>
|
2023-05-11 11:10:34 +02:00
|
|
|
</MkFolder>
|
|
|
|
<div>
|
|
|
|
<MkButton large primary gradate rounded style="margin: 0 auto;" @click="search">{{ i18n.ts.search }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<MkFoldableSection v-if="notePagination">
|
|
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
|
|
<MkNotes :key="key" :pagination="notePagination"/>
|
|
|
|
</MkFoldableSection>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-21 03:36:45 +01:00
|
|
|
import { ref } from 'vue';
|
2023-05-11 11:10:34 +02:00
|
|
|
import MkNotes from '@/components/MkNotes.vue';
|
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-08-20 06:39:37 +02:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import * as os from '@/os.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-05-11 11:10:34 +02:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2024-01-30 13:07:34 +01:00
|
|
|
import { useRouter } from '@/router/supplier.js';
|
2023-05-11 11:10:34 +02:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const key = ref(0);
|
|
|
|
const searchQuery = ref('');
|
|
|
|
const searchOrigin = ref('combined');
|
|
|
|
const notePagination = ref();
|
2023-12-26 06:19:35 +01:00
|
|
|
const user = ref<any>(null);
|
2023-12-07 06:42:09 +01:00
|
|
|
const isLocalOnly = ref(false);
|
2023-05-11 11:10:34 +02:00
|
|
|
|
|
|
|
function selectUser() {
|
2024-02-02 08:49:09 +01:00
|
|
|
os.selectUser({ includeSelf: true }).then(_user => {
|
2023-12-07 06:42:09 +01:00
|
|
|
user.value = _user;
|
2023-05-11 11:10:34 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function search() {
|
2023-12-07 06:42:09 +01:00
|
|
|
const query = searchQuery.value.toString().trim();
|
2023-05-11 11:10:34 +02:00
|
|
|
|
|
|
|
if (query == null || query === '') return;
|
|
|
|
|
|
|
|
if (query.startsWith('https://')) {
|
2024-01-04 10:32:46 +01:00
|
|
|
const promise = misskeyApi('ap/show', {
|
2023-05-11 11:10:34 +02:00
|
|
|
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-07 06:42:09 +01:00
|
|
|
notePagination.value = {
|
2023-05-11 11:10:34 +02:00
|
|
|
endpoint: 'notes/search',
|
|
|
|
limit: 10,
|
|
|
|
params: {
|
2023-12-07 06:42:09 +01:00
|
|
|
query: searchQuery.value,
|
|
|
|
userId: user.value ? user.value.id : null,
|
2023-05-11 11:10:34 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
if (isLocalOnly.value) notePagination.value.params.host = '.';
|
2023-08-20 06:39:37 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
key.value++;
|
2023-05-11 11:10:34 +02:00
|
|
|
}
|
|
|
|
</script>
|