From 72c39772520208c24578fe4d725a147518d172ed Mon Sep 17 00:00:00 2001 From: johnniang Date: Sun, 28 Apr 2019 22:28:22 +0800 Subject: [PATCH] Perfect installation --- src/components/Upload/Upload.vue | 14 ++++++-- src/views/system/Installation.vue | 56 ++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/src/components/Upload/Upload.vue b/src/components/Upload/Upload.vue index 3afdb7b3..31006ac8 100644 --- a/src/components/Upload/Upload.vue +++ b/src/components/Upload/Upload.vue @@ -6,6 +6,7 @@ :multiple="multiple" :accept="accept" :customRequest="handleUpload" + :remove="handleRemove" @change="handleChange" > @@ -61,13 +63,17 @@ export default { handleChange(info) { this.$emit('change', info) }, + handleRemove(file) { + this.$log.debug('Removed file', file) + this.$emit('remove', file) + }, handleUpload(option) { this.$log.debug('Uploading option', option) const CancelToken = axios.CancelToken const source = CancelToken.source() const data = new FormData() - data.append('file', option.file) + data.append(this.name, option.file) this.uploadHandler( data, @@ -78,18 +84,22 @@ export default { this.$log.debug('Uploading percent: ', progressEvent.percent) option.onProgress(progressEvent) }, - source.token + source.token, + option.file ) .then(response => { + this.$log.debug('Uploaded successfully', response) option.onSuccess(response, option.file) this.$emit('success', response, option.file) }) .catch(error => { + this.$log.debug('Failed to upload file', error) option.onError(error, error.response) this.$emit('failure', error, option.file) }) return { abort: () => { + this.$log.debug('Upload operation aborted by the user') source.cancel('Upload operation canceled by the user.') } } diff --git a/src/views/system/Installation.vue b/src/views/system/Installation.vue index a964307e..5f4a66e1 100644 --- a/src/views/system/Installation.vue +++ b/src/views/system/Installation.vue @@ -117,6 +117,26 @@ layout="horizontal" v-show="stepCurrent == 1" > + + + + + http:// + https:// + + + - - - - -
+

@@ -212,6 +227,7 @@ export default { } }, installation: {}, + migrationUploadName: 'file', migrationData: null, stepCurrent: 0 } @@ -220,11 +236,19 @@ export default { handleMigrationUpload(data) { this.$log.debug('Selected data', data) this.migrationData = data - return new Promise(resolve => { + return new Promise((resolve, reject) => { this.$log.debug('Handle uploading') - resolve.resolve() + resolve() }) }, + handleMigrationFileRemove(file) { + this.$log.debug('Removed file', file) + this.$log.debug('Migration file from data', this.migrationData.get(this.migrationUploadName)) + if (this.migrationData.get(this.migrationUploadName).uid === file.uid) { + this.migrationData = null + this.migrationFile = null + } + }, install() { adminApi.install(this.installation).then(response => { this.$log.debug('Installation response', response) @@ -247,7 +271,7 @@ export default { } // Handle migration - if (this.migrationData) { + if (this.migrationFile) { recoveryApi.migrate(this.migrationData).then(response => { this.$log.debug('Migrated successfullly') this.$message.success('数据迁移成功')