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