-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Debug Main Process", | ||
"type": "node", | ||
"request": "launch", | ||
"cwd": "${workspaceFolder}", | ||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", | ||
"windows": { | ||
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" | ||
}, | ||
"args" : ["."], | ||
"outputCapture": "std" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { app, shell, BrowserWindow, dialog } from 'electron' | ||
import { app, shell, BrowserWindow, dialog, autoUpdater } from 'electron' | ||
import { join } from 'path' | ||
import { platform } from 'os' | ||
import { electronApp, optimizer, is } from '@electron-toolkit/utils' | ||
|
@@ -26,45 +26,8 @@ if (app.isPackaged) { | |
Sentry.init({ | ||
dsn: "https://[email protected]/4507621723144192", | ||
}); | ||
|
||
import('update-electron-app').then(autoUpdater => { | ||
autoUpdater.updateElectronApp() | ||
|
||
// autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { | ||
// const dialogOpts: Electron.MessageBoxOptions = { | ||
// type: 'info', | ||
// buttons: ['Restart', 'Later'], | ||
// title: 'Application Update', | ||
// message: process.platform === 'win32' ? releaseNotes : releaseName, | ||
// detail: | ||
// 'A new version has been downloaded. Restart the application to apply the updates.' | ||
// } | ||
|
||
// dialog.showMessageBox(dialogOpts).then((returnValue) => { | ||
// if (returnValue.response === 0) autoUpdater.quitAndInstall() | ||
// }) | ||
// }) | ||
|
||
// autoUpdater.on('error', (message) => { | ||
// console.error('There was a problem updating the application') | ||
// console.error(message) | ||
// }) | ||
|
||
// autoUpdater.on('update-available', (info) => { | ||
// console.log('Found update') | ||
// }) | ||
|
||
// autoUpdater.on('update-not-available', (info) => { | ||
// console.log('No update available') | ||
// }) | ||
|
||
// autoUpdater.on('', (progressObj) => { | ||
// console.log('Download progress: ' + progressObj.percent) | ||
// }) | ||
}) | ||
} | ||
|
||
|
||
function createWindow(): void { | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
|
@@ -108,6 +71,50 @@ const { registerBuiltIn } = usePlugins() | |
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
app.whenReady().then(async () => { | ||
autoUpdater.setFeedURL({ | ||
serverType: 'default', | ||
url: 'https://github.com/CynToolkit/cyn/releases/latest/download', | ||
headers: { | ||
'Cache-Control': 'no-cache', | ||
}, | ||
}) | ||
|
||
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { | ||
const dialogOpts: Electron.MessageBoxOptions = { | ||
type: 'info', | ||
buttons: ['Restart', 'Later'], | ||
title: 'Application Update', | ||
message: process.platform === 'win32' ? releaseNotes : releaseName, | ||
detail: | ||
'A new version has been downloaded. Restart the application to apply the updates.' | ||
} | ||
|
||
dialog.showMessageBox(dialogOpts).then((returnValue) => { | ||
if (returnValue.response === 0) autoUpdater.quitAndInstall() | ||
}) | ||
}) | ||
|
||
autoUpdater.on('error', (message) => { | ||
console.error('There was a problem updating the application') | ||
console.error(message) | ||
}) | ||
|
||
autoUpdater.on('update-available', (info) => { | ||
console.log('Found update') | ||
}) | ||
|
||
autoUpdater.on('update-not-available', (info) => { | ||
console.log('No update available') | ||
}) | ||
|
||
autoUpdater.on('checking-for-update', (info) => { | ||
console.log('checking-for-update', info) | ||
}) | ||
|
||
console.log('app ready') | ||
autoUpdater.checkForUpdates() | ||
console.log('autoUpdater.getFeedURL()', autoUpdater.getFeedURL()) | ||
|
||
// Set app user model id for windows | ||
electronApp.setAppUserModelId('com.cyn') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters