🎨
This commit is contained in:
parent
79f8eb910f
commit
a74beaac36
1 changed files with 50 additions and 28 deletions
|
@ -1,49 +1,71 @@
|
||||||
<template>
|
<template>
|
||||||
<section class="_section">
|
<FormBase>
|
||||||
<div class="_title"><Fa :icon="faBoxes"/> {{ $ts.importAndExport }}</div>
|
<FormGroup>
|
||||||
<div class="_content">
|
<template #label>{{ $ts._exportOrImport.allNotes }}</template>
|
||||||
<MkSelect v-model:value="exportTarget">
|
<FormButton @click="doExport('notes')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
||||||
<option value="notes">{{ $ts._exportOrImport.allNotes }}</option>
|
</FormGroup>
|
||||||
<option value="following">{{ $ts._exportOrImport.followingList }}</option>
|
<FormGroup>
|
||||||
<option value="user-lists">{{ $ts._exportOrImport.userLists }}</option>
|
<template #label>{{ $ts._exportOrImport.followingList }}</template>
|
||||||
<option value="mute">{{ $ts._exportOrImport.muteList }}</option>
|
<FormButton @click="doExport('following')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
||||||
<option value="blocking">{{ $ts._exportOrImport.blockingList }}</option>
|
<FormButton @click="doImport('following', $event)"><Fa :icon="faUpload"/> {{ $ts.import }}</FormButton>
|
||||||
</MkSelect>
|
</FormGroup>
|
||||||
<MkButton inline primary @click="doExport"><Fa :icon="faDownload"/> {{ $ts.export }}</MkButton>
|
<FormGroup>
|
||||||
<MkButton inline primary @click="doImport" :disabled="!['following', 'user-lists'].includes(exportTarget)"><Fa :icon="faUpload"/> {{ $ts.import }}</MkButton>
|
<template #label>{{ $ts._exportOrImport.userLists }}</template>
|
||||||
</div>
|
<FormButton @click="doExport('user-lists')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
||||||
</section>
|
<FormButton @click="doImport('user-lists', $event)"><Fa :icon="faUpload"/> {{ $ts.import }}</FormButton>
|
||||||
|
</FormGroup>
|
||||||
|
<FormGroup>
|
||||||
|
<template #label>{{ $ts._exportOrImport.muteList }}</template>
|
||||||
|
<FormButton @click="doExport('mute')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
||||||
|
</FormGroup>
|
||||||
|
<FormGroup>
|
||||||
|
<template #label>{{ $ts._exportOrImport.blockingList }}</template>
|
||||||
|
<FormButton @click="doExport('blocking')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
||||||
|
</FormGroup>
|
||||||
|
</FormBase>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { faDownload, faUpload, faBoxes } from '@fortawesome/free-solid-svg-icons';
|
import { faDownload, faUpload, faBoxes } from '@fortawesome/free-solid-svg-icons';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import FormSelect from '@/components/form/select.vue';
|
||||||
import MkSelect from '@/components/ui/select.vue';
|
import FormButton from '@/components/form/button.vue';
|
||||||
|
import FormBase from '@/components/form/base.vue';
|
||||||
|
import FormGroup from '@/components/form/group.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { selectFile } from '@/scripts/select-file';
|
import { selectFile } from '@/scripts/select-file';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
MkButton,
|
FormBase,
|
||||||
MkSelect,
|
FormGroup,
|
||||||
|
FormButton,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
emits: ['info'],
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
exportTarget: 'notes',
|
INFO: {
|
||||||
|
title: this.$ts.importAndExport,
|
||||||
|
icon: faBoxes
|
||||||
|
},
|
||||||
faDownload, faUpload, faBoxes
|
faDownload, faUpload, faBoxes
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this.$emit('info', this.INFO);
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
doExport() {
|
doExport(target) {
|
||||||
os.api(
|
os.api(
|
||||||
this.exportTarget == 'notes' ? 'i/export-notes' :
|
target == 'notes' ? 'i/export-notes' :
|
||||||
this.exportTarget == 'following' ? 'i/export-following' :
|
target == 'following' ? 'i/export-following' :
|
||||||
this.exportTarget == 'blocking' ? 'i/export-blocking' :
|
target == 'blocking' ? 'i/export-blocking' :
|
||||||
this.exportTarget == 'user-lists' ? 'i/export-user-lists' :
|
target == 'user-lists' ? 'i/export-user-lists' :
|
||||||
this.exportTarget == 'mute' ? 'i/export-mute' :
|
target == 'mute' ? 'i/export-mute' :
|
||||||
null, {})
|
null, {})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
os.dialog({
|
os.dialog({
|
||||||
|
@ -58,12 +80,12 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async doImport(e) {
|
async doImport(target, e) {
|
||||||
const file = await selectFile(e.currentTarget || e.target);
|
const file = await selectFile(e.currentTarget || e.target);
|
||||||
|
|
||||||
os.api(
|
os.api(
|
||||||
this.exportTarget == 'following' ? 'i/import-following' :
|
target == 'following' ? 'i/import-following' :
|
||||||
this.exportTarget == 'user-lists' ? 'i/import-user-lists' :
|
target == 'user-lists' ? 'i/import-user-lists' :
|
||||||
null, {
|
null, {
|
||||||
fileId: file.id
|
fileId: file.id
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
Loading…
Reference in a new issue