Compare commits
No commits in common. "a618032d25fc648d117a8582fb12e3340fc9f19d" and "ac5cafe1e8d373f0cf60424b1236158ef1a10266" have entirely different histories.
a618032d25
...
ac5cafe1e8
|
@ -9,13 +9,6 @@ export const getSmarttalkPage = (params) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const getPrepareById = (id) => {
|
||||
return request({
|
||||
url: '/smarttalk/file/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteSmarttalk(id) {
|
||||
return request({
|
||||
url: '/smarttalk/file/' + id,
|
||||
|
|
|
@ -1,49 +1,5 @@
|
|||
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) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.send('is-have-local-file', fileNewName)
|
||||
|
|
|
@ -100,10 +100,10 @@ import { Check, UploadFilled, Switch } from '@element-plus/icons-vue'
|
|||
</script>
|
||||
<script>
|
||||
import FileImage from '@/components/file-image/index.vue'
|
||||
import { asyncLocalFile } from '@/utils/talkFile'
|
||||
import { isHaveLocalFile } from '@/utils/talkFile'
|
||||
import { toTimeText } from '@/utils/date'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file'
|
||||
import { deleteSmarttalk, updateSmarttalk } from '@/api/file'
|
||||
|
||||
const { ipcRenderer } = window.electron || {}
|
||||
export default {
|
||||
|
@ -182,10 +182,9 @@ export default {
|
|||
return temp + 'GB'
|
||||
}
|
||||
},
|
||||
openFileWin(items) {
|
||||
getPrepareById(items.id).then((item) => {
|
||||
Object.assign(items, item)
|
||||
asyncLocalFile(items).then(() => {
|
||||
openFileWin(item) {
|
||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
||||
if (res === true) {
|
||||
ipcRenderer.send('open-path-app', item.fileNewName)
|
||||
if (this.listenList.indexOf(item.fileNewName) === -1) {
|
||||
this.listenList.push(item.fileNewName)
|
||||
|
@ -200,13 +199,22 @@ export default {
|
|||
ipcRenderer.on('listen-file-change-on' + item.fileNewName, () => {
|
||||
item.async = 'on'
|
||||
})
|
||||
ipcRenderer.on('listen-file-change-success' + item.fileNewName, (e, { data, md5 }) => {
|
||||
ipcRenderer.on('listen-file-change-success' + item.fileNewName, (e,{data,md5}) => {
|
||||
item.fileSize = data.fileSize
|
||||
item.md5 = md5
|
||||
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
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ import FileListItem from '@/views/prepare/container/file-list-item.vue'
|
|||
import { getSmarttalkPage, moveSmarttalk } from '@/api/file'
|
||||
import { toTimeText } from '@/utils/date'
|
||||
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 useUserStore from '@/store/modules/user'
|
||||
import { homeWorkConfig } from '@/utils/config'
|
||||
|
@ -121,6 +121,15 @@ export default {
|
|||
this.userStore = useUserStore()
|
||||
},
|
||||
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: {
|
||||
createFile() {
|
||||
|
@ -150,6 +159,59 @@ export default {
|
|||
clickChoose(value) {
|
||||
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) {
|
||||
let index = this.currentFileList.indexOf(item)
|
||||
this.currentFileList.splice(index, 1)
|
||||
|
@ -215,30 +277,6 @@ export default {
|
|||
}
|
||||
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) {
|
||||
if (this.currentNode.id === data.node.id) return
|
||||
this.curBookImg = data.textBook.curBookImg
|
||||
|
@ -249,7 +287,26 @@ export default {
|
|||
this.uploadData.levelSecondId = cata[1]
|
||||
this.uploadData.levelThirdId = cata[2]
|
||||
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(){
|
||||
|
|
Loading…
Reference in New Issue