config.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict';
  2. const path = require('path');
  3. const dayjs = require('dayjs');
  4. const storage = require('./storage');
  5. const config = {
  6. log: {
  7. file: {
  8. fileName: path.normalize('./logs/electron-' + dayjs().format('YYYY-MM-DD') + '.log'),
  9. level: 'silly', // error, warn, info, verbose, debug, silly
  10. format: '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}] {text}',
  11. maxSize: '1048576' // 1048576 (1mb) by default.
  12. }
  13. },
  14. windowsOption: {
  15. width: 800,
  16. height: 600,
  17. minWidth: 800,
  18. minHeight: 600,
  19. webPreferences: {
  20. //webSecurity: false,
  21. nodeIntegration: true,
  22. preload: path.join(__dirname, 'preload.js')
  23. },
  24. //frame: false,
  25. //titleBarStyle: 'hidden'
  26. },
  27. egg: {
  28. title: 'electron-egg',
  29. env: 'prod',
  30. port: 7068,
  31. hostname: '0.0.0.0',
  32. workers: 1
  33. }
  34. }
  35. exports.get = function (flag = '') {
  36. console.log('config flag:', flag);
  37. if (flag === 'log') {
  38. return config.log;
  39. }
  40. if (flag === 'windowsOption') {
  41. return config.windowsOption;
  42. }
  43. if (flag === 'web-egg') {
  44. return config.egg;
  45. }
  46. if (flag === 'egg') {
  47. const eggConfig = storage.getEggConfig();
  48. console.log('eggConfig:', eggConfig);
  49. if (eggConfig.port) {
  50. console.log('eggConfig.port:', eggConfig.port);
  51. config.egg.port = eggConfig.port;
  52. }
  53. return config.egg;
  54. }
  55. return {};
  56. };
  57. exports = module.exports;