This commit is contained in:
zdg 2024-08-20 14:21:29 +08:00
commit a80a3b006c
4 changed files with 72 additions and 18 deletions

View File

@ -100,12 +100,17 @@ const renderPage = async (canvasobj) => {
}) })
} }
// //
const savaDataStore = () => { const savaDataStore = (type) => {
if(!toolState.isToolWin){ if(!toolState.isToolWin){
toolState.isPdfWin=false toolState.isPdfWin=false
toolState.showBoardAll=true // toolState.showBoardAll=true //
if(type=='rest'){
ipcRenderer.invoke('tool-sphere:reset') //tool ipcRenderer.invoke('tool-sphere:reset') //tool
ipcRenderer.send('open-PDF:minimize') ipcRenderer.send('open-PDF:close')
}else{
ipcRenderer.invoke('open-PDF:minimize')
}
return return
} }
imgarr.value.forEach((a) => { imgarr.value.forEach((a) => {
@ -139,8 +144,15 @@ const savaDataStore = () => {
Promise.all(promises).then(res=>{ Promise.all(promises).then(res=>{
toolState.isPdfWin=false toolState.isPdfWin=false
toolState.showBoardAll=true // toolState.showBoardAll=true //
// ipcRenderer.send('open-PDF:minimize')
if(type=='rest'){
ipcRenderer.invoke('tool-sphere:reset') //tool ipcRenderer.invoke('tool-sphere:reset') //tool
ipcRenderer.send('open-PDF:close')
}else{
ipcRenderer.send('open-PDF:minimize') ipcRenderer.send('open-PDF:minimize')
}
// ipcRenderer.send('open-PDF:close')
}) })
} }
const updatePage = (canvasobj) => { const updatePage = (canvasobj) => {

View File

@ -115,6 +115,16 @@ export const createWindow = async (type, data) => {
return wins_tool return wins_tool
} }
case 'open-PDF': { //课本展示-pdf case 'open-PDF': { //课本展示-pdf
if(winPdf){ //判断是否已经打开
if (winPdf.isMinimized()){
winPdf.restore();
} else{
winPdf.focus();
toolState.isPdfWin=true
}
return
}
const option = data.option||{} const option = data.option||{}
const defOption = { const defOption = {
frame: false, // 要创建无边框窗口 frame: false, // 要创建无边框窗口
@ -123,12 +133,6 @@ export const createWindow = async (type, data) => {
} }
data.isConsole = true // 是否开启控制台 data.isConsole = true // 是否开启控制台
data.option = {...defOption, ...option} data.option = {...defOption, ...option}
if(winPdf){ //判断是否已经打开
// if (winPdf.isMinimized()) winPdf.restore();
winPdf.focus();
// toolState.isPdfWin=true
return
}
const win = await toolWindow(data) const win = await toolWindow(data)
win.type = type // 唯一标识 win.type = type // 唯一标识
win.show() win.show()
@ -239,12 +243,22 @@ const eventHandles = (type, win) => {
break} break}
case 'open-PDF': { case 'open-PDF': {
// 最小化窗口 minimize() // 最小化窗口 minimize()
Remote.ipcMain.once('open-PDF:minimize', () => { Remote.ipcMain.handle('open-PDF:minimize', () => {
// winPdf=null
// win&&win.destroy()
win&&win.minimize(); //缩小功能
})
// 关闭窗口
Remote.ipcMain.once('open-PDF:close', () => {
winPdf=null winPdf=null
win&&win.destroy() win&&win.destroy()
// win&&win.minimize(); //缩小功能
}) })
publicMethods() // 加载公共方法 const on = {
onClosed: () => {
Remote.ipcMain.removeHandler('open-PDF:minimize')
}
}
publicMethods(on) // 加载公共方法
break} break}
default: default:
break break

View File

@ -26,7 +26,10 @@
<i class="iconfont icon-xiayiye"></i> <i class="iconfont icon-xiayiye"></i>
<span class="texts">下一页</span> <span class="texts">下一页</span>
</el-button> </el-button>
</div>
<div class="pdf-btn-right">
<el-button @click="minimize" >最小化</el-button> <el-button @click="minimize" >最小化</el-button>
<el-button @click="minimize('rest')" >关闭</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -72,9 +75,10 @@ const navtopage = (type) => {
pdfCanvaslist.value.initPdf('rest') pdfCanvaslist.value.initPdf('rest')
} }
// //
const minimize = async () => { const minimize = async (type='minimize') => {
await pdfCanvaslist.value.savaDataStore() await pdfCanvaslist.value.savaDataStore(type)
} }
const handleUpdate = (data) => { const handleUpdate = (data) => {
numPagesTotal.value = data numPagesTotal.value = data
if (numPagesTotal.value == 1) { if (numPagesTotal.value == 1) {
@ -138,7 +142,8 @@ const getUniqueArrayByLastOccurrence=(array)=> {
flex-wrap: wrap; flex-wrap: wrap;
.pdf-btn { .pdf-btn {
position: absolute; position: absolute;
right: 0; // right: 0;
left: 0;
bottom: 0; bottom: 0;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5); box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
border-radius: 5px 0 0 0; border-radius: 5px 0 0 0;
@ -163,5 +168,28 @@ const getUniqueArrayByLastOccurrence=(array)=> {
} }
} }
} }
.pdf-btn-right{
position: absolute;
right: 0;
bottom: 0;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
border-radius: 5px 0 0 0;
button {
margin-left: 0;
border: none;
font-size: 16px;
// padding: 4px 7px;
border-radius: 0;
width: 80px;
height: 70px;
:deep(> span) {
display: block !important;
}
.iconfont {
font-size: 26px;
margin-bottom: 10px;
}
}
}
} }
</style> </style>

View File

@ -493,7 +493,7 @@ export default {
// PDF- // PDF-
async navtoPdf() { async navtoPdf() {
if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作') // if (toolStore.isPdfWin) return this.$message.error('')
let path = await this.getBookPathFromServer() let path = await this.getBookPathFromServer()
createWindow('open-PDF', { createWindow('open-PDF', {
url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path