mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-09 10:56:44 +08:00
pdf预览地址加密处理
This commit is contained in:
@@ -114,33 +114,33 @@ export default {
|
||||
this.showPages++;
|
||||
}
|
||||
this.isscroll = true;
|
||||
|
||||
},
|
||||
|
||||
},
|
||||
//加载页面
|
||||
loadInitPdf(url) {
|
||||
|
||||
|
||||
if(url && url.indexOf('.pdf')>-1){
|
||||
let loadingTask = pdf.createLoadingTask(url);
|
||||
this.src=loadingTask;
|
||||
|
||||
|
||||
loadingTask.promise.then((pdf) =>{
|
||||
console.log(pdf)
|
||||
this.totalPages=pdf.numPages;
|
||||
|
||||
|
||||
|
||||
if(pdf.numPages>this.initNum){
|
||||
this.showPages = this.initNum;
|
||||
|
||||
|
||||
} else{
|
||||
this.showPages =pdf.numPages;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}).catch((err) =>{
|
||||
this.$message.error("加载内容失败,请联系管理员");
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
@@ -149,11 +149,11 @@ export default {
|
||||
let innerHeight = document.querySelector('#pdf-perView').clientHeight
|
||||
let outerHeight = document.documentElement.clientHeight
|
||||
let scrollTop = document.documentElement.scrollTop
|
||||
|
||||
|
||||
if(this.isscroll){
|
||||
this.showPages++;
|
||||
this.debounce(this.loadInitPdf(),5000);
|
||||
|
||||
|
||||
}
|
||||
// console.log(this.pdfpage,'000')
|
||||
// console.log(this.totalPages,this.pdfpage)
|
||||
@@ -168,8 +168,8 @@ export default {
|
||||
// document.querySelector('#articleAnking').style.cssText = "position: static";
|
||||
// }
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
debounce(func, wait) {// 非立即执行
|
||||
let timeout;
|
||||
return function () {
|
||||
@@ -229,6 +229,7 @@ export default {
|
||||
min-height: 300px;
|
||||
width: 100%;
|
||||
//border: 1px solid #dfdfdf;
|
||||
background-color: #e9e9e9;
|
||||
overflow-y: hidden;
|
||||
overflow-x: hidden;
|
||||
>span{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- <span>案例编号:{{ caseDetail.id }}</span> -->
|
||||
<span v-if="caseDetail.sysCreateTime">{{ caseDetail.sysCreateTime.substring(0,10) }}</span>
|
||||
<interactBar :data="caseDetail" :type="3" :comments="false" :shares="true"></interactBar>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="case-summary"><span>{{ caseDetail.summary }}</span></div>
|
||||
<div class="btn-div" >
|
||||
@@ -138,6 +138,8 @@ import apiUser from '@/api/system/user.js';
|
||||
import author from '@/components/Portal/authorInfo.vue';
|
||||
import apiMessage from '@/api/system/message.js';
|
||||
import apiDict from "@/api/modules/dict.js"
|
||||
import {encrypt} from '@/utils/jsencrypt.js';
|
||||
import cookies from 'vue-cookies'
|
||||
export default {
|
||||
name: 'atticle',
|
||||
components: { portalHeader, portalFooter, interactBar, author, comments,pdfPreview },
|
||||
@@ -168,7 +170,7 @@ export default {
|
||||
this.getCaseData();
|
||||
}
|
||||
this.getAnkingData();
|
||||
this.getPopularity();
|
||||
this.getPopularity();
|
||||
this.getPositive();
|
||||
window.addEventListener(
|
||||
"scroll",
|
||||
@@ -176,9 +178,20 @@ export default {
|
||||
);
|
||||
},
|
||||
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() {
|
||||
let innerHeight = document.querySelector('#case-list-content').clientHeight
|
||||
let outerHeight = document.documentElement.clientHeight
|
||||
@@ -226,11 +239,16 @@ export default {
|
||||
this.caseDetail = res.result;
|
||||
this.getCaseUserDetail();
|
||||
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{
|
||||
this.$message.error('内容文件不存在或已被删除,请与管理员联系');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -354,6 +372,7 @@ export default {
|
||||
.jianjie {
|
||||
margin: 15px 0;
|
||||
background-color: #fff;
|
||||
min-height: 300px;
|
||||
padding: 0px 0px 10px 0px;
|
||||
.content {
|
||||
padding: 10px 0;
|
||||
|
||||
Reference in New Issue
Block a user