二期:教材打开开发
This commit is contained in:
parent
3bcb0a2ef3
commit
9f510187c0
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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' })
|
||||
},
|
||||
// 上课-工具类悬浮
|
||||
|
|
Loading…
Reference in New Issue