mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-17 08:08:17 +09:00
406b4bdbe7
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
112 lines
3.0 KiB
Vue
112 lines
3.0 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<div class="_gaps">
|
|
<div class="_gaps">
|
|
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search">
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
|
</MkInput>
|
|
<MkFolder>
|
|
<template #label>{{ i18n.ts.options }}</template>
|
|
|
|
<div class="_gaps_m">
|
|
<MkSwitch v-model="isLocalOnly">{{ i18n.ts.localOnly }}</MkSwitch>
|
|
|
|
<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>
|
|
</div>
|
|
</MkFolder>
|
|
</div>
|
|
</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>
|
|
import { computed, onMounted, ref } from 'vue';
|
|
import MkNotes from '@/components/MkNotes.vue';
|
|
import MkInput from '@/components/MkInput.vue';
|
|
import MkRadios from '@/components/MkRadios.vue';
|
|
import MkButton from '@/components/MkButton.vue';
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
|
import { i18n } from '@/i18n.js';
|
|
import * as os from '@/os.js';
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
|
import { $i } from '@/account.js';
|
|
import { instance } from '@/instance.js';
|
|
import MkInfo from '@/components/MkInfo.vue';
|
|
import { useRouter } from '@/router.js';
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
const router = useRouter();
|
|
|
|
const key = ref(0);
|
|
const searchQuery = ref('');
|
|
const searchOrigin = ref('combined');
|
|
const notePagination = ref();
|
|
const user = ref(null);
|
|
const isLocalOnly = ref(false);
|
|
|
|
function selectUser() {
|
|
os.selectUser().then(_user => {
|
|
user.value = _user;
|
|
});
|
|
}
|
|
|
|
async function search() {
|
|
const query = searchQuery.value.toString().trim();
|
|
|
|
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;
|
|
}
|
|
|
|
notePagination.value = {
|
|
endpoint: 'notes/search',
|
|
limit: 10,
|
|
params: {
|
|
query: searchQuery.value,
|
|
userId: user.value ? user.value.id : null,
|
|
},
|
|
};
|
|
|
|
if (isLocalOnly.value) notePagination.value.params.host = '.';
|
|
|
|
key.value++;
|
|
}
|
|
</script>
|