2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-10-17 11:12:00 +00:00
|
|
|
<section class="_section">
|
|
|
|
<div class="_title"><Fa :icon="faBoxes"/> {{ $t('importAndExport') }}</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
<div class="_content">
|
2020-10-17 11:12:00 +00:00
|
|
|
<MkSelect v-model:value="exportTarget">
|
2020-07-24 16:56:52 +00:00
|
|
|
<option value="notes">{{ $t('_exportOrImport.allNotes') }}</option>
|
|
|
|
<option value="following">{{ $t('_exportOrImport.followingList') }}</option>
|
|
|
|
<option value="user-lists">{{ $t('_exportOrImport.userLists') }}</option>
|
|
|
|
<option value="mute">{{ $t('_exportOrImport.muteList') }}</option>
|
|
|
|
<option value="blocking">{{ $t('_exportOrImport.blockingList') }}</option>
|
2020-10-17 11:12:00 +00:00
|
|
|
</MkSelect>
|
2020-10-25 01:48:33 +00:00
|
|
|
<MkButton inline primary @click="doExport"><Fa :icon="faDownload"/> {{ $t('export') }}</MkButton>
|
|
|
|
<MkButton inline primary @click="doImport" :disabled="!['following', 'user-lists'].includes(exportTarget)"><Fa :icon="faUpload"/> {{ $t('import') }}</MkButton>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 19:37:25 +00:00
|
|
|
import { faDownload, faUpload, faBoxes } from '@fortawesome/free-solid-svg-icons';
|
2020-10-17 11:12:00 +00:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import MkSelect from '@/components/ui/select.vue';
|
|
|
|
import * as os from '@/os';
|
2020-10-25 01:48:33 +00:00
|
|
|
import { selectFile } from '@/scripts/select-file';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
|
|
|
MkButton,
|
|
|
|
MkSelect,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
exportTarget: 'notes',
|
|
|
|
faDownload, faUpload, faBoxes
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
doExport() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api(
|
2020-01-29 19:37:25 +00:00
|
|
|
this.exportTarget == 'notes' ? 'i/export-notes' :
|
|
|
|
this.exportTarget == 'following' ? 'i/export-following' :
|
|
|
|
this.exportTarget == 'blocking' ? 'i/export-blocking' :
|
|
|
|
this.exportTarget == 'user-lists' ? 'i/export-user-lists' :
|
2020-10-18 07:43:22 +00:00
|
|
|
this.exportTarget == 'mute' ? 'i/export-mute' :
|
2020-01-29 19:37:25 +00:00
|
|
|
null, {})
|
|
|
|
.then(() => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-01-29 19:37:25 +00:00
|
|
|
type: 'info',
|
|
|
|
text: this.$t('exportRequested')
|
|
|
|
});
|
|
|
|
}).catch((e: any) => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-01-29 19:37:25 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e.message
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-10-25 01:48:33 +00:00
|
|
|
async doImport(e) {
|
|
|
|
const file = await selectFile(e.currentTarget || e.target);
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api(
|
2020-01-29 19:37:25 +00:00
|
|
|
this.exportTarget == 'following' ? 'i/import-following' :
|
|
|
|
this.exportTarget == 'user-lists' ? 'i/import-user-lists' :
|
|
|
|
null, {
|
|
|
|
fileId: file.id
|
|
|
|
}).then(() => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-01-29 19:37:25 +00:00
|
|
|
type: 'info',
|
|
|
|
text: this.$t('importRequested')
|
|
|
|
});
|
|
|
|
}).catch((e: any) => {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.dialog({
|
2020-01-29 19:37:25 +00:00
|
|
|
type: 'error',
|
|
|
|
text: e.message
|
|
|
|
});
|
|
|
|
});
|
2020-10-25 01:48:33 +00:00
|
|
|
},
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|