From da066e40cea0fe19e4fa16ce21f503c05b466852 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 14 Nov 2024 14:05:19 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/build.js | 66 ++++++++++++++++++++++++++------------------ electron/electron.js | 7 ++++- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/electron/build.js b/electron/build.js index 7d10bedd6..f7f5fd13e 100644 --- a/electron/build.js +++ b/electron/build.js @@ -142,6 +142,7 @@ async function detectAndDownloadUpdater() { const writer = fs.createWriteStream(outputPath); readStream.pipe(writer); writer.on('finish', () => { + fs.chmodSync(outputPath, 0o755); zipfile.readEntry(); }); }); @@ -650,34 +651,48 @@ if (["dev"].includes(argv[2])) { // 手编译(默认) const questions = [ { - type: 'list', + type: 'checkbox', name: 'platform', message: "选择编译系统", - choices: [{ - name: "MacOS", - value: platforms[0] - }, { - name: "Windows", - value: platforms[1] - }, { - name: "全平台", - value: platforms - }] + choices: [ + { + name: "MacOS", + value: platforms[0], + checked: true + }, + { + name: "Windows", + value: platforms[1] + } + ], + validate: function(answer) { + if (answer.length < 1) { + return '请至少选择一个系统'; + } + return true; + } }, { - type: 'list', + type: 'checkbox', name: 'arch', message: "选择系统架构", - choices: [{ - name: "arm64", - value: architectures[0] - }, { - name: "x64", - value: architectures[1] - }, { - name: "全架构", - value: architectures - }] + choices: [ + { + name: "arm64", + value: architectures[0], + checked: true + }, + { + name: "x64", + value: architectures[1] + } + ], + validate: function(answer) { + if (answer.length < 1) { + return '请至少选择一个架构'; + } + return true; + } }, { type: 'list', @@ -747,14 +762,11 @@ if (["dev"].includes(argv[2])) { } // 开始构建 - const platformList = utils.isArray(answers.platform) ? answers.platform : [answers.platform]; - const archList = utils.isArray(answers.arch) ? answers.arch : [answers.arch]; - - for (const platform of platformList) { + for (const platform of answers.platform) { for (const data of config.app) { data.configure = { platform, - archs: archList, + archs: answers.arch, publish: answers.publish, release: answers.release, notarize: answers.notarize diff --git a/electron/electron.js b/electron/electron.js index e140f7379..9785026c1 100644 --- a/electron/electron.js +++ b/electron/electron.js @@ -212,8 +212,13 @@ function createUpdaterWindow(loadingTip) { } catch (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); + } } - return; } // 检查updater应用是否存在