2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-04-22 22:29:33 +09:00
|
|
|
<div class="ogwlenmc">
|
|
|
|
<MkTab v-model:value="tab">
|
|
|
|
<option value="local">{{ $ts.local }}</option>
|
|
|
|
<option value="remote">{{ $ts.remote }}</option>
|
|
|
|
</MkTab>
|
|
|
|
|
|
|
|
<div class="local" v-if="tab === 'local'">
|
|
|
|
<MkButton primary @click="add" style="margin: var(--margin) auto;"><i class="fas fa-plus"></i> {{ $ts.addEmoji }}</MkButton>
|
2021-08-06 22:29:19 +09:00
|
|
|
<MkInput v-model="query" :debounce="true" type="search" style="margin: var(--margin);">
|
|
|
|
<template #prefix><i class="fas fa-search"></i></template>
|
|
|
|
<template #label>{{ $ts.search }}</template>
|
|
|
|
</MkInput>
|
2021-04-22 22:29:33 +09:00
|
|
|
<MkPagination :pagination="pagination" ref="emojis">
|
|
|
|
<template #empty><span>{{ $ts.noCustomEmojis }}</span></template>
|
|
|
|
<template #default="{items}">
|
|
|
|
<div class="ldhfsamy">
|
|
|
|
<button class="emoji _panel _button" v-for="emoji in items" :key="emoji.id" @click="edit(emoji)">
|
|
|
|
<img :src="emoji.url" class="img" :alt="emoji.name"/>
|
|
|
|
<div class="body">
|
|
|
|
<div class="name _monospace">{{ emoji.name }}</div>
|
|
|
|
<div class="info">{{ emoji.category }}</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
<div class="remote" v-else-if="tab === 'remote'">
|
2021-08-06 22:29:19 +09:00
|
|
|
<MkInput v-model="queryRemote" :debounce="true" type="search" style="margin: var(--margin);">
|
|
|
|
<template #prefix><i class="fas fa-search"></i></template>
|
|
|
|
<template #label>{{ $ts.search }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="host" :debounce="true" style="margin: var(--margin);">
|
|
|
|
<template #label>{{ $ts.host }}</template>
|
|
|
|
</MkInput>
|
2021-04-22 22:29:33 +09:00
|
|
|
<MkPagination :pagination="remotePagination" ref="remoteEmojis">
|
|
|
|
<template #empty><span>{{ $ts.noCustomEmojis }}</span></template>
|
|
|
|
<template #default="{items}">
|
|
|
|
<div class="ldhfsamy">
|
|
|
|
<div class="emoji _panel _button" v-for="emoji in items" :key="emoji.id" @click="remoteMenu(emoji, $event)">
|
|
|
|
<img :src="emoji.url" class="img" :alt="emoji.name"/>
|
|
|
|
<div class="body">
|
|
|
|
<div class="name _monospace">{{ emoji.name }}</div>
|
|
|
|
<div class="info">{{ emoji.host }}</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-22 22:29:33 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import MkInput from '@client/components/ui/input.vue';
|
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
|
|
|
import MkTab from '@client/components/tab.vue';
|
|
|
|
import { selectFile } from '@client/scripts/select-file';
|
|
|
|
import * as os from '@client/os';
|
2021-04-10 12:54:12 +09:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
2020-10-17 20:12:00 +09:00
|
|
|
MkTab,
|
2020-01-30 04:37:25 +09:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.customEmojis,
|
2021-04-20 23:22:59 +09:00
|
|
|
icon: 'fas fa-laugh',
|
2020-10-17 20:12:00 +09:00
|
|
|
action: {
|
2021-04-20 23:22:59 +09:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 20:12:00 +09:00
|
|
|
handler: this.add
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tab: 'local',
|
|
|
|
query: null,
|
|
|
|
queryRemote: null,
|
2020-01-30 04:37:25 +09:00
|
|
|
host: '',
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/emoji/list',
|
2020-11-03 10:54:41 +09:00
|
|
|
limit: 30,
|
2020-10-17 20:12:00 +09:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.query && this.query !== '') ? this.query : null
|
|
|
|
}))
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
remotePagination: {
|
|
|
|
endpoint: 'admin/emoji/list-remote',
|
2020-11-03 10:54:41 +09:00
|
|
|
limit: 30,
|
2020-10-17 20:12:00 +09:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.queryRemote && this.queryRemote !== '') ? this.queryRemote : null,
|
|
|
|
host: (this.host && this.host !== '') ? this.host : null
|
|
|
|
}))
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
async mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
methods: {
|
2020-02-14 01:09:39 +09:00
|
|
|
async add(e) {
|
2020-10-17 20:12:00 +09:00
|
|
|
const files = await selectFile(e.currentTarget || e.target, null, true);
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-10-18 10:11:34 +09:00
|
|
|
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
2020-02-14 01:09:39 +09:00
|
|
|
fileId: file.id,
|
2020-10-18 10:11:34 +09:00
|
|
|
})));
|
|
|
|
promise.then(() => {
|
2020-01-30 04:37:25 +09:00
|
|
|
this.$refs.emojis.reload();
|
|
|
|
});
|
2020-10-18 10:11:34 +09:00
|
|
|
os.promiseDialog(promise);
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
|
2020-11-03 15:22:55 +09:00
|
|
|
edit(emoji) {
|
|
|
|
os.popup(import('./emoji-edit-dialog.vue'), {
|
2020-10-17 20:12:00 +09:00
|
|
|
emoji: emoji
|
|
|
|
}, {
|
|
|
|
done: result => {
|
|
|
|
if (result.updated) {
|
|
|
|
this.$refs.emojis.replaceItem(item => item.id === emoji.id, {
|
|
|
|
...emoji,
|
|
|
|
...result.updated
|
|
|
|
});
|
|
|
|
} else if (result.deleted) {
|
|
|
|
this.$refs.emojis.removeItem(item => item.id === emoji.id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, 'closed');
|
2020-02-14 01:09:39 +09:00
|
|
|
},
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
im(emoji) {
|
|
|
|
os.apiWithDialog('admin/emoji/copy', {
|
|
|
|
emojiId: emoji.id,
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
remoteMenu(emoji, ev) {
|
2021-08-08 12:19:10 +09:00
|
|
|
os.popupMenu([{
|
2020-10-17 20:12:00 +09:00
|
|
|
type: 'label',
|
|
|
|
text: ':' + emoji.name + ':',
|
|
|
|
}, {
|
2020-12-26 10:47:36 +09:00
|
|
|
text: this.$ts.import,
|
2021-04-20 23:22:59 +09:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 20:12:00 +09:00
|
|
|
action: () => { this.im(emoji) }
|
|
|
|
}], ev.currentTarget || ev.target);
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 22:29:33 +09:00
|
|
|
.ogwlenmc {
|
|
|
|
> .local {
|
|
|
|
.ldhfsamy {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: var(--margin);
|
|
|
|
|
|
|
|
> .emoji {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 12px;
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .img {
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2020-02-14 01:09:39 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .remote {
|
|
|
|
.ldhfsamy {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: var(--margin);
|
|
|
|
|
|
|
|
> .emoji {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 12px;
|
|
|
|
text-align: left;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
|
2021-04-22 22:29:33 +09:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
font-size: 90%;
|
|
|
|
text-overflow: ellipsis;
|
2021-03-02 22:57:16 +09:00
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|