获取配置文件对象;该对象根据当前环境变量的不同,返回的结果不同。

使用方法:

  1. this.app.config

属性说明:

env

环境变量,local-本地,prod-生产环境

name

应用名称

baseDir

框架中electron目录路径。如果使用加密功能,打包后路径为 ./public/electron

HOME

APP根目录路径

homeDir

APP根目录路径

root

APP在操作系统中的数据目录,根据环境变量而变化

appUserDataDir

APP在操作系统中的数据目录,与环境变量无关

userHome

操作系统用户的home目录

appVersion

APP版本号

isPackaged

APP是否已经打包

execDir

APP安装后,可执行程序(exe、dmg、dep)的根目录

logger

APP日志配置

socketServer

内置socket服务配置

developmentMode

APP类型配置

openDevTools

开发者工具栏

openAppMenu

APP顶部菜单栏

loadingPage

loading页面

windowsOption

主窗口属性配置

remoteUrl

APP远程类型(web)

autoUpdate

自动升级配置

awakeProtocol

唤醒协议配置

tray

托盘栏配置

testConfig

用户自定义配置

config值举例:

  1. # 值
  2. {
  3. "env": "local",
  4. "name": "ee",
  5. "baseDir": "D:\\www\\xing\\ee\\electron",
  6. "HOME": "D:\\www\\xing\\ee",
  7. "rundir": "D:\\www\\xing\\ee\\electron\\run",
  8. "dump": {
  9. "ignore": {}
  10. },
  11. "homeDir": "D:\\www\\xing\\ee",
  12. "root": "D:\\www\\xing\\ee",
  13. "appUserDataDir": "C:\\Users\\gaoshuaixing\\AppData\\Roaming\\ee",
  14. "userHome": "C:\\Users\\gaoshuaixing",
  15. "appVersion": "2.0.3",
  16. "isPackaged": false,
  17. "execDir": "D:\\www\\xing\\ee",
  18. "logger": {
  19. "dir": "D:\\www\\xing\\ee\\logs",
  20. "encoding": "utf8",
  21. "env": "local",
  22. "level": "INFO",
  23. "consoleLevel": "INFO",
  24. "disableConsoleAfterReady": false,
  25. "outputJSON": false,
  26. "buffer": true,
  27. "appLogName": "ee-2022-03-04.log",
  28. "coreLogName": "ee-core.log",
  29. "agentLogName": "ee-agent.log",
  30. "errorLogName": "ee-error-2022-03-04.log",
  31. "coreLogger": {},
  32. "allowDebugAtProd": false,
  33. "enablePerformanceTimer": false,
  34. "type": "application"
  35. },
  36. "httpclient": {
  37. "enableDNSCache": false,
  38. "dnsCacheLookupInterval": 10000,
  39. "dnsCacheMaxLength": 1000,
  40. "request": {
  41. "timeout": 5000
  42. },
  43. "httpAgent": {
  44. "keepAlive": true,
  45. "freeSocketTimeout": 4000,
  46. "maxSockets": 9007199254740991,
  47. "maxFreeSockets": 256
  48. },
  49. "httpsAgent": {
  50. "keepAlive": true,
  51. "freeSocketTimeout": 4000,
  52. "maxSockets": 9007199254740991,
  53. "maxFreeSockets": 256
  54. }
  55. },
  56. "socketServer": {
  57. "port": 7070,
  58. "isDynamic": false
  59. },
  60. "developmentMode": {
  61. "default": "vue",
  62. "mode": {
  63. "vue": {
  64. "hostname": "localhost",
  65. "port": 8080
  66. },
  67. "react": {
  68. "hostname": "localhost",
  69. "port": 3000
  70. },
  71. "html": {
  72. "hostname": "localhost",
  73. "indexPage": "index.html"
  74. }
  75. }
  76. },
  77. "openDevTools": false,
  78. "openAppMenu": true,
  79. "loadingPage": true,
  80. "windowsOption": {
  81. "width": 980,
  82. "height": 650,
  83. "minWidth": 800,
  84. "minHeight": 650,
  85. "webPreferences": {
  86. "contextIsolation": false,
  87. "nodeIntegration": true
  88. },
  89. "frame": true
  90. },
  91. "remoteUrl": {
  92. "enable": false,
  93. "url": "https://discuz.chat/"
  94. },
  95. "autoUpdate": {
  96. "windows": false,
  97. "macOS": false,
  98. "linux": false,
  99. "options": {
  100. "provider": "generic",
  101. "url": "http://kodo.qiniu.com/"
  102. },
  103. "force": false
  104. },
  105. "awakeProtocol": {
  106. "protocol": "ee",
  107. "args": []
  108. },
  109. "tray": {
  110. "title": "EE程序",
  111. "icon": "/public/images/tray_logo.png"
  112. },
  113. "testConfig": {
  114. "login": "http://local.com/api/login"
  115. },
  116. "coreMiddlewares": [],
  117. "coreMiddleware": [],
  118. "appMiddlewares": [],
  119. "appMiddleware": []
  120. }