2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
2024-02-12 11:37:45 +09:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<div>
|
|
|
|
<MkStickyContainer>
|
2023-01-13 14:58:27 +09:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-18 18:45:49 +09:00
|
|
|
<MkSpacer :contentMax="900">
|
2023-10-20 17:03:09 +09:00
|
|
|
<div class="ogwlenmc">
|
|
|
|
<div v-if="tab === 'local'" class="local">
|
|
|
|
<MkCustomEmojiEditLocal/>
|
|
|
|
</div>
|
2023-10-24 16:55:22 +09:00
|
|
|
<div v-if="tab === 'request'" class="request">
|
|
|
|
<MkCustomEmojiEditRequest/>
|
2023-10-20 17:03:09 +09:00
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'remote'" class="remote">
|
|
|
|
<MkCustomEmojiEditRemote/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-20 17:38:49 +09:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-13 00:47:05 +09:00
|
|
|
<script lang="ts" setup>
|
2023-08-18 21:41:33 +09:00
|
|
|
import { computed, defineAsyncComponent, ref } from 'vue';
|
2023-10-24 16:55:22 +09:00
|
|
|
import MkCustomEmojiEditRequest from '@/components/MkCustomEmojiEditRequest.vue';
|
2023-08-18 21:41:33 +09:00
|
|
|
import MkCustomEmojiEditLocal from '@/components/MkCustomEmojiEditLocal.vue';
|
|
|
|
import MkCustomEmojiEditRemote from '@/components/MkCustomEmojiEditRemote.vue';
|
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as os from '@/os';
|
2024-01-04 18:32:46 +09:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-08-18 21:41:33 +09:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2023-10-24 16:55:22 +09:00
|
|
|
const tab = ref('request');
|
2022-01-13 00:47:05 +09:00
|
|
|
|
|
|
|
const add = async (ev: MouseEvent) => {
|
2023-12-23 10:44:01 +09:00
|
|
|
os.popup(defineAsyncComponent(() => import('../components/MkEmojiEditDialog.vue')), {
|
2023-05-18 18:45:49 +09:00
|
|
|
}, {
|
|
|
|
done: result => {
|
2023-10-20 17:03:09 +09:00
|
|
|
//TODO: emitにして追加を反映
|
|
|
|
// if (result.created) {
|
|
|
|
// emojisPaginationComponent.value.prepend(result.created);
|
|
|
|
// emojisPaginationComponent.value.reload();
|
|
|
|
// }
|
2023-05-18 18:45:49 +09:00
|
|
|
},
|
|
|
|
}, 'closed');
|
2022-01-13 00:47:05 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
const menu = (ev: MouseEvent) => {
|
|
|
|
os.popupMenu([{
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-download',
|
2022-01-28 11:39:49 +09:00
|
|
|
text: i18n.ts.export,
|
2022-01-13 00:47:05 +09:00
|
|
|
action: async () => {
|
2024-01-04 18:32:46 +09:00
|
|
|
misskeyApi('export-custom-emojis', {
|
2022-01-13 00:47:05 +09:00
|
|
|
})
|
2022-12-19 19:01:30 +09:00
|
|
|
.then(() => {
|
|
|
|
os.alert({
|
|
|
|
type: 'info',
|
|
|
|
text: i18n.ts.exportRequested,
|
|
|
|
});
|
|
|
|
}).catch((err) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: err.message,
|
|
|
|
});
|
2022-01-13 00:47:05 +09:00
|
|
|
});
|
2022-06-20 17:38:49 +09:00
|
|
|
},
|
2022-01-13 00:47:40 +09:00
|
|
|
}, {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-upload',
|
2022-01-28 11:39:49 +09:00
|
|
|
text: i18n.ts.import,
|
2022-01-13 00:47:40 +09:00
|
|
|
action: async () => {
|
2022-01-28 11:53:12 +09:00
|
|
|
const file = await selectFile(ev.currentTarget ?? ev.target);
|
2024-01-04 18:32:46 +09:00
|
|
|
misskeyApi('admin/emoji/import-zip', {
|
2022-01-13 00:47:40 +09:00
|
|
|
fileId: file.id,
|
|
|
|
})
|
2022-12-19 19:01:30 +09:00
|
|
|
.then(() => {
|
|
|
|
os.alert({
|
|
|
|
type: 'info',
|
|
|
|
text: i18n.ts.importRequested,
|
|
|
|
});
|
|
|
|
}).catch((err) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: err.message,
|
|
|
|
});
|
2022-01-13 00:47:40 +09:00
|
|
|
});
|
2022-06-20 17:38:49 +09:00
|
|
|
},
|
2022-01-28 11:53:12 +09:00
|
|
|
}], ev.currentTarget ?? ev.target);
|
2022-01-13 00:47:05 +09:00
|
|
|
};
|
|
|
|
|
2023-12-23 10:44:01 +09:00
|
|
|
const headerActions = computed(() => [{
|
2022-06-20 17:38:49 +09:00
|
|
|
asFullButton: true,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-plus',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: i18n.ts.addEmoji,
|
|
|
|
handler: add,
|
|
|
|
}, {
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-dots',
|
2022-06-20 17:38:49 +09:00
|
|
|
handler: menu,
|
|
|
|
}]);
|
|
|
|
|
2023-12-23 10:44:01 +09:00
|
|
|
const headerTabs = computed(() => [{
|
2023-10-24 16:55:22 +09:00
|
|
|
key: 'request',
|
2023-10-28 16:13:16 +09:00
|
|
|
title: i18n.ts.requestingEmojis,
|
2023-08-11 23:02:54 +09:00
|
|
|
}, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'local',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts.local,
|
|
|
|
}, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'remote',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts.remote,
|
|
|
|
}]);
|
|
|
|
|
2024-02-16 16:17:09 +09:00
|
|
|
definePageMetadata(() => ({
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts.customEmojis,
|
2022-12-31 20:36:49 +09:00
|
|
|
icon: 'ti ti-icons',
|
2024-02-16 16:17:09 +09:00
|
|
|
}));
|
2020-01-30 04:37:25 +09:00
|
|
|
</script>
|
|
|
|
|
2022-12-27 18:29:39 +09:00
|
|
|
<style lang="scss" scoped>
|
2020-01-30 04:37:25 +09:00
|
|
|
</style>
|