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 }