视频-本地资源

This commit is contained in:
zhanglipeng 2021-01-29 15:34:39 +08:00
parent 4fbb01b54e
commit 611695463a
5 changed files with 28 additions and 22 deletions

View File

@ -18,15 +18,16 @@ export function downLoadZip(str, filename) {
resolveBlob(res, mimeMap.zip) resolveBlob(res, mimeMap.zip)
}) })
} }
export function downLoadRequestUrl(str) { export function downLoadVideoUrl(str) {
var url = baseUrl + str var url = baseUrl + str
axios({ axios({
method: 'get', method: 'get',
url: url, url: url,
responseType: 'blob', responseType: 'arraybuffer',
headers: { 'Authorization': 'Bearer ' + getToken() }, headers: { 'Authorization': 'Bearer ' + getToken() },
}).then(res => { }).then(res => {
// console.log(res); // console.log(res);
res.send();
}) })
} }
@ -39,7 +40,8 @@ export function downLoadUrl(str, item) {
headers: { 'Authorization': 'Bearer ' + getToken() }, headers: { 'Authorization': 'Bearer ' + getToken() },
}).then(res => { }).then(res => {
// console.log(res); // console.log(res);
downloadFileFun(res.data, item) // downloadFileFun(res.data, item)
res.send();
}) })
} }

View File

@ -22,8 +22,8 @@
<span>{{ i + 1 }}.</span> <span>{{ i + 1 }}.</span>
<i class="el-icon-document icon"></i>{{ ele.name }} <i class="el-icon-document icon"></i>{{ ele.name }}
</div> </div>
<a class="right" :href="apiurl + ele.fileurl">下载</a> <!-- <a class="right" :href="apiurl + ele.fileurl">下载</a> -->
<!-- <a class="right" @click="down(ele)">下载</a> --> <a class="right" @click="down(ele)">下载</a>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -103,10 +103,11 @@
import { import {
listVideo, listVideo,
getVideo, getVideo,
privateDownloadUrl privateDownloadUrl,
} from "@/api/benyi_train/video"; } from "@/api/benyi_train/video";
import { listAllLecturer } from "@/api/benyi_train/lecturer"; import { listAllLecturer } from "@/api/benyi_train/lecturer";
import { listMoedata } from "@/api/system/moedata"; import { listMoedata } from "@/api/system/moedata";
import { downLoadVideoUrl } from "@/utils/zipdownload";
export default { export default {
name: "VideoStudy", name: "VideoStudy",
@ -132,17 +133,17 @@ export default {
type: undefined, type: undefined,
status: "0", status: "0",
pageNum: 1, pageNum: 1,
pageSize: 8 pageSize: 8,
} },
}; };
}, },
created() { created() {
this.getList(); this.getList();
listAllLecturer().then(response => { listAllLecturer().then((response) => {
//console.log(response.lecturer); //console.log(response.lecturer);
this.lecturerOptions = response.lecturer; this.lecturerOptions = response.lecturer;
}); });
listMoedata(this.queryParams).then(response => { listMoedata(this.queryParams).then((response) => {
// //
this.optionTypes = this.handleTree(response.data, "id", "pid"); this.optionTypes = this.handleTree(response.data, "id", "pid");
//children0children0 undefined //children0children0 undefined
@ -172,9 +173,10 @@ export default {
/** 查询培训列表 */ /** 查询培训列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listVideo(this.queryParams).then(response => { listVideo(this.queryParams).then((response) => {
this.videoList = response.rows; this.videoList = response.rows;
this.playerOptions = response.rows.map(ele => { this.playerOptions = response.rows.map((ele) => {
console.log(ele.videourl);
return { return {
autoplay: false, autoplay: false,
muted: true, muted: true,
@ -185,8 +187,9 @@ export default {
{ {
type: ele.filetype, type: ele.filetype,
// mp4 // mp4
src: ele.videourl // src: ele.videourl
} src: downLoadVideoUrl(ele.videourl),
},
], ],
notSupportedMessage: "此视频暂无法播放,请稍后再试", notSupportedMessage: "此视频暂无法播放,请稍后再试",
poster: "", poster: "",
@ -194,8 +197,8 @@ export default {
timeDivider: true, timeDivider: true,
durationDisplay: false, durationDisplay: false,
remainingTimeDisplay: false, remainingTimeDisplay: false,
fullscreenToggle: true // fullscreenToggle: true, //
} },
}; };
}); });
this.total = response.total; this.total = response.total;
@ -217,8 +220,8 @@ export default {
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
} },
} },
}; };
</script> </script>

View File

@ -94,9 +94,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/**/*.css", "/**/*.css",
"/**/*.js" "/**/*.js"
).permitAll() ).permitAll()
.antMatchers("/profile/**").anonymous() // .antMatchers("/profile/**").anonymous()
.antMatchers("/common/download**").anonymous() // .antMatchers("/common/download**").anonymous()
.antMatchers("/common/download/resource**").anonymous() // .antMatchers("/common/download/resource**").anonymous()
.antMatchers("/swagger-ui.html").anonymous() .antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous() .antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous() .antMatchers("/webjars/**").anonymous()

View File

@ -62,7 +62,8 @@ public class ByTrainVideoController extends BaseController {
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) { 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");
} }
} }