二期:自动同步功能开发
This commit is contained in:
parent
4c635e9fe3
commit
4dc180a26f
|
@ -127,9 +127,10 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
||||||
} else {
|
} else {
|
||||||
const stats = fs.statSync(filePath)
|
const stats = fs.statSync(filePath)
|
||||||
//如果线上时间大于线下时间,就需要从线上下载,否则则需要上传
|
//如果线上时间大于线下时间,就需要从线上下载,否则则需要上传
|
||||||
if (lastModifyTime > stats.mtime.getTime()) {
|
let time = new Date(lastModifyTime)
|
||||||
|
if (time > stats.mtime.getTime()) {
|
||||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
||||||
} else if (lastModifyTime < stats.mtime.getTime()) {
|
} else if (time < stats.mtime.getTime()) {
|
||||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'upload' })
|
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'upload' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,6 +163,7 @@ export default {
|
||||||
//判断是否需要从线上拿新的文件
|
//判断是否需要从线上拿新的文件
|
||||||
isAsyncLocalFile(item.fileNewName, item.lastModifyTime, item.fileMd5).then(
|
isAsyncLocalFile(item.fileNewName, item.lastModifyTime, item.fileMd5).then(
|
||||||
({ isAsync, type }) => {
|
({ isAsync, type }) => {
|
||||||
|
console.log(isAsync, type)
|
||||||
item.async = !isAsync
|
item.async = !isAsync
|
||||||
if (isAsync === true) {
|
if (isAsync === true) {
|
||||||
item.async = 'on'
|
item.async = 'on'
|
||||||
|
@ -177,9 +178,12 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (type === 'upload') {
|
if (type === 'upload') {
|
||||||
|
let cookie = localStorage.getItem('Admin-Token')
|
||||||
ipcRenderer.send('upload-file-change', {
|
ipcRenderer.send('upload-file-change', {
|
||||||
url: item.fileFullPath,
|
id: item.id,
|
||||||
fileName: item.fileNewName
|
fileNewName: item.fileNewName,
|
||||||
|
cookie,
|
||||||
|
fileType: item.fileType
|
||||||
})
|
})
|
||||||
ipcRenderer.once(
|
ipcRenderer.once(
|
||||||
'upload-file-change-success' + item.fileNewName,
|
'upload-file-change-success' + item.fileNewName,
|
||||||
|
|
Loading…
Reference in New Issue