2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2021-04-22 13:29:33 +00: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 13:29:19 +00: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 13:29:33 +00: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 11:12:00 +00:00
|
|
|
</div>
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
<div class="remote" v-else-if="tab === 'remote'">
|
2021-08-06 13:29:19 +00: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 13:29:33 +00: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-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-22 13:29:33 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-10-17 11:12:00 +00:00
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 08:30:14 +00: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 03:54:12 +00:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
2020-10-17 11:12:00 +00:00
|
|
|
MkTab,
|
2020-01-29 19:37:25 +00:00
|
|
|
MkButton,
|
|
|
|
MkInput,
|
|
|
|
MkPagination,
|
|
|
|
},
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 03:54:12 +00:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.customEmojis,
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-laugh',
|
2020-10-17 11:12:00 +00:00
|
|
|
action: {
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 11:12:00 +00:00
|
|
|
handler: this.add
|
|
|
|
}
|
|
|
|
},
|
|
|
|
tab: 'local',
|
|
|
|
query: null,
|
|
|
|
queryRemote: null,
|
2020-01-29 19:37:25 +00:00
|
|
|
host: '',
|
|
|
|
pagination: {
|
|
|
|
endpoint: 'admin/emoji/list',
|
2020-11-03 01:54:41 +00:00
|
|
|
limit: 30,
|
2020-10-17 11:12:00 +00:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.query && this.query !== '') ? this.query : null
|
|
|
|
}))
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
remotePagination: {
|
|
|
|
endpoint: 'admin/emoji/list-remote',
|
2020-11-03 01:54:41 +00:00
|
|
|
limit: 30,
|
2020-10-17 11:12:00 +00:00
|
|
|
params: computed(() => ({
|
|
|
|
query: (this.queryRemote && this.queryRemote !== '') ? this.queryRemote : null,
|
|
|
|
host: (this.host && this.host !== '') ? this.host : null
|
|
|
|
}))
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
async mounted() {
|
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
methods: {
|
2020-02-13 16:09:39 +00:00
|
|
|
async add(e) {
|
2020-10-17 11:12:00 +00:00
|
|
|
const files = await selectFile(e.currentTarget || e.target, null, true);
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-18 01:11:34 +00:00
|
|
|
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
2020-02-13 16:09:39 +00:00
|
|
|
fileId: file.id,
|
2020-10-18 01:11:34 +00:00
|
|
|
})));
|
|
|
|
promise.then(() => {
|
2020-01-29 19:37:25 +00:00
|
|
|
this.$refs.emojis.reload();
|
|
|
|
});
|
2020-10-18 01:11:34 +00:00
|
|
|
os.promiseDialog(promise);
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
2020-11-03 06:22:55 +00:00
|
|
|
edit(emoji) {
|
|
|
|
os.popup(import('./emoji-edit-dialog.vue'), {
|
2020-10-17 11:12:00 +00: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-13 16:09:39 +00:00
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
im(emoji) {
|
|
|
|
os.apiWithDialog('admin/emoji/copy', {
|
|
|
|
emojiId: emoji.id,
|
2020-01-29 19:37:25 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
remoteMenu(emoji, ev) {
|
2021-08-08 03:19:10 +00:00
|
|
|
os.popupMenu([{
|
2020-10-17 11:12:00 +00:00
|
|
|
type: 'label',
|
|
|
|
text: ':' + emoji.name + ':',
|
|
|
|
}, {
|
2020-12-26 01:47:36 +00:00
|
|
|
text: this.$ts.import,
|
2021-04-20 14:22:59 +00:00
|
|
|
icon: 'fas fa-plus',
|
2020-10-17 11:12:00 +00:00
|
|
|
action: () => { this.im(emoji) }
|
|
|
|
}], ev.currentTarget || ev.target);
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-22 13:29:33 +00: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-29 19:37:25 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .img {
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
2020-02-13 16:09:39 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-22 13:29:33 +00:00
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2021-04-22 13:29:33 +00: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 11:12:00 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .img {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .body {
|
|
|
|
padding: 0 0 0 8px;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
2021-04-22 13:29:33 +00:00
|
|
|
> .info {
|
|
|
|
opacity: 0.5;
|
|
|
|
font-size: 90%;
|
|
|
|
text-overflow: ellipsis;
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|