Adapt to Calckey
This commit is contained in:
parent
3144ab1e23
commit
ee3a7511aa
|
@ -131,7 +131,7 @@ import * as ep___drive_folders_show from "./endpoints/drive/folders/show.js";
|
|||
import * as ep___drive_folders_update from "./endpoints/drive/folders/update.js";
|
||||
import * as ep___drive_stream from "./endpoints/drive/stream.js";
|
||||
import * as ep___emailAddress_available from "./endpoints/email-address/available.js";
|
||||
import * as ep___emoji from './endpoints/emoji.js';
|
||||
import * as ep___emoji from "./endpoints/emoji.js";
|
||||
import * as ep___endpoint from "./endpoints/endpoint.js";
|
||||
import * as ep___endpoints from "./endpoints/endpoints.js";
|
||||
import * as ep___exportCustomEmojis from "./endpoints/export-custom-emojis.js";
|
||||
|
@ -472,7 +472,7 @@ const eps = [
|
|||
["drive/folders/update", ep___drive_folders_update],
|
||||
["drive/stream", ep___drive_stream],
|
||||
["email-address/available", ep___emailAddress_available],
|
||||
['emoji', ep___emoji],
|
||||
["emoji", ep___emoji],
|
||||
["endpoint", ep___endpoint],
|
||||
["endpoints", ep___endpoints],
|
||||
["export-custom-emojis", ep___exportCustomEmojis],
|
||||
|
|
|
@ -1,56 +1,39 @@
|
|||
import { IsNull } from 'typeorm';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import type { EmojisRepository } from '@/models/index.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { IsNull } from "typeorm";
|
||||
import { Emoji } from "@/models/entities/emoji.js";
|
||||
import { Emojis } from "@/models/index.js";
|
||||
import define from "../define.js";
|
||||
|
||||
export const meta = {
|
||||
tags: ['meta'],
|
||||
tags: ["meta"],
|
||||
|
||||
requireCredential: false,
|
||||
allowGet: true,
|
||||
cacheSec: 3600,
|
||||
|
||||
res: {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
optional: false, nullable: false,
|
||||
ref: 'EmojiDetailed',
|
||||
ref: "Emoji",
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const paramDef = {
|
||||
type: 'object',
|
||||
type: "object",
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
required: ['name'],
|
||||
required: ["name"],
|
||||
} as const;
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
||||
@Inject(DI.emojisRepository)
|
||||
private emojisRepository: EmojisRepository,
|
||||
export default define(meta, paramDef, async (ps, me) => {
|
||||
const emoji = await Emojis.findOneOrFail({
|
||||
where: {
|
||||
name: ps.name,
|
||||
host: IsNull(),
|
||||
},
|
||||
});
|
||||
|
||||
private emojiEntityService: EmojiEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const emoji = await this.emojisRepository.findOneOrFail({
|
||||
where: {
|
||||
name: ps.name,
|
||||
host: IsNull(),
|
||||
},
|
||||
});
|
||||
|
||||
return this.emojiEntityService.packDetailed(emoji);
|
||||
});
|
||||
}
|
||||
}
|
||||
return Emojis.pack(emoji);
|
||||
});
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
<img :src="emoji.url" class="img" :alt="emoji.name"/>
|
||||
<div class="body">
|
||||
<div class="name _monospace">{{ emoji.name }}</div>
|
||||
<div class="info">{{ emoji.aliases.join(' ') }}</div>
|
||||
<div class="info">{{ emoji.aliases.join(" ") }}</div>
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { } from 'vue';
|
||||
import * as os from '@/os';
|
||||
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
||||
import { i18n } from '@/i18n';
|
||||
import { } from "vue";
|
||||
import * as os from "@/os";
|
||||
import copyToClipboard from "@/scripts/copy-to-clipboard";
|
||||
import { i18n } from "@/i18n";
|
||||
|
||||
const props = defineProps<{
|
||||
emoji: Record<string, unknown>; // TODO
|
||||
|
@ -20,22 +20,22 @@ const props = defineProps<{
|
|||
|
||||
function menu(ev) {
|
||||
os.popupMenu([{
|
||||
type: 'label',
|
||||
text: ':' + props.emoji.name + ':',
|
||||
type: "label",
|
||||
text: ":" + props.emoji.name + ":",
|
||||
}, {
|
||||
text: i18n.ts.copy,
|
||||
icon: 'ph-clipboard-text ph-bold ph-lg',
|
||||
icon: "ph-clipboard-text ph-bold ph-lg",
|
||||
action: () => {
|
||||
copyToClipboard(`:${props.emoji.name}:`);
|
||||
os.success();
|
||||
},
|
||||
}, {
|
||||
text: i18n.ts.info,
|
||||
icon: 'ti ti-info-circle',
|
||||
icon: "ti ti-info-circle",
|
||||
action: () => {
|
||||
os.apiGet('emoji', { name: props.emoji.name }).then(res => {
|
||||
os.apiGet("emoji", { name: props.emoji.name }).then(res => {
|
||||
os.alert({
|
||||
type: 'info',
|
||||
type: "info",
|
||||
text: `License: ${res.license}`,
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue