mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 21:28:06 +00:00
fix(electron): auto update
This commit is contained in:
parent
02c4ee9fb2
commit
b7f51f02c2
4 changed files with 34 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
import { app, protocol, BrowserWindow, shell } from "electron";
|
||||
import { app, protocol, BrowserWindow, shell, dialog } from "electron";
|
||||
import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
|
||||
import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
|
||||
import { startNeteaseMusicApi } from "./electron/services";
|
||||
|
|
@ -20,9 +20,6 @@ let win;
|
|||
// ipcMain
|
||||
initIpcMain(win);
|
||||
|
||||
// check for update
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
|
||||
// Scheme must be registered before the app is ready
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{ scheme: "app", privileges: { secure: true, standard: true } },
|
||||
|
|
@ -91,6 +88,34 @@ app.on("ready", async () => {
|
|||
// start netease music api
|
||||
startNeteaseMusicApi();
|
||||
|
||||
// check for update
|
||||
const log = require("electron-log");
|
||||
log.transports.file.level = "debug";
|
||||
autoUpdater.logger = log;
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
autoUpdater.on("update-available", (info) => {
|
||||
log.debug(info);
|
||||
dialog
|
||||
.showMessageBox({
|
||||
title: "发现新版本 v" + info.version,
|
||||
message: "发现新版本 v" + info.version,
|
||||
detail: "是否前往 Github 下载新版本安装包?",
|
||||
buttons: ["下载", "取消"],
|
||||
type: "question",
|
||||
noLink: true,
|
||||
})
|
||||
.then((result) => {
|
||||
if (result.response === 0) {
|
||||
shell.openExternal(
|
||||
"https://github.com/qier222/YesPlayMusic/releases"
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Install Vue Devtools extension
|
||||
if (isDevelopment && !process.env.IS_TEST) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue