From 611695463af65856d2b18f4433185fadf2c792c1 Mon Sep 17 00:00:00 2001 From: zhanglipeng Date: Fri, 29 Jan 2021 15:34:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91-=E6=9C=AC=E5=9C=B0=E8=B5=84?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/utils/zipdownload.js | 8 +++-- .../src/views/benyi/child_files/index.vue | 4 +-- .../views/benyi_train/video_study/index.vue | 29 ++++++++++--------- .../framework/config/SecurityConfig.java | 6 ++-- .../controller/ByTrainVideoController.java | 3 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/ruoyi-ui/src/utils/zipdownload.js b/ruoyi-ui/src/utils/zipdownload.js index dee87b7a8..06198090b 100644 --- a/ruoyi-ui/src/utils/zipdownload.js +++ b/ruoyi-ui/src/utils/zipdownload.js @@ -18,15 +18,16 @@ export function downLoadZip(str, filename) { resolveBlob(res, mimeMap.zip) }) } -export function downLoadRequestUrl(str) { +export function downLoadVideoUrl(str) { var url = baseUrl + str axios({ method: 'get', url: url, - responseType: 'blob', + responseType: 'arraybuffer', headers: { 'Authorization': 'Bearer ' + getToken() }, }).then(res => { // console.log(res); + res.send(); }) } @@ -39,7 +40,8 @@ export function downLoadUrl(str, item) { headers: { 'Authorization': 'Bearer ' + getToken() }, }).then(res => { // console.log(res); - downloadFileFun(res.data, item) + // downloadFileFun(res.data, item) + res.send(); }) } diff --git a/ruoyi-ui/src/views/benyi/child_files/index.vue b/ruoyi-ui/src/views/benyi/child_files/index.vue index e2abd1951..a4924e670 100644 --- a/ruoyi-ui/src/views/benyi/child_files/index.vue +++ b/ruoyi-ui/src/views/benyi/child_files/index.vue @@ -22,8 +22,8 @@ {{ i + 1 }}. {{ ele.name }} - 下载 - + + 下载 diff --git a/ruoyi-ui/src/views/benyi_train/video_study/index.vue b/ruoyi-ui/src/views/benyi_train/video_study/index.vue index 7f13a6dfb..caecf08e9 100644 --- a/ruoyi-ui/src/views/benyi_train/video_study/index.vue +++ b/ruoyi-ui/src/views/benyi_train/video_study/index.vue @@ -103,10 +103,11 @@ import { listVideo, getVideo, - privateDownloadUrl + privateDownloadUrl, } from "@/api/benyi_train/video"; import { listAllLecturer } from "@/api/benyi_train/lecturer"; import { listMoedata } from "@/api/system/moedata"; +import { downLoadVideoUrl } from "@/utils/zipdownload"; export default { name: "VideoStudy", @@ -132,17 +133,17 @@ export default { type: undefined, status: "0", pageNum: 1, - pageSize: 8 - } + pageSize: 8, + }, }; }, created() { this.getList(); - listAllLecturer().then(response => { + listAllLecturer().then((response) => { //console.log(response.lecturer); this.lecturerOptions = response.lecturer; }); - listMoedata(this.queryParams).then(response => { + listMoedata(this.queryParams).then((response) => { //第一步转换数组 this.optionTypes = this.handleTree(response.data, "id", "pid"); //第二步移除children为0的数组,也就是将children为0 设置为undefined @@ -172,9 +173,10 @@ export default { /** 查询培训列表 */ getList() { this.loading = true; - listVideo(this.queryParams).then(response => { + listVideo(this.queryParams).then((response) => { this.videoList = response.rows; - this.playerOptions = response.rows.map(ele => { + this.playerOptions = response.rows.map((ele) => { + console.log(ele.videourl); return { autoplay: false, muted: true, @@ -185,8 +187,9 @@ export default { { type: ele.filetype, // mp4 - src: ele.videourl - } + // src: ele.videourl + src: downLoadVideoUrl(ele.videourl), + }, ], notSupportedMessage: "此视频暂无法播放,请稍后再试", poster: "", @@ -194,8 +197,8 @@ export default { timeDivider: true, durationDisplay: false, remainingTimeDisplay: false, - fullscreenToggle: true //全屏按钮 - } + fullscreenToggle: true, //全屏按钮 + }, }; }); this.total = response.total; @@ -217,8 +220,8 @@ export default { resetQuery() { this.resetForm("queryForm"); this.handleQuery(); - } - } + }, + }, }; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index a05c525ac..ef3add97c 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -94,9 +94,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/**/*.css", "/**/*.js" ).permitAll() - .antMatchers("/profile/**").anonymous() - .antMatchers("/common/download**").anonymous() - .antMatchers("/common/download/resource**").anonymous() +// .antMatchers("/profile/**").anonymous() +// .antMatchers("/common/download**").anonymous() +// .antMatchers("/common/download/resource**").anonymous() .antMatchers("/swagger-ui.html").anonymous() .antMatchers("/swagger-resources/**").anonymous() .antMatchers("/webjars/**").anonymous() diff --git a/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByTrainVideoController.java b/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByTrainVideoController.java index c9096777f..517ba8b94 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByTrainVideoController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/ByTrainVideoController.java @@ -62,7 +62,8 @@ public class ByTrainVideoController extends BaseController { if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { - list.get(i).setVideourl(commonController.privateDownloadUrl(list.get(i).getVideourl())); +// list.get(i).setVideourl(commonController.privateDownloadUrl(list.get(i).getVideourl())); + list.get(i).setVideourl("profile/video/"+list.get(i).getVideourl()+".mp4"); } }