mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-10 11:26:43 +08:00
pdf预览地址加密处理
This commit is contained in:
@@ -114,33 +114,33 @@ export default {
|
|||||||
this.showPages++;
|
this.showPages++;
|
||||||
}
|
}
|
||||||
this.isscroll = true;
|
this.isscroll = true;
|
||||||
|
|
||||||
},
|
},
|
||||||
//加载页面
|
//加载页面
|
||||||
loadInitPdf(url) {
|
loadInitPdf(url) {
|
||||||
|
|
||||||
if(url && url.indexOf('.pdf')>-1){
|
if(url && url.indexOf('.pdf')>-1){
|
||||||
let loadingTask = pdf.createLoadingTask(url);
|
let loadingTask = pdf.createLoadingTask(url);
|
||||||
this.src=loadingTask;
|
this.src=loadingTask;
|
||||||
|
|
||||||
loadingTask.promise.then((pdf) =>{
|
loadingTask.promise.then((pdf) =>{
|
||||||
console.log(pdf)
|
console.log(pdf)
|
||||||
this.totalPages=pdf.numPages;
|
this.totalPages=pdf.numPages;
|
||||||
|
|
||||||
|
|
||||||
if(pdf.numPages>this.initNum){
|
if(pdf.numPages>this.initNum){
|
||||||
this.showPages = this.initNum;
|
this.showPages = this.initNum;
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
this.showPages =pdf.numPages;
|
this.showPages =pdf.numPages;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}).catch((err) =>{
|
}).catch((err) =>{
|
||||||
this.$message.error("加载内容失败,请联系管理员");
|
this.$message.error("加载内容失败,请联系管理员");
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -149,11 +149,11 @@ export default {
|
|||||||
let innerHeight = document.querySelector('#pdf-perView').clientHeight
|
let innerHeight = document.querySelector('#pdf-perView').clientHeight
|
||||||
let outerHeight = document.documentElement.clientHeight
|
let outerHeight = document.documentElement.clientHeight
|
||||||
let scrollTop = document.documentElement.scrollTop
|
let scrollTop = document.documentElement.scrollTop
|
||||||
|
|
||||||
if(this.isscroll){
|
if(this.isscroll){
|
||||||
this.showPages++;
|
this.showPages++;
|
||||||
this.debounce(this.loadInitPdf(),5000);
|
this.debounce(this.loadInitPdf(),5000);
|
||||||
|
|
||||||
}
|
}
|
||||||
// console.log(this.pdfpage,'000')
|
// console.log(this.pdfpage,'000')
|
||||||
// console.log(this.totalPages,this.pdfpage)
|
// console.log(this.totalPages,this.pdfpage)
|
||||||
@@ -168,8 +168,8 @@ export default {
|
|||||||
// document.querySelector('#articleAnking').style.cssText = "position: static";
|
// document.querySelector('#articleAnking').style.cssText = "position: static";
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
debounce(func, wait) {// 非立即执行
|
debounce(func, wait) {// 非立即执行
|
||||||
let timeout;
|
let timeout;
|
||||||
return function () {
|
return function () {
|
||||||
@@ -229,6 +229,7 @@ export default {
|
|||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
//border: 1px solid #dfdfdf;
|
//border: 1px solid #dfdfdf;
|
||||||
|
background-color: #e9e9e9;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
>span{
|
>span{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<!-- <span>案例编号:{{ caseDetail.id }}</span> -->
|
<!-- <span>案例编号:{{ caseDetail.id }}</span> -->
|
||||||
<span v-if="caseDetail.sysCreateTime">{{ caseDetail.sysCreateTime.substring(0,10) }}</span>
|
<span v-if="caseDetail.sysCreateTime">{{ caseDetail.sysCreateTime.substring(0,10) }}</span>
|
||||||
<interactBar :data="caseDetail" :type="3" :comments="false" :shares="true"></interactBar>
|
<interactBar :data="caseDetail" :type="3" :comments="false" :shares="true"></interactBar>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="case-summary"><span>{{ caseDetail.summary }}</span></div>
|
<div class="case-summary"><span>{{ caseDetail.summary }}</span></div>
|
||||||
<div class="btn-div" >
|
<div class="btn-div" >
|
||||||
@@ -138,6 +138,8 @@ import apiUser from '@/api/system/user.js';
|
|||||||
import author from '@/components/Portal/authorInfo.vue';
|
import author from '@/components/Portal/authorInfo.vue';
|
||||||
import apiMessage from '@/api/system/message.js';
|
import apiMessage from '@/api/system/message.js';
|
||||||
import apiDict from "@/api/modules/dict.js"
|
import apiDict from "@/api/modules/dict.js"
|
||||||
|
import {encrypt} from '@/utils/jsencrypt.js';
|
||||||
|
import cookies from 'vue-cookies'
|
||||||
export default {
|
export default {
|
||||||
name: 'atticle',
|
name: 'atticle',
|
||||||
components: { portalHeader, portalFooter, interactBar, author, comments,pdfPreview },
|
components: { portalHeader, portalFooter, interactBar, author, comments,pdfPreview },
|
||||||
@@ -168,7 +170,7 @@ export default {
|
|||||||
this.getCaseData();
|
this.getCaseData();
|
||||||
}
|
}
|
||||||
this.getAnkingData();
|
this.getAnkingData();
|
||||||
this.getPopularity();
|
this.getPopularity();
|
||||||
this.getPositive();
|
this.getPositive();
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
"scroll",
|
"scroll",
|
||||||
@@ -176,9 +178,20 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
createPlayUrl(u){
|
||||||
|
let nowDate=new Date();
|
||||||
|
let ctime=parseInt(nowDate.getTime()/1000);
|
||||||
|
let beforeUrl=parseInt(nowDate.getTime()/1000)+'/'+u;
|
||||||
|
let urlSign=encodeURIComponent(encrypt(beforeUrl));
|
||||||
|
cookies.set('CASE_TIME', ctime);//写客户端的cookie保存
|
||||||
|
//以下判断是为了区分本地环境和服务器环境
|
||||||
|
if(process.env.NODE_ENV == 'development'){
|
||||||
|
this.pdfPath=process.env.VUE_APP_FILE_BASE_URL+u;
|
||||||
|
}else{
|
||||||
|
this.pdfPath=process.env.VUE_APP_BASE_API+'/xboe/m/course/cware/resource?sign='+urlSign;
|
||||||
|
}
|
||||||
|
//console.log(this.pdfPath,'this.blobUrl');
|
||||||
|
},
|
||||||
handleScroll() {
|
handleScroll() {
|
||||||
let innerHeight = document.querySelector('#case-list-content').clientHeight
|
let innerHeight = document.querySelector('#case-list-content').clientHeight
|
||||||
let outerHeight = document.documentElement.clientHeight
|
let outerHeight = document.documentElement.clientHeight
|
||||||
@@ -226,11 +239,16 @@ export default {
|
|||||||
this.caseDetail = res.result;
|
this.caseDetail = res.result;
|
||||||
this.getCaseUserDetail();
|
this.getCaseUserDetail();
|
||||||
if(this.caseDetail.filePath){
|
if(this.caseDetail.filePath){
|
||||||
this.pdfPath=this.basePath+this.caseDetail.filePath;
|
if(this.caseDetail.filePath){
|
||||||
|
//this.pdfPath=this.basePath+this.caseDetail.filePath;
|
||||||
|
this.createPlayUrl(this.caseDetail.filePath);
|
||||||
|
}else{
|
||||||
|
this.$message.error('无内容文件,请与管理员联系');
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
this.$message.error('内容文件不存在或已被删除,请与管理员联系');
|
this.$message.error('内容文件不存在或已被删除,请与管理员联系');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -354,6 +372,7 @@ export default {
|
|||||||
.jianjie {
|
.jianjie {
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
min-height: 300px;
|
||||||
padding: 0px 0px 10px 0px;
|
padding: 0px 0px 10px 0px;
|
||||||
.content {
|
.content {
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user