跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[Electron] 请教一下, electron 打包的安装包,包含的 bin 文件无法执行问题

发表于

请教一下各位大佬一个 electron 问题: 在 mac 上打包 electron(使用 electron-vite + react + python),其中将后端 python api 服务打包为 main.dist 文件(里面包含 main.bin )

开发环境: 一切都正常,main.bin 文件正常启动;

打包并安装到 mac 后:

  • 没有反应
  • 但是用终端在 app 路径下的 resources 里面执行该 bin 文件又可以正常启动。

不知道是什么问题,问 AI 改了好多遍还是这样,请教下大家帮忙看下,谢谢了。

下面是 main 下的该部分代码:

  let pythonBinPath: string;
  if (app.isPackaged) {
    // 打包后的路径
    pythonBinPath = join(process.resourcesPath,'main.dist', 'main.bin');
  } else {
    // 开发模式下的路径
    pythonBinPath = join(app.getAppPath(), 'resources/main.dist', 'main.bin');
  }

  console.log('Python binary path:', pythonBinPath);

  // 尝试设置 Python 可执行文件的权限
  try {
    chmodSync(pythonBinPath, '755');
  } catch (error) {
    console.error(`设置 Python 可执行文件权限失败: ${error}`);
    dialog.showErrorBox('权限错误', `设置 Python 可执行文件权限失败: ${error}`);
    return;
  }

  // 启动 Python 进程
  pythonProcess = spawn(pythonBinPath);

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.