electron disable inspect

 https://github.com/electron-userland/electron-builder/issues/6365
 
import { flipFuses, FuseVersion, FuseV1Options } from '@electron/fuses'
 
async function initApp() {
  const exePath = app.getPath('exe')
  await flipFuses(
    exePath, // Returns the path to the electron binary
    {
      version: FuseVersion.V1,
      [FuseV1Options.RunAsNode]: false, // Disables ELECTRON_RUN_AS_NODE
      [FuseV1Options.EnableCookieEncryption]: true, // Enables cookie encryption
      [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, // Disables the NODE_OPTIONS environment variable
      [FuseV1Options.EnableNodeCliInspectArguments]: false, // Disables the --inspect and --inspect-brk family of CLI options
      [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, // Enables validation of the app.asar archive on macOS
      [FuseV1Options.OnlyLoadAppFromAsar]: true, // Enforces that Electron will only load your app from "app.asar" instead of its normal search paths
      [FuseV1Options.LoadBrowserProcessSpecificV8Snapshot]: true, // Loads V8 Snapshot from `browser_v8_context_snapshot.bin` for the browser process
      [FuseV1Options.GrantFileProtocolExtraPrivileges]: true // Grants the file protocol extra privileges
    }
  )
}
 
程序启动后调用initApp。
虽然端口可以连上(client debugger可以连上),但是调试协议会失效

posted on 2024-10-20 17:27  拥剑公子  阅读(4)  评论(0编辑  收藏  举报

导航