|
|
@ -17,6 +17,8 @@ ipcMain.on('new-task-notification', (event) => { |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let isUpdate = false; |
|
|
|
ipcMain.on('put-in-tray', (event) => { |
|
|
|
if (!tray) { |
|
|
|
tray = new Tray(path.join(__dirname, '../windows-icon.png')) |
|
|
@ -180,22 +182,54 @@ ipcMain.on('put-in-tray', (event) => { |
|
|
|
}, { |
|
|
|
label: "检查更新", |
|
|
|
click: function () { |
|
|
|
if (isUpdate) { |
|
|
|
dialog.showErrorBox(`正在更新`, "请稍后重试"); |
|
|
|
return |
|
|
|
} |
|
|
|
isUpdate = true; |
|
|
|
|
|
|
|
let git_url = "https://git.ouxuan.net/3136352472/ouxuan.oa.git"; |
|
|
|
|
|
|
|
let workingDirPath = path.join(__dirname, "../"); |
|
|
|
const simpleGit = require('simple-git')(workingDirPath); |
|
|
|
simpleGit.checkIsRepo(function (err, ok) { |
|
|
|
if (ok) { |
|
|
|
simpleGit.pull(function (r, d) { |
|
|
|
if (d.files.length > 0) { |
|
|
|
app.quit() |
|
|
|
app.relaunch(); |
|
|
|
} |
|
|
|
let workingDirPath = path.join(__dirname, "../../ouxuan.oa/"); |
|
|
|
let appDir = path.join(__dirname, "../../app/"); |
|
|
|
if (!fs.existsSync(workingDirPath)) { |
|
|
|
fs.mkdirSync(workingDirPath) |
|
|
|
const simpleGit = require('simple-git')(workingDirPath); |
|
|
|
simpleGit.clone(git_url, workingDirPath, function (e) { |
|
|
|
console.log(e) |
|
|
|
|
|
|
|
require('sync-copydir')("resources/ouxuan.oa/", "resources/app/") |
|
|
|
isUpdate = false; |
|
|
|
|
|
|
|
dialog.showMessageBoxSync({ |
|
|
|
"message": "更新完成" |
|
|
|
}) |
|
|
|
} else { |
|
|
|
dialog.showErrorBox(`更新时发生错误`, workingDirPath, err); |
|
|
|
} |
|
|
|
}); |
|
|
|
app.quit() |
|
|
|
app.relaunch(); |
|
|
|
}) |
|
|
|
} else { |
|
|
|
const simpleGit = require('simple-git')(workingDirPath); |
|
|
|
simpleGit.checkIsRepo(function (err, ok) { |
|
|
|
if (ok) { |
|
|
|
simpleGit.pull(function (r, d) { |
|
|
|
if (d.files.length > 0) { |
|
|
|
require('sync-copydir')("resources/ouxuan.oa/", "resources/app/") |
|
|
|
dialog.showMessageBoxSync({ |
|
|
|
"message": "更新完成" |
|
|
|
}) |
|
|
|
isUpdate = false; |
|
|
|
|
|
|
|
app.quit() |
|
|
|
app.relaunch(); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
isUpdate = false; |
|
|
|
|
|
|
|
dialog.showErrorBox(`更新时发生错误`, workingDirPath + err); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, { |
|
|
|
label: "退出", |
|
|
|