测试 用electron + springboot 构建桌面应用
he wei
2022-03-21 c036bed301fcd484e7ba7f7f931efb85831d11fd
src/main/demo/src/background.js
@@ -21,8 +21,11 @@
    let path = pathArr.join('\\');
    // require('child_process').spawn('cmd.exe', ['/c', 'echo '+path+' > 123.txt']);
    serverProcess = require('child_process').spawn('cmd.exe', ['/c', 'testElectronJ.bat'], {
      cwd: path + '/bundled/bin'
    // serverProcess = require('child_process').spawn('cmd.exe', ['/c', 'testElectronJ.bat'], {
    //   cwd: path + '/bundled/bin'
    // })
    serverProcess = require('child_process').spawn('app_x64.exe', {
      cwd: path + '/bundled'
    })
  } else {
    const chmod = require('child_process').spawn('chmod', ['+x', app.getAppPath() + "/bin/testElectronJ"]);
@@ -67,10 +70,11 @@
  if (process.env.WEBPACK_DEV_SERVER_URL) {
    // Load the url of the dev server if in development mode
    await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
    // if (!process.env.IS_TEST) win.webContents.openDevTools()
    if (!process.env.IS_TEST) win.webContents.openDevTools()
  } else {
    createProtocol('app')
    // Load the index.html when not in development
    // win.webContents.openDevTools();
    win.loadURL('app://./index.html')
  }
}
@@ -123,6 +127,9 @@
  })
}
// 禁用本地缓存
// app.commandLine.appendSwitch("--disable-http-cache");
app.on('ready', async () => {
  // require('child_process').spawn('cmd.exe', ['/c', 'echo ready >> 123.txt'])
  startUp()