From 9d808ee583ea6b71620fb06b0fbb443304d93396 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Tue, 30 Jul 2019 13:48:21 +0800 Subject: [PATCH] download --- .../courses/busyWork/CommonWorkDetailIndex.js | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js index ff8e3e3a2..4f2283499 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js @@ -8,7 +8,7 @@ import { CNotificationHOC } from '../common/CNotificationHOC' import { RouteHOC } from './common' import locale from 'antd/lib/date-picker/locale/zh_CN'; -import { WordsBtn, MarkdownToHtml, trigger, queryString } from 'educoder'; +import { WordsBtn, MarkdownToHtml, trigger, queryString, downloadFile } from 'educoder'; import axios from 'axios'; import Modals from '../../modals/Modals'; import CoursesListType from '../coursesPublic/CoursesListType'; @@ -18,6 +18,8 @@ import '../css/Courses.css' import CBreadcrumb from '../common/CBreadcrumb' import DownloadMessageysl from "../../modals/DownloadMessageysl"; +import { Spin } from 'antd' + //引入对应跳转的组件 //新建分组/普通作业 @@ -64,6 +66,7 @@ class CommonWorkDetailIndex extends Component{ this.state = { DownloadType:false, DownloadMessageval:undefined, + donwloading: false, } } initWorkDetailCommonState = (data) => { @@ -123,7 +126,20 @@ class CommonWorkDetailIndex extends Component{ } }else { this.props.showNotification(`正在下载中`); - window.open("/api"+url, '_blank'); + + this.setState({ donwloading: true }) + downloadFile({ + url: url, + successCallback: (url) => { + this.setState({ donwloading: false }) + console.log('successCallback') + }, + failCallback: (responseHtml, url) => { + this.setState({ donwloading: false }) + console.log('failCallback') + } + }) + // window.open("/api"+url, '_blank'); } }).catch((error) => { console.log(error) @@ -244,7 +260,7 @@ class CommonWorkDetailIndex extends Component{ } - { noTab !== true &&