mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 03:52:07 +08:00
release: v4
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[](https://gitee.com/dromara/electron-egg/stargazers)
|
||||
|
||||
<div align=center>
|
||||
<h3>🎉🎉🎉 ElectronEgg V3.14.0已发布! 🎉🎉🎉</h3>
|
||||
<h3>🎉🎉🎉 ElectronEgg v4.0.0 已发布! 🎉🎉🎉</h3>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
## 📺 特点
|
||||
- 🍩 **为什么使用?** 桌面软件(办公方向、 个人工具),仍然是未来十几年PC端需求之一,提高工作效率
|
||||
- 🍉 **简单:** 只需懂 JavaScript
|
||||
- 🍉 **简单:** 支持 js、ts
|
||||
- 🍑 **愿景:** 所有开发者都能学会桌面软件研发
|
||||
- 🍰 **gitee:** https://gitee.com/dromara/electron-egg **5200+**
|
||||
- 🍨 **github:** https://github.com/dromara/electron-egg **1900+**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[](https://gitee.com/dromara/electron-egg/stargazers)
|
||||
|
||||
<div align=center>
|
||||
<h3>🎉🎉🎉 ElectronEgg V3.15.0已发布! 🎉🎉🎉</h3>
|
||||
<h3>🎉🎉🎉 ElectronEgg v4.0.0 已发布! 🎉🎉🎉</h3>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
## 📺 特点
|
||||
- 🍩 **为什么使用?** 桌面软件(办公方向、 个人工具),仍然是未来十几年PC端需求之一,提高工作效率
|
||||
- 🍉 **简单:** 只需懂 JavaScript
|
||||
- 🍉 **简单:** 支持 js、ts
|
||||
- 🍑 **愿景:** 所有开发者都能学会桌面软件研发
|
||||
- 🍰 **gitee:** https://gitee.com/dromara/electron-egg **5200+**
|
||||
- 🍨 **github:** https://github.com/dromara/electron-egg **1900+**
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
chrome应用商店ctx文件,解压后,放置在此目录中,打包时会将资源加入安装包内。
|
||||
195
cmd/bin.js
Normal file
195
cmd/bin.js
Normal file
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* ee-bin 配置
|
||||
* 仅适用于开发环境
|
||||
*/
|
||||
module.exports = {
|
||||
/**
|
||||
* development serve ("frontend" "electron" )
|
||||
* ee-bin dev
|
||||
*/
|
||||
dev: {
|
||||
frontend: {
|
||||
directory: './frontend',
|
||||
cmd: 'npm',
|
||||
args: ['run', 'dev'],
|
||||
port: 8080,
|
||||
},
|
||||
electron: {
|
||||
directory: './',
|
||||
cmd: 'electron',
|
||||
args: ['.', '--env=local'],
|
||||
watch: true,
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 构建
|
||||
* ee-bin build
|
||||
*/
|
||||
build: {
|
||||
frontend: {
|
||||
directory: './frontend',
|
||||
cmd: 'npm',
|
||||
args: ['run', 'build'],
|
||||
},
|
||||
electron: {
|
||||
type: 'javascript',
|
||||
bundleType: 'copy'
|
||||
},
|
||||
win64: {
|
||||
cmd: 'electron-builder',
|
||||
directory: './',
|
||||
args: ['--config=./cmd/builder.json', '-w=nsis', '--x64'],
|
||||
},
|
||||
win32: {
|
||||
args: ['--config=./cmd/builder.json', '-w=nsis', '--ia32'],
|
||||
},
|
||||
win_e: {
|
||||
args: ['--config=./cmd/builder.json', '-w=portable', '--x64'],
|
||||
},
|
||||
win_7z: {
|
||||
args: ['--config=./cmd/builder.json', '-w=7z', '--x64'],
|
||||
},
|
||||
mac: {
|
||||
args: ['--config=./cmd/builder-mac.json', '-m'],
|
||||
},
|
||||
mac_arm64: {
|
||||
args: ['--config=./cmd/builder-mac-arm64.json', '-m', '--arm64'],
|
||||
},
|
||||
linux: {
|
||||
args: ['--config=./cmd/builder-linux.json', '-l=deb', '--x64'],
|
||||
},
|
||||
linux_arm64: {
|
||||
args: ['--config=./cmd/builder-linux.json', '-l=deb', '--arm64'],
|
||||
},
|
||||
go_w: {
|
||||
directory: './go',
|
||||
cmd: 'go',
|
||||
args: ['build', '-o=../build/extraResources/goapp.exe'],
|
||||
},
|
||||
go_m: {
|
||||
directory: './go',
|
||||
cmd: 'go',
|
||||
args: ['build', '-o=../build/extraResources/goapp'],
|
||||
},
|
||||
go_l: {
|
||||
directory: './go',
|
||||
cmd: 'go',
|
||||
args: ['build', '-o=../build/extraResources/goapp'],
|
||||
},
|
||||
python: {
|
||||
directory: './python',
|
||||
cmd: 'python',
|
||||
args: ['./setup.py', 'build'],
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 移动资源
|
||||
* ee-bin move
|
||||
*/
|
||||
move: {
|
||||
frontend_dist: {
|
||||
src: './frontend/dist',
|
||||
dest: './public/dist'
|
||||
},
|
||||
go_static: {
|
||||
src: './frontend/dist',
|
||||
dest: './go/public/dist'
|
||||
},
|
||||
go_config: {
|
||||
src: './go/config',
|
||||
dest: './go/public/config'
|
||||
},
|
||||
go_package: {
|
||||
src: './package.json',
|
||||
dest: './go/public/package.json'
|
||||
},
|
||||
go_images: {
|
||||
src: './public/images',
|
||||
dest: './go/public/images'
|
||||
},
|
||||
python_dist: {
|
||||
src: './python/dist',
|
||||
dest: './build/extraResources/py'
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* 预发布模式(prod)
|
||||
* ee-bin start
|
||||
*/
|
||||
start: {
|
||||
directory: './',
|
||||
cmd: 'electron',
|
||||
args: ['.', '--env=prod']
|
||||
},
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
encrypt: {
|
||||
frontend: {
|
||||
type: 'none',
|
||||
files: [
|
||||
'./public/dist/**/*.(js|json)',
|
||||
],
|
||||
cleanFiles: ['./public/dist'],
|
||||
confusionOptions: {
|
||||
compact: true,
|
||||
stringArray: true,
|
||||
stringArrayEncoding: ['none'],
|
||||
stringArrayCallsTransform: true,
|
||||
numbersToExpressions: true,
|
||||
target: 'browser',
|
||||
}
|
||||
},
|
||||
electron: {
|
||||
type: 'confusion',
|
||||
files: [
|
||||
'./public/electron/**/*.(js|json)',
|
||||
],
|
||||
cleanFiles: ['./public/electron'],
|
||||
confusionOptions: {
|
||||
compact: true,
|
||||
stringArray: true,
|
||||
stringArrayEncoding: ['rc4'],
|
||||
deadCodeInjection: false,
|
||||
stringArrayCallsTransform: true,
|
||||
numbersToExpressions: true,
|
||||
target: 'node',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 执行自定义命令
|
||||
* ee-bin exec
|
||||
*/
|
||||
exec: {
|
||||
// 单独调试,air 实现 go 热重载
|
||||
go: {
|
||||
directory: './go',
|
||||
cmd: 'air',
|
||||
args: ['-c=config/.air.toml' ],
|
||||
},
|
||||
// windows 单独调试,air 实现 go 热重载
|
||||
go_w: {
|
||||
directory: './go',
|
||||
cmd: 'air',
|
||||
args: ['-c=config/.air.windows.toml' ],
|
||||
},
|
||||
// 单独调试,以基础方式启动 go
|
||||
go2: {
|
||||
directory: './go',
|
||||
cmd: 'go',
|
||||
args: ['run', './main.go', '--env=dev','--basedir=../', '--port=7073'],
|
||||
},
|
||||
python: {
|
||||
directory: './python',
|
||||
cmd: 'python',
|
||||
args: ['./main.py', '--port=7074'],
|
||||
stdio: "inherit", // ignore
|
||||
},
|
||||
},
|
||||
};
|
||||
40
cmd/builder-linux.json
Normal file
40
cmd/builder-linux.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"productName": "ee",
|
||||
"appId": "com.bilibili.ee",
|
||||
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||
"directories": {
|
||||
"output": "out"
|
||||
},
|
||||
"asar": true,
|
||||
"files": [
|
||||
"**/*",
|
||||
"!cmd/",
|
||||
"!data/",
|
||||
"!electron/",
|
||||
"!frontend/",
|
||||
"!logs/",
|
||||
"!out/",
|
||||
"!go/",
|
||||
"!python/"
|
||||
],
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "build/extraResources",
|
||||
"to": "extraResources"
|
||||
}
|
||||
],
|
||||
"publish": [
|
||||
{
|
||||
"provider": "generic",
|
||||
"url": ""
|
||||
}
|
||||
],
|
||||
"linux": {
|
||||
"icon": "build/icons/icon.icns",
|
||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||
"target": [
|
||||
"deb"
|
||||
],
|
||||
"category": "Utility"
|
||||
}
|
||||
}
|
||||
38
cmd/builder-mac-arm64.json
Normal file
38
cmd/builder-mac-arm64.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"productName": "ee",
|
||||
"appId": "com.bilibili.ee",
|
||||
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||
"directories": {
|
||||
"output": "out"
|
||||
},
|
||||
"asar": true,
|
||||
"files": [
|
||||
"**/*",
|
||||
"!cmd/",
|
||||
"!data/",
|
||||
"!electron/",
|
||||
"!frontend/",
|
||||
"!logs/",
|
||||
"!out/",
|
||||
"!go/",
|
||||
"!python/"
|
||||
],
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "build/extraResources",
|
||||
"to": "extraResources"
|
||||
}
|
||||
],
|
||||
"publish": [
|
||||
{
|
||||
"provider": "generic",
|
||||
"url": ""
|
||||
}
|
||||
],
|
||||
"mac": {
|
||||
"icon": "build/icons/icon.icns",
|
||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||
"darkModeSupport": true,
|
||||
"hardenedRuntime": false
|
||||
}
|
||||
}
|
||||
38
cmd/builder-mac.json
Normal file
38
cmd/builder-mac.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"productName": "ee",
|
||||
"appId": "com.bilibili.ee",
|
||||
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||
"directories": {
|
||||
"output": "out"
|
||||
},
|
||||
"asar": true,
|
||||
"files": [
|
||||
"**/*",
|
||||
"!cmd/",
|
||||
"!data/",
|
||||
"!electron/",
|
||||
"!frontend/",
|
||||
"!logs/",
|
||||
"!out/",
|
||||
"!go/",
|
||||
"!python/"
|
||||
],
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "build/extraResources",
|
||||
"to": "extraResources"
|
||||
}
|
||||
],
|
||||
"publish": [
|
||||
{
|
||||
"provider": "generic",
|
||||
"url": ""
|
||||
}
|
||||
],
|
||||
"mac": {
|
||||
"icon": "build/icons/icon.icns",
|
||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||
"darkModeSupport": true,
|
||||
"hardenedRuntime": false
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,21 @@
|
||||
{
|
||||
"productName": "ee",
|
||||
"appId": "com.electron.ee",
|
||||
"copyright": "© 2025 哆啦好梦 Technology Co., Ltd.",
|
||||
"copyright": "© 2025 duola Technology Co., Ltd.",
|
||||
"directories": {
|
||||
"output": "out"
|
||||
},
|
||||
"asar": true,
|
||||
"files": [
|
||||
"**/*",
|
||||
"!cmd/",
|
||||
"!data/",
|
||||
"!electron/",
|
||||
"!frontend/",
|
||||
"!run/",
|
||||
"!logs/",
|
||||
"!data/"
|
||||
"!out/",
|
||||
"!go/",
|
||||
"!python/"
|
||||
],
|
||||
"extraResources": {
|
||||
"from": "build/extraResources/",
|
||||
@@ -26,7 +30,7 @@
|
||||
"installerHeaderIcon": "build/icons/icon.ico",
|
||||
"createDesktopShortcut": true,
|
||||
"createStartMenuShortcut": true,
|
||||
"shortcutName": "EE框架"
|
||||
"shortcutName": "ee"
|
||||
},
|
||||
"publish": [
|
||||
{
|
||||
@@ -34,12 +38,6 @@
|
||||
"url": "https://github.com/wallace5303/electron-egg"
|
||||
}
|
||||
],
|
||||
"mac": {
|
||||
"icon": "build/icons/icon.icns",
|
||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||
"darkModeSupport": true,
|
||||
"hardenedRuntime": false
|
||||
},
|
||||
"win": {
|
||||
"icon": "build/icons/icon.ico",
|
||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||
@@ -48,13 +46,5 @@
|
||||
"target": "nsis"
|
||||
}
|
||||
]
|
||||
},
|
||||
"linux": {
|
||||
"icon": "build/icons/icon.icns",
|
||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||
"target": [
|
||||
"deb"
|
||||
],
|
||||
"category": "Utility"
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
const { app: electronApp } = require('electron');
|
||||
const { autoUpdater } = require("electron-updater");
|
||||
const is = require('ee-core/utils/is');
|
||||
const Log = require('ee-core/log');
|
||||
const Conf = require('ee-core/config');
|
||||
const CoreWindow = require('ee-core/electron/window');
|
||||
const Electron = require('ee-core/electron');
|
||||
|
||||
/**
|
||||
* 自动升级插件
|
||||
* @class
|
||||
*/
|
||||
class AutoUpdaterAddon {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
create () {
|
||||
Log.info('[addon:autoUpdater] load');
|
||||
const cfg = Conf.getValue('addons.autoUpdater');
|
||||
if ((is.windows() && cfg.windows)
|
||||
|| (is.macOS() && cfg.macOS)
|
||||
|| (is.linux() && cfg.linux))
|
||||
{
|
||||
// continue
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
// 是否检查更新
|
||||
if (cfg.force) {
|
||||
this.checkUpdate();
|
||||
}
|
||||
|
||||
const status = {
|
||||
error: -1,
|
||||
available: 1,
|
||||
noAvailable: 2,
|
||||
downloading: 3,
|
||||
downloaded: 4,
|
||||
}
|
||||
|
||||
const version = electronApp.getVersion();
|
||||
Log.info('[addon:autoUpdater] current version: ', version);
|
||||
|
||||
// 设置下载服务器地址
|
||||
let server = cfg.options.url;
|
||||
let lastChar = server.substring(server.length - 1);
|
||||
server = lastChar === '/' ? server : server + "/";
|
||||
//Log.info('[addon:autoUpdater] server: ', server);
|
||||
cfg.options.url = server;
|
||||
|
||||
// 是否后台自动下载
|
||||
autoUpdater.autoDownload = cfg.force ? true : false;
|
||||
|
||||
try {
|
||||
autoUpdater.setFeedURL(cfg.options);
|
||||
} catch (error) {
|
||||
Log.error('[addon:autoUpdater] setFeedURL error : ', error);
|
||||
}
|
||||
|
||||
autoUpdater.on('checking-for-update', () => {
|
||||
//sendStatusToWindow('正在检查更新...');
|
||||
})
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
info.status = status.available;
|
||||
info.desc = '有可用更新';
|
||||
this.sendStatusToWindow(info);
|
||||
})
|
||||
autoUpdater.on('update-not-available', (info) => {
|
||||
info.status = status.noAvailable;
|
||||
info.desc = '没有可用更新';
|
||||
this.sendStatusToWindow(info);
|
||||
})
|
||||
autoUpdater.on('error', (err) => {
|
||||
let info = {
|
||||
status: status.error,
|
||||
desc: err
|
||||
}
|
||||
this.sendStatusToWindow(info);
|
||||
})
|
||||
autoUpdater.on('download-progress', (progressObj) => {
|
||||
let percentNumber = parseInt(progressObj.percent);
|
||||
let totalSize = this.bytesChange(progressObj.total);
|
||||
let transferredSize = this.bytesChange(progressObj.transferred);
|
||||
let text = '已下载 ' + percentNumber + '%';
|
||||
text = text + ' (' + transferredSize + "/" + totalSize + ')';
|
||||
|
||||
let info = {
|
||||
status: status.downloading,
|
||||
desc: text,
|
||||
percentNumber: percentNumber,
|
||||
totalSize: totalSize,
|
||||
transferredSize: transferredSize
|
||||
}
|
||||
Log.info('[addon:autoUpdater] progress: ', text);
|
||||
this.sendStatusToWindow(info);
|
||||
})
|
||||
autoUpdater.on('update-downloaded', (info) => {
|
||||
info.status = status.downloaded;
|
||||
info.desc = '下载完成';
|
||||
this.sendStatusToWindow(info);
|
||||
|
||||
// 托盘插件默认会阻止窗口关闭,这里设置允许关闭窗口
|
||||
Electron.extra.closeWindow = true;
|
||||
|
||||
autoUpdater.quitAndInstall();
|
||||
// const mainWindow = CoreWindow.getMainWindow();
|
||||
// if (mainWindow) {
|
||||
// mainWindow.destroy()
|
||||
// }
|
||||
// electronApp.appQuit()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查更新
|
||||
*/
|
||||
checkUpdate () {
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载更新
|
||||
*/
|
||||
download () {
|
||||
autoUpdater.downloadUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 向前端发消息
|
||||
*/
|
||||
sendStatusToWindow(content = {}) {
|
||||
const textJson = JSON.stringify(content);
|
||||
const channel = 'app.updater';
|
||||
const win = CoreWindow.getMainWindow();
|
||||
win.webContents.send(channel, textJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位转换
|
||||
*/
|
||||
bytesChange (limit) {
|
||||
let size = "";
|
||||
if(limit < 0.1 * 1024){
|
||||
size = limit.toFixed(2) + "B";
|
||||
}else if(limit < 0.1 * 1024 * 1024){
|
||||
size = (limit/1024).toFixed(2) + "KB";
|
||||
}else if(limit < 0.1 * 1024 * 1024 * 1024){
|
||||
size = (limit/(1024 * 1024)).toFixed(2) + "MB";
|
||||
}else{
|
||||
size = (limit/(1024 * 1024 * 1024)).toFixed(2) + "GB";
|
||||
}
|
||||
|
||||
let sizeStr = size + "";
|
||||
let index = sizeStr.indexOf(".");
|
||||
let dou = sizeStr.substring(index + 1 , index + 3);
|
||||
if(dou == "00"){
|
||||
return sizeStr.substring(0, index) + sizeStr.substring(index + 3, index + 5);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
AutoUpdaterAddon.toString = () => '[class AutoUpdaterAddon]';
|
||||
module.exports = AutoUpdaterAddon;
|
||||
@@ -1,67 +0,0 @@
|
||||
const { app: electronApp } = require('electron');
|
||||
const Log = require('ee-core/log');
|
||||
const Conf = require('ee-core/config');
|
||||
|
||||
/**
|
||||
* 唤醒插件
|
||||
* @class
|
||||
*/
|
||||
class AwakenAddon {
|
||||
|
||||
constructor() {
|
||||
this.protocol = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
create () {
|
||||
Log.info('[addon:awaken] load');
|
||||
|
||||
const cfg = Conf.getValue('addons.awaken');
|
||||
this.protocol = cfg.protocol;
|
||||
|
||||
electronApp.setAsDefaultProtocolClient(this.protocol);
|
||||
|
||||
this.handleArgv(process.argv);
|
||||
electronApp.on('second-instance', (event, argv) => {
|
||||
if (process.platform === 'win32') {
|
||||
this.handleArgv(argv)
|
||||
}
|
||||
})
|
||||
|
||||
// 仅用于macOS
|
||||
electronApp.on('open-url', (event, urlStr) => {
|
||||
this.handleUrl(urlStr)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数处理
|
||||
*/
|
||||
handleArgv(argv) {
|
||||
const offset = electronApp.isPackaged ? 1 : 2;
|
||||
const url = argv.find((arg, i) => i >= offset && arg.startsWith(this.protocol));
|
||||
this.handleUrl(url)
|
||||
}
|
||||
|
||||
/**
|
||||
* url解析
|
||||
*/
|
||||
handleUrl(awakeUrlStr) {
|
||||
if (!awakeUrlStr || awakeUrlStr.length === 0) {
|
||||
return
|
||||
}
|
||||
const {hostname, pathname, search} = new URL(awakeUrlStr);
|
||||
let awakeUrlInfo = {
|
||||
urlStr: awakeUrlStr,
|
||||
urlHost: hostname,
|
||||
urlPath: pathname,
|
||||
urlParams: search && search.slice(1)
|
||||
}
|
||||
Log.info('[addon:awaken] awakeUrlInfo:', awakeUrlInfo);
|
||||
}
|
||||
}
|
||||
|
||||
AwakenAddon.toString = () => '[class AwakenAddon]';
|
||||
module.exports = AwakenAddon;
|
||||
@@ -1,94 +0,0 @@
|
||||
const { app, session } = require('electron');
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Log = require('ee-core/log');
|
||||
|
||||
/**
|
||||
* 扩展插件 (electron自身对该功能并不完全支持,官方也不建议使用)
|
||||
* @class
|
||||
*/
|
||||
class ChromeExtensionAddon {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
async create () {
|
||||
Log.info('[addon:chromeExtension] load');
|
||||
|
||||
const extensionIds = this.getAllIds();
|
||||
for (let i = 0; i < extensionIds.length; i++) {
|
||||
await this.load(extensionIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取扩展id列表(crx解压后的目录名,即是该扩展的id)
|
||||
*/
|
||||
getAllIds () {
|
||||
const extendsionDir = this.getDirectory();
|
||||
const ids = this.getDirs(extendsionDir);
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展所在目录
|
||||
*/
|
||||
getDirectory () {
|
||||
let extensionDirPath = '';
|
||||
let variablePath = 'build'; // 打包前路径
|
||||
if (app.isPackaged) {
|
||||
variablePath = '..'; // 打包后路径
|
||||
}
|
||||
extensionDirPath = path.join(app.getAppPath(), variablePath, "extraResources", "chromeExtension");
|
||||
|
||||
return extensionDirPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载扩展
|
||||
*/
|
||||
async load (extensionId = '') {
|
||||
if (_.isEmpty(extensionId)) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
const extensionPath = path.join(this.getDirectory(), extensionId);
|
||||
Log.info('[addon:chromeExtension] extensionPath:', extensionPath);
|
||||
await session.defaultSession.loadExtension(extensionPath, { allowFileAccess: true });
|
||||
} catch (e) {
|
||||
Log.info('[addon:chromeExtension] load extension error extensionId:%s, errorInfo:%s', extensionId, e.toString());
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目录下所有文件夹
|
||||
*/
|
||||
getDirs(dir) {
|
||||
if (!dir) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const components = [];
|
||||
const files = fs.readdirSync(dir);
|
||||
files.forEach(function(item, index) {
|
||||
const stat = fs.lstatSync(dir + '/' + item);
|
||||
if (stat.isDirectory() === true) {
|
||||
components.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return components;
|
||||
};
|
||||
}
|
||||
|
||||
ChromeExtensionAddon.toString = () => '[class ChromeExtensionAddon]';
|
||||
module.exports = ChromeExtensionAddon;
|
||||
@@ -1,33 +0,0 @@
|
||||
const Log = require('ee-core/log');
|
||||
const EE = require('ee-core/ee');
|
||||
|
||||
/**
|
||||
* 安全插件
|
||||
* @class
|
||||
*/
|
||||
class SecurityAddon {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
create () {
|
||||
Log.info('[addon:security] load');
|
||||
const { CoreApp } = EE;
|
||||
const runWithDebug = process.argv.find(function(e){
|
||||
let isHasDebug = e.includes("--inspect") || e.includes("--inspect-brk") || e.includes("--remote-debugging-port");
|
||||
return isHasDebug;
|
||||
})
|
||||
|
||||
// 不允许远程调试
|
||||
if (runWithDebug) {
|
||||
Log.error('[error] Remote debugging is not allowed, runWithDebug:', runWithDebug);
|
||||
CoreApp.appQuit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SecurityAddon.toString = () => '[class SecurityAddon]';
|
||||
module.exports = SecurityAddon;
|
||||
@@ -1,72 +0,0 @@
|
||||
const { Tray, Menu } = require('electron');
|
||||
const path = require('path');
|
||||
const Ps = require('ee-core/ps');
|
||||
const Log = require('ee-core/log');
|
||||
const Electron = require('ee-core/electron');
|
||||
const CoreWindow = require('ee-core/electron/window');
|
||||
const Conf = require('ee-core/config');
|
||||
const EE = require('ee-core/ee');
|
||||
|
||||
/**
|
||||
* 托盘插件
|
||||
* @class
|
||||
*/
|
||||
class TrayAddon {
|
||||
|
||||
constructor() {
|
||||
this.tray = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建托盘
|
||||
*/
|
||||
create () {
|
||||
// 开发环境,代码热更新开启时,会导致托盘中有残影
|
||||
if (Ps.isDev() && Ps.isHotReload()) return;
|
||||
|
||||
Log.info('[addon:tray] load');
|
||||
const { CoreApp } = EE;
|
||||
const cfg = Conf.getValue('addons.tray');
|
||||
const mainWindow = CoreWindow.getMainWindow();
|
||||
|
||||
// 托盘图标
|
||||
let iconPath = path.join(Ps.getHomeDir(), cfg.icon);
|
||||
|
||||
// 托盘菜单功能列表
|
||||
let trayMenuTemplate = [
|
||||
{
|
||||
label: '显示',
|
||||
click: function () {
|
||||
mainWindow.show();
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '退出',
|
||||
click: function () {
|
||||
CoreApp.appQuit();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
// 点击关闭,最小化到托盘
|
||||
mainWindow.on('close', (event) => {
|
||||
if (Electron.extra.closeWindow == true) {
|
||||
return;
|
||||
}
|
||||
mainWindow.hide();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// 实例化托盘
|
||||
this.tray = new Tray(iconPath);
|
||||
this.tray.setToolTip(cfg.title);
|
||||
const contextMenu = Menu.buildFromTemplate(trayMenuTemplate);
|
||||
this.tray.setContextMenu(contextMenu);
|
||||
this.tray.on('double-click', () => {
|
||||
mainWindow.show()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
TrayAddon.toString = () => '[class TrayAddon]';
|
||||
module.exports = TrayAddon;
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* ee-bin 配置
|
||||
* 仅适用于开发环境
|
||||
*/
|
||||
module.exports = {
|
||||
/**
|
||||
* development serve ("frontend" "electron" )
|
||||
* ee-bin dev
|
||||
*/
|
||||
dev: {
|
||||
frontend: {
|
||||
directory: './frontend',
|
||||
cmd: 'npm',
|
||||
args: ['run', 'dev'],
|
||||
protocol: 'http://',
|
||||
hostname: 'localhost',
|
||||
port: 8080,
|
||||
indexPath: 'index.html'
|
||||
},
|
||||
electron: {
|
||||
directory: './',
|
||||
cmd: 'electron',
|
||||
args: ['.', '--env=local', '--color=always'],
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 构建
|
||||
* ee-bin build
|
||||
*/
|
||||
build: {
|
||||
frontend: {
|
||||
directory: './frontend',
|
||||
cmd: 'npm',
|
||||
args: ['run', 'build'],
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 移动资源
|
||||
* ee-bin move
|
||||
*/
|
||||
move: {
|
||||
frontend_dist: {
|
||||
dist: './frontend/dist',
|
||||
target: './public/dist'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 预发布模式(prod)
|
||||
* ee-bin start
|
||||
*/
|
||||
start: {
|
||||
directory: './',
|
||||
cmd: 'electron',
|
||||
args: ['.', '--env=prod']
|
||||
},
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
encrypt: {
|
||||
type: 'confusion',
|
||||
files: [
|
||||
'electron/**/*.(js|json)',
|
||||
'!electron/config/encrypt.js',
|
||||
'!electron/config/nodemon.json',
|
||||
'!electron/config/builder.json',
|
||||
'!electron/config/bin.json',
|
||||
],
|
||||
fileExt: ['.js'],
|
||||
confusionOptions: {
|
||||
compact: true,
|
||||
stringArray: true,
|
||||
stringArrayEncoding: ['none'],
|
||||
deadCodeInjection: false,
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 执行自定义命令
|
||||
* ee-bin exec
|
||||
*/
|
||||
exec: {
|
||||
node_v: {
|
||||
directory: './',
|
||||
cmd: 'node',
|
||||
args: ['-v'],
|
||||
},
|
||||
npm_v: {
|
||||
directory: './',
|
||||
cmd: 'npm',
|
||||
args: ['-v'],
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,179 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const { getBaseDir } = require('ee-core/ps');
|
||||
|
||||
/**
|
||||
* 默认配置
|
||||
*/
|
||||
module.exports = (appInfo) => {
|
||||
|
||||
const config = {};
|
||||
|
||||
/**
|
||||
* 开发者工具
|
||||
*/
|
||||
config.openDevTools = false;
|
||||
|
||||
/**
|
||||
* 应用程序顶部菜单
|
||||
*/
|
||||
config.openAppMenu = true;
|
||||
|
||||
/**
|
||||
* 主窗口
|
||||
*/
|
||||
config.windowsOption = {
|
||||
title: 'EE框架',
|
||||
width: 980,
|
||||
height: 650,
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
webPreferences: {
|
||||
//webSecurity: false,
|
||||
contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
|
||||
nodeIntegration: true,
|
||||
//preload: path.join(appInfo.baseDir, 'preload', 'bridge.js'),
|
||||
},
|
||||
frame: true,
|
||||
show: false,
|
||||
icon: path.join(appInfo.home, 'public', 'images', 'logo-32.png'),
|
||||
};
|
||||
|
||||
/**
|
||||
* ee框架日志
|
||||
*/
|
||||
config.logger = {
|
||||
encoding: 'utf8',
|
||||
level: 'INFO',
|
||||
outputJSON: false,
|
||||
buffer: true,
|
||||
enablePerformanceTimer: false,
|
||||
rotator: 'day',
|
||||
appLogName: 'ee.log',
|
||||
coreLogName: 'ee-core.log',
|
||||
errorLogName: 'ee-error.log'
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程模式-web地址
|
||||
*/
|
||||
config.remoteUrl = {
|
||||
enable: false,
|
||||
url: 'http://electron-egg.kaka996.com/'
|
||||
};
|
||||
|
||||
/**
|
||||
* 内置socket服务
|
||||
*/
|
||||
config.socketServer = {
|
||||
enable: false,
|
||||
port: 7070,
|
||||
path: "/socket.io/",
|
||||
connectTimeout: 45000,
|
||||
pingTimeout: 30000,
|
||||
pingInterval: 25000,
|
||||
maxHttpBufferSize: 1e8,
|
||||
transports: ["polling", "websocket"],
|
||||
cors: {
|
||||
origin: true,
|
||||
},
|
||||
channel: 'c1'
|
||||
};
|
||||
|
||||
/**
|
||||
* 内置http服务
|
||||
*/
|
||||
config.httpServer = {
|
||||
enable: false,
|
||||
https: {
|
||||
enable: false,
|
||||
key: '/public/ssl/localhost+1.key',
|
||||
cert: '/public/ssl/localhost+1.pem'
|
||||
},
|
||||
host: '127.0.0.1',
|
||||
port: 7071,
|
||||
cors: {
|
||||
origin: "*"
|
||||
},
|
||||
body: {
|
||||
multipart: true,
|
||||
formidable: {
|
||||
keepExtensions: true
|
||||
}
|
||||
},
|
||||
filterRequest: {
|
||||
uris: [
|
||||
'favicon.ico'
|
||||
],
|
||||
returnData: ''
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 主进程
|
||||
*/
|
||||
config.mainServer = {
|
||||
protocol: 'file://',
|
||||
indexPath: '/public/dist/index.html',
|
||||
};
|
||||
|
||||
/**
|
||||
* 硬件加速
|
||||
*/
|
||||
config.hardGpu = {
|
||||
enable: true
|
||||
};
|
||||
|
||||
/**
|
||||
* 异常捕获
|
||||
*/
|
||||
config.exception = {
|
||||
mainExit: false,
|
||||
childExit: true,
|
||||
rendererExit: true,
|
||||
};
|
||||
|
||||
/**
|
||||
* jobs
|
||||
*/
|
||||
config.jobs = {
|
||||
messageLog: true
|
||||
};
|
||||
|
||||
/**
|
||||
* 插件功能
|
||||
*/
|
||||
config.addons = {
|
||||
window: {
|
||||
enable: true,
|
||||
},
|
||||
tray: {
|
||||
enable: true,
|
||||
title: 'EE程序',
|
||||
icon: '/public/images/tray.png'
|
||||
},
|
||||
security: {
|
||||
enable: true,
|
||||
},
|
||||
awaken: {
|
||||
enable: true,
|
||||
protocol: 'ee',
|
||||
args: []
|
||||
},
|
||||
autoUpdater: {
|
||||
enable: true,
|
||||
windows: false,
|
||||
macOS: false,
|
||||
linux: false,
|
||||
options: {
|
||||
provider: 'generic',
|
||||
url: 'http://kodo.qiniu.com/'
|
||||
},
|
||||
force: false,
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = () => {
|
||||
return {
|
||||
...config
|
||||
};
|
||||
openDevTools: false,
|
||||
singleLock: true,
|
||||
windowsOption: {
|
||||
title: 'electron-egg',
|
||||
width: 980,
|
||||
height: 650,
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
webPreferences: {
|
||||
//webSecurity: false,
|
||||
contextIsolation: false, // false -> 可在渲染进程中使用electron的api,true->需要bridge.js(contextBridge)
|
||||
nodeIntegration: true,
|
||||
//preload: path.join(getElectronDir(), 'preload', 'bridge.js'),
|
||||
},
|
||||
frame: true,
|
||||
show: true,
|
||||
icon: path.join(getBaseDir(), 'public', 'images', 'logo-32.png'),
|
||||
},
|
||||
logger: {
|
||||
level: 'INFO',
|
||||
outputJSON: false,
|
||||
appLogName: 'ee.log',
|
||||
coreLogName: 'ee-core.log',
|
||||
errorLogName: 'ee-error.log'
|
||||
},
|
||||
remote: {
|
||||
enable: false,
|
||||
url: 'http://electron-egg.kaka996.com/'
|
||||
},
|
||||
socketServer: {
|
||||
enable: false,
|
||||
port: 7070,
|
||||
path: "/socket.io/",
|
||||
connectTimeout: 45000,
|
||||
pingTimeout: 30000,
|
||||
pingInterval: 25000,
|
||||
maxHttpBufferSize: 1e8,
|
||||
transports: ["polling", "websocket"],
|
||||
cors: {
|
||||
origin: true,
|
||||
},
|
||||
channel: 'socket-channel'
|
||||
},
|
||||
httpServer: {
|
||||
enable: false,
|
||||
https: {
|
||||
enable: false,
|
||||
key: '/public/ssl/localhost+1.key',
|
||||
cert: '/public/ssl/localhost+1.pem'
|
||||
},
|
||||
host: '127.0.0.1',
|
||||
port: 7071,
|
||||
},
|
||||
mainServer: {
|
||||
indexPath: '/public/dist/index.html',
|
||||
channelSeparator: '/',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 开发环境配置,覆盖 config.default.js
|
||||
* Development environment configuration, coverage config.default.js
|
||||
*/
|
||||
module.exports = (appInfo) => {
|
||||
const config = {};
|
||||
|
||||
/**
|
||||
* 开发者工具
|
||||
*/
|
||||
config.openDevTools = {
|
||||
mode: 'undocked'
|
||||
};
|
||||
|
||||
/**
|
||||
* 应用程序顶部菜单
|
||||
*/
|
||||
config.openAppMenu = true;
|
||||
|
||||
/**
|
||||
* jobs
|
||||
*/
|
||||
config.jobs = {
|
||||
messageLog: true
|
||||
};
|
||||
|
||||
module.exports = () => {
|
||||
return {
|
||||
...config
|
||||
openDevTools: false,
|
||||
jobs: {
|
||||
messageLog: false
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,29 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 生产环境配置,覆盖 config.default.js
|
||||
* coverage config.default.js
|
||||
*/
|
||||
module.exports = (appInfo) => {
|
||||
const config = {};
|
||||
|
||||
/**
|
||||
* 开发者工具
|
||||
*/
|
||||
config.openDevTools = false;
|
||||
|
||||
/**
|
||||
* 应用程序顶部菜单
|
||||
*/
|
||||
config.openAppMenu = false;
|
||||
|
||||
/**
|
||||
* jobs
|
||||
*/
|
||||
config.jobs = {
|
||||
messageLog: false
|
||||
};
|
||||
|
||||
module.exports = () => {
|
||||
return {
|
||||
...config
|
||||
openDevTools: false,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"watch": [
|
||||
"electron/",
|
||||
"main.js"
|
||||
],
|
||||
"ignore": [],
|
||||
"ext": "js,json",
|
||||
"verbose": true,
|
||||
"exec": "electron . --env=local --hot-reload=1",
|
||||
"restartable": "hr",
|
||||
"colours": true,
|
||||
"events": {}
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const { Controller } = require('ee-core');
|
||||
const Log = require('ee-core/log');
|
||||
const Services = require('ee-core/services');
|
||||
const { logger } = require('ee-core/log');
|
||||
const { exampleService } = require('../service/example');
|
||||
|
||||
/**
|
||||
* example
|
||||
* @class
|
||||
*/
|
||||
class ExampleController extends Controller {
|
||||
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
class ExampleController {
|
||||
|
||||
/**
|
||||
* 所有方法接收两个参数
|
||||
@@ -25,12 +19,12 @@ class ExampleController extends Controller {
|
||||
* test
|
||||
*/
|
||||
async test () {
|
||||
const result = await Services.get('example').test('electron');
|
||||
Log.info('service result:', result);
|
||||
const result = await exampleService.test('electron');
|
||||
logger.info('service result:', result);
|
||||
|
||||
return 'hello electron-egg';
|
||||
}
|
||||
}
|
||||
|
||||
ExampleController.toString = () => '[class ExampleController]';
|
||||
module.exports = ExampleController;
|
||||
|
||||
module.exports = ExampleController;
|
||||
@@ -1,50 +0,0 @@
|
||||
const { Application } = require('ee-core');
|
||||
|
||||
class Index extends Application {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
// this === eeApp;
|
||||
}
|
||||
|
||||
/**
|
||||
* core app have been loaded
|
||||
*/
|
||||
async ready () {
|
||||
// do some things
|
||||
}
|
||||
|
||||
/**
|
||||
* electron app ready
|
||||
*/
|
||||
async electronAppReady () {
|
||||
// do some things
|
||||
}
|
||||
|
||||
/**
|
||||
* main window have been loaded
|
||||
*/
|
||||
async windowReady () {
|
||||
// do some things
|
||||
// 延迟加载,无白屏
|
||||
const winOpt = this.config.windowsOption;
|
||||
if (winOpt.show == false) {
|
||||
const win = this.electron.mainWindow;
|
||||
win.once('ready-to-show', () => {
|
||||
win.show();
|
||||
win.focus();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* before app close
|
||||
*/
|
||||
async beforeClose () {
|
||||
// do some things
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Index.toString = () => '[class Index]';
|
||||
module.exports = Index;
|
||||
@@ -1,5 +0,0 @@
|
||||
const Log = require('ee-core/log');
|
||||
|
||||
exports.welcome = function () {
|
||||
Log.info('[child-process] [jobs/example/hello] welcome ! ');
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
const Job = require('ee-core/jobs/baseJobClass');
|
||||
const Log = require('ee-core/log');
|
||||
const Ps = require('ee-core/ps');
|
||||
|
||||
/**
|
||||
* example - TimerJob
|
||||
* @class
|
||||
*/
|
||||
class TimerJob extends Job {
|
||||
|
||||
constructor(params) {
|
||||
super();
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/**
|
||||
* handle()方法是必要的,且会被自动调用
|
||||
*/
|
||||
async handle () {
|
||||
Log.info("[child-process] TimerJob params: ", this.params);
|
||||
|
||||
if (Ps.isChildJob()) {
|
||||
Ps.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TimerJob.toString = () => '[class TimerJob]';
|
||||
module.exports = TimerJob;
|
||||
19
electron/main.js
Normal file
19
electron/main.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const { ElectronEgg } = require('ee-core');
|
||||
const { Lifecycle } = require('./preload/lifecycle');
|
||||
const { preload } = require('./preload');
|
||||
|
||||
// new app
|
||||
const app = new ElectronEgg();
|
||||
|
||||
// register lifecycle
|
||||
const life = new Lifecycle();
|
||||
app.register("ready", life.ready);
|
||||
app.register("electron-app-ready", life.electronAppReady);
|
||||
app.register("window-ready", life.windowReady);
|
||||
app.register("before-close", life.beforeClose);
|
||||
|
||||
// register preload
|
||||
app.register("preload", preload);
|
||||
|
||||
// run
|
||||
app.run();
|
||||
@@ -1,14 +1,16 @@
|
||||
/*************************************************
|
||||
** preload为预加载模块,该文件将会在程序启动时加载 **
|
||||
*************************************************/
|
||||
const Addon = require('ee-core/addon');
|
||||
|
||||
/**
|
||||
* 预加载模块入口
|
||||
*/
|
||||
module.exports = async () => {
|
||||
|
||||
// 示例功能模块,可选择性使用和修改
|
||||
Addon.get('tray').create();
|
||||
Addon.get('security').create();
|
||||
}
|
||||
const { logger } = require('ee-core/log');
|
||||
|
||||
function preload() {
|
||||
logger.info('[preload] load 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* 预加载模块入口
|
||||
*/
|
||||
module.exports = {
|
||||
preload
|
||||
}
|
||||
50
electron/preload/lifecycle.js
Normal file
50
electron/preload/lifecycle.js
Normal file
@@ -0,0 +1,50 @@
|
||||
'use strict';
|
||||
|
||||
const { logger } = require('ee-core/log');
|
||||
const { getConfig } = require('ee-core/config');
|
||||
const { getMainWindow } = require('ee-core/electron');
|
||||
|
||||
class Lifecycle {
|
||||
|
||||
/**
|
||||
* core app have been loaded
|
||||
*/
|
||||
async ready() {
|
||||
logger.info('[lifecycle] ready');
|
||||
}
|
||||
|
||||
/**
|
||||
* electron app ready
|
||||
*/
|
||||
async electronAppReady() {
|
||||
logger.info('[lifecycle] electron-app-ready');
|
||||
}
|
||||
|
||||
/**
|
||||
* main window have been loaded
|
||||
*/
|
||||
async windowReady() {
|
||||
logger.info('[lifecycle] window-ready');
|
||||
// 延迟加载,无白屏
|
||||
const { windowsOption } = getConfig();
|
||||
if (windowsOption.show == false) {
|
||||
const win = getMainWindow();
|
||||
win.once('ready-to-show', () => {
|
||||
win.show();
|
||||
win.focus();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* before app close
|
||||
*/
|
||||
async beforeClose() {
|
||||
logger.info('[lifecycle] before-close');
|
||||
}
|
||||
}
|
||||
Lifecycle.toString = () => '[class Lifecycle]';
|
||||
|
||||
module.exports = {
|
||||
Lifecycle
|
||||
};
|
||||
@@ -1,16 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const { Service } = require('ee-core');
|
||||
const { logger } = require('ee-core/log');
|
||||
|
||||
/**
|
||||
* 示例服务(service层为单例)
|
||||
* 示例服务
|
||||
* @class
|
||||
*/
|
||||
class ExampleService extends Service {
|
||||
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
class ExampleService {
|
||||
|
||||
/**
|
||||
* test
|
||||
@@ -21,9 +17,14 @@ class ExampleService extends Service {
|
||||
params: args
|
||||
}
|
||||
|
||||
logger.info('ExampleService obj:', obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
ExampleService.toString = () => '[class ExampleService]';
|
||||
module.exports = ExampleService;
|
||||
|
||||
module.exports = {
|
||||
ExampleService,
|
||||
exampleService: new ExampleService()
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ee",
|
||||
"version": "1.0.0",
|
||||
"version": "4.0.0",
|
||||
"scripts": {
|
||||
"dev": "vite --host --port 8080",
|
||||
"serve": "vite --host --port 8080",
|
||||
@@ -9,7 +9,7 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.2.33",
|
||||
"vue": "^3.5.12",
|
||||
"vue-router": "^4.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -18,6 +18,6 @@
|
||||
"less": "^4.1.2",
|
||||
"less-loader": "^10.2.0",
|
||||
"terser": "^5.19.1",
|
||||
"vite": "^4.4.4"
|
||||
"vite": "^5.4.11"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<template>
|
||||
<router-view/>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted } from 'vue';
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App',
|
||||
setup() {
|
||||
document.getElementById('loadingPage').remove()
|
||||
}
|
||||
onMounted(() => {
|
||||
const loadingElement = document.getElementById('loadingPage');
|
||||
if (loadingElement) {
|
||||
loadingElement.remove();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Definition of communication channels between main process and rendering process
|
||||
*/
|
||||
const ipcApiRoute = {
|
||||
test: 'controller.example.test',
|
||||
test: 'controller/example/test',
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -1,4 +1,4 @@
|
||||
const modules = import.meta.globEager('./*.vue')
|
||||
const modules = import.meta.glob('./*.vue', { eager: true })
|
||||
const map = {}
|
||||
Object.keys(modules).forEach(file => {
|
||||
const modulesName = file.replace('./', '').replace('.vue', '')
|
||||
|
||||
@@ -5,7 +5,6 @@ import components from './components/global';
|
||||
import Router from './router/index';
|
||||
|
||||
const app = createApp(App)
|
||||
app.config.productionTip = false
|
||||
|
||||
// components
|
||||
for (const i in components) {
|
||||
|
||||
@@ -11,13 +11,8 @@
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
<script setup>
|
||||
console.log("hello")
|
||||
</script>
|
||||
<style scoped>
|
||||
section {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineConfig } from 'vite'
|
||||
|
||||
import path from 'path'
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
// 项目插件
|
||||
plugins: [
|
||||
|
||||
58
package.json
58
package.json
@@ -1,40 +1,24 @@
|
||||
{
|
||||
"name": "ee",
|
||||
"version": "3.15.0",
|
||||
"version": "4.0.0",
|
||||
"description": "A fast, desktop software development framework",
|
||||
"main": "main.js",
|
||||
"main": "./public/electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "ee-bin dev",
|
||||
"build": "npm run build-frontend && npm run build-electron && ee-bin encrypt",
|
||||
"start": "ee-bin start",
|
||||
"dev-frontend": "ee-bin dev --serve=frontend",
|
||||
"dev-electron": "ee-bin dev --serve=electron",
|
||||
"build-frontend": "ee-bin build --cmds=frontend && ee-bin move --flag=frontend_dist",
|
||||
"start": "ee-bin start",
|
||||
"rd": "ee-bin move --flag=frontend_dist",
|
||||
"build-electron": "ee-bin build --cmds=electron",
|
||||
"encrypt": "ee-bin encrypt",
|
||||
"clean": "ee-bin clean",
|
||||
"icon": "ee-bin icon",
|
||||
"reload": "nodemon --config ./electron/config/nodemon.json",
|
||||
"rebuild": "electron-rebuild",
|
||||
"re-sqlite": "electron-rebuild -f -w better-sqlite3",
|
||||
"build-w": "electron-builder --config=./electron/config/builder.json -w=nsis --x64",
|
||||
"build-w-32": "electron-builder --config=./electron/config/builder.json -w=nsis --ia32",
|
||||
"build-w-64": "electron-builder --config=./electron/config/builder.json -w=nsis --x64",
|
||||
"build-w-arm64": "electron-builder --config=./electron/config/builder.json -w=nsis --arm64",
|
||||
"build-we": "electron-builder --config=./electron/config/builder.json -w=portable --x64",
|
||||
"build-wz": "electron-builder --config=./electron/config/builder.json -w=7z --x64",
|
||||
"build-wz-32": "electron-builder --config=./electron/config/builder.json -w=7z --ia32",
|
||||
"build-wz-64": "electron-builder --config=./electron/config/builder.json -w=7z --x64",
|
||||
"build-wz-arm64": "electron-builder --config=./electron/config/builder.json -w=7z --arm64",
|
||||
"build-m": "electron-builder --config=./electron/config/builder.json -m",
|
||||
"build-m-arm64": "electron-builder --config=./electron/config/builder.json -m --arm64",
|
||||
"build-l": "electron-builder --config=./electron/config/builder.json -l=deb --x64",
|
||||
"build-l-32": "electron-builder --config=./electron/config/builder.json -l=deb --ia32",
|
||||
"build-l-64": "electron-builder --config=./electron/config/builder.json -l=deb --x64",
|
||||
"build-l-arm64": "electron-builder --config=./electron/config/builder.json -l=deb --arm64",
|
||||
"build-l-armv7l": "electron-builder --config=./electron/config/builder.json -l=deb --armv7l",
|
||||
"build-lr-64": "electron-builder --config=./electron/config/builder.json -l=rpm --x64",
|
||||
"build-lp-64": "electron-builder --config=./electron/config/builder.json -l=pacman --x64",
|
||||
"test": "set DEBUG=* && electron . --env=local"
|
||||
"build-w": "ee-bin build --cmds=win64",
|
||||
"build-we": "ee-bin build --cmds=win_e",
|
||||
"build-m": "ee-bin build --cmds=mac",
|
||||
"build-m-arm64": "ee-bin build --cmds=mac_arm64",
|
||||
"build-l": "ee-bin build --cmds=linux"
|
||||
},
|
||||
"repository": "https://github.com/dromara/electron-egg.git",
|
||||
"keywords": [
|
||||
@@ -45,19 +29,15 @@
|
||||
"author": "哆啦好梦, Inc <530353222@qq.com>",
|
||||
"license": "Apache",
|
||||
"devDependencies": {
|
||||
"@electron/rebuild": "^3.2.13",
|
||||
"debug": "^4.3.3",
|
||||
"ee-bin": "1.8.3",
|
||||
"electron": "^21.4.4",
|
||||
"electron-builder": "^23.6.0",
|
||||
"eslint": "^5.13.0",
|
||||
"eslint-plugin-prettier": "^3.0.1",
|
||||
"nodemon": "^2.0.16"
|
||||
"@electron/rebuild": "^3.7.1",
|
||||
"@types/node": "^20.16.0",
|
||||
"debug": "^4.4.0",
|
||||
"ee-bin": "^4.0.0",
|
||||
"electron": "^31.7.6",
|
||||
"electron-builder": "^25.1.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"dayjs": "^1.10.7",
|
||||
"ee-core": "2.12.0",
|
||||
"electron-updater": "^5.3.0",
|
||||
"lodash": "^4.17.21"
|
||||
"ee-core": "^4.0.0",
|
||||
"electron-updater": "^6.3.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
public/dist/assets/Index-630507e4.js
vendored
1
public/dist/assets/Index-630507e4.js
vendored
@@ -1 +0,0 @@
|
||||
import{_ as a,o as t,c as s,a as e}from"./index-94991f0a.js";const o={data:()=>({})},c={id:"hero"},n=[e('<h1 class="tagline" data-v-505540b8><span class="accent" data-v-505540b8>Electron-Egg</span></h1><p class="description" data-v-505540b8> A fast, desktop software development framework </p><p class="actions" data-v-505540b8><a class="setup" href="https://www.kaka996.com/" target="_blank" data-v-505540b8>Get Started</a></p>',3)];const d=a(o,[["render",function(a,e,o,d,r,p){return t(),s("section",c,n)}],["__scopeId","data-v-505540b8"]]);export{d as default};
|
||||
1
public/dist/assets/Index-812274cb.css
vendored
1
public/dist/assets/Index-812274cb.css
vendored
@@ -1 +0,0 @@
|
||||
section[data-v-505540b8]{padding:42px 32px}#hero[data-v-505540b8]{padding:150px 32px;text-align:center;height:100%}.tagline[data-v-505540b8]{font-size:52px;line-height:1.25;font-weight:700;letter-spacing:-1.5px;max-width:960px;margin:0 auto}html:not(.dark) .accent[data-v-505540b8],.dark .tagline[data-v-505540b8]{background:-webkit-linear-gradient(315deg,#42d392 25%,#647eff);background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}.description[data-v-505540b8]{max-width:960px;line-height:1.5;color:var(--vt-c-text-2);transition:color .5s;font-size:22px;margin:24px auto 40px}.actions a[data-v-505540b8]{font-size:16px;display:inline-block;background-color:var(--vt-c-bg-mute);padding:8px 18px;font-weight:500;border-radius:8px;transition:background-color .5s,color .5s;text-decoration:none}.actions .setup[data-v-505540b8]{color:var(--vt-c-text-code);background:-webkit-linear-gradient(315deg,#42d392 25%,#647eff)}.actions .setup[data-v-505540b8]:hover{background-color:var(--vt-c-gray-light-4);transition-duration:.2s}
|
||||
7
public/dist/assets/index-94991f0a.js
vendored
7
public/dist/assets/index-94991f0a.js
vendored
File diff suppressed because one or more lines are too long
1
public/dist/assets/index-b7b2ffb7.css
vendored
1
public/dist/assets/index-b7b2ffb7.css
vendored
@@ -1 +0,0 @@
|
||||
#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;height:100%}
|
||||
107
public/dist/index.html
vendored
107
public/dist/index.html
vendored
@@ -1,107 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0" />
|
||||
<title></title>
|
||||
<!-- 优化:vue渲染未完成之前,先加一个css动画 -->
|
||||
<style>
|
||||
#loadingPage {
|
||||
background-color: #dedede;
|
||||
font-size: 12px;
|
||||
}
|
||||
.base {
|
||||
height: 9em;
|
||||
left: 50%;
|
||||
margin: -7.5em;
|
||||
padding: 3em;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 9em;
|
||||
transform: rotateX(45deg) rotateZ(45deg);
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
.cube,
|
||||
.cube:after,
|
||||
.cube:before {
|
||||
content: '';
|
||||
float: left;
|
||||
height: 3em;
|
||||
position: absolute;
|
||||
width: 3em;
|
||||
}
|
||||
/* Top */
|
||||
.cube {
|
||||
background-color: #06cf68;
|
||||
position: relative;
|
||||
transform: translateZ(3em);
|
||||
transform-style: preserve-3d;
|
||||
transition: .25s;
|
||||
box-shadow: 13em 13em 1.5em rgba(0, 0, 0, 0.1);
|
||||
animation: anim 1s infinite;
|
||||
}
|
||||
.cube:after {
|
||||
background-color: #05a151;
|
||||
transform: rotateX(-90deg) translateY(3em);
|
||||
transform-origin: 100% 100%;
|
||||
}
|
||||
.cube:before {
|
||||
background-color: #026934;
|
||||
transform: rotateY(90deg) translateX(3em);
|
||||
transform-origin: 100% 0;
|
||||
}
|
||||
.cube:nth-child(1) {
|
||||
animation-delay: 0.05s;
|
||||
}
|
||||
.cube:nth-child(2) {
|
||||
animation-delay: 0.1s;
|
||||
}
|
||||
.cube:nth-child(3) {
|
||||
animation-delay: 0.15s;
|
||||
}
|
||||
.cube:nth-child(4) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
.cube:nth-child(5) {
|
||||
animation-delay: 0.25s;
|
||||
}
|
||||
.cube:nth-child(6) {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
.cube:nth-child(7) {
|
||||
animation-delay: 0.35s;
|
||||
}
|
||||
.cube:nth-child(8) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
.cube:nth-child(9) {
|
||||
animation-delay: 0.45s;
|
||||
}
|
||||
@keyframes anim {
|
||||
50% {
|
||||
transform: translateZ(0.5em);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script type="module" crossorigin src="./assets/index-94991f0a.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index-b7b2ffb7.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="loadingPage">
|
||||
<div class='base'>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
<div class='cube'></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="app"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user