diff --git a/src/layouts/navbar/index.vue b/src/layouts/navbar/index.vue
index a73b53b..c0869dc 100644
--- a/src/layouts/navbar/index.vue
+++ b/src/layouts/navbar/index.vue
@@ -35,7 +35,7 @@ export default {
{
icon: 'el-icon-lx-copy',
index: '/wrongBook/list',
- title: '我的错题本'
+ title: '错题练习'
},
{
icon: 'el-icon-chat-dot-round',
diff --git a/src/libs/util.js b/src/libs/util.js
index 2943822..32458d7 100644
--- a/src/libs/util.js
+++ b/src/libs/util.js
@@ -89,6 +89,20 @@ const util = {
getFileExt(fileName) {
return fileName.substring(fileName.lastIndexOf('.') + 1)
},
+ // 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域
+ downloadFile(fileName,url) {
+ var x = new XMLHttpRequest()
+ x.open("GET", url, true)
+ x.responseType = 'blob'
+ x.onload=function(e) {
+ var url = window.URL.createObjectURL(x.response)
+ var a = document.createElement('a')
+ a.href = url
+ a.download = fileName
+ a.click()
+ }
+ x.send()
+ },
}
export default util
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 8a5e331..5a63a36 100644
--- a/src/main.js
+++ b/src/main.js
@@ -16,9 +16,12 @@ import permission from '@/router/permission';
// 插件
import plugins from '@/plugins';
+import filters from '@/plugins/filters'
Vue.use(plugins);
+Object.keys(filters).forEach(item => Vue.filter(item,filters[item]))
+
Vue.prototype.api = api;
Vue.prototype.$get = get;
Vue.prototype.$post = post;
diff --git a/src/mixins/file/index.js b/src/mixins/file/index.js
index 29ff8f0..6132920 100644
--- a/src/mixins/file/index.js
+++ b/src/mixins/file/index.js
@@ -1,4 +1,5 @@
import util from '@/libs/util'
+import { Loading } from 'element-ui'
export default {
data() {
return {
@@ -7,15 +8,16 @@ export default {
iframeSrc: '',
pdfVisible: false,
pdfSrc: '',
- imgName: '',
- imgSrc: ''
+ isDownload: 0,
+ loadIns: null,
}
},
mounted() {
this.insertScript()
},
methods: {
- preview(url,isVideo){
+ preview(url,isVideo,isDownload){
+ this.isDownload = isDownload
let ext = util.getFileExt(url)
if(isVideo){
this.$get(`${this.api.getPlayAuth}/${url}`).then(res => {
@@ -63,14 +65,22 @@ export default {
this.playAuth = ''
this.player.pause()
},
- download(fileName,url){
- let ext = util.getFileExt(url)
- if(util.isImg(ext)){
- this.imgName = fileName
- this.imgSrc = url
- this.$refs.picLink.click()
+ download(fileName,url,isVideo){
+ if(isVideo){
+ this.loadIns = Loading.service()
+ this.preview(url,isVideo,1)
+ setTimeout(() => {
+ util.downloadFile(fileName,document.querySelector('#player video').src)
+ this.loadIns.close()
+ this.playAuth = ''
+ },1000)
}else{
- window.open(url)
+ let ext = util.getFileExt(url)
+ if(util.isImg(ext)){
+ util.downloadFile(fileName,url)
+ }else{
+ window.open(url)
+ }
}
}
}
diff --git a/src/pages/achievement/assessment/index.vue b/src/pages/achievement/assessment/index.vue
index 017518f..fe4deac 100644
--- a/src/pages/achievement/assessment/index.vue
+++ b/src/pages/achievement/assessment/index.vue
@@ -64,13 +64,13 @@