electron-version-deployer-cli 0.1.5 → 0.2.0
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 +234 -0
- package/dist/cli.cjs +35 -3
- package/dist/main.d.ts +2 -1
- package/dist/main.js +23 -11
- package/dist/templates/changelogs.html +29 -0
- package/dist/templates/newVersionDialog.html +15 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# electron-version-deployer-cli
|
|
2
|
+
|
|
3
|
+
electron 版本版本更新命令行
|
|
4
|
+
|
|
5
|
+
# 目的
|
|
6
|
+
|
|
7
|
+
1. 减少每次版本更新包的大小,最理想的情况是每次只更新修改的代码,而不是整个软件.
|
|
8
|
+
2. 快速更新而不需要经过任何商店审核
|
|
9
|
+
|
|
10
|
+
# 实现原理
|
|
11
|
+
|
|
12
|
+
[部署流程](https://mermaid.live/edit#pako:eNqdkd1KAkEYhm9lmCMj8wI8CMJfoqM63JUYdsfV3B9ZdwtxBaMiJSHEsKigoiBPRJGQhU27md3Z9S4aG4WNPGqO5vned96Z75saFDQRwzjMy9qJUEC6Afb2eRXQtcP5n71g2AmmQ9eZ5MDW1jZI1Eir67UvXOfVfz6tM2NiIVlMmDecYNZhsgWSXMS1neDrwe9fbRJ7TJ66DMI2nlfLSCghCceOKpq6kfubSloN8thapab-kUpRpY0eKppoyrjy-5Jg6HjXvUQBqRKWNckCaS4irGjNo5gfhPMtkOEi69pI_swty3mDO3Iz85oj1_4gtxP__hzE8LEISO-STte1B0t_ivkZpMOQCUN2OZ334KU9P-v707HXmbrOmwV2uSU3R0DFhlzMV2k0OwWjUMG6gooi_fHaosZDo4AVzMM43YpIL_GQV-vUh0xDO6iqAowbuomj0CyLyMDJIpJ0pLBi_Run1P63)
|
|
13
|
+
|
|
14
|
+
[检测更新流程](https://mermaid.live/edit#pako:eNp1kstO6zAQhl9l5C2UB8iim7Bmk202VuIWQ5rkJM4CEBJCXEIJt6MedKAVFSAu4tYiIVEQFS-TccqKV8BRqSASeGXN_8381j9eIJZnM6KRkP2JmGuxSU6rAa2Zrk8DwS3uU1eADjQEvDuR8WN23SlqRq7J1hbWj_Hg0nRBHb1ULo_pGgzWr7B-KZsPcr8rT5dk--ybbii98yjvl8Gn1iytsomZ0HOHgFEqlUv5gNcGNo9-AHQF5A7YeZKdhmzdYKuLfxOYYsLhlTlIe_VCF2QbsaKywxVMnjG-fn9J0t7moN9Pe1u4m6g6zHMfMFkdzp_yBIOAV6cFeBXIjc6X5VGrODPt3eaNNvOZa6vwOFMp7exljXb6vIY7_zHZx-790AcqkeMYfJ5NKJ_fPHbPMT745B2vyi1dLSf86hjl9okUXmwo7VtkBW2U1uDiFLc3Me4C9X3ImnfY__dF5N1v6yoOteFhlYyTGgtqlNvqhyzkNZOIaVZjJtHU1abBrElMd1FxNBKeMedaRBNBxMZJ5NtUjH4T0SrUCdniB57VDHA)
|
|
15
|
+
|
|
16
|
+
# 安装
|
|
17
|
+
|
|
18
|
+
首先在你项目的根目录(与 package.json 同级)运行
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
$ npm install electron-version-deployer-cli
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
注意 ⚠️,我们需要将它安装在 `dependencies` 下,因此请不要添加额外参数。
|
|
25
|
+
|
|
26
|
+
# 使用
|
|
27
|
+
|
|
28
|
+
## 添加依赖包
|
|
29
|
+
|
|
30
|
+
添加一下包到你的 `devDependencies` 中
|
|
31
|
+
|
|
32
|
+
> 添加后,可能会有些包出现重复,手动删下就行了(编译器会有提示)
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"@inquirer/prompts": "^1.2.3",
|
|
37
|
+
"changelog-parser": "^3.0.1",
|
|
38
|
+
"commander": "^10.0.1",
|
|
39
|
+
"dompurify": "^3.0.3",
|
|
40
|
+
"download": "^8.0.0",
|
|
41
|
+
"electron": ">=10.0.0",
|
|
42
|
+
"esno": "^0.16.3",
|
|
43
|
+
"jsdom": "^22.1.0",
|
|
44
|
+
"log-symbols": "=4.1.0",
|
|
45
|
+
"marked": "^5.0.4",
|
|
46
|
+
"netlify-cli": "^15.2.0",
|
|
47
|
+
"vite": "^4.3.9",
|
|
48
|
+
"wrangler": "^3.3.0"
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> 由于我们需要在主进程里面调用 `electron-version-deployer-cli` 的检测自动更新逻辑,如果把依赖的包都放到 `dependencies`, 那么你的软件编译后也会附带这些依赖包,这是完全没有必要的。因此需要手动添加下
|
|
53
|
+
|
|
54
|
+
## 使用
|
|
55
|
+
|
|
56
|
+
### 主进程添加自动更新检测
|
|
57
|
+
|
|
58
|
+
在你的主进程中,添加以下代码, 来实现更新检测
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// main.js
|
|
62
|
+
import { EVDInit } from "electron-version-deployer-cli/dist/main";
|
|
63
|
+
|
|
64
|
+
EVDInit({
|
|
65
|
+
remoteUrl: import.meta.env.REMOTE_URL,
|
|
66
|
+
logo: `file://${join(
|
|
67
|
+
app.getAppPath(),
|
|
68
|
+
"packages",
|
|
69
|
+
"main",
|
|
70
|
+
"dist",
|
|
71
|
+
"icon.png"
|
|
72
|
+
)}`,
|
|
73
|
+
onError(error) {
|
|
74
|
+
// 记录更新检测遇到的错误
|
|
75
|
+
writeError(error, "evd");
|
|
76
|
+
},
|
|
77
|
+
onBeforeNewPkgInstall(next, version:string) {
|
|
78
|
+
// window 下如果某些程序正在使用 node_modules 会导致
|
|
79
|
+
// Error: EBUSY: resource busy or locked 错误
|
|
80
|
+
|
|
81
|
+
// 因此在安装前, 你可以手动关闭这些程序
|
|
82
|
+
DB.close();
|
|
83
|
+
|
|
84
|
+
// 执行 next 方法,继续安装
|
|
85
|
+
next();
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
EVDInit 方法接受的参数如下
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
type EVDInitPropsType = {
|
|
94
|
+
// 检测远程更新的地址
|
|
95
|
+
remoteUrl: string;
|
|
96
|
+
|
|
97
|
+
// 弹窗宽度
|
|
98
|
+
windowWidth?: number;
|
|
99
|
+
// 弹窗高度
|
|
100
|
+
windowHeight?: number;
|
|
101
|
+
// logo 图标
|
|
102
|
+
logo?: string;
|
|
103
|
+
// 检测频率/s
|
|
104
|
+
detectionFrequency?: number;
|
|
105
|
+
// 是否在程序开始运行时进行检测
|
|
106
|
+
detectAtStart?: boolean;
|
|
107
|
+
// 当自动更新出现错误时的回掉
|
|
108
|
+
onError?: (err: unknown) => void;
|
|
109
|
+
onBeforeNewPkgInstall?: (next: () => any) => void;
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> 一下命令全部必须在项目根目录执行 (与 package.json 同级)
|
|
114
|
+
|
|
115
|
+
### 初始化配置
|
|
116
|
+
|
|
117
|
+
```shell
|
|
118
|
+
# 进入命令行交互模式
|
|
119
|
+
$ evd init
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
该命令主要是生成一个 evd.config.js 的配置文件。
|
|
123
|
+
|
|
124
|
+
> ⚠️ 如果你根目录下已经有了这个文件,就不需要再执行了
|
|
125
|
+
|
|
126
|
+
## 配置项
|
|
127
|
+
|
|
128
|
+
> 如果你用 typescript 是有完全的提示的
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
export type PrebuiltConfigType = Record<
|
|
132
|
+
string,
|
|
133
|
+
{ files: string[]; outputPath: string[] }
|
|
134
|
+
>;
|
|
135
|
+
|
|
136
|
+
export type EVDConfigType = {
|
|
137
|
+
// 编译命令, 如 pack-mac
|
|
138
|
+
// 在部署前,需要从编译后的软件里面,获取逻辑代码
|
|
139
|
+
compileCommand: string;
|
|
140
|
+
// CHANGELOG.md 文件位置,用于读取显示给用户此次版本更新的内容
|
|
141
|
+
changelogsPath: string;
|
|
142
|
+
// 编译后的源文件位置
|
|
143
|
+
sources: {
|
|
144
|
+
// 源文件目录, 编译后的 软件名称.app/Contents/Resources/app 文件夹
|
|
145
|
+
folder: string;
|
|
146
|
+
// node_modules 路径(相对 folder)
|
|
147
|
+
nodeModules: string;
|
|
148
|
+
// 逻辑代码路径(相对 folder)
|
|
149
|
+
codes: string;
|
|
150
|
+
// package.json 文件路径(相对 folder)
|
|
151
|
+
packageJSON: string;
|
|
152
|
+
};
|
|
153
|
+
// netlify 部署设置
|
|
154
|
+
netlify?: {
|
|
155
|
+
// 网站域名如 https://site.netlify.app
|
|
156
|
+
url: string;
|
|
157
|
+
token: string;
|
|
158
|
+
siteID: string;
|
|
159
|
+
};
|
|
160
|
+
cloudflare?: {
|
|
161
|
+
url: string;
|
|
162
|
+
token: string;
|
|
163
|
+
projectName: string;
|
|
164
|
+
};
|
|
165
|
+
prebuiltConfig: PrebuiltConfigType;
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## 更新版本
|
|
170
|
+
|
|
171
|
+
如果你要更新一个版本,需要执行一下两个步骤
|
|
172
|
+
|
|
173
|
+
### 编译
|
|
174
|
+
|
|
175
|
+
```shell
|
|
176
|
+
$ evd prepare
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
这个命令首先对软件进行编译,然后将一些代码和 changelog 放到 .evd 文件夹中
|
|
180
|
+
|
|
181
|
+
### 部署
|
|
182
|
+
|
|
183
|
+
```shell
|
|
184
|
+
$ evd deploy
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
这个命令主要是把 .evd 文件夹部署到 netlity 上,并且对远程版本号,和当前版本号进行多方面的判断,尽量避免误操作问题
|
|
188
|
+
|
|
189
|
+
### 手动检查版本更新
|
|
190
|
+
|
|
191
|
+
如果你想要通过 **编程** 的方式,检测版本更新,可以使用 `EVDCheckUpdate` 这个方法
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
// main.ts
|
|
195
|
+
import { EVDCheckUpdate } from "electron-version-deployer-cli/dist/main";
|
|
196
|
+
|
|
197
|
+
// 如果有新版本,isHaveNewVersion 返回的就是 false,否则是 true
|
|
198
|
+
// 如果有新版本,它会自动打开更新框
|
|
199
|
+
EVDCheckUpdate().then((isHaveNewVersion: boolean) => {
|
|
200
|
+
if (!isHaveNewVersion) {
|
|
201
|
+
IPC.send("showMessage", "success", "当前已是最新版本!");
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 安装预构建
|
|
207
|
+
|
|
208
|
+
某些依赖包需要预构建才能在不同平台上执行,比如 sqlite3,这样才能保证用户更新 node_modules 不会出现预构建找不到而导致的报错问题
|
|
209
|
+
|
|
210
|
+
比如我们要配置 sqlite3 的预构建
|
|
211
|
+
只需要添加 `configs.prebuiltConfig` 即可
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"prebuiltConfig": {
|
|
216
|
+
"sqlite3": {
|
|
217
|
+
"files": [
|
|
218
|
+
"napi-v6-darwin-unknown-arm64.tar.gz",
|
|
219
|
+
"napi-v6-darwin-unknown-x64.tar.gz",
|
|
220
|
+
"napi-v6-win32-unknown-x64.tar.gz"
|
|
221
|
+
],
|
|
222
|
+
"outputPath": ["lib", "binding"]
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
其中 files 是你需要安装的 prebuilt 版本。 outputPath 是你需要将这些与构建版本放到 sqlite3 的那个目录下,上面的配置会把这些预构建的 `.gz` 文件放到 `node_modules/sqlite3/lib/binding` 目录下面去
|
|
229
|
+
|
|
230
|
+
配置完后,只需要执行以下命令,他就会自动安装了
|
|
231
|
+
|
|
232
|
+
```shell
|
|
233
|
+
evd install-prebuilt
|
|
234
|
+
```
|
package/dist/cli.cjs
CHANGED
|
@@ -278,6 +278,20 @@ async function genChangelog(configs) {
|
|
|
278
278
|
headerIds: false
|
|
279
279
|
})
|
|
280
280
|
);
|
|
281
|
+
const allChanges = changes.map((change) => {
|
|
282
|
+
const { date: date2, version: version2, title: title2, body: body2 } = change;
|
|
283
|
+
return {
|
|
284
|
+
date: date2,
|
|
285
|
+
version: version2,
|
|
286
|
+
title: title2,
|
|
287
|
+
changes: purify.sanitize(
|
|
288
|
+
marked.marked.parse(body2, {
|
|
289
|
+
mangle: false,
|
|
290
|
+
headerIds: false
|
|
291
|
+
})
|
|
292
|
+
)
|
|
293
|
+
};
|
|
294
|
+
});
|
|
281
295
|
node_fs.writeFileSync(
|
|
282
296
|
r("node_modules/.evd/changelog.json"),
|
|
283
297
|
JSON.stringify({
|
|
@@ -288,6 +302,15 @@ async function genChangelog(configs) {
|
|
|
288
302
|
}),
|
|
289
303
|
"utf-8"
|
|
290
304
|
);
|
|
305
|
+
const changelogTemplate = node_fs.readFileSync(
|
|
306
|
+
r("public/templates/changelogs.html"),
|
|
307
|
+
"utf-8"
|
|
308
|
+
);
|
|
309
|
+
node_fs.writeFileSync(
|
|
310
|
+
r("node_modules/.evd/changelogs.html"),
|
|
311
|
+
changelogTemplate.replace("__INJECT__", JSON.stringify(allChanges)),
|
|
312
|
+
"utf-8"
|
|
313
|
+
);
|
|
291
314
|
console.log(
|
|
292
315
|
logSymbols.success,
|
|
293
316
|
`写入 changelog.json 成功 ${r("node_modules/.evd/changelog.json")}`
|
|
@@ -368,7 +391,8 @@ const _Netlify = class {
|
|
|
368
391
|
"--prod",
|
|
369
392
|
"--debug"
|
|
370
393
|
], {
|
|
371
|
-
stdio: ["pipe", "inherit", "inherit"]
|
|
394
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
395
|
+
shell: true
|
|
372
396
|
});
|
|
373
397
|
output.on("exit", function(code) {
|
|
374
398
|
if (code === 0) {
|
|
@@ -417,7 +441,14 @@ const _Cloudflare = class {
|
|
|
417
441
|
const fileSize = fileStats.size;
|
|
418
442
|
const fileSizeInMB = fileSize / (1024 * 1024);
|
|
419
443
|
const outputFolder = node_path.join(folderPath, "fullCodeZipSplitZips");
|
|
420
|
-
|
|
444
|
+
if (node_fs.existsSync(outputFolder)) {
|
|
445
|
+
node_fs.rmSync(outputFolder, {
|
|
446
|
+
force: true,
|
|
447
|
+
maxRetries: 3,
|
|
448
|
+
recursive: true
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
node_fs.mkdirSync(outputFolder);
|
|
421
452
|
if (fileSizeInMB < 24)
|
|
422
453
|
return;
|
|
423
454
|
const SPLIT_SIZE = 20;
|
|
@@ -458,6 +489,7 @@ const _Cloudflare = class {
|
|
|
458
489
|
"main"
|
|
459
490
|
], {
|
|
460
491
|
stdio: ["pipe", "inherit", "inherit"],
|
|
492
|
+
shell: true,
|
|
461
493
|
env: {
|
|
462
494
|
...process.env,
|
|
463
495
|
"CLOUDFLARE_API_TOKEN": cloudflareConfig.token
|
|
@@ -605,4 +637,4 @@ async function installPrebuilt(configs) {
|
|
|
605
637
|
}
|
|
606
638
|
commander.program.description(
|
|
607
639
|
"Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
|
|
608
|
-
).helpOption("-h, --help", "使用帮助").version("0.
|
|
640
|
+
).helpOption("-h, --help", "使用帮助").version("0.2.0", "-V, --version", "显示版本号").parse(process.argv);
|
package/dist/main.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export declare enum EVDEventEnum {
|
|
|
3
3
|
UPDATE = "evd-update-now",
|
|
4
4
|
SKIP = "evd-skip",
|
|
5
5
|
GET_CHANGELOGS = "evd-get-change-logs",
|
|
6
|
-
GET_LOGO = "evd-get-logo"
|
|
6
|
+
GET_LOGO = "evd-get-logo",
|
|
7
|
+
GET_CHANGELOGS_LINK = "evd-get-changelogs-link"
|
|
7
8
|
}
|
|
8
9
|
type EVDInitPropsType = {
|
|
9
10
|
netlifyUrl?: string;
|
package/dist/main.js
CHANGED
|
@@ -77,6 +77,7 @@ var EVDEventEnum = /* @__PURE__ */ ((EVDEventEnum2) => {
|
|
|
77
77
|
EVDEventEnum2["SKIP"] = "evd-skip";
|
|
78
78
|
EVDEventEnum2["GET_CHANGELOGS"] = "evd-get-change-logs";
|
|
79
79
|
EVDEventEnum2["GET_LOGO"] = "evd-get-logo";
|
|
80
|
+
EVDEventEnum2["GET_CHANGELOGS_LINK"] = "evd-get-changelogs-link";
|
|
80
81
|
return EVDEventEnum2;
|
|
81
82
|
})(EVDEventEnum || {});
|
|
82
83
|
let globalArgs = null;
|
|
@@ -219,7 +220,7 @@ async function installPkg(zipFile) {
|
|
|
219
220
|
let fullCodeSplitIndexFile = false;
|
|
220
221
|
try {
|
|
221
222
|
const request = await fetch(
|
|
222
|
-
`${remoteUrl}/fullCodeZipSplitZips/index.json`
|
|
223
|
+
`${remoteUrl}/fullCodeZipSplitZips/index.json?hash=${Math.random()}`
|
|
223
224
|
);
|
|
224
225
|
fullCodeSplitIndexFile = await request.json();
|
|
225
226
|
} catch (e) {
|
|
@@ -230,16 +231,19 @@ async function installPkg(zipFile) {
|
|
|
230
231
|
const tmpFilePath = node_path.join(appPath, fileName);
|
|
231
232
|
const tmpSplitZip = node_fs.createWriteStream(tmpFilePath);
|
|
232
233
|
await new Promise((_res) => {
|
|
233
|
-
node_https.get(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
node_https.get(
|
|
235
|
+
`${remoteUrl}/fullCodeZipSplitZips/${fileName}?hash=${Math.random()}`,
|
|
236
|
+
(response) => {
|
|
237
|
+
response.pipe(tmpSplitZip).on("finish", () => {
|
|
238
|
+
tmpSplitZip.end(() => {
|
|
239
|
+
mergedStream.write(node_fs.readFileSync(tmpFilePath));
|
|
240
|
+
_res();
|
|
241
|
+
});
|
|
242
|
+
}).on("error", (err) => {
|
|
243
|
+
rej(err);
|
|
238
244
|
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
});
|
|
242
|
-
}).on("error", (err) => {
|
|
245
|
+
}
|
|
246
|
+
).on("error", (err) => {
|
|
243
247
|
rej(err);
|
|
244
248
|
});
|
|
245
249
|
});
|
|
@@ -250,7 +254,7 @@ async function installPkg(zipFile) {
|
|
|
250
254
|
});
|
|
251
255
|
} else {
|
|
252
256
|
const tmpZipFilePath = node_fs.createWriteStream(unzipPath + ".zip");
|
|
253
|
-
node_https.get(`${remoteUrl}/${zipFile}`, (response) => {
|
|
257
|
+
node_https.get(`${remoteUrl}/${zipFile}?hash=${Math.random()}`, (response) => {
|
|
254
258
|
response.pipe(tmpZipFilePath).on("finish", () => {
|
|
255
259
|
tmpZipFilePath.end(() => {
|
|
256
260
|
res();
|
|
@@ -319,6 +323,10 @@ function bindEvent(promptWindow, onError) {
|
|
|
319
323
|
const { remoteUrl: remoteUrl2 } = getConfigs();
|
|
320
324
|
return await fetchRemoteChangelogJSON(remoteUrl2);
|
|
321
325
|
});
|
|
326
|
+
electron.ipcMain.handle("evd-get-changelogs-link", async () => {
|
|
327
|
+
const { remoteUrl: remoteUrl2 } = getConfigs();
|
|
328
|
+
return `${remoteUrl2}/changelogs.html`;
|
|
329
|
+
});
|
|
322
330
|
}
|
|
323
331
|
function cleanup(promptWindow) {
|
|
324
332
|
electron.ipcMain.removeAllListeners(
|
|
@@ -341,6 +349,10 @@ function cleanup(promptWindow) {
|
|
|
341
349
|
"evd-get-logo"
|
|
342
350
|
/* GET_LOGO */
|
|
343
351
|
);
|
|
352
|
+
electron.ipcMain.removeHandler(
|
|
353
|
+
"evd-get-changelogs-link"
|
|
354
|
+
/* GET_CHANGELOGS_LINK */
|
|
355
|
+
);
|
|
344
356
|
try {
|
|
345
357
|
promptWindow == null ? void 0 : promptWindow.focus();
|
|
346
358
|
promptWindow == null ? void 0 : promptWindow.destroy();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta
|
|
6
|
+
name="viewport"
|
|
7
|
+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
|
8
|
+
/>
|
|
9
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
|
10
|
+
<title>Changelogs</title>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div id="container"></div>
|
|
14
|
+
</body>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
const changelogs = __INJECT__;
|
|
18
|
+
|
|
19
|
+
let html = ``;
|
|
20
|
+
for (const change of changelogs) {
|
|
21
|
+
html += `<div class="item">`;
|
|
22
|
+
html += `<div class="title">${change.title}</div>`;
|
|
23
|
+
html += `<div class="changes">${change.changes}</div>`;
|
|
24
|
+
html += `</div>`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
document.querySelector("#container").innerHTML = html;
|
|
28
|
+
</script>
|
|
29
|
+
</html>
|
|
@@ -119,6 +119,12 @@
|
|
|
119
119
|
<div class="title-bar">
|
|
120
120
|
<img src="" width="34" class="logo" style="display: none" />
|
|
121
121
|
<span>有可用的新版本:</span>
|
|
122
|
+
<a
|
|
123
|
+
href="#"
|
|
124
|
+
class="see-all-changes"
|
|
125
|
+
style="text-decoration: underline; font-size: 12px"
|
|
126
|
+
>(所有版本更新记录)</a
|
|
127
|
+
>
|
|
122
128
|
</div>
|
|
123
129
|
<div class="content">具体更新内容请查看 Changelogs</div>
|
|
124
130
|
<div class="buttons-box">
|
|
@@ -146,6 +152,15 @@
|
|
|
146
152
|
}
|
|
147
153
|
});
|
|
148
154
|
|
|
155
|
+
ipcRenderer.invoke("evd-get-changelogs-link").then((link) => {
|
|
156
|
+
const aTag = document.querySelector(".see-all-changes");
|
|
157
|
+
if (link) {
|
|
158
|
+
aTag.href = link;
|
|
159
|
+
} else {
|
|
160
|
+
aTag.remove();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
149
164
|
ipcRenderer.invoke("evd-get-change-logs").then((data) => {
|
|
150
165
|
// 如果没有数据就不渲染
|
|
151
166
|
if (!data) return;
|