zhuhao_dev #104

Merged
zhuhao merged 6 commits from zhuhao_dev into main 2024-08-07 15:51:13 +08:00
2 changed files with 51 additions and 7 deletions
Showing only changes of commit 9f510187c0 - Show all commits

View File

@ -71,6 +71,8 @@ const curBookId = ref(-1)
const curBookName = ref('')
//
const curBookImg = ref('')
//
const curBookPath = ref('')
//
const volumeOne = ref([])
//
@ -126,10 +128,11 @@ const getSubjectContent = async () => {
}
//
const changeBook = ({ id, itemtitle, avartar }) => {
const changeBook = ({ id, itemtitle, avartar, fileurl }) => {
curBookId.value = id
curBookName.value = itemtitle
curBookImg.value = BaseUrl + avartar
curBookPath.value = fileurl
getTreeData()
setTimeout(() => {
dialogVisible.value = false
@ -176,7 +179,8 @@ const emitChangeBook = () => {
textBook: {
curBookId: curBookId.value,
curBookName: curBookName.value,
curBookImg: curBookImg.value
curBookImg: curBookImg.value,
curBookPath: curBookPath.value
},
node: curNode
}
@ -276,6 +280,7 @@ const getSubject = async () => {
curBookName.value = subjectList.value[0].itemtitle
curBookId.value = subjectList.value[0].id
curBookImg.value = BaseUrl + subjectList.value[0].avartar
curBookPath.value = subjectList.value[0].fileurl
}
@ -306,7 +311,8 @@ const handleNodeClick = (data, node) => {
textBook: {
curBookId: curBookId.value,
curBookName: curBookName.value,
curBookImg: curBookImg.value
curBookImg: curBookImg.value,
curBookPath: curBookPath.value
},
node: toRaw(nodeData)
}

View File

@ -66,6 +66,7 @@ import { Check } from '@element-plus/icons-vue'
import Reserv from '@/views/prepare/container/reserv.vue'
</script>
<script>
const Remote = require('@electron/remote')
import ChooseTextbook from '@/components/choose-textbook/index.vue'
import uploadDialog from '@/components/upload-dialog/index.vue'
import { Refresh } from '@element-plus/icons-vue'
@ -84,7 +85,7 @@ import outLink from '@/utils/linkConfig'
import { createWindow } from '@/utils/tool'
import { uniqBy, cloneDeep } from 'lodash'
import { delClasswork, addEntpcourse } from '@/api/teaching/classwork'
const fs = require('fs');
const { ipcRenderer } = window.electron || {}
export default {
@ -110,6 +111,7 @@ export default {
fileList: [],
currentNode: {},
currentFileList: [],
curBookPath: '',
lastAsyncAllTime: '',
uploadData: {
textbookId: null,
@ -160,6 +162,38 @@ export default {
}
},
methods: {
getBookPathFromServer() {
let fileName = this.curBookPath
if (!fileName) return
fileName = fileName.replace('.txt', '.pdf')
return new Promise((resolve, reject)=>{
const userDataPath = Remote.app.getPath('userData')
const appRootFilePath = userDataPath + '\\selfFile\\'
let filePath = appRootFilePath + fileName
fs.access(filePath, fs.constants.F_OK, (err) => {
let filePath = import.meta.env.VITE_APP_RES_FILE_PATH + fileName
if (err) {
//线
ipcRenderer.send('download-file-default', {
url: filePath,
fileName: fileName
})
ipcRenderer.once('download-file-default' + fileName, (e, isSuccess) => {
if (isSuccess === true) {
resolve(appRootFilePath + fileName)
}else {
ElMessage({
type: 'info',
message: `下载教材失败!`
})
}
})
}else {
resolve(appRootFilePath + fileName)
}
})
})
},
createFile() {
creatPPT(this.currentNode.label + '.pptx', this.uploadData).then((res) => {
this.currentFileList.unshift(res.resData)
@ -279,8 +313,10 @@ export default {
})
},
async nodeClick(data) {
console.log(data)
if (this.currentNode.id === data.node.id) return
this.curBookImg = data.textBook.curBookImg
this.curBookPath = data.textBook.curBookPath
this.checkFileList = []
let cata = parseCataByNode(data.node)
this.currentNode = data.node
@ -453,7 +489,9 @@ export default {
},
// PDF-
navtoPdf() {
async navtoPdf() {
let path = await this.getBookPathFromServer()
console.log(path)
createWindow('open-PDF', { url: '/classBegins/index' })
},
// -