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

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

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' })
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()) {

View File

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