config.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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: true, // windows可以开启;macOs 需要签名验证
  54. macOS: false,
  55. linux: false,
  56. options: {
  57. provider: 'generic',
  58. url: 'https://kaka996.coding.net/p/resource/d/tx-resource2/git/raw/master/ee' // resource dir
  59. },
  60. force: false, // 强制更新
  61. autoDownload: false, // 是否自动下载
  62. },
  63. awakeProtocol: {
  64. protocol: 'electron-egg', // 自定义协议名(默认你的应用名称-英文)
  65. args: []
  66. },
  67. crashReport: {
  68. submitURL: "",
  69. productName: "",
  70. rateLimit: false,
  71. uploadToServer: false,
  72. ignoreSystemCrashHandler: true,
  73. compress: false
  74. },
  75. remoteUrl: {
  76. enable: false,
  77. url: 'https://discuz.chat/' // Any web url
  78. },
  79. tray: {
  80. title: 'EE程序', // 托盘显示标题
  81. icon: '/asset/images/tray_logo.png' // 托盘图标
  82. }
  83. }
  84. exports.get = function (flag = '', env = 'prod') {
  85. if (flag === 'egg') {
  86. const eggConfig = storage.getEggConfig();
  87. if (env === 'prod' && eggConfig.port) {
  88. config.egg.port = eggConfig.port;
  89. }
  90. return config.egg;
  91. }
  92. if (flag in config) {
  93. return config[flag];
  94. }
  95. return {};
  96. };
  97. exports = module.exports;