うごいた

This commit is contained in:
ThinaticSystem 2022-09-12 00:02:31 +09:00 committed by sim1222
parent c56f8fd953
commit 3a7fbf9406
4 changed files with 24 additions and 9 deletions

View File

@ -1,6 +1,8 @@
<template> <template>
<div class="omfetrab" :class="['s' + size, 'w' + width, 'h' + height, { asDrawer }]" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }"> <div class="omfetrab" :class="['s' + size, 'w' + width, 'h' + height, { asDrawer }]" :style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }">
<input ref="search" v-model.trim="q" class="search" data-prevent-emoji-insert :class="{ filled: q != null && q != '' }" :placeholder="i18n.ts.search" type="search" @paste.stop="paste" @keyup.enter="done()"> <input ref="search" v-model.trim="q" class="search" data-prevent-emoji-insert :class="{ filled: q != null && q != '' }" :placeholder="i18n.ts.search" type="search" @paste.stop="paste" @keyup.enter="done()">
<MkSwitch class="_formBlock" v-model="withRenote">renote
</MkSwitch>
<div ref="emojis" class="emojis"> <div ref="emojis" class="emojis">
<section class="result"> <section class="result">
<div v-if="searchResultCustom.length > 0" class="body"> <div v-if="searchResultCustom.length > 0" class="body">
@ -90,6 +92,7 @@ import { deviceKind } from '@/scripts/device-kind';
import { emojiCategories, instance } from '@/instance'; import { emojiCategories, instance } from '@/instance';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import MkSwitch from '@/components/form/switch.vue';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
showPinned?: boolean; showPinned?: boolean;
@ -101,10 +104,11 @@ const props = withDefaults(defineProps<{
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'chosen', v: string): void; (ev: 'chosen', v: { reaction: string, withRenote: boolean }): void;
}>(); }>();
const search = ref<HTMLInputElement>(); const search = ref<HTMLInputElement>();
const withRenote = ref<boolean>(true);
const emojis = ref<HTMLDivElement>(); const emojis = ref<HTMLDivElement>();
const { const {
@ -294,7 +298,7 @@ function chosen(emoji: any, ev?: MouseEvent) {
} }
const key = getKey(emoji); const key = getKey(emoji);
emit('chosen', key); emit('chosen', { reaction: key, withRenote: withRenote.value });
// 使 // 使
if (!pinned.value.includes(key)) { if (!pinned.value.includes(key)) {
@ -452,6 +456,10 @@ defineExpose({
} }
} }
> .renote {
width: 100%;
}
> .tabs { > .tabs {
display: flex; display: flex;
display: none; display: none;

View File

@ -51,8 +51,8 @@ const emit = defineEmits<{
const modal = ref<InstanceType<typeof MkModal>>(); const modal = ref<InstanceType<typeof MkModal>>();
const picker = ref<InstanceType<typeof MkEmojiPicker>>(); const picker = ref<InstanceType<typeof MkEmojiPicker>>();
function chosen(emoji: any) { function chosen(emoji: any, withRenote: boolean) {
emit('done', emoji); emit('done', { reaction: emoji, withRenote: withRenote });
modal.value?.close(); modal.value?.close();
} }

View File

@ -207,11 +207,18 @@ function reply(viaKeyboard = false): void {
function react(viaKeyboard = false): void { function react(viaKeyboard = false): void {
pleaseLogin(); pleaseLogin();
blur(); blur();
reactionPicker.show(reactButton.value, reaction => { reactionPicker.show(reactButton.value, results => {
os.api('notes/reactions/create', { os.api('notes/reactions/create', {
noteId: appearNote.id, noteId: appearNote.id,
reaction: reaction, reaction: results.reaction,
}); });
console.log(results)
if (results.withRenote) {
os.api('notes/create', {
renoteId: appearNote.id,
isRenote: true,
});
}
}, () => { }, () => {
focus(); focus();
}); });

View File

@ -4,7 +4,7 @@ import { popup } from '@/os';
class ReactionPicker { class ReactionPicker {
private src: Ref<HTMLElement | null> = ref(null); private src: Ref<HTMLElement | null> = ref(null);
private manualShowing = ref(false); private manualShowing = ref(false);
private onChosen?: (reaction: string) => void; private onChosen?: ({ reaction: string, withRenote: boolean }) => void;
private onClosed?: () => void; private onClosed?: () => void;
constructor() { constructor() {
@ -17,8 +17,8 @@ class ReactionPicker {
asReactionPicker: true, asReactionPicker: true,
manualShowing: this.manualShowing manualShowing: this.manualShowing
}, { }, {
done: reaction => { done: results => {
this.onChosen!(reaction); this.onChosen!(results.reaction, results.withRenote);
}, },
close: () => { close: () => {
this.manualShowing.value = false; this.manualShowing.value = false;