| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- // Electron 应用配置
- const path = require('path')
- // 根目录 = 本文件所在目录(开发时在仓库根;打包后在 exe 同目录,且 __dirname 含 app.asar 时用 exe 目录)
- const projectRoot = (typeof __dirname !== 'undefined' && __dirname.includes('app.asar'))
- ? path.dirname(process.execPath)
- : __dirname
- // Node.js:便携版固定 nodejs/node
- const nodeDir = path.join(projectRoot, 'nodejs', 'node')
- const isWin = process.platform === 'win32'
- // Python:嵌入式解释器在 python/py(依赖装入 py/Lib/site-packages,不使用虚拟环境)
- const pythonDir = path.join(projectRoot, 'python', 'py')
- /** 解释器可执行文件:业务代码请通过 nodejs/python-exe-from-config 或此字段获取,禁止自行拼路径 */
- const pythonExePath = path.join(pythonDir, isWin ? 'python.exe' : 'python')
- module.exports = {
- // 项目根目录:开发时为仓库根,打包后由 package/pack-resources/electron-pack-win 流程写入 exe 同目录的 config.js
- projectRoot,
- // 窗口配置
- window: {
- width: 800,
- height: 600,
- autoHideMenuBar: true,
- },
- devTools: {
- enabled: false,
- },
- vite: {
- port: 9527,
- host: 'localhost',
- },
- pythonPath: {
- path: pythonDir,
- },
- pythonDir,
- pythonExePath,
- adbPath: {
- path: path.join(projectRoot, 'lib/scrcpy-adb/adb.exe'),
- },
- nodejsPath: path.join(nodeDir, isWin ? 'node.exe' : 'node'),
- nodeDir,
- npmCmdPath: path.join(nodeDir, isWin ? 'npm.cmd' : 'npm'),
- npmCliPath: path.join(nodeDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
- }
|