diff --git a/src/main/index.ts b/src/main/index.ts index d16d066c9..faffc31a0 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -516,7 +516,7 @@ async function createWindow(first = true): Promise { backgroundThrottling: false, contextIsolation: true, devTools: true, - nodeIntegration: true, + nodeIntegration: false, preload: join(__dirname, '../preload/index.js'), sandbox: false, webSecurity: !store.get('ignore_cors'), diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index 70f7d3b13..ff0c6730a 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -1,11 +1,8 @@ -import { ElectronAPI } from '@electron-toolkit/preload'; - import { PreloadApi } from './index'; declare global { interface Window { api: PreloadApi; - electron: ElectronAPI; LEGACY_AUTHENTICATION?: boolean; queryLocalFonts?: () => Promise; REMOTE_URL?: string; diff --git a/src/preload/index.ts b/src/preload/index.ts index 112b23eb5..9953bc312 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -1,5 +1,4 @@ -import { electronAPI } from '@electron-toolkit/preload'; -import { contextBridge } from 'electron'; +import { contextBridge, webUtils } from 'electron'; import { autodiscover } from './autodiscover'; import { browser } from './browser'; @@ -18,6 +17,7 @@ const api = { autodiscover, browser, discordRpc, + getPathForFile: webUtils.getPathForFile, ipc, localSettings, lyrics, @@ -36,14 +36,11 @@ export type PreloadApi = typeof api; // just add to the DOM global. if (process.contextIsolated) { try { - contextBridge.exposeInMainWorld('electron', electronAPI); contextBridge.exposeInMainWorld('api', api); } catch (error) { console.error(error); } } else { - // @ts-ignore (define in dts) - window.electron = electronAPI; // @ts-ignore (define in dts) window.api = api; } diff --git a/src/renderer/features/settings/components/general/application-settings.tsx b/src/renderer/features/settings/components/general/application-settings.tsx index 926e56dc2..6ce39ea96 100644 --- a/src/renderer/features/settings/components/general/application-settings.tsx +++ b/src/renderer/features/settings/components/general/application-settings.tsx @@ -39,7 +39,7 @@ import { FontType } from '/@/shared/types/types'; const localSettings = isElectron() ? window.api.localSettings : null; const ipc = isElectron() ? window.api.ipc : null; // Electron 32+ removed file.path, use this which is exposed in preload to get real path -const webUtils = isElectron() ? window.electron.webUtils : null; +const getPathForFile = isElectron() ? window.api.getPathForFile : null; const HOME_FEATURE_STYLE_OPTIONS = [ { @@ -295,7 +295,7 @@ export const ApplicationSettings = memo(() => { setSettings({ font: { ...fontSettings, - custom: e ? webUtils?.getPathForFile(e) || null : null, + custom: e ? getPathForFile?.(e) || null : null, }, }) }