-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add progress report. * Refactor. * Add comment. * Update.
- Loading branch information
1 parent
e052778
commit 0a374cf
Showing
7 changed files
with
347 additions
and
278 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const IPC_CHANNELS = { | ||
LOADING_PROGRESS: 'loading-progress', | ||
}; | ||
|
||
export const ELECTRON_BRIDGE_API = 'electronAPI'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
// See the Electron documentation for details on how to use preload scripts: | ||
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts | ||
// preload.ts | ||
|
||
import { contextBridge, ipcRenderer } from 'electron'; | ||
import { IPC_CHANNELS, ELECTRON_BRIDGE_API } from './constants'; | ||
|
||
const electronAPI = { | ||
onProgressUpdate: (callback: (update: { percentage: number; status: string }) => void) => { | ||
ipcRenderer.on(IPC_CHANNELS.LOADING_PROGRESS, (_event, value) => { | ||
console.log(`Received ${IPC_CHANNELS.LOADING_PROGRESS} event`, value); | ||
callback(value); | ||
}); | ||
}, | ||
}; | ||
|
||
contextBridge.exposeInMainWorld(ELECTRON_BRIDGE_API, electronAPI); |
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
Oops, something went wrong.