2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2021-10-10 18:36:47 +03:00
|
|
|
<div style="margin: 16px;">
|
2021-10-03 17:51:54 +03:00
|
|
|
<FormSection>
|
2020-12-31 12:01:12 +02:00
|
|
|
<template #label>{{ $ts._exportOrImport.allNotes }}</template>
|
2021-10-03 17:51:54 +03:00
|
|
|
<MkButton :class="$style.button" inline @click="doExport('notes')"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 12:01:12 +02:00
|
|
|
<template #label>{{ $ts._exportOrImport.followingList }}</template>
|
2021-10-03 17:51:54 +03:00
|
|
|
<MkButton :class="$style.button" inline @click="doExport('following')"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
<MkButton :class="$style.button" inline @click="doImport('following', $event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 12:01:12 +02:00
|
|
|
<template #label>{{ $ts._exportOrImport.userLists }}</template>
|
2021-10-03 17:51:54 +03:00
|
|
|
<MkButton :class="$style.button" inline @click="doExport('user-lists')"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
<MkButton :class="$style.button" inline @click="doImport('user-lists', $event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 12:01:12 +02:00
|
|
|
<template #label>{{ $ts._exportOrImport.muteList }}</template>
|
2021-10-19 19:11:13 +03:00
|
|
|
<MkButton :class="$style.button" inline @click="doExport('muting')"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
<MkButton :class="$style.button" inline @click="doImport('muting', $event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
2021-10-03 17:51:54 +03:00
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 12:01:12 +02:00
|
|
|
<template #label>{{ $ts._exportOrImport.blockingList }}</template>
|
2021-10-03 17:51:54 +03:00
|
|
|
<MkButton :class="$style.button" inline @click="doExport('blocking')"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
2021-10-19 19:11:13 +03:00
|
|
|
<MkButton :class="$style.button" inline @click="doImport('blocking', $event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
2021-10-03 17:51:54 +03:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-01-29 21:37:25 +02:00
|
|
|
components: {
|
2021-10-03 17:51:54 +03:00
|
|
|
FormSection,
|
|
|
|
MkButton,
|
2020-01-29 21:37:25 +02:00
|
|
|
},
|
|
|
|
|
2020-12-31 12:01:12 +02:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 06:54:12 +03:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-31 12:01:12 +02:00
|
|
|
title: this.$ts.importAndExport,
|
2021-09-29 18:50:45 +03:00
|
|
|
icon: 'fas fa-boxes',
|
|
|
|
bg: 'var(--bg)',
|
2020-12-31 12:01:12 +02:00
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-31 12:01:12 +02:00
|
|
|
mounted() {
|
2021-04-10 06:54:12 +03:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2020-12-31 12:01:12 +02:00
|
|
|
},
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
methods: {
|
2020-12-31 12:01:12 +02:00
|
|
|
doExport(target) {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.api(
|
2021-10-19 19:11:13 +03:00
|
|
|
target === 'notes' ? 'i/export-notes' :
|
|
|
|
target === 'following' ? 'i/export-following' :
|
|
|
|
target === 'blocking' ? 'i/export-blocking' :
|
|
|
|
target === 'user-lists' ? 'i/export-user-lists' :
|
|
|
|
target === 'muting' ? 'i/export-mute' :
|
2020-01-29 21:37:25 +02:00
|
|
|
null, {})
|
|
|
|
.then(() => {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.dialog({
|
2020-01-29 21:37:25 +02:00
|
|
|
type: 'info',
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts.exportRequested
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
}).catch((e: any) => {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.dialog({
|
2020-01-29 21:37:25 +02:00
|
|
|
type: 'error',
|
|
|
|
text: e.message
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-12-31 12:01:12 +02:00
|
|
|
async doImport(target, e) {
|
2020-10-25 03:48:33 +02:00
|
|
|
const file = await selectFile(e.currentTarget || e.target);
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
os.api(
|
2021-10-19 19:11:13 +03:00
|
|
|
target === 'following' ? 'i/import-following' :
|
|
|
|
target === 'user-lists' ? 'i/import-user-lists' :
|
|
|
|
target === 'muting' ? 'i/import-muting' :
|
|
|
|
target === 'blocking' ? 'i/import-blocking' :
|
2020-01-29 21:37:25 +02:00
|
|
|
null, {
|
|
|
|
fileId: file.id
|
|
|
|
}).then(() => {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.dialog({
|
2020-01-29 21:37:25 +02:00
|
|
|
type: 'info',
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts.importRequested
|
2020-01-29 21:37:25 +02:00
|
|
|
});
|
|
|
|
}).catch((e: any) => {
|
2020-10-17 14:12:00 +03:00
|
|
|
os.dialog({
|
2020-01-29 21:37:25 +02:00
|
|
|
type: 'error',
|
|
|
|
text: e.message
|
|
|
|
});
|
|
|
|
});
|
2020-10-25 03:48:33 +02:00
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2021-10-03 17:51:54 +03:00
|
|
|
|
|
|
|
<style module>
|
|
|
|
.button {
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
|
|
|
</style>
|