使用downloadFile

dev_unstable
hjm 6 years ago
parent 177d733da1
commit 199bb1862f

@ -1,4 +1,4 @@
import { bytesToSize, getUrl2 } from 'educoder';
import { bytesToSize, getUrl, getUrl2 } from 'educoder';
const $ = window.$
export function isImageExtension(fileName) {
@ -40,7 +40,7 @@ export function markdownToHTML(oldContent, selector) {
}
}
function _doDownload(options) {
$.fileDownload("/api" + options.url, {
$.fileDownload(getUrl() + "/api" + options.url, {
successCallback: options.successCallback,
failCallback: options.failCallback
});

@ -8,7 +8,7 @@ import CourseLayoutcomponent from '../common/CourseLayoutComponent'
import Titlesearchsection from '../common/titleSearch/TitleSearchSection'
import ColorCountText from '../common/titleSearch/ColorCountText'
import { WordsBtn, trigger, on, off } from 'educoder'
import { WordsBtn, trigger, on, off, getUrl, downloadFile } from 'educoder'
import Modals from "../../modals/Modals";
import axios from 'axios'
import _ from 'lodash'
@ -150,7 +150,19 @@ class studentsList extends Component{
}
}else {
this.props.showNotification(`正在下载中`);
window.open("/api"+url, '_blank');
// getUrl() + "/api"+
const fileUrl = url;
downloadFile({
url: fileUrl,
successCallback: (url) => {
console.log('successCallback')
},
failCallback: (responseHtml, url) => {
console.log('failCallback')
}
})
// window.open(fileUrl, "_self");// , '_blank'
}
}).catch((error) => {
console.log(error)

Loading…
Cancel
Save