[英]Integration of PortQry with ElectronJS Desktop App
我目前正在嘗試使用ElectronJS圍繞Microsoft的PortQry CLI構建包裝器,以自動檢查與我公司服務(Active Directory,Outlook等)的連接,並具有外觀更好的GUI。 (我喜歡引導程序)
該計划是讓我的electronJS應用程序在本地運行CLI並獲取輸出。 我嘗試使用node-cmd,但無法顯示輸出。
以下是我的electronJS文件:
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div>
<p id="input">Hello World</p>
</div>
<script src="./backend.js"></script>
</body>
</html>
backend.js
var cmd=require('node-cmd');
cmd.get(
'C:\PortQryV2\portqry -n google.com -p tcp -o 8080',
function(err, data, stderr){
document.getElementById("input").innerHTML=data;
}
);
main.js
const { app, BrowserWindow } = require('electron')
function createWindow () {
// Create the browser window.
let win = new BrowserWindow({ width: 800, height: 600 })
// and load the index.html of the app.
win.loadFile('index.html')
win.webContents.openDevTools()
}
app.on('ready', createWindow)
因此,應該運行PortQry,並更改p標簽以顯示輸出。 但是我無法使它正常工作。 我當時在想看看nodejs的child_process是否可以正常工作,但是似乎無法將其導入到我的代碼中。
任何幫助將不勝感激!
我意識到現在這個問題多么愚蠢。
Electronjs使用nodejs作為運行時。 我以前在Chrome中啟動index.html,因此它永遠無法正常工作。 您必須啟動電子應用程序才能使其正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.