From 4804bbb211cd4566ff62487573fe45e3f5c3cdf7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 25 Oct 2020 10:48:33 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=88/?= =?UTF-8?q?=E3=82=A8=E3=82=AF=E3=82=B9=E3=83=9D=E3=83=BC=E3=83=88=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E5=BE=A9=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/pages/settings/import-export.vue | 33 ++++----------------- src/client/pages/settings/index.vue | 5 ++-- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/client/pages/settings/import-export.vue b/src/client/pages/settings/import-export.vue index 1c69c48f2..c081c9bb4 100644 --- a/src/client/pages/settings/import-export.vue +++ b/src/client/pages/settings/import-export.vue @@ -9,10 +9,9 @@ - {{ $t('export') }} - {{ $t('import') }} + {{ $t('export') }} + {{ $t('import') }} - @@ -21,8 +20,8 @@ import { defineComponent } from 'vue'; import { faDownload, faUpload, faBoxes } from '@fortawesome/free-solid-svg-icons'; import MkButton from '@/components/ui/button.vue'; import MkSelect from '@/components/ui/select.vue'; -import { apiUrl } from '@/config'; import * as os from '@/os'; +import { selectFile } from '@/scripts/select-file'; export default defineComponent({ components: { @@ -59,29 +58,9 @@ export default defineComponent({ }); }, - doImport() { - (this.$refs.file as any).click(); - }, - - onChangeFile() { - const [file] = Array.from((this.$refs.file as any).files); + async doImport(e) { + const file = await selectFile(e.currentTarget || e.target); - const data = new FormData(); - data.append('file', file); - data.append('i', this.$store.state.i.token); - - const promise = fetch(apiUrl + '/drive/files/create', { - method: 'POST', - body: data - }) - .then(response => response.json()) - .then(f => { - this.reqImport(f); - }); - os.promiseDialog(promise); - }, - - reqImport(file) { os.api( this.exportTarget == 'following' ? 'i/import-following' : this.exportTarget == 'user-lists' ? 'i/import-user-lists' : @@ -98,7 +77,7 @@ export default defineComponent({ text: e.message }); }); - } + }, } }); diff --git a/src/client/pages/settings/index.vue b/src/client/pages/settings/index.vue index c3cc3cc93..677229597 100644 --- a/src/client/pages/settings/index.vue +++ b/src/client/pages/settings/index.vue @@ -20,6 +20,7 @@