Compare commits

..

No commits in common. "a618032d25fc648d117a8582fb12e3340fc9f19d" and "ac5cafe1e8d373f0cf60424b1236158ef1a10266" have entirely different histories.

4 changed files with 99 additions and 85 deletions

View File

@ -9,13 +9,6 @@ export const getSmarttalkPage = (params) => {
}) })
} }
export const getPrepareById = (id) => {
return request({
url: '/smarttalk/file/' + id,
method: 'get'
})
}
export function deleteSmarttalk(id) { export function deleteSmarttalk(id) {
return request({ return request({
url: '/smarttalk/file/' + id, url: '/smarttalk/file/' + id,

View File

@ -1,49 +1,5 @@
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
export const asyncLocalFile = (item) => {
return new Promise((resolve) => {
//判断是否需要从线上拿新的文件
isAsyncLocalFile(item.fileNewName, item.lastModifyTime, item.fileMd5).then(
({ isAsync, type }) => {
item.async = !isAsync
if (isAsync === true) {
item.async = 'on'
if (type === 'down') {
ipcRenderer.send('download-file-default', {
url: item.fileFullPath,
fileName: item.fileNewName
})
ipcRenderer.once('download-file-default' + item.fileNewName, (e, isSuccess) => {
item.async = isSuccess
resolve()
})
}
if (type === 'upload') {
let cookie = localStorage.getItem('Admin-Token')
ipcRenderer.send('upload-file-change', {
id: item.id,
fileNewName: item.fileNewName,
cookie,
fileType: item.fileType
})
ipcRenderer.once(
'upload-file-change-success' + item.fileNewName,
(e, { data, md5 }) => {
item.fileSize = data.fileSize
item.md5 = md5
item.async = true
resolve()
}
)
}
} else {
resolve()
}
}
)
})
}
export const isHaveLocalFile = async (fileNewName) => { export const isHaveLocalFile = async (fileNewName) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
ipcRenderer.send('is-have-local-file', fileNewName) ipcRenderer.send('is-have-local-file', fileNewName)

View File

@ -100,10 +100,10 @@ import { Check, UploadFilled, Switch } from '@element-plus/icons-vue'
</script> </script>
<script> <script>
import FileImage from '@/components/file-image/index.vue' import FileImage from '@/components/file-image/index.vue'
import { asyncLocalFile } from '@/utils/talkFile' import { isHaveLocalFile } from '@/utils/talkFile'
import { toTimeText } from '@/utils/date' import { toTimeText } from '@/utils/date'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file' import { deleteSmarttalk, updateSmarttalk } from '@/api/file'
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
export default { export default {
@ -182,10 +182,9 @@ export default {
return temp + 'GB' return temp + 'GB'
} }
}, },
openFileWin(items) { openFileWin(item) {
getPrepareById(items.id).then((item) => { isHaveLocalFile(item.fileNewName).then((res) => {
Object.assign(items, item) if (res === true) {
asyncLocalFile(items).then(() => {
ipcRenderer.send('open-path-app', item.fileNewName) ipcRenderer.send('open-path-app', item.fileNewName)
if (this.listenList.indexOf(item.fileNewName) === -1) { if (this.listenList.indexOf(item.fileNewName) === -1) {
this.listenList.push(item.fileNewName) this.listenList.push(item.fileNewName)
@ -206,7 +205,16 @@ export default {
item.async = true item.async = true
}) })
} }
} else {
item.async = 'on'
ipcRenderer.once('download-file-default' + item.fileNewName, (e, isSuccess) => {
item.async = isSuccess
}) })
ipcRenderer.send('download-file-default', {
url: item.fileFullPath,
fileName: item.fileNewName
})
}
}) })
} }
} }

View File

@ -71,7 +71,7 @@ import FileListItem from '@/views/prepare/container/file-list-item.vue'
import { getSmarttalkPage, moveSmarttalk } from '@/api/file' import { getSmarttalkPage, moveSmarttalk } from '@/api/file'
import { toTimeText } from '@/utils/date' import { toTimeText } from '@/utils/date'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { parseCataByNode, creatPPT, asyncLocalFile } from '@/utils/talkFile' import { isHaveLocalFile, parseCataByNode, creatPPT, isAsyncLocalFile } from '@/utils/talkFile'
import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue' import FileOperBatch from '@/views/prepare/container/file-oper-batch.vue'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { homeWorkConfig } from '@/utils/config' import { homeWorkConfig } from '@/utils/config'
@ -121,6 +121,15 @@ export default {
this.userStore = useUserStore() this.userStore = useUserStore()
}, },
mounted() { mounted() {
// const destination = '0901(A)-PPT.pptx'
// ipcRenderer.send('open-path-app',this.filePath)
// const source = 'D:\\edufile\\0901(A)-PPT.pptx'
// ipcRenderer.send('copy-file-default',{ source, destination })
// ipcRenderer.send('download-file-default',this.fileUrl)
// getSmarttalkPage({nowPage:1,pageSize:2}).then(res=>{
// console.log(res)
// })
// let filePath = window.rootTalkFilePath + item.fileNewName
}, },
methods: { methods: {
createFile() { createFile() {
@ -150,6 +159,59 @@ export default {
clickChoose(value) { clickChoose(value) {
this.checkFileList = value ? this.currentFileList : [] this.checkFileList = value ? this.currentFileList : []
}, },
async asyncAllFile() {
this.lastAsyncAllTime = new Date()
localStorage.setItem('lastAsyncAllTime', this.lastAsyncAllTime)
this.asyncAllFileVisiable = true
const test = (item) => {
return new Promise((resolve) => {
//线
isAsyncLocalFile(item.fileNewName, item.lastModifyTime, item.fileMd5).then(
({ isAsync, type }) => {
console.log(isAsync, type)
item.async = !isAsync
if (isAsync === true) {
item.async = 'on'
if (type === 'down') {
ipcRenderer.send('download-file-default', {
url: item.fileFullPath,
fileName: item.fileNewName
})
ipcRenderer.once('download-file-default' + item.fileNewName, (e, isSuccess) => {
item.async = isSuccess
resolve()
})
}
if (type === 'upload') {
let cookie = localStorage.getItem('Admin-Token')
ipcRenderer.send('upload-file-change', {
id: item.id,
fileNewName: item.fileNewName,
cookie,
fileType: item.fileType
})
ipcRenderer.once(
'upload-file-change-success' + item.fileNewName,
(e, { data, md5 }) => {
item.fileSize = data.fileSize
item.md5 = md5
item.async = true
resolve()
}
)
}
} else {
resolve()
}
}
)
})
}
for (let i = 0; i < this.currentFileList.length; i++) {
await test(this.currentFileList[i])
}
this.asyncAllFileVisiable = false
},
deleteTalk(item) { deleteTalk(item) {
let index = this.currentFileList.indexOf(item) let index = this.currentFileList.indexOf(item)
this.currentFileList.splice(index, 1) this.currentFileList.splice(index, 1)
@ -215,30 +277,6 @@ export default {
} }
console.log('File copied to:', filePath) console.log('File copied to:', filePath)
}, },
asyncAllFile() {
this.isLoading = true
getSmarttalkPage({
...this.uploadData,
orderByColumn: 'uploadTime',
isAsc: 'desc',
pageSize: 500
})
.then(async (res) => {
this.currentFileList = [...res.rows]
this.isLoading = false
this.lastAsyncAllTime = new Date()
localStorage.setItem('lastAsyncAllTime', this.lastAsyncAllTime)
this.asyncAllFileVisiable = true
for (let i = 0; i < this.currentFileList.length; i++) {
let item = this.currentFileList[i]
await asyncLocalFile(item)
}
this.asyncAllFileVisiable = false
})
.catch(() => {
this.isLoading = false
})
},
nodeClick(data) { nodeClick(data) {
if (this.currentNode.id === data.node.id) return if (this.currentNode.id === data.node.id) return
this.curBookImg = data.textBook.curBookImg this.curBookImg = data.textBook.curBookImg
@ -249,7 +287,26 @@ export default {
this.uploadData.levelSecondId = cata[1] this.uploadData.levelSecondId = cata[1]
this.uploadData.levelThirdId = cata[2] this.uploadData.levelThirdId = cata[2]
this.uploadData.textbookId = data.textBook.curBookId this.uploadData.textbookId = data.textBook.curBookId
this.asyncAllFile() this.isLoading = true
getSmarttalkPage({
...this.uploadData,
orderByColumn: 'uploadTime',
isAsc: 'desc',
pageSize: 500
})
.then((res) => {
this.currentFileList = [...res.rows]
this.isLoading = false
this.currentFileList.filter((item) => {
isHaveLocalFile(item.fileNewName).then((res) => {
item.async = res
})
})
})
.catch((res) => {
console.log(res)
this.isLoading = false
})
}, },
// //
handleHomeWork(){ handleHomeWork(){