config.default.js 4.5 KB

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