mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 03:14:57 +08:00
🦄 refactor: convert to TypeScript #174
This commit is contained in:
16
electron/preload/index.ts
Normal file
16
electron/preload/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { contextBridge } from "electron";
|
||||
import { electronAPI } from "@electron-toolkit/preload";
|
||||
|
||||
// Use `contextBridge` APIs to expose Electron APIs to
|
||||
// renderer only if context isolation is enabled, otherwise
|
||||
// just add to the DOM global.
|
||||
if (process.contextIsolated) {
|
||||
try {
|
||||
contextBridge.exposeInMainWorld("electron", electronAPI);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
// @ts-expect-error (define in dts)
|
||||
window.electron = electronAPI;
|
||||
}
|
||||
Reference in New Issue
Block a user