diff --git a/README.md b/README.md deleted file mode 100644 index eee5d64..0000000 --- a/README.md +++ /dev/null @@ -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 -``` diff --git a/electron-builder.yml b/electron-builder.yml index d72296e..2261448 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -39,4 +39,4 @@ appImage: npmRebuild: false publish: provider: generic - url: https://example.com/auto-updates + url: https://storage.ragestudio.net/rs-bundler/release diff --git a/package.json b/package.json index 88f15df..64ffb75 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main/index.js b/src/main/index.js index 8b06669..b1b4d94 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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() } diff --git a/src/preload/index.js b/src/preload/index.js index 6c76a5f..7a5b60a 100644 --- a/src/preload/index.js +++ b/src/preload/index.js @@ -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) } diff --git a/src/renderer/src/App.jsx b/src/renderer/src/App.jsx index d8a5817..91640b7 100644 --- a/src/renderer/src/App.jsx +++ b/src/renderer/src/App.jsx @@ -36,6 +36,9 @@ const PageRender = () => { return } +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) } }