升级electron egg脚手架版本
This commit is contained in:
@@ -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
|
||||
}
|
||||
58
electron/preload/lifecycle.js
Normal file
58
electron/preload/lifecycle.js
Normal file
@@ -0,0 +1,58 @@
|
||||
'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 win = getMainWindow();
|
||||
const { windowsOption } = getConfig();
|
||||
if (windowsOption.show == false) {
|
||||
win.once('ready-to-show', () => {
|
||||
win.show();
|
||||
win.focus();
|
||||
})
|
||||
} else {
|
||||
win.show();
|
||||
win.focus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* before app close
|
||||
*/
|
||||
async beforeClose() {
|
||||
logger.info('[lifecycle] before-close');
|
||||
}
|
||||
}
|
||||
Lifecycle.toString = () => '[class Lifecycle]';
|
||||
|
||||
module.exports = {
|
||||
Lifecycle
|
||||
};
|
||||
Reference in New Issue
Block a user