二期:修改自动同步检测逻辑

This commit is contained in:
朱浩 2024-08-16 18:10:20 +08:00
parent 6dfb2d4a8a
commit 0ff0cd42bc
3 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "aix-win", "name": "aix-win",
"version": "1.1.1", "version": "1.1.2",
"description": "An Electron application with Vue", "description": "An Electron application with Vue",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "example.com", "author": "example.com",
@ -33,7 +33,6 @@
"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",

View File

@ -132,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()) {

View File

@ -12,7 +12,7 @@ export function shareStorePlugin({store}) {
// console.log('store.$subscribe', mutation) // console.log('store.$subscribe', mutation)
// 在存储变化的时候执行 // 在存储变化的时候执行
// const storeName = store.$id // const storeName = store.$id
// const storeName = mutation.storeId const storeName = mutation.storeId
// 用于多窗口共享(需要共享的状态名称) // 用于多窗口共享(需要共享的状态名称)
const names = ['tool'] const names = ['tool']
if (names.includes(storeName)) { if (names.includes(storeName)) {
@ -37,7 +37,9 @@ export function shareStorePlugin({store}) {
function stateSync(storeName, key, value) { function stateSync(storeName, key, value) {
// console.log('state-change', storeName, key, value) // console.log('state-change', storeName, key, value)
let jsonStr = '' let jsonStr = ''
if (typeof key === 'string') jsonStr = JSON.stringify({[key]:value}) let obj = {[key]:value}
window.test = obj
if (typeof key === 'string') jsonStr = JSON.stringify(obj)
else if (typeof value === 'object') jsonStr = JSON.stringify(key) else if (typeof value === 'object') jsonStr = JSON.stringify(key)
// 通知主线程更新 // 通知主线程更新
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr) ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)