Compare commits
3 Commits
af941a22b7
...
a25be335e6
Author | SHA1 | Date |
---|---|---|
朱浩 | a25be335e6 | |
朱浩 | 62248dfafa | |
朱浩 | 2926b4bd63 |
|
@ -9,6 +9,13 @@ 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,
|
||||||
|
|
|
@ -1,5 +1,49 @@
|
||||||
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)
|
||||||
|
|
|
@ -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 { isHaveLocalFile } from '@/utils/talkFile'
|
import { asyncLocalFile } 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 } from '@/api/file'
|
import { deleteSmarttalk, updateSmarttalk, getPrepareById } from '@/api/file'
|
||||||
|
|
||||||
const { ipcRenderer } = window.electron || {}
|
const { ipcRenderer } = window.electron || {}
|
||||||
export default {
|
export default {
|
||||||
|
@ -182,9 +182,10 @@ export default {
|
||||||
return temp + 'GB'
|
return temp + 'GB'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openFileWin(item) {
|
openFileWin(items) {
|
||||||
isHaveLocalFile(item.fileNewName).then((res) => {
|
getPrepareById(items.id).then((item) => {
|
||||||
if (res === true) {
|
Object.assign(items, item)
|
||||||
|
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)
|
||||||
|
@ -199,22 +200,13 @@ export default {
|
||||||
ipcRenderer.on('listen-file-change-on' + item.fileNewName, () => {
|
ipcRenderer.on('listen-file-change-on' + item.fileNewName, () => {
|
||||||
item.async = 'on'
|
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.fileSize = data.fileSize
|
||||||
item.md5 = md5
|
item.md5 = md5
|
||||||
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
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 { isHaveLocalFile, parseCataByNode, creatPPT, isAsyncLocalFile } from '@/utils/talkFile'
|
import { parseCataByNode, creatPPT, asyncLocalFile } 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,15 +121,6 @@ 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() {
|
||||||
|
@ -159,59 +150,6 @@ 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)
|
||||||
|
@ -277,6 +215,30 @@ 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
|
||||||
|
@ -287,26 +249,7 @@ 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.isLoading = true
|
this.asyncAllFile()
|
||||||
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(){
|
||||||
|
|
Loading…
Reference in New Issue