mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
perf: 优化客户端升级
This commit is contained in:
parent
fbb74e09e8
commit
a09f2038ee
27
electron/electron.js
vendored
27
electron/electron.js
vendored
@ -202,30 +202,30 @@ function createUpdaterWindow(loadingTip) {
|
|||||||
updaterPath = path.join(process.resourcesPath, 'updater', 'updater');
|
updaterPath = path.join(process.resourcesPath, 'updater', 'updater');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查updater应用是否存在
|
||||||
|
if (!fs.existsSync(updaterPath)) {
|
||||||
|
console.log('Updater not found:', updaterPath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查文件权限
|
// 检查文件权限
|
||||||
try {
|
try {
|
||||||
fs.accessSync(updaterPath, fs.constants.X_OK);
|
fs.accessSync(updaterPath, fs.constants.X_OK);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (process.platform === 'darwin') {
|
if (isWin) {
|
||||||
|
try {
|
||||||
|
spawn('icacls', [updaterPath, '/grant', 'everyone:F'], { stdio: 'inherit', shell: true });
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Failed to set executable permission:', e);
|
||||||
|
}
|
||||||
|
} else if (process.platform === 'darwin') {
|
||||||
try {
|
try {
|
||||||
spawn('chmod', ['+x', updaterPath], {stdio: 'inherit'});
|
spawn('chmod', ['+x', updaterPath], {stdio: 'inherit'});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Failed to set executable permission:', e);
|
console.log('Failed to set executable permission:', e);
|
||||||
}
|
}
|
||||||
} else if (process.platform === 'win32') {
|
|
||||||
try {
|
|
||||||
spawn('icacls', [updaterPath, '/set', 'everyone:F'], {stdio: 'inherit'});
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Failed to set executable permission:', e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 检查updater应用是否存在
|
|
||||||
if (!fs.existsSync(updaterPath)) {
|
|
||||||
console.log('Updater not found:', updaterPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建锁文件
|
// 创建锁文件
|
||||||
fs.writeFileSync(updaterLockFile, loadingTip || '');
|
fs.writeFileSync(updaterLockFile, loadingTip || '');
|
||||||
@ -234,6 +234,7 @@ function createUpdaterWindow(loadingTip) {
|
|||||||
const child = spawn(updaterPath, [updaterLockFile], {
|
const child = spawn(updaterPath, [updaterLockFile], {
|
||||||
detached: true,
|
detached: true,
|
||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
|
shell: isWin,
|
||||||
env: {
|
env: {
|
||||||
...process.env,
|
...process.env,
|
||||||
ELECTRON_RUN_AS_NODE: '1',
|
ELECTRON_RUN_AS_NODE: '1',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user