config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. 'use strict';
  2. const path = require('path');
  3. const dayjs = require('dayjs');
  4. const storage = require('./lib/storage');
  5. const config = {
  6. developmentMode: {
  7. default: 'vue',
  8. mode: {
  9. vue: {
  10. hostname: 'localhost',
  11. port: 8080
  12. },
  13. react: {
  14. hostname: 'localhost',
  15. port: 3000
  16. },
  17. ejs: {
  18. hostname: 'localhost',
  19. port: 7068 // The same as the egg port
  20. }
  21. }
  22. },
  23. log: {
  24. file: {
  25. fileName: path.normalize(storage.getStorageDir() + 'logs/electron-' + dayjs().format('YYYY-MM-DD') + '.log'),
  26. level: 'silly', // error, warn, info, verbose, debug, silly
  27. format: '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}',
  28. maxSize: '1048576' // 1048576 (1mb) by default.
  29. }
  30. },
  31. windowsOption: {
  32. width: 980,
  33. height: 650,
  34. minWidth: 800,
  35. minHeight: 650,
  36. webPreferences: {
  37. //webSecurity: false,
  38. contextIsolation: false, // 设置此项为false后,才可在渲染进程中使用electron api
  39. nodeIntegration: true,
  40. preload: path.join(__dirname, '../preload.js')
  41. },
  42. frame: true,
  43. //titleBarStyle: 'hidden'
  44. },
  45. egg: {
  46. title: 'electron-egg', // 进程的title属性标识(默认你的应用名称-英文)
  47. env: 'prod',
  48. port: 7068,
  49. hostname: 'localhost',
  50. workers: 1
  51. },
  52. autoUpdate: {
  53. windows: false, // windows可以开启;macOs 需要签名验证
  54. macOS: false,
  55. linux: false,
  56. options: {
  57. provider: 'generic', // or github, s3, bintray
  58. url: 'http://kodo.qiniu.com/' // resource dir, end with '/'
  59. }
  60. },
  61. awakeProtocol: {
  62. protocol: 'electron-egg', // 自定义协议名(默认你的应用名称-英文)
  63. args: []
  64. },
  65. crashReport: {
  66. submitURL: "",
  67. productName: "",
  68. rateLimit: false,
  69. uploadToServer: false,
  70. ignoreSystemCrashHandler: true,
  71. compress: false
  72. },
  73. remoteUrl: {
  74. enable: false,
  75. url: 'https://discuz.chat/' // Any web url
  76. },
  77. tray: {
  78. title: 'EE程序', // 托盘显示标题
  79. icon: '/asset/images/tray_logo.png' // 托盘图标
  80. }
  81. }
  82. exports.get = function (flag = '', env = 'prod') {
  83. if (flag === 'egg') {
  84. const eggConfig = storage.getEggConfig();
  85. if (env === 'prod' && eggConfig.port) {
  86. config.egg.port = eggConfig.port;
  87. }
  88. return config.egg;
  89. }
  90. if (flag in config) {
  91. return config[flag];
  92. }
  93. return {};
  94. };
  95. exports = module.exports;