config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Electron 应用配置
  2. const path = require('path')
  3. // 根目录 = 本文件所在目录(开发时在仓库根;打包后在 exe 同目录,且 __dirname 含 app.asar 时用 exe 目录)
  4. const projectRoot = (typeof __dirname !== 'undefined' && __dirname.includes('app.asar'))
  5. ? path.dirname(process.execPath)
  6. : __dirname
  7. // Node.js:便携版固定 nodejs/node
  8. const nodeDir = path.join(projectRoot, 'nodejs', 'node')
  9. // Python:嵌入式解释器在 python/py(依赖装入 py/Lib/site-packages,不使用虚拟环境)
  10. const pythonDir = path.join(projectRoot, 'python', 'py')
  11. const isWin = process.platform === 'win32'
  12. module.exports = {
  13. // 项目根目录:开发时为仓库根,打包后由 package/pack-resources/electron-pack-win 流程写入 exe 同目录的 config.js
  14. projectRoot,
  15. // 窗口配置
  16. window: {
  17. width: 800,
  18. height: 600,
  19. autoHideMenuBar: true,
  20. },
  21. devTools: {
  22. enabled: false,
  23. },
  24. vite: {
  25. port: 9527,
  26. host: 'localhost',
  27. },
  28. pythonPath: {
  29. path: pythonDir,
  30. },
  31. pythonDir,
  32. adbPath: {
  33. path: path.join(projectRoot, 'lib/scrcpy-adb/adb.exe'),
  34. },
  35. nodejsPath: path.join(nodeDir, isWin ? 'node.exe' : 'node'),
  36. nodeDir,
  37. npmCmdPath: path.join(nodeDir, isWin ? 'npm.cmd' : 'npm'),
  38. npmCliPath: path.join(nodeDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
  39. }