【问题标题】:Integration of PortQry with ElectronJS Desktop AppPortQry 与 ElectronJS 桌面应用程序的集成
【发布时间】:2019-08-08 21:27:17
【问题描述】:

我目前正在尝试使用 ElectronJS 围绕 Microsoft's PortQry CLI 构建一个包装器,以自动检查与我公司服务(Active Directory、Outlook 等)的连接性,并拥有一个更好看的 GUI。 (我喜欢引导)

计划是让我的 electronJS 应用程序在本地运行 CLI 并获取输出。我尝试使用node-cmd,但无法显示输出。

以下是我的 electronJS 文件:

索引.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>

后端.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 是否可以工作,但我似乎无法将它导入到我的代码中。

任何帮助将不胜感激!

【问题讨论】:

    标签: javascript tcp udp electron port


    【解决方案1】:

    我现在意识到这个问题有多愚蠢。

    Electronjs 使用 nodejs 作为运行时。我以前在 chrome 中启动 index.html,因此它从来没有工作过。您必须启动电子应用程序才能运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多