config.default.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. */
  135. config.autoUpdate = {
  136. windows: false, // windows平台
  137. macOS: false, // macOs 需要签名验证
  138. linux: false, // linux平台
  139. options: {
  140. provider: 'generic', // or github, s3, bintray
  141. url: 'http://kodo.qiniu.com/' // resource dir, end with '/'
  142. },
  143. force: false, // 强制更新(运行软件时,检查新版本并后台下载安装)
  144. };
  145. /**
  146. * 被浏览器唤醒 (可选)
  147. */
  148. config.awakeProtocol = {
  149. protocol: 'ee', // 自定义协议名(默认你的应用名称-英文)
  150. args: []
  151. };
  152. /**
  153. * 托盘 (可选)
  154. */
  155. config.tray = {
  156. title: 'EE程序', // 托盘显示标题
  157. icon: '/public/images/tray_logo.png' // 托盘图标
  158. };
  159. /**
  160. * 插件功能
  161. * window 官方内置插件
  162. * example demo插件
  163. */
  164. config.addons = {
  165. // 多窗口
  166. window: {
  167. enable: true,
  168. },
  169. // java服务
  170. javaServer: {
  171. enable: true, // 是否启用,true时,启动程序时,会自动启动 build/extraResources/java-app.jar 下的 java程序
  172. port: 18080, // 端口,端口被占用时随机一个端口,并通知前端修改请求地址。
  173. jreVersion: 'jre1.8.0_201', // build/extraResources/目录下 jre 文件夹名称
  174. opt: '-server -Xms512M -Xmx512M -Xss512k -Dspring.profiles.active=prod -Dserver.port=${port} -Dlogging.file.path="${path}" ',
  175. name: 'java-app.jar' // build/extraResources/目录下 jar 名称
  176. },
  177. example: {
  178. enable: true,
  179. },
  180. };
  181. return {
  182. ...config
  183. };
  184. }