format
This commit is contained in:
parent
54f6876c9c
commit
8a2135ba28
|
@ -89,7 +89,7 @@ import * as ep___channels_featured from "./endpoints/channels/featured.js";
|
|||
import * as ep___channels_follow from "./endpoints/channels/follow.js";
|
||||
import * as ep___channels_followed from "./endpoints/channels/followed.js";
|
||||
import * as ep___channels_owned from "./endpoints/channels/owned.js";
|
||||
import * as ep___channels_search from './endpoints/channels/search.js';
|
||||
import * as ep___channels_search from "./endpoints/channels/search.js";
|
||||
import * as ep___channels_show from "./endpoints/channels/show.js";
|
||||
import * as ep___channels_timeline from "./endpoints/channels/timeline.js";
|
||||
import * as ep___channels_unfollow from "./endpoints/channels/unfollow.js";
|
||||
|
@ -439,7 +439,7 @@ const eps = [
|
|||
["channels/follow", ep___channels_follow],
|
||||
["channels/followed", ep___channels_followed],
|
||||
["channels/owned", ep___channels_owned],
|
||||
['channels/search', ep___channels_search],
|
||||
["channels/search", ep___channels_search],
|
||||
["channels/show", ep___channels_show],
|
||||
["channels/timeline", ep___channels_timeline],
|
||||
["channels/unfollow", ep___channels_unfollow],
|
||||
|
|
|
@ -1,38 +1,44 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Brackets } from 'typeorm';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
import type { ChannelsRepository } from '@/models/index.js';
|
||||
import { ChannelEntityService } from '@/core/entities/ChannelEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
|
||||
import { Inject, Injectable } from "@nestjs/common";
|
||||
import { Brackets } from "typeorm";
|
||||
import { Endpoint } from "@/server/api/endpoint-base.js";
|
||||
import { QueryService } from "@/core/QueryService.js";
|
||||
import type { ChannelsRepository } from "@/models/index.js";
|
||||
import { ChannelEntityService } from "@/core/entities/ChannelEntityService.js";
|
||||
import { DI } from "@/di-symbols.js";
|
||||
import { sqlLikeEscape } from "@/misc/sql-like-escape.js";
|
||||
|
||||
export const meta = {
|
||||
tags: ['channels'],
|
||||
tags: ["channels"],
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
res: {
|
||||
type: 'array',
|
||||
optional: false, nullable: false,
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: 'object',
|
||||
optional: false, nullable: false,
|
||||
ref: 'Channel',
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "Channel",
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
properties: {
|
||||
query: { type: 'string' },
|
||||
type: { type: 'string', enum: ['nameAndDescription', 'nameOnly'], default: 'nameAndDescription' },
|
||||
sinceId: { type: 'string', format: 'misskey:id' },
|
||||
untilId: { type: 'string', format: 'misskey:id' },
|
||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 5 },
|
||||
query: { type: "string" },
|
||||
type: {
|
||||
type: "string",
|
||||
enum: ["nameAndDescription", "nameOnly"],
|
||||
default: "nameAndDescription",
|
||||
},
|
||||
required: ['query'],
|
||||
sinceId: { type: "string", format: "misskey:id" },
|
||||
untilId: { type: "string", format: "misskey:id" },
|
||||
limit: { type: "integer", minimum: 1, maximum: 100, default: 5 },
|
||||
},
|
||||
required: ["query"],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
|
@ -46,22 +52,33 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const query = this.queryService.makePaginationQuery(this.channelsRepository.createQueryBuilder('channel'), ps.sinceId, ps.untilId);
|
||||
const query = this.queryService.makePaginationQuery(
|
||||
this.channelsRepository.createQueryBuilder("channel"),
|
||||
ps.sinceId,
|
||||
ps.untilId,
|
||||
);
|
||||
|
||||
if (ps.type === 'nameAndDescription') {
|
||||
query.andWhere(new Brackets(qb => { qb
|
||||
.where('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` })
|
||||
.orWhere('channel.description ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
|
||||
}));
|
||||
if (ps.type === "nameAndDescription") {
|
||||
query.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.where("channel.name ILIKE :q", {
|
||||
q: `%${sqlLikeEscape(ps.query)}%`,
|
||||
}).orWhere("channel.description ILIKE :q", {
|
||||
q: `%${sqlLikeEscape(ps.query)}%`,
|
||||
});
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
query.andWhere('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
|
||||
query.andWhere("channel.name ILIKE :q", {
|
||||
q: `%${sqlLikeEscape(ps.query)}%`,
|
||||
});
|
||||
}
|
||||
|
||||
const channels = await query
|
||||
.take(ps.limit)
|
||||
.getMany();
|
||||
const channels = await query.take(ps.limit).getMany();
|
||||
|
||||
return await Promise.all(channels.map(x => this.channelEntityService.pack(x, me)));
|
||||
return await Promise.all(
|
||||
channels.map((x) => this.channelEntityService.pack(x, me)),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -606,8 +606,7 @@ export default async (
|
|||
});
|
||||
|
||||
async function renderNoteOrRenoteActivity(data: Option, note: Note) {
|
||||
if (data.localOnly ||
|
||||
note.visibility !== "hidden") return null;
|
||||
if (data.localOnly || note.visibility !== "hidden") return null;
|
||||
|
||||
const content =
|
||||
data.renote &&
|
||||
|
|
|
@ -144,10 +144,7 @@ export default async (
|
|||
});
|
||||
|
||||
//#region deliver
|
||||
if (
|
||||
Users.isLocalUser(user) &&
|
||||
!note.localOnly
|
||||
) {
|
||||
if (Users.isLocalUser(user) && !note.localOnly) {
|
||||
const content = renderActivity(await renderLike(record, note));
|
||||
const dm = new DeliverManager(user, content);
|
||||
if (note.userHost !== null) {
|
||||
|
|
|
@ -2,30 +2,40 @@
|
|||
<MkPagination :pagination="pagination">
|
||||
<template #empty>
|
||||
<div class="_fullinfo">
|
||||
<img src="https://xn--931a.moe/assets/info.jpg" class="_ghost"/>
|
||||
<img
|
||||
src="https://xn--931a.moe/assets/info.jpg"
|
||||
class="_ghost"
|
||||
/>
|
||||
<div>{{ i18n.ts.notFound }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #default="{ items }">
|
||||
<MkChannelPreview v-for="item in items" :key="item.id" class="_margin" :channel="extractor(item)"/>
|
||||
<MkChannelPreview
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
class="_margin"
|
||||
:channel="extractor(item)"
|
||||
/>
|
||||
</template>
|
||||
</MkPagination>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
||||
import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
||||
import { i18n } from '@/i18n';
|
||||
import MkChannelPreview from "@/components/MkChannelPreview.vue";
|
||||
import MkPagination, { Paging } from "@/components/MkPagination.vue";
|
||||
import { i18n } from "@/i18n";
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
pagination: Paging;
|
||||
noGap?: boolean;
|
||||
extractor?: (item: any) => any;
|
||||
}>(), {
|
||||
}>(),
|
||||
{
|
||||
extractor: (item) => item,
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
@ -75,7 +75,10 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
|
|||
|
||||
let buttonActions = [];
|
||||
|
||||
if (props.note.visibility === "public" || props.note.visibility === "hidden") {
|
||||
if (
|
||||
props.note.visibility === "public" ||
|
||||
props.note.visibility === "hidden"
|
||||
) {
|
||||
buttonActions.push({
|
||||
text: i18n.ts.renote,
|
||||
textStyle: "font-weight: bold",
|
||||
|
|
|
@ -23,18 +23,44 @@
|
|||
<swiper-slide>
|
||||
<div class="_content grwlizim search">
|
||||
<div class="gaps">
|
||||
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search">
|
||||
<template #prefix><i class="ti ti-search"></i></template>
|
||||
<MkInput
|
||||
v-model="searchQuery"
|
||||
:large="true"
|
||||
:autofocus="true"
|
||||
type="search"
|
||||
>
|
||||
<template #prefix
|
||||
><i class="ti ti-search"></i
|
||||
></template>
|
||||
</MkInput>
|
||||
<MkRadios v-model="searchType" @update:model-value="search()">
|
||||
<option value="nameAndDescription">{{ i18n.ts._channel.nameAndDescription }}</option>
|
||||
<option value="nameOnly">{{ i18n.ts._channel.nameOnly }}</option>
|
||||
<MkRadios
|
||||
v-model="searchType"
|
||||
@update:model-value="search()"
|
||||
>
|
||||
<option value="nameAndDescription">
|
||||
{{ i18n.ts._channel.nameAndDescription }}
|
||||
</option>
|
||||
<option value="nameOnly">
|
||||
{{ i18n.ts._channel.nameOnly }}
|
||||
</option>
|
||||
</MkRadios>
|
||||
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
|
||||
<MkButton
|
||||
large
|
||||
primary
|
||||
gradate
|
||||
rounded
|
||||
@click="search"
|
||||
>{{ i18n.ts.search }}</MkButton
|
||||
>
|
||||
</div>
|
||||
<MkFoldableSection v-if="channelPagination">
|
||||
<template #header>{{ i18n.ts.searchResult }}</template>
|
||||
<MkChannelList :key="key" :pagination="channelPagination"/>
|
||||
<template #header>{{
|
||||
i18n.ts.searchResult
|
||||
}}</template>
|
||||
<MkChannelList
|
||||
:key="key"
|
||||
:pagination="channelPagination"
|
||||
/>
|
||||
</MkFoldableSection>
|
||||
</div>
|
||||
</swiper-slide>
|
||||
|
@ -96,12 +122,12 @@ import { computed, onMounted, defineComponent, inject, watch } from "vue";
|
|||
import { Virtual } from "swiper";
|
||||
import { Swiper, SwiperSlide } from "swiper/vue";
|
||||
import MkChannelPreview from "@/components/MkChannelPreview.vue";
|
||||
import MkChannelList from '@/components/MkChannelList.vue';
|
||||
import MkChannelList from "@/components/MkChannelList.vue";
|
||||
import MkPagination from "@/components/MkPagination.vue";
|
||||
import MkInput from '@/components/MkInput.vue';
|
||||
import MkRadios from '@/components/MkRadios.vue';
|
||||
import MkInput from "@/components/MkInput.vue";
|
||||
import MkRadios from "@/components/MkRadios.vue";
|
||||
import MkButton from "@/components/MkButton.vue";
|
||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||
import MkFoldableSection from "@/components/MkFoldableSection.vue";
|
||||
import { useRouter } from "@/router";
|
||||
import { definePageMetadata } from "@/scripts/page-metadata";
|
||||
import { deviceKind } from "@/scripts/device-kind";
|
||||
|
@ -120,14 +146,14 @@ const props = defineProps<{
|
|||
query: string;
|
||||
type?: string;
|
||||
}>();
|
||||
let key = $ref('');
|
||||
let tab = $ref('search');
|
||||
let searchQuery = $ref('');
|
||||
let searchType = $ref('nameAndDescription');
|
||||
let key = $ref("");
|
||||
let tab = $ref("search");
|
||||
let searchQuery = $ref("");
|
||||
let searchType = $ref("nameAndDescription");
|
||||
let channelPagination = $ref();
|
||||
onMounted(() => {
|
||||
searchQuery = props.query ?? '';
|
||||
searchType = props.type ?? 'nameAndDescription';
|
||||
searchQuery = props.query ?? "";
|
||||
searchType = props.type ?? "nameAndDescription";
|
||||
});
|
||||
|
||||
const featuredPagination = {
|
||||
|
@ -146,10 +172,10 @@ const ownedPagination = {
|
|||
|
||||
async function search() {
|
||||
const query = searchQuery.toString().trim();
|
||||
if (query == null || query === '') return;
|
||||
if (query == null || query === "") return;
|
||||
const type = searchType.toString().trim();
|
||||
channelPagination = {
|
||||
endpoint: 'channels/search',
|
||||
endpoint: "channels/search",
|
||||
limit: 10,
|
||||
params: {
|
||||
query: searchQuery,
|
||||
|
@ -173,9 +199,9 @@ const headerActions = $computed(() => [
|
|||
|
||||
const headerTabs = $computed(() => [
|
||||
{
|
||||
key: 'search',
|
||||
key: "search",
|
||||
title: i18n.ts.search,
|
||||
icon: 'ti ti-search',
|
||||
icon: "ti ti-search",
|
||||
},
|
||||
{
|
||||
key: "featured",
|
||||
|
|
Loading…
Reference in New Issue