config.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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',
  58. url: 'https://www.coding.net/' // resource dir
  59. },
  60. force: false, // 强制更新
  61. },
  62. awakeProtocol: {
  63. protocol: 'electron-egg', // 自定义协议名(默认你的应用名称-英文)
  64. args: []
  65. },
  66. crashReport: {
  67. submitURL: "",
  68. productName: "",
  69. rateLimit: false,
  70. uploadToServer: false,
  71. ignoreSystemCrashHandler: true,
  72. compress: false
  73. },
  74. remoteUrl: {
  75. enable: false,
  76. url: 'https://discuz.chat/' // Any web url
  77. },
  78. tray: {
  79. title: 'EE程序', // 托盘显示标题
  80. icon: '/asset/images/tray_logo.png' // 托盘图标
  81. }
  82. }
  83. exports.get = function (flag = '', env = 'prod') {
  84. if (flag === 'egg') {
  85. const eggConfig = storage.getEggConfig();
  86. if (env === 'prod' && eggConfig.port) {
  87. config.egg.port = eggConfig.port;
  88. }
  89. return config.egg;
  90. }
  91. if (flag in config) {
  92. return config[flag];
  93. }
  94. return {};
  95. };
  96. exports = module.exports;