基础
# 基础 config 文件
# 位置
./electron/config/
# 说明
config.default.js // 默认配置文件,开发环境和生产环境都会加载
config.local.js // 开发环境配置文件,追加和覆盖default配置文件
config.prod.js // 生产环境配置文件,追加和覆盖default配置文件
# 属性说明
# 开发者工具
openDevTools: boolean | object;
// 说明
false, // false: 不开启,true: 开启
{
mode: 'detach', // left, right, bottom, undocked, detach
activate: true, // 是否将打开的开发者工具窗口置于前台
title: '', // A title for the DevTools window (only in undocked or detach mode).
}
# 单应用
singleLock = true; // 只能打开一个应用实例
# 主窗口
// 更多属性,见文档:https://www.electronjs.org/zh/docs/latest/api/browser-window#new-browserwindowoptions
windowsOption = {
title: 'EE框架', // 软件顶部或左上角名称(会被 html中的 title标签覆盖)
width: 980, // 软件窗口宽度
height: 650, // 软件窗口高度
minWidth: 800, // 软件窗口最小宽度
minHeight: 650, // 软件窗口最小高度
webPreferences: {
//webSecurity: false, // 如果需要跨域,请打开注释
contextIsolation: false, // 设置此项为false后,才可在渲染进程中使用electron api
nodeIntegration: true, // node模块
//preload: path.join(getBaseDir(), 'preload', 'bridge.js'),
},
frame: true,
show: true,
icon: path.join(getBaseDir(), 'public', 'images', 'logo-32.png'),
};
# 业务日志
logger = {
encoding: 'utf8',
dir: getLogDir(),
level: 'INFO',
outputJSON: false,
buffer: true,
enablePerformanceTimer: false,
rotator: 'day', // day:按天切割
appLogName: 'ee.log',
coreLogName: 'ee-core.log',
errorLogName: 'ee-error.log'
}
# 远程web地址
remoteUrl = {
enable: false, // 是否启用
url: 'http://electron-egg.kaka996.com/' // Any web url
};
# 内置socket服务
# 第三方软件,可通过socket-client监听端口,与ee框架通信
socketServer = {
enable: false, // 是否启用
port: 7070, // 默认端口
isDynamic: false, // 如果值为false,框架默认使用port端口(如果默认端口被使用,则随机获取一个);如果为true,默认端口无效,框架随机生成
path: "/socket.io/", // 默认路径名称
connectTimeout: 45000, // 客户端连接超时时间
pingTimeout: 30000, // 心跳检测超时时间
pingInterval: 25000, // 心跳检测间隔
maxHttpBufferSize: 1e8, // 每条消息的数据最大值 1M
transports: ["polling", "websocket"], // http轮询和websocket
cors: {
origin: true, // http协议时,要设置允许跨域
},
channel: 'socket-channel' // 自定义通道名称,默认socket-channel
};
# 内置http服务
# 可在前端、浏览器、终端命令中,访问EE程序
httpServer = {
enable: false, // 是否启用
https: {
enable: false,
key: '/public/ssl/localhost+1.key', // key文件
cert: '/public/ssl/localhost+1.pem' // cert文件
},
host: '127.0.0.1',
port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
cors: {
origin: "*" // 跨域
},
body: {
multipart: true,
formidable: {
keepExtensions: true
}
},
filterRequest: {
uris: [
'favicon.ico' // 要过滤的请求uri
],
returnData: '' // 任意数据类型
}
};
# 主进程
mainServer = {
// 协议:file://
protocol: 'file://',
// 前端资源入口文件
indexPath: '/public/dist/index.html',
// 兼容electron参数
// https://www.electronjs.org/zh/docs/latest/api/browser-window#winloadurlurl-options
options: {},
// 加载一个loading页,一般不用开启
loadingPage: '/public/html/loading.html',
// 接管。如果想加载一个go web程序,来替代 protocol
takeover: 'go',
channelSeparator: '/', // 通信频道路径分割符,v4 版本后,默认为 /
};
# 跨语言服务
运行其它语言的可执行程序。
cross = {
// 自定义服务名
go: {
// 是否开启
enable: true,
// 可执行程序名
name: 'goapp',
// 参数
args: ['--port=7073'],
// 可执行程序退出时,是否退出整个桌面程序
appExit: true,
}
};
# 异常捕获
进程捕获异常后,是否退出。
exception = {
// 主进程
mainExit: false,
// jobs 子进程
childExit: false,
};
# jobs 任务
jobs = {
// 是否 打印/记录 进程间通信的消息log
messageLog: true
};
上次更新: 2025/04/10, 03:07:49