diff --git a/package-lock.json b/package-lock.json index 6e77c84..53193ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1018,6 +1018,11 @@ "@types/node": "*" } }, + "@types/json-schema": { + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", + "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==" + }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -1568,8 +1573,7 @@ "ajv-keywords": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.1.tgz", - "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==", - "dev": true + "integrity": "sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==" }, "alphanum-sort": { "version": "1.0.2", @@ -1998,6 +2002,11 @@ "resolve": "^1.4.0" } }, + "babel-plugin-syntax-dynamic-import": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz", + "integrity": "sha1-jWomIpyDdFqZgqRBBRVyyqF5sdo=" + }, "babel-polyfill": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz", @@ -9154,6 +9163,11 @@ "sha.js": "^2.4.8" } }, + "pdfjs-dist": { + "version": "2.5.207", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-2.5.207.tgz", + "integrity": "sha512-xGDUhnCYPfHy+unMXCLCJtlpZaaZ17Ew3WIL0tnSgKFUZXHAPD49GO9xScyszSsQMoutNDgRb+rfBXIaX/lJbw==" + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -10233,6 +10247,76 @@ "unpipe": "1.0.0" } }, + "raw-loader": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.2.tgz", + "integrity": "sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==", + "requires": { + "loader-utils": "^2.0.0", + "schema-utils": "^3.0.0" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==" + }, + "emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==" + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "json5": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", + "requires": { + "minimist": "^1.2.5" + } + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "schema-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz", + "integrity": "sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==", + "requires": { + "@types/json-schema": "^7.0.6", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + } + } + }, "read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -12616,6 +12700,44 @@ "vue-style-loader": "^4.1.0" } }, + "vue-pdf": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/vue-pdf/-/vue-pdf-4.2.0.tgz", + "integrity": "sha512-GpAbZfM48Hom1R8f4XL5ZzoVBLlbyy+4z0VYmTQORVOSieVIIu+XtnNl0RY6EXg60Qni6T6nIgrmsCcCkWv39A==", + "requires": { + "babel-plugin-syntax-dynamic-import": "^6.18.0", + "loader-utils": "^1.4.0", + "pdfjs-dist": "^2.5.207", + "raw-loader": "^4.0.1", + "vue-resize-sensor": "^2.0.0", + "worker-loader": "^2.0.0" + }, + "dependencies": { + "emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==" + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "requires": { + "minimist": "^1.2.0" + } + }, + "loader-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", + "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^1.0.1" + } + } + } + }, "vue-quill-editor": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/vue-quill-editor/-/vue-quill-editor-3.0.6.tgz", @@ -12625,6 +12747,11 @@ "quill": "^1.3.4" } }, + "vue-resize-sensor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/vue-resize-sensor/-/vue-resize-sensor-2.0.0.tgz", + "integrity": "sha512-W+y2EAI/BxS4Vlcca9scQv8ifeBFck56DRtSwWJ2H4Cw1GLNUYxiZxUHHkuzuI5JPW/cYtL1bPO5xPyEXx4LmQ==" + }, "vue-router": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.1.3.tgz", @@ -13105,6 +13232,26 @@ "errno": "~0.1.7" } }, + "worker-loader": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/worker-loader/-/worker-loader-2.0.0.tgz", + "integrity": "sha512-tnvNp4K3KQOpfRnD20m8xltE3eWh89Ye+5oj7wXEEHKac1P4oZ6p9oTj8/8ExqoSBnk9nu5Pr4nKfQ1hn2APJw==", + "requires": { + "loader-utils": "^1.0.0", + "schema-utils": "^0.4.0" + }, + "dependencies": { + "schema-utils": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz", + "integrity": "sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==", + "requires": { + "ajv": "^6.1.0", + "ajv-keywords": "^3.1.0" + } + } + } + }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", diff --git a/package.json b/package.json index 53254ff..532785d 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "vue": "^2.6.10", "vue-cropperjs": "^3.0.0", "vue-i18n": "^8.10.0", + "vue-pdf": "^4.2.0", "vue-quill-editor": "^3.0.6", "vue-router": "^3.0.3", "vue-schart": "^2.0.0", diff --git a/src/layouts/navbar/index.vue b/src/layouts/navbar/index.vue index 8a7432b..a73b53b 100644 --- a/src/layouts/navbar/index.vue +++ b/src/layouts/navbar/index.vue @@ -15,7 +15,7 @@ export default { { icon: 'el-icon-folder-checked', index: '/index/list', - title: '首页' + title: '我的首页' }, { icon: 'el-icon-lx-home', diff --git a/src/libs/util.js b/src/libs/util.js index acb054d..2943822 100644 --- a/src/libs/util.js +++ b/src/libs/util.js @@ -85,6 +85,10 @@ const util = { }) return list }, + // 传入文件名获取文件后缀 + getFileExt(fileName) { + return fileName.substring(fileName.lastIndexOf('.') + 1) + }, } export default util \ No newline at end of file diff --git a/src/mixins/examDo/index.js b/src/mixins/examDo/index.js index 617aea0..a811eb4 100644 --- a/src/mixins/examDo/index.js +++ b/src/mixins/examDo/index.js @@ -69,23 +69,19 @@ export default { ) }, beforeUpload(file,item){ - if(util.isDoc(file.name.substring(file.name.lastIndexOf('.') + 1)) && (file.size / 1024 / 1024) > this.maxSize){ + let ext = util.getFileExt(file.name) + if(util.isDoc(ext) && (file.size / 1024 / 1024) > this.maxSize){ this.$message.error(`请上传${this.maxSize}M以内的文件`) return false } - item.fileName = file.name - console.log('上传前:',item,file) }, uploadSuccess(res, file, fileList, item) { - console.log('上传成功:',res, file, fileList, item) let ext = file.response.data.filesResult.fileType - item.fileExt = ext if(util.isVideo(ext)){ - item.video = res.data.filesResult.fileId + item.video[file.name] = res.data.filesResult.fileId }else{ - item.fileUrl = res.data.filesResult.fileUrl + item.fileUrl[file.name] = res.data.filesResult.fileUrl } - console.log('上传成功:',item) }, uploadError(err, file, fileList) { this.$message({ @@ -98,18 +94,15 @@ export default { return this.$confirm(`确定移除 ${file.name}?`) }, handleRemove(file, fileList, item) { - console.log('删除:',item) - if(util.isVideo(item.fileExt)){ - this.$del(`${this.api.removeVideo}/${item.video}`).then(res => { - item.video = '' + if(util.isVideo(util.getFileExt(file.name))){ + this.$del(`${this.api.removeVideo}/${item.video[file.name]}`).then(res => { + delete item.video[file.name] }).catch(res => {}) }else{ - console.log('删除前:',item.fileUrl) - let fileName = item.fileUrl.replace('https://cj-oss.oss-cn-guangzhou.aliyuncs.com/','') - console.log('删除前:',fileName) + let fileName = item.fileUrl[file.name].replace('https://cj-oss.oss-cn-guangzhou.aliyuncs.com/','') this.$del(`${this.api.fileDeletion}?keys=${fileName}`).then(res => { - item.fileUrl = '' + delete item.fileUrl[file.name] }).catch(res => {}) } }, diff --git a/src/mixins/file/index.js b/src/mixins/file/index.js new file mode 100644 index 0000000..29ff8f0 --- /dev/null +++ b/src/mixins/file/index.js @@ -0,0 +1,77 @@ +import util from '@/libs/util' +export default { + data() { + return { + playAuth: '', + player: null, + iframeSrc: '', + pdfVisible: false, + pdfSrc: '', + imgName: '', + imgSrc: '' + } + }, + mounted() { + this.insertScript() + }, + methods: { + preview(url,isVideo){ + let ext = util.getFileExt(url) + if(isVideo){ + this.$get(`${this.api.getPlayAuth}/${url}`).then(res => { + this.playAuth = res.data.playAuth + if(this.player){ + this.player.replayByVidAndPlayAuth(url,this.playAuth) + }else{ + this.player = new Aliplayer({ + id: 'player', + width: '100%', + autoplay: false, + vid : url, + playauth : this.playAuth, + encryptType:1, //当播放私有加密流时需要设置。 + }) + } + }).catch(res => {}) + }else if(ext == 'pdf'){ + this.pdfSrc = url + this.pdfVisible = true + }else if(util.isDoc(ext)){ + window.open(`https://view.officeapps.live.com/op/view.aspx?src=${url}`) + }else if(util.isImg(ext)){ + window.open(url) + } + }, + insertScript(){ + const linkTag = document.createElement('link') + linkTag.id = 'aliplayerLink' + linkTag.rel = 'stylesheet' + linkTag.href = 'https://g.alicdn.com/de/prismplayer/2.8.2/skins/default/aliplayer-min.css' + document.body.appendChild(linkTag) + + const scriptTag = document.createElement('script') + scriptTag.id = 'aliplayerScript' + scriptTag.type = 'text/javascript' + scriptTag.src = 'https://g.alicdn.com/de/prismplayer/2.8.2/aliplayer-min.js' + document.body.appendChild(scriptTag) + this.$once('hook:beforeDestroy', function () { + document.body.removeChild(document.querySelector('#aliplayerLink')) + document.body.removeChild(document.querySelector('#aliplayerScript')) + }) + }, + closePlayer(){ + 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() + }else{ + window.open(url) + } + } + } +} \ No newline at end of file diff --git a/src/pages/achievement/assessment/index.vue b/src/pages/achievement/assessment/index.vue index b542a8c..017518f 100644 --- a/src/pages/achievement/assessment/index.vue +++ b/src/pages/achievement/assessment/index.vue @@ -58,19 +58,46 @@

{{item.user_answer}}

+
+

附件:

+
+ + +
+

答案解析:

+ +
+
+ +
+
+ + 下载图片