electron-smallest-updater 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -26
- package/dist/builder.js +3 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -72,31 +72,34 @@ import { SmallestUpdater } from 'electron-smallest-updater'
|
|
|
72
72
|
|
|
73
73
|
export function initSmallestUpdater(mainWindow: BrowserWindow): SmallestUpdater {
|
|
74
74
|
// 下载进度条
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
let progressBar: ProgressBar
|
|
76
|
+
function createProgressBar() {
|
|
77
|
+
return new Promise<ProgressBar>((resolve) => {
|
|
78
|
+
const ins = new ProgressBar({
|
|
79
|
+
title: '更新',
|
|
80
|
+
text: '下载更新',
|
|
81
|
+
detail: '等待下载',
|
|
82
|
+
indeterminate: false,
|
|
83
|
+
closeOnComplete: false,
|
|
84
|
+
browserWindow: {
|
|
85
|
+
modal: true,
|
|
86
|
+
parent: mainWindow
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
ins.on('ready', () => {
|
|
90
|
+
resolve(ins)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}
|
|
91
94
|
|
|
92
95
|
// 创建实例
|
|
93
96
|
const smallestUpdater = new SmallestUpdater({
|
|
94
97
|
logger,
|
|
95
98
|
publish: {
|
|
96
|
-
url: 'http://localhost:3000/smallest-updates'
|
|
99
|
+
url: 'http://localhost:3000/smallest-updates'
|
|
97
100
|
},
|
|
98
101
|
autoDownload: false,
|
|
99
|
-
forceDevUpdateConfig: true
|
|
102
|
+
forceDevUpdateConfig: true
|
|
100
103
|
})
|
|
101
104
|
|
|
102
105
|
// 更新可用
|
|
@@ -109,14 +112,11 @@ export function initSmallestUpdater(mainWindow: BrowserWindow): SmallestUpdater
|
|
|
109
112
|
title: '版本更新',
|
|
110
113
|
message: `发现新版本${version},是否更新\n\n${releaseNotes}`,
|
|
111
114
|
type: 'info',
|
|
112
|
-
buttons: ['稍后更新', '立即更新']
|
|
115
|
+
buttons: ['稍后更新', '立即更新']
|
|
113
116
|
})
|
|
114
|
-
.then(({ response }) => {
|
|
117
|
+
.then(async ({ response }) => {
|
|
115
118
|
if (response === 1) {
|
|
116
|
-
|
|
117
|
-
progressBar._window.show()
|
|
118
|
-
// @ts-expect-error
|
|
119
|
-
progressBar._window.setProgressBar(0)
|
|
119
|
+
progressBar = await createProgressBar()
|
|
120
120
|
smallestUpdater.downloadUpdate() // 手动下载更新
|
|
121
121
|
}
|
|
122
122
|
})
|
|
@@ -124,7 +124,7 @@ export function initSmallestUpdater(mainWindow: BrowserWindow): SmallestUpdater
|
|
|
124
124
|
|
|
125
125
|
// 更新不可用
|
|
126
126
|
smallestUpdater.on('update-not-available', () => {
|
|
127
|
-
|
|
127
|
+
console.log('[electron-updater]', '更新不可用')
|
|
128
128
|
})
|
|
129
129
|
|
|
130
130
|
// 下载进度
|
|
@@ -137,12 +137,13 @@ export function initSmallestUpdater(mainWindow: BrowserWindow): SmallestUpdater
|
|
|
137
137
|
// 下载完成
|
|
138
138
|
smallestUpdater.on('update-downloaded', (info) => {
|
|
139
139
|
console.log('[electron-updater]', '下载完成', info)
|
|
140
|
+
progressBar.close()
|
|
140
141
|
dialog
|
|
141
142
|
.showMessageBox(mainWindow, {
|
|
142
143
|
title: '下载完成',
|
|
143
144
|
message: `重启可应用新版本`,
|
|
144
145
|
type: 'info',
|
|
145
|
-
buttons: ['稍后重启', '立即重启']
|
|
146
|
+
buttons: ['稍后重启', '立即重启']
|
|
146
147
|
})
|
|
147
148
|
.then(({ response }) => {
|
|
148
149
|
if (response === 1) {
|
package/dist/builder.js
CHANGED
|
@@ -33,6 +33,9 @@ function smallestBuilder(context, options) {
|
|
|
33
33
|
let resourcesPath;
|
|
34
34
|
if (platform === 'darwin') {
|
|
35
35
|
resourcesPath = path_1.default.join(context.appOutDir, `${appInfo.name}.app`, 'Contents', 'Resources');
|
|
36
|
+
if (!(yield fs_extra_1.default.pathExists(resourcesPath))) {
|
|
37
|
+
resourcesPath = path_1.default.join(context.appOutDir, `${appInfo.productName}.app`, 'Contents', 'Resources');
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
else {
|
|
38
41
|
resourcesPath = path_1.default.join(context.appOutDir, 'resources');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-smallest-updater",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Electron Resources 按需最小更新、自动构建发布包及信息。",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@bfehub/eslint-config-typescript": "^2.1.0",
|
|
41
|
-
"@release-it/conventional-changelog": "^
|
|
41
|
+
"@release-it/conventional-changelog": "^10.0.0",
|
|
42
42
|
"@types/adm-zip": "^0.5.5",
|
|
43
43
|
"@types/fs-extra": "^11.0.4",
|
|
44
44
|
"@types/semver": "^7.5.8",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"electron-builder": "^24.9.1",
|
|
47
47
|
"eslint": "^8.56.0",
|
|
48
48
|
"prettier": "^3.2.4",
|
|
49
|
-
"release-it": "^
|
|
49
|
+
"release-it": "^19.2.4",
|
|
50
50
|
"typescript": "^5.4.2"
|
|
51
51
|
}
|
|
52
52
|
}
|