提交 96126acf authored 作者: caicai's avatar caicai

修改管理窗口的打开和关闭

上级 23d555ab
......@@ -329,6 +329,10 @@ class IpcEvents {
this.categoryPlugin.addCategory({name:data, sender:e.sender})
// e.sender.send("category-list", list);
})
ipcMain.on("changeNameOfCategory", (e, data) => {
let { name,detail,index } = data;
this.categoryPlugin.updateName({name, detail, sender:e.sender})
})
}
}
......
......@@ -80,6 +80,19 @@ class category {
this.mainWindow.win.webContents.send('getMsg', categoryList)
}
/* 修改分类名称 */
updateName({name, detail, sender}) {
let categoryList = this.store.get('category');
let id = detail.id;
let hasIn = categoryList.findIndex(v => v.id == id);
console.log('hasIn-updateName', hasIn)
if(hasIn == -1) return null;
categoryList[hasIn].name = name;
this.store.set('category', categoryList);
sender.send('update-category-name',{detail,id,name});
}
/* 软件改变所属分类、加入到某个分类 */
softChangeCategory({soft,category, sender}) {
let softId = soft.id;
......
......@@ -121,6 +121,12 @@ class MainWindow {
return BrowserWindow.fromId(id)
}
getWinOf(webType) {
let winList = this.getAllWindows();
let targetIndex = winList.findIndex(v => v.webContents.webType === webType);
return targetIndex != -1 ? winList[targetIndex] : null;
}
// 获取全部窗口
getAllWindows() {
return BrowserWindow.getAllWindows()
......@@ -137,6 +143,7 @@ class MainWindow {
// 判断窗口是否存在
for(let i in this.group) {
if(this.getWindow(Number(i)) && this.group[i].route === args.route && !this.group[i].isMultiWindow) {
if(args.visible == 'hide') return;
if(!this.getWindow(Number(i)).isVisible()) this.getWindow(Number(i)).show()
this.getWindow(Number(i)).focus()
return
......@@ -229,6 +236,7 @@ class MainWindow {
// })
// 等待加载完成再去显示,不显示白屏加载过程
win.once('ready-to-show', () => {
console.log('是否显示', args.visible)
if(args.visible!='hide') win.show();
// win.setAlwaysOnTop(true);
if(win.webContents.webType === 'mainWindow') {
......@@ -241,9 +249,28 @@ class MainWindow {
console.log(`Window ${win.id} lost focus webType:${win.webContents.webType}`)
// 如果当前app 管理页 失去焦点,则隐藏
// if(win.webContents.webType === 'appManage') {
// event.sender.send('manageVisible',false);
// // win.hide();
// let winList = this.getAllWindows();
// console.log(winList[0].webContents.webType, winList[1].webContents.webType)
// if(winList[1].webContents.webType === 'mainWindow') {
// console.log('通知')
// winList[1].webContents.send('manageVisible',false);
// }
// }
})
win.on('hide', (event) => {
// 如果当前app 管理页 隐藏
if(win.webContents.webType === 'appManage') {
event.sender.send('manageVisible',false);
// win.hide();
let winList = this.getAllWindows();
if(winList[1].webContents.webType === 'mainWindow') {
winList[1].webContents.send('manageVisible',false);
}
}
})
......@@ -256,6 +283,8 @@ class MainWindow {
this.openWithBrowser()
// 应用程序的“关于”面板
this.setAboutPanel()
// 监听事件
this.listen()
// 读取Linux系统中已经安装的软件
if(args.isMainWin) this.softList.getList();
......@@ -288,7 +317,12 @@ class MainWindow {
})
// 隐藏
ipcMain.on('window-hide', (event, winId) => {
ipcMain.on('window-hide', (event, {winId, webType}) => {
if(webType) {
let currentWin = this.getWinOf(webType);
currentWin && currentWin.hide();
return;
}
if(winId) {
// this.getWindow(Number(winId)).hide()
} else {
......@@ -297,7 +331,12 @@ class MainWindow {
})
// 显示
ipcMain.on('window-show', (event, winId) => {
ipcMain.on('window-show', (event, {winId, webType}) => {
if(webType) {
let currentWin = this.getWinOf(webType);
currentWin && currentWin.show();
return;
}
if(winId) {
this.getWindow(Number(winId)).show()
} else {
......
......@@ -18,6 +18,6 @@ body {
</style>
<style>
/* CDN 服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
@import url('https://at.alicdn.com/t/c/font_4010399_o3284rt85e.css');
@import url('https://at.alicdn.com/t/c/font_4010399_0wmcyi78r3v.css');
</style>
......@@ -183,7 +183,8 @@ export default {
this.$emit('softAddtoCate', {
cate: item,
soft: {id,current}
})
});
this.closeMenu();
},
closeMenu() {
this.showMenu = false;
......
......@@ -5,7 +5,8 @@
</div>
<cateBox v-for="(cItem, cIndex) in cateList" :key="cIndex">
<div class="dragbox_cate">
<div class="dragbox_cate_name">{{cItem.name}}</div>
<div v-if="editIndex != cIndex" class="dragbox_cate_name" @dblclick="modifyName(cItem.name,cIndex)">{{cItem.name}}</div>
<el-input v-else v-model="editName" placeholder="" @blur="closeEdit(cIndex)" class="dragbox_cate_input"></el-input>
<div v-if="cItem.softList" class="dragbox_cate_list">
<cateItem v-for="(sItem, sIndex) in cItem.softList" :key="sIndex" :detail="sItem" :src="sItem.icon" :name="sItem.name"></cateItem>
</div>
......@@ -67,10 +68,27 @@ export default {
data() {
return {
centerDialogVisible:false,
cateName:""
cateName:"",
editIndex: -1,
editName:"",
};
},
methods: {
closeEdit(index) {
let oldName = this.cateList[index].name;
let editName = this.editName.trim();
if(editName == '') editName = "未命名";
if(oldName != editName) {
this.$emit( "changeName", {index,name:editName, detail:this.cateList[index]} );
}
this.editName = "";
this.editIndex = -1;
},
modifyName(name, index) {
console.log('修改名字')
this.editName = name;
this.editIndex = index;
},
cancelAdd() {
this.centerDialogVisible = false;
this.cateName = "";
......@@ -82,6 +100,10 @@ export default {
},
addCate() {
// 添加分类
if(!this.cateList || this.cateList.length >= 6) {
this.$message.warning("最多允许有6个分类")
return;
}
this.centerDialogVisible = true;
},
add: function() {
......@@ -126,6 +148,17 @@ export default {
font-size: 18px;
font-weight: 500;
color: #333333;
cursor: text;
user-select: none;
}
.dragbox_cate_input /deep/.el-input__inner {
padding-left: 25px;
font-size: 18px;
font-weight: 500;
color: #333333;
border: none;
outline: none;
background-color: inherit;
}
.dragbox_cate_list {
display: flex;
......
......@@ -88,18 +88,15 @@ export default {
// 接收主进程消息
this.ipcOn();
// 提前创建,后续显示
this.newWin({visible:'hide'});
this.createAppWin();
},
methods: {
changeSecond({item,index}) {
if(this.secondAcitveIndex == index) return;
this.secondAcitveIndex = index;
},
newWin(arg = {visible:'show'}) {
if(arg.visible === "show") {
this.showManage = this.showManage ? false : true;
if(!this.showManage) return;
}
createAppWin() {
// 创建
const screen = this.$electron.remote.screen;
const { width, height } = screen.getPrimaryDisplay().workAreaSize; //获取到屏幕的宽度和高度
const main_win = this.$electron.remote.getCurrentWindow();
......@@ -118,9 +115,23 @@ export default {
x: 0,
y: mainY - height * 0.7,
webType:'appManage',
visible: arg.visible
visible: 'hide'
});
},
newWin(arg = {visible:'show'}) {
if(arg.visible === "show") {
this.showManage = this.showManage ? false : true;
if(!this.showManage) {
// 隐藏
this.ipcRenderer.send('window-hide',{winId:0, webType:'appManage'});
return;
}
// 显示
this.ipcRenderer.send('window-show',{winId:0, webType:'appManage'});
return;
}
},
listener() {
// 监听右键菜单
window.addEventListener("contextmenu", (e) => {
......@@ -200,6 +211,7 @@ export default {
// 管理页隐藏
this.ipcRenderer.on("manageVisible", (event,visible) => {
console.log('visible', visible)
this.showManage = false;
})
// 获取到base64
......
......@@ -34,7 +34,7 @@
<div>
<Appbox v-if="current === 'all'" :cateList="categoryList" :listObj="listObj" :listAll="appList" @softAddtoCate="softAddtoCate"></Appbox>
<SchoolBox v-if="current === 'school'"></SchoolBox>
<DragBox ref="dragEl" v-if="current === 'mine'" :cateList="categoryList" @addCategory="addCategory" ></DragBox>
<DragBox ref="dragEl" v-if="current === 'mine'" :cateList="categoryList" @addCategory="addCategory" @changeName="changeName"></DragBox>
</div>
</el-scrollbar>
</el-main>
......@@ -105,10 +105,14 @@ export default {
setTimeout(() => {
this.getAppList();
this.getCategoryList();
}, 100)
}, 10)
},
methods: {
changeName({name,detail,index}) {
// 修改分类名字
this.ipcRenderer.send("changeNameOfCategory",{name,detail,index});
},
addCategory(name) {
// 添加分类
this.ipcRenderer.send("addCategory",name);
......@@ -130,6 +134,9 @@ export default {
this.ipcRenderer.send("getCategoryList");
},
ipcOn() {
this.ipcRenderer.on("manageVisible", (event,visible) => {
console.log('visible 2', visible)
})
// 获取到app列表
this.ipcRenderer.on("appsList", (event, list) => {
console.log("获取到app列表 2", list);
......@@ -152,12 +159,23 @@ export default {
// this.categoryList = list;
let curIndex = this.categoryList.findIndex(v => v.id == id);
this.categoryList[curIndex] = detail;
this.$message.success("加入成功");
});
this.ipcRenderer.on("add-category", (event, data) => {
console.log("添加分类 2", data);
this.categoryList.unshift(data);
this.$message("添加成功");
this.$message.success("添加成功");
this.$refs.dragEl.cancelAdd();
});
this.ipcRenderer.on("update-category-name", (event, data) => {
let {detail,id,name} = data;
console.log("修改分类名字 2", detail,id);
let curIndex = this.categoryList.findIndex(v => v.id == id);
this.categoryList[curIndex].name = name;
this.$message.success("修改成功");
});
},
changeTap(tabType) {
if(this.current === tabType) return;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论