读取本地pdf文件

This commit is contained in:
zhangxuelin 2024-08-08 16:50:21 +08:00
parent a8f9c828d7
commit e1e9f171e0
3 changed files with 5 additions and 4 deletions

View File

@ -274,6 +274,7 @@ const initPdfone = async () => {
} }
onMounted(async () => { onMounted(async () => {
try { try {
console.log(props.pdfObj.pdfUrl)
// canvas // canvas
const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise const pdf = await pdfjsLib.getDocument(props.pdfObj.pdfUrl).promise
numPagesTotal.value = pdf.numPages numPagesTotal.value = pdf.numPages

View File

@ -50,7 +50,8 @@ const isOnLoadShow = ref(false) //加载完毕显示
// //
const pdfObj = reactive({ const pdfObj = reactive({
numberOfPdf: 2, // numberOfPdf: 2, //
pdfUrl: getStaticUrl('aaa.pdf', 'user', 'selfFile', true), // pdfUrl: getStaticUrl('aaa.pdf', 'user', 'selfFile', true),//
pdfUrl: null,
allPageData:[], allPageData:[],
bookId:null, bookId:null,
numPages: 1 // numPages: 1 //
@ -107,8 +108,7 @@ const switchPageMode = () => {
} }
onMounted(async () => { onMounted(async () => {
toolState.isPdfWin=true toolState.isPdfWin=true
console.log(route.query.path,"c初始") pdfObj.pdfUrl = getStaticUrl(route.query.path, 'user', 'selfFile', true)
pdfObj.pdfUrl = route.query.path
textbookId.value = route.query.textbookId textbookId.value = route.query.textbookId
pdfObj.bookId=textbookId.value pdfObj.bookId=textbookId.value
getBookMarkById(textbookId.value).then(res=>{ getBookMarkById(textbookId.value).then(res=>{

View File

@ -538,7 +538,7 @@ export default {
const toolStore = useToolState() const toolStore = useToolState()
if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作') if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
let path = await this.getBookPathFromServer() let path = await this.getBookPathFromServer()
console.log(path) path=path.replace(/^.*[\\\/]/, '');
// console.log(this.uploadData.textbookId) // console.log(this.uploadData.textbookId)
createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId+'&path='+ path }) createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId+'&path='+ path })
}, },