config.default.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. 'use strict';
  2. const dayjs = require('dayjs');
  3. const path = require('path');
  4. /**
  5. * 默认配置
  6. * @see https://www.yuque.com/u34495/mivcfg/guk1x0
  7. */
  8. module.exports = (appInfo) => {
  9. /**
  10. * built-in config
  11. * @type {Ee.EeAppConfig}
  12. **/
  13. const config = {};
  14. /* 应用模式配置 */
  15. config.developmentMode = {
  16. default: 'vue',
  17. mode: {
  18. vue: {
  19. hostname: 'localhost',
  20. port: 8080
  21. },
  22. react: {
  23. hostname: 'localhost',
  24. port: 3000
  25. },
  26. html: {
  27. hostname: 'localhost',
  28. indexPage: 'index.html'
  29. },
  30. }
  31. };
  32. /* 开发者工具 */
  33. config.openDevTools = false;
  34. /**
  35. * 应用程序顶部菜单
  36. * boolean | string
  37. * true, false, 'dev-show'(dev环境显示,prod环境隐藏)
  38. */
  39. config.openAppMenu = 'dev-show';
  40. /**
  41. * 主窗口
  42. */
  43. config.windowsOption = {
  44. title: 'EE框架',
  45. width: 980,
  46. height: 650,
  47. minWidth: 800,
  48. minHeight: 650,
  49. webPreferences: {
  50. //webSecurity: false, // 跨域问题 -> 打开注释
  51. contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
  52. nodeIntegration: true,
  53. //preload: path.join(appInfo.baseDir, 'preload', 'bridge.js'),
  54. },
  55. frame: true,
  56. show: true,
  57. icon: path.join(appInfo.home, 'public', 'images', 'logo-32.png'),
  58. //backgroundColor: '#000000'
  59. //titleBarStyle: 'hidden'
  60. };
  61. /* ee框架日志 */
  62. config.logger = {
  63. appLogName: `ee-${dayjs().format('YYYY-MM-DD')}.log`,
  64. errorLogName: `ee-error-${dayjs().format('YYYY-MM-DD')}.log`
  65. }
  66. /* 远程web地址 (可选) */
  67. config.remoteUrl = {
  68. enable: false, // 是否启用
  69. url: 'https://discuz.chat/' // Any web url
  70. };
  71. /* 内置socket服务 */
  72. config.socketServer = {
  73. enable: false, // 是否启用
  74. port: 7070, // 默认端口(如果端口被使用,则随机获取一个)
  75. path: "/socket.io/", // 默认路径名称
  76. connectTimeout: 45000, // 客户端连接超时时间
  77. pingTimeout: 30000, // 心跳检测超时时间
  78. pingInterval: 25000, // 心跳检测间隔
  79. maxHttpBufferSize: 1e8, // 每条消息的数据最大值 1M
  80. transports: ["polling", "websocket"], // http轮询和websocket
  81. cors: {
  82. origin: true, // http协议时,要设置允许跨域
  83. }
  84. };
  85. /* 内置http服务 */
  86. config.httpServer = {
  87. enable: false, // 是否启用
  88. https: {
  89. enable: false,
  90. key: '/public/ssl/localhost+1.key', // key文件
  91. cert: '/public/ssl/localhost+1.pem' // cert文件
  92. },
  93. port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
  94. cors: {
  95. origin: "*" // 跨域
  96. },
  97. body: {
  98. multipart: true,
  99. formidable: {
  100. keepExtensions: true
  101. }
  102. },
  103. filterRequest: {
  104. uris: [
  105. 'favicon.ico'
  106. ],
  107. returnData: '' // 任何数据类型
  108. }
  109. };
  110. /* 主进程 */
  111. config.mainServer = {
  112. host: '127.0.0.1',
  113. port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
  114. };
  115. /**
  116. * 硬件加速
  117. */
  118. config.hardGpu = {
  119. enable: false
  120. };
  121. /* 应用自动升级 (可选) */
  122. config.autoUpdate = {
  123. windows: false, // windows平台
  124. macOS: false, // macOs 需要签名验证
  125. linux: false, // linux平台
  126. options: {
  127. provider: 'generic', // or github, s3, bintray
  128. url: 'http://kodo.qiniu.com/' // resource dir, end with '/'
  129. },
  130. force: false, // 强制更新(运行软件时,检查新版本并后台下载安装)
  131. };
  132. /* 被浏览器唤醒 (可选) */
  133. config.awakeProtocol = {
  134. protocol: 'ee', // 自定义协议名(默认你的应用名称-英文)
  135. args: []
  136. };
  137. /* 托盘 (可选) */
  138. config.tray = {
  139. title: 'EE程序', // 托盘显示标题
  140. icon: '/public/images/tray_logo.png' // 托盘图标
  141. }
  142. return {
  143. ...config
  144. };
  145. }