From 1b2cd2deeb8b80779e13acd1389e9b397c96c447 Mon Sep 17 00:00:00 2001 From: maxmon <541182180@qq.com> Date: Sat, 16 Apr 2022 22:16:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=82=B9=E6=A0=87=E6=B3=A8=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/app/api/v1/files.py | 9 +++++++++ fe/src/components/NER/index.vue | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/be/app/api/v1/files.py b/be/app/api/v1/files.py index fa906a4..363d596 100644 --- a/be/app/api/v1/files.py +++ b/be/app/api/v1/files.py @@ -96,6 +96,15 @@ def get_lables(): ret_info.errMsg = str(e) return json.dumps(download_json, default=lambda o: o.__dict__) +@api.route('/get_anno_json', methods=['GET']) +def get_anno_json(): + project_name = request.args.get("projectName") + anno_json_path = DOWNLOAD_FILE_LOCATION.format(project_name).replace('result.json', 'anno.json') + print(anno_json_path) + response = make_response(send_from_directory(directory='', path=anno_json_path, as_attachment=True)) + response.headers["Content-disposition"] = 'attachment; filename=result.json' + + return response @api.route('/get_json', methods=['GET']) def get_json(): diff --git a/fe/src/components/NER/index.vue b/fe/src/components/NER/index.vue index 9e52e21..f57068d 100644 --- a/fe/src/components/NER/index.vue +++ b/fe/src/components/NER/index.vue @@ -624,11 +624,12 @@ export default { // 非单机版,就直接通过url下载 if (this.projectType === '命名实体识别') { window.open(`/v1/files/get_json?projectName=${this.projectName}`, '_self') - } - if (this.projectType === '文本分类') { + } else if (this.projectType === '文本分类') { get(`/v1/files/get_labels?projectName=${this.projectName}`, (text) => { saveAsFile(JSON.stringify(JSON.parse(text)), 'labels.json') }, {isDirect: true}) + } else { + window.open(`/v1/files/get_anno_json?projectName=${this.projectName}`, '_self') } return true }