软件调用
调用第三方程序
注意
请先将【powershell.exe】复制到【electron-egg/build/extraResources】目录中
# 调用其它软件(exe、bash等可执行程序)
// frontend/src/views/framework/software/Index.vue
<script>
openSoft (id) {
this.$ipc.invoke(ipcApiRoute.openSoftware, id).then(result => {
if (!result) {
this.$message.error('程序不存在');
}
})
},
</script>
// electron/controller/framework.js
/**
* 调用其它程序(exe、bash等可执行程序)
*/
openSoftware(softName) {
if (!softName) {
return false;
}
let softwarePath = path.join(Ps.getExtraResourcesDir(), softName);
Log.info('[openSoftware] softwarePath:', softwarePath);
// 检查程序是否存在
if (!fs.existsSync(softwarePath)) {
return false;
}
// 命令行字符串 并 执行
let cmdStr = 'start ' + softwarePath;
exec(cmdStr);
return true;
}
// Make sure to add code blocks to your code group
# 完整代码
上次更新: 2025/04/10, 03:07:49