mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-12 15:22:35 +02:00
disable node integration (#2049)
This commit is contained in:
+1
-1
@@ -516,7 +516,7 @@ async function createWindow(first = true): Promise<void> {
|
|||||||
backgroundThrottling: false,
|
backgroundThrottling: false,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
devTools: true,
|
devTools: true,
|
||||||
nodeIntegration: true,
|
nodeIntegration: false,
|
||||||
preload: join(__dirname, '../preload/index.js'),
|
preload: join(__dirname, '../preload/index.js'),
|
||||||
sandbox: false,
|
sandbox: false,
|
||||||
webSecurity: !store.get('ignore_cors'),
|
webSecurity: !store.get('ignore_cors'),
|
||||||
|
|||||||
Vendored
-3
@@ -1,11 +1,8 @@
|
|||||||
import { ElectronAPI } from '@electron-toolkit/preload';
|
|
||||||
|
|
||||||
import { PreloadApi } from './index';
|
import { PreloadApi } from './index';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
api: PreloadApi;
|
api: PreloadApi;
|
||||||
electron: ElectronAPI;
|
|
||||||
LEGACY_AUTHENTICATION?: boolean;
|
LEGACY_AUTHENTICATION?: boolean;
|
||||||
queryLocalFonts?: () => Promise<Font[]>;
|
queryLocalFonts?: () => Promise<Font[]>;
|
||||||
REMOTE_URL?: string;
|
REMOTE_URL?: string;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { electronAPI } from '@electron-toolkit/preload';
|
import { contextBridge, webUtils } from 'electron';
|
||||||
import { contextBridge } from 'electron';
|
|
||||||
|
|
||||||
import { autodiscover } from './autodiscover';
|
import { autodiscover } from './autodiscover';
|
||||||
import { browser } from './browser';
|
import { browser } from './browser';
|
||||||
@@ -18,6 +17,7 @@ const api = {
|
|||||||
autodiscover,
|
autodiscover,
|
||||||
browser,
|
browser,
|
||||||
discordRpc,
|
discordRpc,
|
||||||
|
getPathForFile: webUtils.getPathForFile,
|
||||||
ipc,
|
ipc,
|
||||||
localSettings,
|
localSettings,
|
||||||
lyrics,
|
lyrics,
|
||||||
@@ -36,14 +36,11 @@ export type PreloadApi = typeof api;
|
|||||||
// just add to the DOM global.
|
// just add to the DOM global.
|
||||||
if (process.contextIsolated) {
|
if (process.contextIsolated) {
|
||||||
try {
|
try {
|
||||||
contextBridge.exposeInMainWorld('electron', electronAPI);
|
|
||||||
contextBridge.exposeInMainWorld('api', api);
|
contextBridge.exposeInMainWorld('api', api);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore (define in dts)
|
|
||||||
window.electron = electronAPI;
|
|
||||||
// @ts-ignore (define in dts)
|
// @ts-ignore (define in dts)
|
||||||
window.api = api;
|
window.api = api;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import { FontType } from '/@/shared/types/types';
|
|||||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||||
const ipc = isElectron() ? window.api.ipc : null;
|
const ipc = isElectron() ? window.api.ipc : null;
|
||||||
// Electron 32+ removed file.path, use this which is exposed in preload to get real path
|
// 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 = [
|
const HOME_FEATURE_STYLE_OPTIONS = [
|
||||||
{
|
{
|
||||||
@@ -295,7 +295,7 @@ export const ApplicationSettings = memo(() => {
|
|||||||
setSettings({
|
setSettings({
|
||||||
font: {
|
font: {
|
||||||
...fontSettings,
|
...fontSettings,
|
||||||
custom: e ? webUtils?.getPathForFile(e) || null : null,
|
custom: e ? getPathForFile?.(e) || null : null,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user