Skip to content

Commit

Permalink
add external browser link to "by jakedoesdev.com"
Browse files Browse the repository at this point in the history
  • Loading branch information
nascarjake committed Dec 18, 2024
1 parent dfeb5db commit bd732a5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
10 changes: 9 additions & 1 deletion electron/main-dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain, protocol, dialog } = require('electron');
const { app, BrowserWindow, ipcMain, protocol, dialog, shell } = require('electron');
const path = require('path');
const fs = require('fs');
const os = require('os');
Expand Down Expand Up @@ -885,3 +885,11 @@ app.whenReady().then(() => {
app.on('window-all-closed', () => {
app.quit();
});

ipcMain.handle('window:minimize', () => mainWindow.minimize());
ipcMain.handle('window:maximize', () => mainWindow.maximize());
ipcMain.handle('window:close', () => mainWindow.close());

ipcMain.handle('shell:openExternal', async (_, url) => {
await shell.openExternal(url);
});
10 changes: 8 additions & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain, protocol, dialog } = require('electron');
const { app, BrowserWindow, ipcMain, protocol, dialog, shell } = require('electron');
const path = require('path');
const fs = require('fs');
const os = require('os');
Expand Down Expand Up @@ -776,7 +776,13 @@ ipcMain.handle('window:close', () => {
BrowserWindow.getFocusedWindow()?.close();
});

// Keep old handlers for backward compatibility during transition
// Shell handlers
ipcMain.handle('shell:openExternal', async (_, url) => {
await shell.openExternal(url);
});

// Profile handlers
{{ ... }}

let mainWindow;
let splashScreen;
Expand Down
17 changes: 14 additions & 3 deletions electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,20 @@ contextBridge.exposeInMainWorld('electron', {
removeListener: (channel, listener) => ipcRenderer.removeListener(channel, listener)
},
window: {
minimize: () => ipcRenderer.invoke('window:minimize'),
maximize: () => ipcRenderer.invoke('window:maximize'),
close: () => ipcRenderer.invoke('window:close'),
minimize() {
return ipcRenderer.invoke('window:minimize');
},
maximize() {
return ipcRenderer.invoke('window:maximize');
},
close() {
return ipcRenderer.invoke('window:close');
}
},
shell: {
openExternal(url) {
return ipcRenderer.invoke('shell:openExternal', url);
}
},
functionNodes: {
save: async (baseDir, profileId, config) => {
Expand Down
6 changes: 5 additions & 1 deletion src/app/layouts/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Subscription } from 'rxjs';
</div>
<div class="sub-nav-container" *ngIf="showSubNav">
<div class="version-container">
<div class="version-text">By Jake Clark</div>
<div class="version-text"><a href="#" style="color: white; text-decoration: none;" (click)="openExternalLink('https://JakeDoesDev.com')">By JakeDoesDev.com</a></div>
<span class="version-text">v{{version}}</span>
</div>
<div class="sub-nav">
Expand Down Expand Up @@ -327,6 +327,10 @@ export class HeaderComponent implements OnInit, OnDestroy {
}
}

async openExternalLink(url: string) {
await window.electron.shell.openExternal(url);
}

ngOnDestroy() {
this.subscription.unsubscribe();
}
Expand Down
5 changes: 5 additions & 0 deletions src/electron.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ declare module 'electron-api' {
close(): Promise<void>;
}

interface ElectronShell {
openExternal(url: string): Promise<void>;
}

interface ElectronIpcRenderer {
invoke(channel: string, ...args: any[]): Promise<any>;
on(channel: string, listener: (event: any, ...args: any[]) => void): void;
Expand All @@ -148,6 +152,7 @@ declare module 'electron-api' {
path: ElectronPath;
fs: ElectronFS;
window: ElectronWindow;
shell: ElectronShell;
functions: ElectronFunctions;
assistant: ElectronAssistant;
download: ElectronDownload;
Expand Down

0 comments on commit bd732a5

Please sign in to comment.