a GUI for prismedia, using Electron.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

  1. /*
  2. ** Nuxt
  3. */
  4. const http = require('http')
  5. const { Nuxt, Builder } = require('nuxt')
  6. let config = require('./nuxt.config.js')
  7. config.rootDir = __dirname // for electron-builder
  8. // Init Nuxt.js
  9. const nuxt = new Nuxt(config)
  10. const builder = new Builder(nuxt)
  11. const server = http.createServer(nuxt.render)
  12. // Build only in dev mode
  13. if (config.dev) {
  14. builder.build().catch(err => {
  15. console.error(err) // eslint-disable-line no-console
  16. process.exit(1)
  17. })
  18. }
  19. // Listen the server
  20. server.listen()
  21. const _NUXT_URL_ = `http://localhost:${server.address().port}`
  22. console.log(`Nuxt working on ${_NUXT_URL_}`)
  23. /*
  24. ** Electron
  25. */
  26. let win = null // Current window
  27. const electron = require('electron')
  28. const path = require('path')
  29. const app = electron.app
  30. const newWin = () => {
  31. win = new electron.BrowserWindow({
  32. icon: path.join(__dirname, 'static/icon.png'),
  33. center: true,
  34. width: 1024,
  35. height: 565,
  36. minWidth: 1024,
  37. minHeight: 565,
  38. frame: false
  39. })
  40. win.on('closed', () => win = null)
  41. if (config.dev) {
  42. // Install vue dev tool and open chrome dev tools
  43. const { default: installExtension, VUEJS_DEVTOOLS } = require('electron-devtools-installer')
  44. installExtension(VUEJS_DEVTOOLS.id).then(name => {
  45. console.log(`Added Extension: ${name}`)
  46. win.webContents.openDevTools({ detach: true })
  47. }).catch(err => console.log('An error occurred: ', err))
  48. // Wait for nuxt to build
  49. nuxt.hook('build:done', () => {
  50. win.loadURL(_NUXT_URL_)
  51. })
  52. } else { return win.loadURL(_NUXT_URL_) }
  53. }
  54. app.on('ready', newWin)
  55. app.on('window-all-closed', () => app.quit())
  56. app.on('activate', () => win === null && newWin())