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-09-30 21:53:52 +02:00
|
|
|
<template #prefix><i class="ph-magnifying-glass ph-bold ph-lg"></i></template>
|
2023-05-11 11:10:34 +02:00
|
|
|
</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>
|
2023-10-21 22:03:19 +02:00
|
|
|
<MkSwitch v-model="order">Sort by newest to oldest</MkSwitch>
|
|
|
|
<MkSelect v-model="filetype" small>
|
|
|
|
<template #label>File Type</template>
|
|
|
|
<option :value="null">None</option>
|
|
|
|
<option value="image">Images</option>
|
|
|
|
<option value="video">Videos</option>
|
|
|
|
<option value="audio">Audio</option>
|
|
|
|
</MkSelect>
|
2023-08-20 06:39:37 +02:00
|
|
|
|
|
|
|
<MkFolder>
|
|
|
|
<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-10-21 22:03:19 +02:00
|
|
|
import MkSelect from '@/components/MkSelect.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-08 06:44:43 +01:00
|
|
|
import { useRouter } from '@/global/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-12-23 02:09:23 +01:00
|
|
|
const order = ref(false);
|
|
|
|
const filetype = ref(null);
|
2023-05-11 11:10:34 +02:00
|
|
|
|
|
|
|
function selectUser() {
|
|
|
|
os.selectUser().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-12-23 02:09:23 +01:00
|
|
|
order: order.value ? 'desc' : 'asc',
|
|
|
|
filetype: filetype.value,
|
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>
|