提交 e854999b authored 作者: caicai's avatar caicai

1

上级 43fa18e7
......@@ -78,15 +78,19 @@ class cateWin {
// 删除所有分类窗口
let winList = this.getAllWindows();
winList.forEach(v => {
v.close();
console.log(v.id)
this.mainWindow.closeWin(v.id);
})
}
delCateIdWin(id) {
// 删除某个分类窗口
let currentWin = this.mainWindow.getWinCateOf(id);
console.log( '删除某个分类窗口' )
console.log(currentWin)
if(currentWin != null) {
currentWin.close();
console.log('删除 窗口id',currentWin.id)
this.mainWindow.closeWin(currentWin.id);
}
}
......@@ -155,13 +159,17 @@ class cateWin {
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) {
// 创建窗口
......@@ -175,7 +183,8 @@ class cateWin {
});
}
// 为下一个准备的偏移
offsetX = item.x + currentWidth + 12;
// offsetX = item.x + currentWidth + 12;
offsetX = item.x + currentWidth;
})
// console.log('最终渲染')
// console.log(pList)
......@@ -186,7 +195,7 @@ class cateWin {
let cateList = this.getCategoryList();
let pList = [];
console.log(cateList)
// console.log(cateList)
cateList.forEach(cItem => {
let currentWin = this.mainWindow.getWinCateOf(cItem.id);
// console.log(currentWin)
......@@ -211,7 +220,7 @@ class cateWin {
width: item.width
} );
})
console.log(pList)
// console.log(pList)
}
/* 获取分类列表 */
......
......@@ -58,44 +58,47 @@ class category {
categoryList.unshift(category);
this.store.set(process.env.VUE_APP_CATENAME, categoryList);
if(this.store.get("currentMode")==="modeJianYue") this.cateWinPlugin.resizeAndCreate({categoryList});
if(this.store.get("currentMode")==="modeJianYue") {
console.log('新增分类')
this.cateWinPlugin.resizeAndCreate({categoryList});
}
sender.send("add-category", category);
this.mainWindow.win.webContents.send("add-category", category);
}
/* 删除分类 */
delCategory({id, sender}) {
delCategory({id, sender}={}) {
try {
if(id == undefined) return;
let categoryList = this.store.get(process.env.VUE_APP_CATENAME);
let hasIn = categoryList.findIndex(v => v.id == id);
let nextId = null;
// console.log('delCategory - hasIn', hasIn, id)
if(hasIn == -1) return null;
if(hasIn == 0 && categoryList[1]) nextId = categoryList[1].id;
if(hasIn == 0 && categoryList[1] != undefined) nextId = categoryList[1].id;
categoryList.splice(hasIn,1);
// 删除对应窗口,主窗口不用
// 分类 id
//根据分类重新渲染
if(this.store.get("currentMode")==="modeJianYue") {
if(hasIn == 0) {
console.log('删除分类')
if(hasIn == 0 && categoryList[1]) {
this.cateWinPlugin.delCateIdWin(nextId);
setTimeout(() => {
this.cateWinPlugin.resizeAndCreate({categoryList});
}, 800);
if(this.store.get("currentMode")==="modeJianYue") this.cateWinPlugin.resizeAndCreate({categoryList});
}else {
this.cateWinPlugin.delCateIdWin(id);
setTimeout(() => {
this.cateWinPlugin.resizeAndCreate({categoryList});
}, 800);
}
if(this.store.get("currentMode")==="modeJianYue") this.cateWinPlugin.resizeAndCreate({categoryList});
}
this.store.set(process.env.VUE_APP_CATENAME, categoryList);
sender.send('remove-category',{id});
this.mainWindow.main.webContents.send("category-list", categoryList);
} catch (error) {
console.error(error)
}
}
// 获取分类详情
......@@ -111,18 +114,20 @@ class category {
let categoryList = this.store.get(process.env.VUE_APP_CATENAME);
let hasIn = categoryList.findIndex(v => v.id == id);
// console.log('hasIn', hasIn)
console.log('分类id',id)
console.log('分类id',id, 'hasIn',hasIn)
if(hasIn == -1) return null;
categoryList[hasIn] = detail;
// 修改窗口大小
let cateWin = this.mainWindow.getWinCateOf(id);
console.log('cateWin', cateWin != null)
if(cateWin != null && (this.store.get("currentMode")==="modeJianYue") ) {
// cateWin.setBounds({
// width:352,
// });
// this.cateWinPlugin.resizeAndPosition({cateId:id, softList:detail.softList});
console.log('当前窗口存在,需要更新')
this.cateWinPlugin.resizeAndCreate({categoryList});
}
......@@ -142,7 +147,10 @@ class category {
// 重新调整窗口大小及其位置
// if(this.store.get("currentMode")==="modeJianYue") this.cateWinPlugin.resizeAndPosition({cateId:id, softList:detail.softList});
if(this.store.get("currentMode")==="modeJianYue") this.cateWinPlugin.resizeAndCreate({categoryList});
if(this.store.get("currentMode")==="modeJianYue") {
console.log('更新分类下的软件列表')
this.cateWinPlugin.resizeAndCreate({categoryList});
}
this.store.set(process.env.VUE_APP_CATENAME, categoryList);
sender.send('remove-soft',{detail,id});
......
......@@ -141,6 +141,8 @@ class MainWindow {
/* 获取分类窗口 */
getWinCateOf(id) {
let winId = "";
console.log('窗口组',id)
console.log(this.group)
let keys = Object.keys(this.group);
let targetIndex = keys.findIndex(v => this.group[v].route === '/category/'+id);
if(targetIndex != -1) winId = keys[targetIndex];
......@@ -166,6 +168,7 @@ class MainWindow {
if(args.visible == 'hide') return;
if(!this.getWindow(Number(i)).isVisible()) this.getWindow(Number(i)).show()
this.getWindow(Number(i)).focus()
console.log('route已存在窗口组中,不再创建', args.route)
return
}
}
......@@ -318,10 +321,18 @@ class MainWindow {
if(this.getWindow(Number(i))) {
this.getWindow(Number(i)).close()
} else {
app.quit()
// app.quit()
}
}
}
}
/* 关闭某个窗口 */
closeWin(winId) {
if(winId) {
this.getWindow(Number(winId)).close()
if(this.group[Number(winId)]) delete this.group[Number(winId)]
}
}
// 开启监听
......@@ -476,7 +487,7 @@ class MainWindow {
quitListener() {
// 注册一个'Alt+CommandOrControl+Q' 快捷键监听器
const ret = globalShortcut.register('Alt+CommandOrControl+Q', function () {
app.quit();
// app.quit();
});
if (!ret) {
console.log('registration failed')
......
......@@ -114,10 +114,13 @@ export default {
opacity: 0;
position: absolute;
left: 6px;
top: 4px;
// top: 4px;
top: 50%;
transform: translateY(-50%);
bottom: 0;
width: 20px;
height: 4em;
max-height: 4em;
height: max-content;
overflow: hidden;
line-height: 1;
// z-index: 1;
......
<template>
<div class="category_container page_wrap app-drag">
<!-- {{id}} -->
<!-- <div style="padding-left:300px;">{{id}}</div> -->
<div v-if="list && list.length > 0" class="group1_wrap_name">{{detail.name}}</div>
<!-- <el-scrollbar ref="scrollContainer" :vertical="false" style="height: 68px;background:red" class=""
@wheel.native.prevent="handleScroll"> -->
......@@ -89,10 +89,13 @@ export default {
opacity: 0;
position: absolute;
left: 16px;
top: 6px;
// top: 6px;
top: 50%;
transform: translateY(-50%);
bottom: 0;
width: 20px;
height: 4em;
max-height: 4em;
height: max-content;
overflow: hidden;
line-height: 1;
font-size: 14px;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论