From 7acd0a3f8827122ddfef307257f7b7bee3e44894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E9=BE=99=E9=91=AB?= Date: Fri, 23 Apr 2021 11:52:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=8E=AF=E5=A2=83=E9=80=89=E6=8B=A9=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E5=86=85=E5=AE=B9=E7=9A=84json=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=E6=9C=89=E9=94=99=E8=AF=AF=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/project/EnvironmentImport.vue | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/src/business/components/settings/project/EnvironmentImport.vue b/frontend/src/business/components/settings/project/EnvironmentImport.vue index bca3cf5adb..ff60c7dd6c 100644 --- a/frontend/src/business/components/settings/project/EnvironmentImport.vue +++ b/frontend/src/business/components/settings/project/EnvironmentImport.vue @@ -77,7 +77,7 @@ export default { this.uploadFiles = uploadFiles; }, save() { - if (this.uploadFiles.length > 0) { + if (this.uploadFiles.length > 0) { for (let i = 0; i < this.uploadFiles.length; i++) { this.uploadValidate(this.uploadFiles[i]); let file = this.uploadFiles[i]; @@ -87,18 +87,22 @@ export default { let reader = new FileReader(); reader.readAsText(file.raw) - reader.onload = (e) => { - let fileString = e.target.result; - JSON.parse(fileString).map(env => { - //projectId为空字符串要转换为null,空字符串会被认为有projectId - env.projectId = this.currentProjectId === '' ? null : this.currentProjectId; - this.$post('/api/environment/add', env, response => { - this.$emit('refresh'); - this.$success(this.$t('commons.save_success')); - }) - }) + reader.onload = (e) => { + let fileString = e.target.result; + try { + JSON.parse(fileString).map(env => { + //projectId为空字符串要转换为null,空字符串会被认为有projectId + env.projectId = this.currentProjectId === '' ? null : this.currentProjectId; + this.$post('/api/environment/add', env, response => { + this.$emit('refresh'); + this.$success(this.$t('commons.save_success')); + }) + }) + } catch (exception) { + this.$warning(this.$t('api_test.api_import.ms_env_import_file_limit')); + } + } - } } } },