2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="800">
|
2021-12-25 05:38:53 +01:00
|
|
|
<XNotes ref="notes" :pagination="pagination"/>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-12 18:21:43 +01:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
2022-08-30 17:24:33 +02:00
|
|
|
import XNotes from '@/components/MkNotes.vue';
|
2022-01-12 18:21:43 +01:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2023-01-08 03:15:54 +01:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { $i } from '@/account';
|
|
|
|
|
|
|
|
const router = useRouter();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-12 18:21:43 +01:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
channel?: string;
|
|
|
|
}>();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-01-08 03:15:54 +01:00
|
|
|
const query = props.query;
|
|
|
|
|
|
|
|
if ($i != null) {
|
|
|
|
if (query.startsWith('https://') || (query.startsWith('@') && !query.includes(' '))) {
|
|
|
|
const promise = os.api('ap/show', {
|
|
|
|
uri: props.query,
|
|
|
|
});
|
|
|
|
|
|
|
|
os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);
|
|
|
|
|
|
|
|
const res = await promise;
|
|
|
|
|
|
|
|
if (res.type === 'User') {
|
|
|
|
router.replace(`/@${res.object.username}@${res.object.host}`);
|
|
|
|
} else if (res.type === 'Note') {
|
|
|
|
router.replace(`/notes/${res.object.id}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-12 18:21:43 +01:00
|
|
|
const pagination = {
|
2022-01-12 18:26:10 +01:00
|
|
|
endpoint: 'notes/search' as const,
|
2022-01-12 18:21:43 +01:00
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
query: props.query,
|
|
|
|
channelId: props.channel,
|
2022-06-20 10:38:49 +02:00
|
|
|
})),
|
2022-01-12 18:21:43 +01:00
|
|
|
};
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.t('searchWith', { q: props.query }),
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-search',
|
2022-06-20 10:38:49 +02:00
|
|
|
})));
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|