perf: 优化客户端升级

This commit is contained in:
kuaifan 2024-11-14 14:05:19 +08:00
parent a219b7b6ee
commit da066e40ce
2 changed files with 45 additions and 28 deletions

66
electron/build.js vendored
View File

@ -142,6 +142,7 @@ async function detectAndDownloadUpdater() {
const writer = fs.createWriteStream(outputPath); const writer = fs.createWriteStream(outputPath);
readStream.pipe(writer); readStream.pipe(writer);
writer.on('finish', () => { writer.on('finish', () => {
fs.chmodSync(outputPath, 0o755);
zipfile.readEntry(); zipfile.readEntry();
}); });
}); });
@ -650,34 +651,48 @@ if (["dev"].includes(argv[2])) {
// 手编译(默认) // 手编译(默认)
const questions = [ const questions = [
{ {
type: 'list', type: 'checkbox',
name: 'platform', name: 'platform',
message: "选择编译系统", message: "选择编译系统",
choices: [{ choices: [
name: "MacOS", {
value: platforms[0] name: "MacOS",
}, { value: platforms[0],
name: "Windows", checked: true
value: platforms[1] },
}, { {
name: "全平台", name: "Windows",
value: platforms value: platforms[1]
}] }
],
validate: function(answer) {
if (answer.length < 1) {
return '请至少选择一个系统';
}
return true;
}
}, },
{ {
type: 'list', type: 'checkbox',
name: 'arch', name: 'arch',
message: "选择系统架构", message: "选择系统架构",
choices: [{ choices: [
name: "arm64", {
value: architectures[0] name: "arm64",
}, { value: architectures[0],
name: "x64", checked: true
value: architectures[1] },
}, { {
name: "全架构", name: "x64",
value: architectures value: architectures[1]
}] }
],
validate: function(answer) {
if (answer.length < 1) {
return '请至少选择一个架构';
}
return true;
}
}, },
{ {
type: 'list', type: 'list',
@ -747,14 +762,11 @@ if (["dev"].includes(argv[2])) {
} }
// 开始构建 // 开始构建
const platformList = utils.isArray(answers.platform) ? answers.platform : [answers.platform]; for (const platform of answers.platform) {
const archList = utils.isArray(answers.arch) ? answers.arch : [answers.arch];
for (const platform of platformList) {
for (const data of config.app) { for (const data of config.app) {
data.configure = { data.configure = {
platform, platform,
archs: archList, archs: answers.arch,
publish: answers.publish, publish: answers.publish,
release: answers.release, release: answers.release,
notarize: answers.notarize notarize: answers.notarize

View File

@ -212,8 +212,13 @@ function createUpdaterWindow(loadingTip) {
} 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);
}
} }
return;
} }
// 检查updater应用是否存在 // 检查updater应用是否存在