MCPcopy Index your code
hub / github.com/CopyTranslator/CopyTranslator / bindUpdateEvents

Method bindUpdateEvents

src/main/views/update.ts:40–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38 }
39
40 bindUpdateEvents() {
41 if (this.bound) return;
42 this.bound = true;
43 const autoUpdater = this._autoUpdater;
44
45 autoUpdater.on("error", (error: Error) => {
46 console.error("Github检查更新失败");
47 this.checkTheGithubPages();
48 });
49
50 autoUpdater.on("update-available", (updateInfo: any) => {
51 updateInfo.needCompile = false;
52 updateInfo.isWin = require("os").platform == "win32";
53 updateInfo.manualLink = constants.manualDownloadLink;
54 this.postUpdateInfo(updateInfo);
55 });
56
57 autoUpdater.on("update-downloaded", () => {
58 dialog
59 .showMessageBox(BrowserWindow.getAllWindows()[0], {
60 type: "info",
61 title: "安装更新",
62 icon: icon,
63 message: "更新已下载",
64 buttons: ["现在退出并安装", "退出后自动安装", "cancel"],
65 cancelId: 2,
66 })
67 .then((res) => res.response)
68 .then((response) => {
69 if (response == 0) {
70 setImmediate(() => autoUpdater.quitAndInstall());
71 } else if (response == 1) {
72 autoUpdater.autoInstallOnAppQuit = true;
73 }
74 });
75 });
76
77 ipcMain.on("confirm-update", (event, args: any) => {
78 const win = BrowserWindow.fromWebContents(event.sender);
79 if (win) {
80 win.close();
81 }
82 autoUpdater.downloadUpdate();
83 });
84 }
85
86 async check() {
87 console.log("正在检查Github更新");

Callers 1

autoUpdaterMethod · 0.95

Calls 4

checkTheGithubPagesMethod · 0.95
postUpdateInfoMethod · 0.95
onMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected