mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 05:13:07 +02:00
feat(frontend): ユーザー指定ノート検索
This commit is contained in:
parent
26d85c8bed
commit
8b352e4e56
5 changed files with 187 additions and 104 deletions
|
@ -18,6 +18,7 @@
|
|||
- 投稿したコンテンツのAIによる学習を軽減するオプションを追加
|
||||
|
||||
### Client
|
||||
- ユーザーを指定してのノート検索が可能に
|
||||
- Fix: ブラーエフェクトを有効にしている状態で高負荷になる問題を修正
|
||||
- Fix: カラーバーがリプライには表示されないのを修正
|
||||
- Fix: チャンネル内の検索ボックスが挙動不審な問題を修正
|
||||
|
|
|
@ -1041,6 +1041,8 @@ initialAccountSetting: "初期設定"
|
|||
youFollowing: "フォロー中"
|
||||
preventAiLearning: "生成AIによる学習を拒否"
|
||||
preventAiLearningDescription: "外部の文章生成AIや画像生成AIに対して、投稿したノートや画像などのコンテンツを学習の対象にしないように要求します。これはnoaiフラグをHTMLレスポンスに含めることによって実現されますが、この要求に従うかはそのAI次第であるため、学習を完全に防止するものではありません。"
|
||||
options: "オプション"
|
||||
specifyUser: "ユーザー指定"
|
||||
|
||||
_initialAccountSetting:
|
||||
accountCreated: "アカウントの作成が完了しました!"
|
||||
|
|
98
packages/frontend/src/pages/search.note.vue
Normal file
98
packages/frontend/src/pages/search.note.vue
Normal file
|
@ -0,0 +1,98 @@
|
|||
<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>
|
||||
|
||||
<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>
|
||||
</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 } 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 { i18n } from '@/i18n';
|
||||
import * as os from '@/os';
|
||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
import { $i } from '@/account';
|
||||
import { instance } from '@/instance';
|
||||
import MkInfo from '@/components/MkInfo.vue';
|
||||
import { useRouter } from '@/router';
|
||||
import MkFolder from '@/components/MkFolder.vue';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
let key = $ref(0);
|
||||
let searchQuery = $ref('');
|
||||
let searchOrigin = $ref('combined');
|
||||
let notePagination = $ref();
|
||||
let user = $ref(null);
|
||||
|
||||
function selectUser() {
|
||||
os.selectUser().then(_user => {
|
||||
user = _user;
|
||||
});
|
||||
}
|
||||
|
||||
async function search() {
|
||||
const query = searchQuery.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 = {
|
||||
endpoint: 'notes/search',
|
||||
limit: 10,
|
||||
params: {
|
||||
query: searchQuery,
|
||||
userId: user ? user.id : null,
|
||||
},
|
||||
};
|
||||
|
||||
key++;
|
||||
}
|
||||
</script>
|
77
packages/frontend/src/pages/search.user.vue
Normal file
77
packages/frontend/src/pages/search.user.vue
Normal file
|
@ -0,0 +1,77 @@
|
|||
<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>
|
||||
<MkRadios v-model="searchOrigin" @update:model-value="search()">
|
||||
<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>
|
||||
import { computed, defineAsyncComponent, onMounted } from 'vue';
|
||||
import MkUserList from '@/components/MkUserList.vue';
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
import MkRadios from '@/components/MkRadios.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { i18n } from '@/i18n';
|
||||
import * as os from '@/os';
|
||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
import { $i } from '@/account';
|
||||
import { instance } from '@/instance';
|
||||
import MkInfo from '@/components/MkInfo.vue';
|
||||
import { useRouter } from '@/router';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
let key = $ref('');
|
||||
let searchQuery = $ref('');
|
||||
let searchOrigin = $ref('combined');
|
||||
let userPagination = $ref();
|
||||
|
||||
async function search() {
|
||||
const query = searchQuery.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;
|
||||
}
|
||||
|
||||
userPagination = {
|
||||
endpoint: 'users/search',
|
||||
limit: 10,
|
||||
params: {
|
||||
query: searchQuery,
|
||||
origin: searchOrigin,
|
||||
},
|
||||
};
|
||||
|
||||
key = query;
|
||||
}
|
||||
</script>
|
|
@ -1,133 +1,38 @@
|
|||
<template>
|
||||
<MkStickyContainer>
|
||||
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
||||
<MkSpacer v-if="tab === 'note'" :content-max="800">
|
||||
<div v-if="notesSearchAvailable" 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>
|
||||
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
|
||||
</div>
|
||||
|
||||
<MkFoldableSection v-if="notePagination">
|
||||
<template #header>{{ i18n.ts.searchResult }}</template>
|
||||
<MkNotes :key="key" :pagination="notePagination"/>
|
||||
</MkFoldableSection>
|
||||
<MkSpacer v-if="tab === 'note'" :content-max="800">
|
||||
<div v-if="notesSearchAvailable">
|
||||
<XNote/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<MkInfo warn>{{ i18n.ts.notesSearchNotAvailable }}</MkInfo>
|
||||
</div>
|
||||
</MkSpacer>
|
||||
<MkSpacer v-else-if="tab === 'user'" :content-max="800">
|
||||
<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>
|
||||
<MkRadios v-model="searchOrigin" @update:model-value="search()">
|
||||
<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>
|
||||
<MkSpacer v-else-if="tab === 'user'" :content-max="800">
|
||||
<XUser/>
|
||||
</MkSpacer>
|
||||
</MkStickyContainer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted } from 'vue';
|
||||
import MkNotes from '@/components/MkNotes.vue';
|
||||
import MkUserList from '@/components/MkUserList.vue';
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
import MkRadios from '@/components/MkRadios.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { computed, defineAsyncComponent, onMounted } from 'vue';
|
||||
import { i18n } from '@/i18n';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||
import * as os from '@/os';
|
||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
import { $i } from '@/account';
|
||||
import { instance } from '@/instance';
|
||||
import MkInfo from '@/components/MkInfo.vue';
|
||||
import { useRouter } from '@/router';
|
||||
|
||||
const router = useRouter();
|
||||
const XNote = defineAsyncComponent(() => import('./search.note.vue'));
|
||||
const XUser = defineAsyncComponent(() => import('./search.user.vue'));
|
||||
|
||||
const props = defineProps<{
|
||||
query: string;
|
||||
channel?: string;
|
||||
type?: string;
|
||||
origin?: string;
|
||||
}>();
|
||||
|
||||
let key = $ref('');
|
||||
let tab = $ref('note');
|
||||
let searchQuery = $ref('');
|
||||
let searchOrigin = $ref('combined');
|
||||
let notePagination = $ref();
|
||||
let userPagination = $ref();
|
||||
|
||||
const notesSearchAvailable = (($i == null && instance.policies.canSearchNotes) || ($i != null && $i.policies.canSearchNotes));
|
||||
|
||||
onMounted(() => {
|
||||
tab = props.type ?? 'note';
|
||||
searchQuery = props.query ?? '';
|
||||
searchOrigin = props.origin ?? 'combined';
|
||||
});
|
||||
|
||||
async function search() {
|
||||
const query = searchQuery.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;
|
||||
}
|
||||
|
||||
if (tab === 'note') {
|
||||
notePagination = {
|
||||
endpoint: 'notes/search',
|
||||
limit: 10,
|
||||
params: {
|
||||
query: searchQuery,
|
||||
channelId: props.channel,
|
||||
},
|
||||
};
|
||||
} else if (tab === 'user') {
|
||||
userPagination = {
|
||||
endpoint: 'users/search',
|
||||
limit: 10,
|
||||
params: {
|
||||
query: searchQuery,
|
||||
origin: searchOrigin,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
key = query;
|
||||
}
|
||||
|
||||
const headerActions = $computed(() => []);
|
||||
|
||||
const headerTabs = $computed(() => [{
|
||||
|
@ -141,7 +46,7 @@ const headerTabs = $computed(() => [{
|
|||
}]);
|
||||
|
||||
definePageMetadata(computed(() => ({
|
||||
title: searchQuery ? i18n.t('searchWith', { q: searchQuery }) : i18n.ts.search,
|
||||
title: i18n.ts.search,
|
||||
icon: 'ti ti-search',
|
||||
})));
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue