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);
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

View File

@ -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应用是否存在