diff --git a/.env.test b/.env.test index 993cace..3d671e1 100644 --- a/.env.test +++ b/.env.test @@ -1,5 +1,5 @@ # 页面标题 -VITE_APP_TITLE = AIx数字平台 +VITE_APP_TITLE = AIx数字平台(测试版) # 生产环境配置 VITE_APP_ENV = 'production' diff --git a/package.json b/package.json index 68b1853..f070ac6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main/file.js b/src/main/file.js index 348c703..ddabb2c 100644 --- a/src/main/file.js +++ b/src/main/file.js @@ -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()) { diff --git a/src/main/index.js b/src/main/index.js index 30ef34e..e4559b2 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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', () => { diff --git a/src/renderer/index.html b/src/renderer/index.html index 8ee7d0b..1de810c 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -2,7 +2,7 @@ - AIx智慧教育 + %VITE_APP_TITLE%