mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
fix auto update
This commit is contained in:
parent
32d7c835c3
commit
0d7857c90a
34
README.md
34
README.md
@ -1,34 +0,0 @@
|
||||
# rs-bundler
|
||||
|
||||
An Electron application with React
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
|
||||
|
||||
## Project Setup
|
||||
|
||||
### Install
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
### Development
|
||||
|
||||
```bash
|
||||
$ npm run dev
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
# For windows
|
||||
$ npm run build:win
|
||||
|
||||
# For macOS
|
||||
$ npm run build:mac
|
||||
|
||||
# For Linux
|
||||
$ npm run build:linux
|
||||
```
|
@ -39,4 +39,4 @@ appImage:
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: generic
|
||||
url: https://example.com/auto-updates
|
||||
url: https://storage.ragestudio.net/rs-bundler/release
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "rs-bundler",
|
||||
"version": "0.3.0",
|
||||
"description": "An Electron application with React",
|
||||
"version": "0.4.0",
|
||||
"description": "RageStudio Bundler Utility GUI",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "RageStudio",
|
||||
"scripts": {
|
||||
@ -18,6 +18,7 @@
|
||||
"dependencies": {
|
||||
"@electron-toolkit/preload": "^2.0.0",
|
||||
"@electron-toolkit/utils": "^2.0.0",
|
||||
"@ragestudio/hermes": "^0.1.1",
|
||||
"antd": "^5.10.2",
|
||||
"classnames": "^2.3.2",
|
||||
"electron-updater": "^6.1.1",
|
||||
|
@ -2,6 +2,7 @@ import path from "node:path"
|
||||
|
||||
import { app, shell, BrowserWindow, ipcMain } from "electron"
|
||||
import { electronApp, optimizer, is } from "@electron-toolkit/utils"
|
||||
import { autoUpdater } from "electron-updater"
|
||||
|
||||
import open from "open"
|
||||
|
||||
@ -51,6 +52,11 @@ class ElectronApp {
|
||||
},
|
||||
}
|
||||
|
||||
sendToRender(event, ...args) {
|
||||
console.log(`[sendToRender][${event}]`, ...args)
|
||||
this.win.webContents.send(event, ...args)
|
||||
}
|
||||
|
||||
createWindow() {
|
||||
this.win = global.win = new BrowserWindow({
|
||||
width: 450,
|
||||
@ -92,6 +98,41 @@ class ElectronApp {
|
||||
|
||||
await app.whenReady()
|
||||
|
||||
autoUpdater.on("update-available", (ev, info) => {
|
||||
console.log(info)
|
||||
|
||||
this.sendToRender("new:message", {
|
||||
message: `New update available, downloading...`,
|
||||
type: "loading",
|
||||
})
|
||||
})
|
||||
|
||||
autoUpdater.on("error", (ev, err) => {
|
||||
console.error(err)
|
||||
|
||||
this.sendToRender("new:message", {
|
||||
message: "Failed to auto update...",
|
||||
type: "error",
|
||||
})
|
||||
})
|
||||
|
||||
autoUpdater.on("update-downloaded", (ev, info) => {
|
||||
console.log(info)
|
||||
|
||||
this.sendToRender("new:message", {
|
||||
message: `Update downloaded, restarting...`,
|
||||
type: "loading",
|
||||
})
|
||||
})
|
||||
|
||||
autoUpdater.on("update-downloaded", (ev, info) => {
|
||||
setTimeout(() => {
|
||||
autoUpdater.quitAndInstall()
|
||||
}, 3000)
|
||||
})
|
||||
|
||||
autoUpdater.checkForUpdates()
|
||||
|
||||
// Set app user model id for windows
|
||||
electronApp.setAppUserModelId("com.electron")
|
||||
|
||||
@ -101,7 +142,7 @@ class ElectronApp {
|
||||
|
||||
this.createWindow()
|
||||
|
||||
app.on("activate", function () {
|
||||
app.on("activate", () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
this.createWindow()
|
||||
}
|
||||
|
@ -21,9 +21,11 @@ if (process.contextIsolated) {
|
||||
ipcRenderer.removeListener(channel, listener)
|
||||
}
|
||||
},
|
||||
|
||||
)
|
||||
contextBridge.exposeInMainWorld('electron', electronAPI)
|
||||
contextBridge.exposeInMainWorld('api', api)
|
||||
contextBridge.exposeInMainWorld("electron", electronAPI)
|
||||
|
||||
contextBridge.exposeInMainWorld("api", api)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ const PageRender = () => {
|
||||
return <InstallationsManager />
|
||||
}
|
||||
|
||||
globalThis.notification = antd.notification
|
||||
globalThis.message = antd.message
|
||||
|
||||
class App extends React.Component {
|
||||
state = {
|
||||
loading: true,
|
||||
@ -54,6 +57,18 @@ class App extends React.Component {
|
||||
this.setState({
|
||||
initializing_text: data,
|
||||
})
|
||||
},
|
||||
"new:notification": (event, data) => {
|
||||
antd.notification[data.type || "info"]({
|
||||
message: data.message,
|
||||
description: data.description,
|
||||
loading: data.loading,
|
||||
duration: data.duration,
|
||||
icon: data.icon,
|
||||
})
|
||||
},
|
||||
"new:message": (event, data) => {
|
||||
antd.message[data.type || "info"]( data.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user