提交 893cf9db authored 作者: 蔡芬's avatar 蔡芬

new

上级 81009cd4
/**
* 通过读取应用程序的.desktop文件来获取应用程序的图标URL。在Linux中,.desktop文件包含了应用程序的元数据信息,包括应用程序的名称、描述、图标等。
您可以使用以下命令来查看应用程序的.desktop文件:
```
cat /usr/share/applications/<application-name>.desktop
```
其中,`<application-name>`是应用程序的名称。
在.desktop文件中,您可以找到`Icon`字段,该字段指定了应用程序的图标文件名。您可以使用以下命令来获取应用程序的图标URL:
```
echo $(grep -i "^Icon=" /usr/share/applications/<application-name>.desktop | cut -d'=' -f2 | sed 's/\s//g') | xargs -I{} xdg-icon-resource lookup --size 48 {}
```
其中,`48`是您想要获取的图标大小。如果应用程序没有指定图标,则此方法将无法获取图标URL。
在Linux中,应用程序图标的大小通常有以下几个:
- 16x16
- 22x22
- 24x24
- 32x32
- 48x48
- 64x64
- 128x128
- 256x256
*/
\ No newline at end of file
{
"name": "feidao",
"name": "menudock",
"version": "0.2.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "feidao",
"name": "menudock",
"version": "0.2.1",
"hasInstallScript": true,
"dependencies": {
......@@ -2,7 +2,7 @@ import { ipcMain, dialog, Menu, BrowserWindow, app} from 'electron'
import { saveJson } from '@/libs/utils/backfunction.js';
const fs = require('fs');
const { exec, execSync } = require('child_process');
const nativeImage = require('electron').nativeImage;
import SoftList from '../plugins/softList';
class IpcEvents {
create (appManager) {
......@@ -10,6 +10,7 @@ class IpcEvents {
this.windowManager = appManager.windowManager;
this.win = this.windowManager.mainWindow.win;
this.store = this.windowManager.mainWindow.store;
this.softList = new SoftList(this.windowManager.mainWindow)
/* 翻译器函数
Translator function */
......@@ -41,6 +42,7 @@ class IpcEvents {
// 显示右键菜单
ipcMain.on('show-context-menu', (event) => {
let currentMode = this.store.get("currentMode");
let displayWH = this.store.get("primaryDisplayWH");
let template = [
{
label: '简约模式',
......@@ -48,6 +50,12 @@ class IpcEvents {
click: () => {
event.sender.send('context-menu-command', 'modeJianYue');
this.store.set("currentMode", "modeJianYue");
this.windowManager.mainWindow.win.setBounds({
x: (displayWH.width-1000)/2,
y: (displayWH.height-40),
width: 1000,
height: 40
}, true);
}
},
{
......@@ -56,6 +64,12 @@ class IpcEvents {
click: () => {
event.sender.send('context-menu-command', 'modeJiJian');
this.store.set("currentMode", "modeJiJian");
this.windowManager.mainWindow.win.setBounds({
x: (displayWH.width-240)/2,
y: (displayWH.height-40),
width: 240,
height: 40
}, true);
}
},
{
......@@ -72,10 +86,13 @@ class IpcEvents {
menu.popup(BrowserWindow.fromWebContents(event.sender))
});
// 设置软件位置
ipcMain.on("setMainWindow0", (e, data) => {
this.store.set("primaryDisplayWH", data);
this.windowManager.mainWindow.win.setPosition((data.width-1000)/2,(data.height-40))
})
// 获取app列表
ipcMain.on("getApps", (e, data) => {
let apps = this.store.get("apps");
// console.log(apps)
......@@ -83,20 +100,64 @@ class IpcEvents {
this.windowManager.mainWindow.win.webContents.send("appsList", apps)
})
// 打开某个软件 - 执行命令
ipcMain.on("openApp", (e, data) => {
exec(data.execCommand);
})
// 某个路径转成base64
ipcMain.on("getBase64", (e, {imagePath,index}) => {
try {
const imageBase64 = fs.readFileSync(imagePath, 'base64');
let src = `data:image/png;base64,${imageBase64}`;
let apps = this.store.get("apps");
src = src.replace(/[\r\n]/g, '');
apps[index].icon = src;
this.store.set("apps", apps);
e.sender.send("base64Info", {url:src,index});
} catch (error) {
}
})
// 移动app列表
ipcMain.on("moveSoft", (e, {appname, addFiles})=>{
let appList = this.store.get("apps");
let addFile = addFiles[0]; //某个拖拽文件
let targetIndex = appList.findIndex(v => v.name == appname);
let resIndex = appList.findIndex(v => v.name == addFile.shortName);
if(targetIndex>=0) {
console.log('替换掉', targetIndex, appList[targetIndex])
console.log('新增', resIndex,addFiles[0])
// addFile.execCommand = `open '${addFile.path}'`
// 同个软件无需移动
if(resIndex == targetIndex) return;
if(resIndex >= 0) {
// 交换位置
let temp = appList[targetIndex];
appList.splice(targetIndex,1,appList[resIndex]);
appList.splice(resIndex,1,temp);
}else {
// 新增
//mac
addFile.execCommand = `open '${addFile.path}'`;
addFile.name = addFile.shortName;
// addFile.icon = '';
addFile.icon = this.softList.getMacIconPath({fileName:addFile.shortName, appPath:addFile.path});
addFile.icon = this.softList.icns2Png({iconPath:addFile.icon,fileNameShort:addFile.shortName});
addFile.icon = this.softList.pngToBase64(addFile.icon);
appList.splice(targetIndex,0,addFile)
}
// 刷新渲染进程app列表
e.sender.send('appsList_update', appList);
this.store.set("apps", appList);
}
})
// mac-获取前台应用程序
ipcMain.on("getfrontApp", (e, data) => {
console.log('获取前台应用程序')
exec('osascript -e \'tell application "System Events" to get name of application processes whose frontmost is true\'', (err, stdout, stderr) => {
......@@ -112,6 +173,7 @@ class IpcEvents {
});
})
// linux-获取应用程序的图标
ipcMain.on("getLinuxApp", (e, data) => {
// 获取应用程序的图标
// const appPath = '/usr/share/applications/firefox.desktop'; // 替换为您要获取图标的应用程序的.desktop文件路径
......@@ -130,7 +192,7 @@ class IpcEvents {
e.sender.send("linuxAppIcon", iconFullPath);
})
// 判断当前应用是否全屏
ipcMain.on("isFullScreen", (e, data) => {
// 1. 判断当前应用是否全屏:
......@@ -143,6 +205,7 @@ class IpcEvents {
// ```
})
// 判断当前应用是否位于最顶层
ipcMain.on("isAlwaysOnTop", (e, data) => {
// 2. 判断当前应用是否位于最顶层:
......@@ -154,7 +217,76 @@ class IpcEvents {
// console.log(`Is always on top: ${isAlwaysOnTop}`);
// ```
})
/**
* linux
* 获取当前正在运行的应用
* 获取系统进程信息
*
可以使用以下命令获取系统当前运行的应用:
1. 使用 top 命令查看系统进程信息:
```
top
```
2. 使用 ps 命令查看系统进程信息:
```
ps -ef
```
3. 使用 htop 命令查看系统进程信息:
```
htop
```
4. 使用 lsof 命令查看系统打开的文件和进程信息:
```
lsof
```
5. 使用 netstat 命令查看系统网络连接信息:
```
netstat -an
```
6. 使用 ss 命令查看系统网络连接信息:
```
ss -an
```
*/
ipcMain.on("getRunApp", (e, data) => {
const { exec } = require('child_process');
exec('ps -eo pid,comm', (err, stdout, stderr) => {
if (err) {
console.error(`exec error: ${err}`);
return;
}
console.log(`stdout: ${stdout}`);
});
})
/**
* 取 /proc 目录下的进程信息
*/
ipcMain.on("getRunApp", (e, data) => {
const fs = require('fs');
fs.readdir('/proc', (err, files) => {
if (err) {
console.error(`readdir error: ${err}`);
return;
}
files.filter(file => /^\d+$/.test(file)).forEach(file => {
const cmd = fs.readFileSync(`/proc/${file}/cmdline`, 'utf8');
console.log(`pid: ${file}, cmd: ${cmd}`);
});
});
})
}
}
......
const { exec, execSync } = require('child_process');
const fs = require('fs');
class SoftList {
constructor (mainWindow) {
this.mainWindow = mainWindow;
this.store = this.mainWindow.store;
}
/* 获取app列表 */
getList () {
console.log('获取app列表')
let appsList = this.store.get('apps');
if(appsList && appsList.length > 0) {
// 已有app列表
console.log('apps-length', appsList.length)
return;
}
if (process.platform === 'linux') {
// 当前是Linux平台
console.log('当前是Linux平台')
this.getLinuxList();
} else if (process.platform === 'darwin') {
// 当前是macOS平台
console.log('当前是macOS平台')
this.getMacList();
} else {
// 其他平台
}
}
/* 获取linux 快捷方式 列表 */
getLinuxList() {
exec('ls /usr/share/applications/*.desktop', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
const apps = stdout.trim().split('\n').map(file => {
const content = fs.readFileSync(file, 'utf8');
const lines = content.trim().split('\n');
const nameLine = lines.find(line => line.startsWith('Name='));
const name = nameLine ? nameLine.substr(5) : path.basename(file, '.desktop');
const iconLine = lines.find(line => line.startsWith('Icon='));
let icon = iconLine ? iconLine.substr(5) : null;
const execLine = lines.find(line => line.startsWith('Exec='));
const execCommand = execLine ? execLine.substr(5) : null;
const nameOfZhLine = lines.find(line => line.startsWith('Name[zh_CN]='));
const nameOfZh = nameOfZhLine ? nameOfZhLine.substr(5) : '';
// 图标为SVG或PNG格式
if(icon && icon.indexOf(".png") == -1) {
icon = `/usr/share/icons/hicolor/48x48/apps/${icon}.png`
}
// icon = `/usr/share/icons/hicolor/48x48/apps/${icon}`
// 2. 打开应用程序的.desktop文件,并查找“Icon=”行。这一行包含应用程序的图标文件的路径。
// 3. 使用以下代码来将图标文件转换为base64编码:
// ```
// base64 -w 0 /usr/share/icons/hicolor/48x48/apps/${icon}
// ```
// try {
// var res = execSync(`base64 -w 0 /usr/share/icons/hicolor/48x48/apps/${icon}.png`
// , { encoding: 'utf8' });
// if(res) icon = res;
// } catch (error) {
// console.error(error)
// }
return {
nameOfZh,
name,
icon,
execCommand,
};
});
this.store.set('apps', apps);
this.mainWindow.win.webContents.send("appsList", apps);
});
}
/* 获取mac 软件 列表 */
getMacList() {
exec('ls /System/Applications/*.app', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
let temp = stdout.replace(/Contents/g, '');
temp=temp.replace(/[:]/g, '');
if(!temp || temp == undefined) return
const apps = temp.trim().split('\n').map((file,index) => {
if(!file || file.indexOf('.app') == -1 || typeof file != 'string') return {};
let fileArr = file.split('/');
let fileName = fileArr[fileArr.length-1];
let fileNameShort = fileName.split('.')[0];
let icon = '';
// try {
// // 获取图标
// var res = execSync(`ls /System/Applications/'${fileName}'/Contents/Resources/*.icns`
// , { encoding: 'utf8' });
// } catch (e) {
// // console.log("Errors:", e);
// }
// icon = res && res.trim().split('\n') || [];
// icon = icon.length > 0 ? icon[0] : '';
icon = this.getMacIconPath({fileName,appPath:file});
console.log('icon', icon)
// 将.icns文件转为.png文件
// let fileRes = '';
// try {
// if(icon) {
// fileRes = execSync(`sips -s format png '${icon}' --out /Users/lianda/Desktop/working/file/'${fileNameShort}'.png`);
// }
// if(fileRes) icon = `/Users/lianda/Desktop/working/file/${fileNameShort}.png`;
// } catch (error) {
// // console.log("Errors2:", error);
// }
icon = this.icns2Png({iconPath:icon,fileNameShort});
let execCommand = `open '${file}'`
return {
name: fileNameShort,
icon,
execCommand,
};
});
let newarr = apps.filter(v => !!v.name)
this.store.set('apps', newarr);
this.mainWindow.win.webContents.send("appsList", newarr)
});
}
// 获取mac 图标
getMacIconPath({fileName,appPath}) {
console.log('getMacIconPath', appPath)
let tempPathArr = [];
let lastIndexItem = '';
fileName = fileName.indexOf('.app') ? fileName : fileName+'.app';
if(appPath) {
tempPathArr = appPath.split('/');
lastIndexItem = tempPathArr[tempPathArr.length - 1];
lastIndexItem = `'${lastIndexItem}'`;
tempPathArr[tempPathArr.length - 1] = lastIndexItem;
appPath = tempPathArr.join('/');
console.log('appPath', appPath)
}
appPath = appPath || `/System/Applications/'${fileName}'`;
let icon = '';
let iconPath = appPath + '/Contents/Resources/*.icns'
try {
// 获取图标
// var res = execSync(`ls /System/Applications/'${fileName}'/Contents/Resources/*.icns`
var res = execSync(`ls ${iconPath}`
, { encoding: 'utf8' });
} catch (e) {
// console.log("Errors:", e);
return icon;
}
icon = res && res.trim().split('\n') || [];
console.log(icon)
icon = icon.length > 0 ? icon[0] : '';
return icon;
}
// 将.icns文件转为.png文件
icns2Png({iconPath,fileNameShort}) {
let fileRes = '';
try {
if(iconPath) {
fileRes = execSync(`sips -s format png '${iconPath}' --out /Users/lianda/Desktop/working/file/'${fileNameShort}'.png`);
}
if(fileRes) iconPath = `/Users/lianda/Desktop/working/file/${fileNameShort}.png`;
} catch (error) {
// console.log("Errors2:", error);
return iconPath;
}
return iconPath;
}
// png转base64
pngToBase64(imagePath) {
const imageBase64 = fs.readFileSync(imagePath, 'base64');
let src = `data:image/png;base64,${imageBase64}`;
src = src.replace(/[\r\n]/g, '');
return src;
}
/* 获取翻译函数(为了保持this正确指向)*/
get () {
return i => {
// return this.$t(i)
return 1
}
}
}
export default SoftList
\ No newline at end of file
......@@ -4,6 +4,7 @@ const fs = require('fs');
const path = require('path')
const Store = require('electron-store');
const { exec, execSync } = require('child_process');
import SoftList from '../plugins/softList';
const store = new Store({
defaults: {
......@@ -17,6 +18,7 @@ class MainWindow {
win is this electron window instance */
this.win = win
this.store = store;
this.softList = new SoftList(this)
}
initBrowserPage () {
......@@ -97,8 +99,9 @@ class MainWindow {
this.openWithBrowser()
// 应用程序的“关于”面板
this.setAboutPanel()
// 读取Linux系统中已经安装的软件
this.updateAppsList()
this.softList.getList();
}
setWindowMenu () {
......@@ -190,100 +193,6 @@ class MainWindow {
// };
// });
}
updateAppsList() {
console.log('linux')
exec('ls /usr/share/applications/*.desktop', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
const apps = stdout.trim().split('\n').map(file => {
const content = fs.readFileSync(file, 'utf8');
const lines = content.trim().split('\n');
const nameLine = lines.find(line => line.startsWith('Name='));
const name = nameLine ? nameLine.substr(5) : path.basename(file, '.desktop');
const iconLine = lines.find(line => line.startsWith('Icon='));
let icon = iconLine ? iconLine.substr(5) : null;
const execLine = lines.find(line => line.startsWith('Exec='));
const execCommand = execLine ? execLine.substr(5) : null;
icon = `/usr/share/icons/hicolor/48x48/apps/${icon}`
// 2. 打开应用程序的.desktop文件,并查找“Icon=”行。这一行包含应用程序的图标文件的路径。
// 3. 使用以下代码来将图标文件转换为base64编码:
// ```
// base64 -w 0 /usr/share/icons/hicolor/48x48/apps/${icon}
// ```
// try {
// var res = execSync(`base64 -w 0 /usr/share/icons/hicolor/48x48/apps/${icon}.png`
// , { encoding: 'utf8' });
// if(res) icon = res;
// } catch (error) {
// console.error(error)
// }
return {
name,
icon,
execCommand,
};
});
store.set('apps', apps);
// console.log(apps)
this.win.webContents.send("appsList", apps)
// updateContextMenu();
});
}
updateAppsList_mac() {
// ls /usr/share/applications/*.desktop
exec('ls /System/Applications/*.app', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
let temp = stdout.replace(/Contents/g, '');
temp=temp.replace(/[:]/g, '');
if(!temp || temp == undefined) return
const apps = temp.trim().split('\n').map((file,index) => {
if(!file || file.indexOf('.app') == -1 || typeof file != 'string') return {};
let fileArr = file.split('/');
let fileName = fileArr[fileArr.length-1];
let fileNameShort = fileName.split('.')[0];
let icon = '';
try {
// AppIcon.icns
var res = execSync(`ls /System/Applications/'${fileName}'/Contents/Resources/*.icns`
, { encoding: 'utf8' });
} catch (e) {
console.log("Errors:", e);
}
icon = res && res.trim().split('\n') || [];
icon = icon.length > 0 ? icon[0] : '';
// console.log('icon', icon)
// 将.icns文件转为.png文件
let fileRes = '';
try {
if(icon) {
fileRes = execSync(`sips -s format png '${icon}' --out /Users/lianda/Desktop/working/file/'${fileNameShort}'.png`);
}
if(fileRes) icon = `/Users/lianda/Desktop/working/file/${fileNameShort}.png`;
} catch (error) {
console.log("Errors2:", error);
}
let execCommand = `open '${file}'`
return {
name: fileNameShort,
icon,
execCommand,
};
});
let newarr = apps.filter(v => !!v.name)
store.set('apps', newarr);
// store.get('apps')
this.win.webContents.send("appsList", newarr)
});
}
}
export default MainWindow
......@@ -5,17 +5,17 @@
<span class="left_name" @click="getFrontApp">许昌市第十六中学</span>
</div>
<div v-if="mode=='modeJianYue'" class="group1_wrap first">
<div v-for="(appItem, appIndex) in group1"
v-show="appIndex < 14"
class="app_item"
<div v-for="(appItem, appIndex) in group1"
:data-appname="appItem.name"
class="app_item"
@click="tapApp(appItem)">
<img :src="appItem.icon" alt="" class="img" v-if="appItem.icon && appItem.icon.indexOf('.png') == -1">
<span class="app_name">{{ appItem.name }}</span>
</div>
</div>
<div v-if="mode=='modeJianYue'" class="group1_wrap">
<div v-for="(appItem, appIndex) in group2"
v-show="appIndex < 14"
<div v-for="(appItem, appIndex) in group2"
:data-appname="appItem.name"
class="app_item"
@click="tapApp(appItem)">
<img :src="appItem.icon" alt="" class="img">
......@@ -23,17 +23,17 @@
</div>
</div>
<div v-if="mode=='modeJianYue'" class="group1_wrap">
<div v-for="(appItem, appIndex) in group3"
v-show="appIndex < 14"
class="app_item"
<div v-for="(appItem, appIndex) in group3"
:data-appname="appItem.name"
class="app_item"
@click="tapApp(appItem)">
<img :src="appItem.icon" alt="" class="img">
<span class="app_name">{{ appItem.name }}</span>
</div>
</div>
<div v-if="mode=='modeJianYue'" class="group1_wrap">
<div v-for="(appItem, appIndex) in group4"
v-show="appIndex < 14"
<div v-for="(appItem, appIndex) in group4"
:data-appname="appItem.name"
class="app_item"
@click="tapApp(appItem)">
<img :src="appItem.icon" alt="" class="img">
......@@ -48,10 +48,6 @@ export default {
return {
appList:[],
mode:'modeJianYue',
// group1:[],
// group2:[],
// group3:[],
// group4:[],
};
},
computed: {
......@@ -67,51 +63,113 @@ export default {
group4() {
return this.appList.length > 14 && this.appList.slice(13,15) || [];
},
ipcRenderer() {
return this.$electron && this.$electron.ipcRenderer || {};
}
},
created() {
},
mounted() {
const screen = this.$electron.remote.screen;
const {width,height} = screen.getPrimaryDisplay().workAreaSize;//获取到屏幕的宽度和高度
console.log('宽高',width,height);
this.listener();
let ipcRenderer = this.$electron && this.$electron.ipcRenderer || {};
ipcRenderer.send("setMainWindow0",{width,height});
ipcRenderer.send("getApps");
ipcRenderer.on("base64Info", (event, {url,index}) => {
// 获取到base64
url = url.replace(/[\r\n]/g, '');
this.appList[index].icon = url;
});
ipcRenderer.on("appsList", (event, list) => {
// console.log('获取到app列表', list)
// 获取到app列表
this.appList = list;
this.appList.forEach((item, index) => {
item.icon && ipcRenderer.send("getBase64", {'imagePath':item.icon,index});
});
});
// 通知主进程
this.ipcSend();
// 接收主进程消息
this.ipcOn();
},
methods: {
listener() {
// 监听右键菜单
window.addEventListener('contextmenu', (e) => {
e.preventDefault();
if(e.target.parentElement && e.target.parentElement.classList.contains("app_item")
|| e.target.classList.contains("app_item")) {
// console.log('app_item')
return;
}
if(e.target.parentElement && e.target.parentElement.classList.contains("left_main")
|| e.target.classList.contains("left_main")) {
// console.log('left_main')
return;
}
// if(e.target.parentElement && e.target.parentElement.classList.contains("left_main")
// || e.target.classList.contains("left_main")) {
// return;
// }
let ipcRenderer = this.$electron && this.$electron.ipcRenderer || {};
ipcRenderer.send("show-context-menu");
});
let ipcRenderer = this.$electron && this.$electron.ipcRenderer || {};
ipcRenderer.on("context-menu-command",(event, mode) => {
// 监听 `dragover` 事件,防止默认行为
window.addEventListener('dragover', (e) => {
e.preventDefault();
});
// 监听 `drop` 事件,获取拖拽的文件路径
window.addEventListener('drop', (e) => {
e.preventDefault();
let appFiles = [];
console.log(e)
let ele = this.findParentOf({className:'app_item',element:e.target});
console.dir(ele)
if(!ele || !ele.dataset ||!ele.dataset.appname) {
// 无法放置
return;
}
let filesArr = new Array(e.dataTransfer.files.length).fill(1);
filesArr.forEach((v,index) => {
// mac-应用程序文件
let file = e.dataTransfer.files[index];
if(file.path.lastIndexOf('.app') == file.path.length-4) {
appFiles.push({
path:file.path,
name: file.name,
shortName: file.name.split('.')[0] || file.name
});
}
// let linux-快捷键
if(file.path.lastIndexOf('.desktop') == file.path.length-8) {
appFiles.push({
path:file.path,
name: file.name,
shortName: file.name.split('.')[0] || file.name
});
}
});
if(appFiles.length==0) {
// 无可用应用程序文件
return;
}
let targetIndex = this.appList.findIndex(v => v.name == ele.dataset.appname);
if(targetIndex>=0) {
// 移动软件
this.ipcRenderer.send('moveSoft', { appname:ele.dataset.appname, addFiles: appFiles });
}
});
},
ipcOn() {
// 接收主进程消息
// 获取到base64
this.ipcRenderer.on("base64Info", (event, {url,index}) => {
url = url.replace(/[\r\n]/g, '');
this.appList[index].icon = url;
});
// 获取到app列表
this.ipcRenderer.on("appsList", (event, list) => {
// console.log('获取到app列表', list)
this.appList = list;
this.appList.forEach((item, index) => {
item.icon && item.icon.indexOf('data:image/png') == -1
&& this.ipcRenderer.send("getBase64", {'imagePath':item.icon,index});
});
});
this.ipcRenderer.on("appsList_update", (event, list) => {
// console.log('刷新app列表', list)
this.appList = list;
});
// 右键菜单点击-切换模式
this.ipcRenderer.on("context-menu-command",(event, mode) => {
console.log('context-menu-command', mode)
let modeObj = {
modeJianYue:'modeJianYue',
......@@ -119,17 +177,39 @@ export default {
modeUXue:'modeUXue',
};
this.mode = modeObj[mode];
console.log(this.mode)
});
},
ipcSend() {
// 通知主进程
const screen = this.$electron.remote.screen;
const {width,height} = screen.getPrimaryDisplay().workAreaSize;//获取到屏幕的宽度和高度
console.log('宽高',width,height);
// 设置程序位置
this.ipcRenderer.send("setMainWindow0",{width,height});
//获取app列表
this.ipcRenderer.send("getApps");
},
tapApp(item) {
console.log(item)
let ipcRenderer = this.$electron && this.$electron.ipcRenderer || {};
ipcRenderer.send("openApp",item);
this.ipcRenderer.send("openApp",item);
},
getFrontApp() {
let ipcRenderer = this.$electron && this.$electron.ipcRenderer || {};
ipcRenderer.send("getfrontApp");
this.ipcRenderer.send("getfrontApp");
},
findParentOf({className,id, element}) {
// 查找当前点击元素是否包含某个类名,或者祖先元素中包含
// tag: .class / #id
if(className) {
if( element.classList.contains(className) ) return element;
else if(element.parentElement) return this.findParentOf({className,id, element:element.parentElement});
else return null;
}
if(id) {
if( element.id = id ) return element;
else if(element.parentElement) return this.findParentOf({className,id, element:element.parentElement});
else return null;
}
}
},
}
......@@ -195,12 +275,14 @@ body {
}
.left_main {
box-sizing: border-box;
position: relative;
display: flex;
align-items: center;
height: 40px;
flex-shrink: 0;
padding: 0 20px;
width: 240px;
background-color: hsl(0, 0%, 25%);
// &::after {
// position: absolute;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论