提交 8225fa36 authored 作者: caicai's avatar caicai

优化切换速度

上级 addd3893
......@@ -89,16 +89,17 @@ class IpcEvents {
let {width,height} = whDetail['modeJianYue'];
event.sender.send('context-menu-command', 'modeJianYue');
this.store.set("currentMode", "modeJianYue");
this.windowManager.mainWindow.win.setBounds({
let data = {
x: window_left_distance,
y: (displayWH.height - height - window_bottom_distance),
width,
height
}, true);
};
this.windowManager.mainWindow.win.setBounds(data, true);
//首次创建三个新窗口
setTimeout(() => {
this.cateWinPlugin.resizeAndCreate();
},1500);
// setTimeout(() => {
this.cateWinPlugin.resizeAndCreate({mainWin:data});
// },1500);
}
},
{
......
......@@ -4,6 +4,8 @@ class cateWin {
this.store = this.mainWindow.store;
//简约模式的窗口
this.webType = "simpleCate";
this.cateWinList = [];
}
/* 窗口初始化跟随,mainwindow */
/* 新建分类窗口 */
......@@ -108,6 +110,8 @@ class cateWin {
// .getBounds
let {width,height,x,y} = main.getBounds();
return {width,height,x,y};
// 固定主窗口位置大小
}
/* 隐藏所有-分类窗口 */
......@@ -119,7 +123,97 @@ class cateWin {
}
// 位置调整,如果当前分类不是第一个,找不到窗口则创建窗口
resizeAndCreate({categoryList} = {}) {
resizeAndCreate({categoryList, mainWin} = {}) {
if(categoryList == undefined) {
categoryList = this.getCategoryList();
}
let mainWidth=0;
let mainHeight=0;
let mainX=0;
let mainY=0;
if(mainWin) {
mainWidth=mainWin.width;
mainHeight=mainWin.height;
mainX=mainWin.x;
mainY=mainWin.y;
}else {
let mainDetail = this.getMainBounds();
mainWidth=mainDetail.width;
mainHeight=mainDetail.height;
mainX=mainDetail.x;
mainY=mainDetail.y;
}
let cateList = categoryList;
let pList = [];
let baseX = Number(mainWidth) + Number(mainX); //基础偏移
cateList.forEach((cItem, cIndex) => {
// console.log('cItem.win')
// console.log(cItem.win)
let currentWin = cItem.win || this.mainWindow.getWinCateOf(cItem.id);
// console.log(currentWin)
if(cIndex == 0) return;
if( currentWin == null ) {
pList.push({
x: 0,
y: mainY,
width:20,
height: mainHeight,
cateId:cItem.id,
softList: cItem.softList,
win:null
});
return;
}
let {x,y,width,height} = currentWin.getBounds();
// pList.push({x,y,width,height,cateId:cItem.id, softList: cItem.softList, win:currentWin});
pList.push({x: 0,y,width,height,cateId:cItem.id, softList: cItem.softList, win:currentWin});
});
// 排序
pList.sort((a, b) => parseInt(a.x) - parseInt(b.x));
// console.log(pList)
let offsetX = 0;
let currentWidth = 0;
let len = 0;
pList.forEach((item, pIndex) => {
len = item.softList && item.softList.length || 0;
currentWidth = len ? (len * 50 + (len-1)*24 + 80) : 20;
item.x = offsetX || item.x;
item.width = currentWidth;
console.log('Id',item.cateId, `窗口${item.win!=null?'已经存在':'不存在'}`)
console.log('width',currentWidth)
if(item.win) {
// item.x =
item.win.setBounds( {
x: baseX + offsetX + (pIndex + 1)*12,
width: currentWidth
} );
if(!item.win.isVisible()) {
item.win.show();
}
}
if(item.win == null) {
// 创建窗口
this.createWin({
cateId:item.cateId,
index:(pIndex + 1),
baseX: Number(mainWidth) + Number(mainX),
baseY: Number(mainY),
width:currentWidth,
offsetX,
});
}
// 为下一个准备的偏移
// offsetX = item.x + currentWidth + 12;
offsetX = item.x + currentWidth;
})
// console.log('最终渲染')
// console.log(pList)
}
resizeAndCreate_Back({categoryList} = {}) {
if(categoryList == undefined) {
categoryList = this.getCategoryList();
}
......@@ -129,7 +223,9 @@ class cateWin {
let baseX = Number(mainWidth) + Number(mainX); //基础偏移
cateList.forEach((cItem, cIndex) => {
let currentWin = this.mainWindow.getWinCateOf(cItem.id);
console.log('cItem.win')
console.log(cItem.win)
let currentWin = cItem.win || this.mainWindow.getWinCateOf(cItem.id);
// console.log(currentWin)
if(cIndex == 0) return;
if( currentWin == null ) {
......
......@@ -155,7 +155,7 @@ class MainWindow {
return BrowserWindow.getAllWindows()
}
createWindow (options = {isMainWin: true}) {
createWindow (options = {isMainWin: true}, callback=()=>{}) {
let args = Object.assign({}, windowsCfg, options);
// if (this.win) {
// console.warn('window is already exists!')
......@@ -191,10 +191,14 @@ class MainWindow {
console.log(opt)
let win = new BrowserWindow(opt)
typeof callback == 'function' && callback(win);
console.log('窗口id:' + win.id)
this.group[win.id] = {
route: args.route,
isMultiWindow: args.isMultiWindow,
win:win
}
// 是否最大化
if(args.maximize && args.resizable) {
......
......@@ -13,24 +13,24 @@ module.exports = {
VERSION: JSON.stringify(machineIdSync({original: true}))
})
],
// devtool: 'source-map', // 'source-map' \ false
// optimization: {
// minimize: true,
// minimizer: [
// new TerserPlugin({ // 要引用 TerserPlugin
// terserOptions: {
// ecma: undefined,
// warnings: false,
// parse: {},
// compress: {
// drop_console: true,
// drop_debugger: false,
// pure_funcs: ['console.log'] // 移除console
// }
// },
// }),
// ],
// }
devtool: 'source-map', // 'source-map' \ false
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({ // 要引用 TerserPlugin
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: {
drop_console: true,
drop_debugger: false,
pure_funcs: ['console.log'] // 移除console
}
},
}),
],
}
},
pages: {
app: {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论