提交 4dd0186c authored 作者: 蔡芬's avatar 蔡芬

应用程序列表

上级 83b0896a
......@@ -28,6 +28,7 @@
"vue-cli-plugin-electron-builder/electron-builder": "^23.0.3"
},
"dependencies": {
"aws-sdk": "^2.1351.0",
"axios": "^0.24.0",
"bluebird": "^3.7.2",
"body-parser": "^1.20.1",
......@@ -36,6 +37,8 @@
"element-ui": "^2.15.6",
"icns": "^0.1.0",
"js-cookie": "^3.0.1",
"mock-aws-s3": "^4.0.2",
"nock": "^13.3.0",
"node-machine-id": "^1.1.12",
"pbkdf2": "3.1.1",
"pinyin": "^3.0.0-alpha.4",
......
......@@ -142,7 +142,8 @@ class SoftList {
name,
icon,
execCommand,
noDisplay
noDisplay,
desktop:file
};
});
let newApps = apps.filter(v => !!v.icon && v.type=='Application' && (v.noDisplay != true && v.noDisplay != 'true'));
......
......@@ -48,24 +48,25 @@ class MainWindow {
const win = new BrowserWindow({
width: 1000,
height: 40,
// height: 40,
// fullscreen:true, //是否全屏显示
// fullscreenable:true,
maxWidth: 1000,
maxHeight: 40,
// maxHeight: 40,
height:720,
resizable: false,
x:400,
y:500,
movable:false,
closable:false,
alwaysOnTop:true,
fullscreen:false,
fullscreenable:false,
autoHideMenuBar:true,
backgroundColor: '#00000000', //透明颜色
transparent:true, //透明开启
skipTaskbar:true,
autoHideMenuBar:true,
// movable:false,
// closable:false,
// alwaysOnTop:true,
// fullscreen:false,
// fullscreenable:false,
// autoHideMenuBar:true,
// backgroundColor: '#00000000', //透明颜色
// transparent:true, //透明开启
// skipTaskbar:true,
// autoHideMenuBar:true,
// useContentSize: true,
webPreferences: {
/* 注意,这些设置有关程序的安全性,请谨慎使用!
......@@ -78,9 +79,9 @@ class MainWindow {
// eslint-disable-next-line no-undef
title: process.env.VUE_APP_TITLE, //如果由loadURL()加载的HTML文件中含有标签<title>,此属性将被忽略 ,或者vue.config.js 里配置了 pages.app.title, 此属性也会被忽略
icon: path.resolve(__static, 'logo.png'), //窗口的图标更换,仅支持svg、ico、 png ,在public下
frame: false, //窗口边框+菜单+放大缩小 都没有
// frame: false, //窗口边框+菜单+放大缩小 都没有
show:false, //窗口状态关闭 - 等待加载完成再去显示,不显示白屏加载过程
resizable:false,
// resizable:false,
})
this.win = win
......@@ -88,7 +89,7 @@ class MainWindow {
// 等待加载完成再去显示,不显示白屏加载过程
win.once('ready-to-show', () => {
win.show();
win.setAlwaysOnTop(true);
// win.setAlwaysOnTop(true);
});
this.quitListener()
......
<template>
<div id="app" ref="appcontainer" class="container">
<div>
<router-view></router-view>
</div>
<!-- <div id="app" ref="appcontainer" class="container">
<div class="left_main">
<img src="~@/assets/WechatIMG17.jpeg" alt="" class="left_img">
<span class="left_name" @click="getFrontApp">许昌市第十六中学</span>
......@@ -40,9 +43,10 @@
<span class="app_name">{{ appItem.name }}</span>
</div>
</div>
</div>
</div> -->
</template>
<script>
import pinyin from 'pinyin';
export default {
data() {
return {
......@@ -73,12 +77,12 @@ export default {
mounted() {
this.listener();
// this.listener();
// 通知主进程
this.ipcSend();
// 接收主进程消息
this.ipcOn();
// // 通知主进程
// this.ipcSend();
// // 接收主进程消息
// this.ipcOn();
},
......
......@@ -23,7 +23,7 @@ export default [
path: "/",
name: "Home",
component: () => import('../views/Home.vue'),
redirect: '/home',
redirect: '/application',
meta: { title: 'Home', icon: 'example' },
hidden: false,
children: [
......@@ -38,5 +38,22 @@ export default [
}
}]
},
{
path: "/application",
name: "Application",
component: () => import('../views/application/list.vue'),
meta: { title: 'Application', icon: 'example' },
hidden: false,
children: [
// {
// path: 'home',
// name: 'CourseList',
// component: () => import('../views/Home.vue'),
// meta: {
// title: 'Home' // 页签标题
// }
// }
]
},
{ path: '*', redirect: '/404', hidden: true }
]
\ No newline at end of file
<template>
<div>
<div style="color:#fff;font-size: 24px;">
Home
</div>
</template>
......
<template>
<div class="application-list-container">
<div v-for="(appItem) in appList" class="application-item" @click="tapApp(appItem)">
<div>名字:{{ appItem.name }}</div>
<img :src="appItem.icon" alt="" class="img">
<div>中文名字:{{ appItem.nameOfZh }}</div>
<div>文件路径:{{ appItem.desktop }}</div>
</div>
</div>
</template>
<script>
import pinyin from 'pinyin';
export default {
data() {
return {
appList:[],
mode:'modeJianYue',
};
},
computed: {
group1() {
return this.appList.length > 8 && this.appList.slice(0,9) || [];
},
group2() {
return this.appList.length > 10 && this.appList.slice(9,11) || [];
},
group3() {
return this.appList.length > 12 && this.appList.slice(11,13) || [];
},
group4() {
return this.appList.length > 14 && this.appList.slice(13,15) || [];
},
ipcRenderer() {
return this.$electron && this.$electron.ipcRenderer || {};
}
},
created() {
},
mounted() {
this.listener();
// 通知主进程
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")) {
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");
});
// 监听 `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) => {
// console.log(item.icon)
if(item.icon && item.icon.indexOf('data:image/png') == -1) {
this.ipcRenderer.send("getBase64", {'imagePath':item.icon,index});
}
});
this.getPinyin();
});
this.ipcRenderer.on("appsList_update", (event, list) => {
console.log('刷新app列表', list)
this.appList = list;
this.getPinyin();
});
// 获取到app消息
this.ipcRenderer.on("getMsg", (event, msgStr) => {
console.log('获取到app消息', msgStr)
});
// 右键菜单点击-切换模式
this.ipcRenderer.on("context-menu-command",(event, mode) => {
console.log('context-menu-command', mode)
let modeObj = {
modeJianYue:'modeJianYue',
modeJiJian:'modeJiJian',
modeUXue:'modeUXue',
};
this.mode = modeObj[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)
this.ipcRenderer.send("openApp",item);
},
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;
}
},
// 排序
getPinyin() {
// 将每个应用程序名字转换为拼音,并组成一个新的数组
const appNamesInPinyin = this.appList.map(appItem => {
return {
icon:appItem.icon,
nameOfZh:appItem.nameOfZh,
desktop:appItem.desktop,
name: (appItem.nameOfZh || appItem.name),
pinyin: pinyin((appItem.nameOfZh || appItem.name), {
style: pinyin.STYLE_NORMAL
}).join('')
};
});
// 根据拼音进行排序
appNamesInPinyin.sort((a, b) => {
return a.pinyin.localeCompare(b.pinyin);
});
// 输出排序后的应用程序名字
appNamesInPinyin.forEach(app => {
console.log(app.nameOfZh || app.name);
});
},
},
}
</script>
<style lang="less" scoped>
.application-list-container {
width: 100%;
height: 100vh;
font-size: 24px;
background: #fff;
img {
width: 50px;
height: 50px;
}
.application-item {
display: flex;
}
}
</style>
\ No newline at end of file
差异被折叠。
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论