fix(测试跟踪): 修复xmind模版下载无法自动打开问题

This commit is contained in:
fit2-zhao 2020-09-23 14:36:31 +08:00
parent 37f07b473e
commit 1ba55315c4
2 changed files with 10 additions and 2 deletions

View File

@ -113,6 +113,7 @@
import MsTableButton from '../../../../components/common/components/MsTableButton';
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
import {TokenKey, WORKSPACE_ID} from '../../../../../common/js/constants';
import axios from "axios";
export default {
name: "TestCaseImport",
@ -188,7 +189,14 @@
this.$fileDownload('/test/case/export/template');
},
downloadXmindTemplate() {
this.$fileDownload('/test/case/export/xmindTemplate');
axios.get('/test/case/export/xmindTemplate', {responseType: 'blob'})
.then(response => {
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
let link = document.createElement("a");
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.download = fileName;
link.click();
});
},
upload(file) {
this.isLoading = false;

View File

@ -136,7 +136,7 @@ export default {
.then(response => {
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
let link = document.createElement("a");
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.href = window.URL.createObjectURL(new Blob([response.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"}));
link.download = fileName;
link.click();
});