mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: adding auth window
This commit is contained in:
parent
884ba47b9b
commit
71d79a4a15
9 changed files with 51 additions and 10 deletions
|
@ -15,6 +15,7 @@ import icon from "@resources/icon.png?asset";
|
|||
import trayIcon from "@resources/tray-icon.png?asset";
|
||||
import { gameRepository, userPreferencesRepository } from "@main/repository";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
import { HydraApi } from "./hydra-api";
|
||||
|
||||
export class WindowManager {
|
||||
public static mainWindow: Electron.BrowserWindow | null = null;
|
||||
|
@ -80,6 +81,41 @@ export class WindowManager {
|
|||
});
|
||||
}
|
||||
|
||||
public static openAuthWindow() {
|
||||
if (this.mainWindow) {
|
||||
const authWindow = new BrowserWindow({
|
||||
width: 600,
|
||||
height: 640,
|
||||
backgroundColor: "#1c1c1c",
|
||||
parent: this.mainWindow,
|
||||
modal: true,
|
||||
show: false,
|
||||
maximizable: false,
|
||||
resizable: false,
|
||||
minimizable: false,
|
||||
webPreferences: {
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
|
||||
authWindow.removeMenu();
|
||||
|
||||
authWindow.loadURL("http://localhost:3000");
|
||||
|
||||
authWindow.once("ready-to-show", () => {
|
||||
authWindow.show();
|
||||
});
|
||||
|
||||
authWindow.webContents.on("will-navigate", (_event, url) => {
|
||||
if (url.startsWith("hydralauncher://auth")) {
|
||||
authWindow.close();
|
||||
|
||||
HydraApi.handleExternalAuth(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static redirect(hash: string) {
|
||||
if (!this.mainWindow) this.createMainWindow();
|
||||
this.loadURL(hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue