Merge pull request 'zhuhao_dev' (#170) from zhuhao_dev into main
Reviewed-on: #170
This commit is contained in:
commit
fe41a63b2d
|
@ -1,5 +1,5 @@
|
||||||
# 页面标题
|
# 页面标题
|
||||||
VITE_APP_TITLE = AIx数字平台
|
VITE_APP_TITLE = AIx数字平台(测试版)
|
||||||
|
|
||||||
# 生产环境配置
|
# 生产环境配置
|
||||||
VITE_APP_ENV = 'production'
|
VITE_APP_ENV = 'production'
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
"electron-updater": "^6.1.7",
|
"electron-updater": "^6.1.7",
|
||||||
"element-plus": "^2.7.6",
|
"element-plus": "^2.7.6",
|
||||||
"fabric": "^5.3.0",
|
"fabric": "^5.3.0",
|
||||||
"im_electron_sdk": "^8.0.5904",
|
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"jsencrypt": "^3.3.2",
|
"jsencrypt": "^3.3.2",
|
||||||
"jsondiffpatch": "0.6.0",
|
"jsondiffpatch": "0.6.0",
|
||||||
|
"im_electron_sdk": "^8.0.5904",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pdfjs-dist": "4.4.168",
|
"pdfjs-dist": "4.4.168",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
|
|
|
@ -42,19 +42,23 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
||||||
let filePath = appRootFilePath + fileNewName
|
let filePath = appRootFilePath + fileNewName
|
||||||
let uploadId = null
|
let uploadId = null
|
||||||
let isOn = false
|
let isOn = false
|
||||||
|
let lastMTime = fs.statSync(filePath).mtime.getTime()
|
||||||
|
console.log(lastMTime)
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
getFileMD5(filePath).then((md5New) => {
|
getFileMsg(filePath).then((msg) => {
|
||||||
if (md5New !== md5) {
|
if (msg !== lastMTime) {
|
||||||
md5 = md5New
|
lastMTime = msg
|
||||||
if (uploadId) {
|
if (uploadId) {
|
||||||
clearTimeout(uploadId)
|
clearTimeout(uploadId)
|
||||||
}
|
}
|
||||||
if (isOn === false) {
|
if (isOn === false) {
|
||||||
|
console.log(fileNewName)
|
||||||
e.reply('listen-file-change-on' + fileNewName)
|
e.reply('listen-file-change-on' + fileNewName)
|
||||||
isOn = true
|
isOn = true
|
||||||
}
|
}
|
||||||
//倒数十秒提交更改,十秒之内有继续修改则重置倒数
|
//倒数十秒提交更改,十秒之内有继续修改则重置倒数
|
||||||
uploadId = setTimeout(() => {
|
uploadId = setTimeout(() => {
|
||||||
|
console.log(223)
|
||||||
//执行更新,上传文件
|
//执行更新,上传文件
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
formData.append('id', id)
|
formData.append('id', id)
|
||||||
|
@ -77,12 +81,19 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
||||||
console.error('Error uploading file:', err)
|
console.error('Error uploading file:', err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 20000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, 10000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function getFileMsg(path) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const stats = fs.statSync(path)
|
||||||
|
return resolve(stats.mtime.getTime())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function getFileMD5(path) {
|
function getFileMD5(path) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fs.readFile(path, (err, dataFile) => {
|
fs.readFile(path, (err, dataFile) => {
|
||||||
|
@ -121,13 +132,14 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
|
||||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: true, type: 'down' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
getFileMD5(filePath).then((localMd5) => {
|
getFileMsg(filePath).then((msg) => {
|
||||||
if (localMd5 === md5) {
|
let time = new Date(lastModifyTime).getTime();
|
||||||
|
msg = parseInt(msg/1000)*1000;
|
||||||
|
if (msg == time) {
|
||||||
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: false, type: '' })
|
e.reply('is-async-local-file-reply' + fileNewName, { isAsync: false, type: '' })
|
||||||
} else {
|
} else {
|
||||||
const stats = fs.statSync(filePath)
|
const stats = fs.statSync(filePath)
|
||||||
//如果线上时间大于线下时间,就需要从线上下载,否则则需要上传
|
//如果线上时间大于线下时间,就需要从线上下载,否则则需要上传
|
||||||
let time = new Date(lastModifyTime)
|
|
||||||
if (time > stats.mtime.getTime()) {
|
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 (time < stats.mtime.getTime()) {
|
} else if (time < stats.mtime.getTime()) {
|
||||||
|
|
|
@ -141,6 +141,11 @@ async function createLinkWin(data) {
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
.catch((error) => {})
|
.catch((error) => {})
|
||||||
data.fullPath = data.fullPath.replaceAll('//', '/')
|
data.fullPath = data.fullPath.replaceAll('//', '/')
|
||||||
|
if (data.fullPath.indexOf('?') !== -1) {
|
||||||
|
data.fullPath += '&urlSource=smarttalk'
|
||||||
|
}else {
|
||||||
|
data.fullPath += '?urlSource=smarttalk'
|
||||||
|
}
|
||||||
linkWin[data.key].loadURL(data.fullPath)
|
linkWin[data.key].loadURL(data.fullPath)
|
||||||
|
|
||||||
linkWin[data.key].once('ready-to-show', () => {
|
linkWin[data.key].once('ready-to-show', () => {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>AIx智慧教育</title>
|
<title>%VITE_APP_TITLE%</title>
|
||||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||||
<!-- <meta
|
<!-- <meta
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
|
|
|
@ -246,12 +246,12 @@ export default {
|
||||||
fileType: item.fileType
|
fileType: item.fileType
|
||||||
})
|
})
|
||||||
ipcRenderer.on('listen-file-change-on' + item.fileNewName, () => {
|
ipcRenderer.on('listen-file-change-on' + item.fileNewName, () => {
|
||||||
item.async = 'on'
|
items.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
|
items.fileSize = data.fileSize
|
||||||
item.md5 = md5
|
items.md5 = md5
|
||||||
item.async = true
|
items.async = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue