【问题标题】:Electron (Atom-Shell) Run unix command from link in pageElectron(Atom-Shell)从页面中的链接运行 unix 命令
【发布时间】:2015-08-13 01:32:31
【问题描述】:

我正在尝试学习 Electron (Atom-Shell),但我发现很难找到它的文档...

我只是想弄清楚如何在 index.html 中创建带有<a href="something"></a> 的链接,并让它打开一个终端窗口或运行某种程序。

我通过学习程序中需要的特定任务来学习语言,这就是我问的原因,以便我可以在我的程序中以其他方式使用该技术。

感谢您的帮助。

【问题讨论】:

    标签: javascript html node.js command electron


    【解决方案1】:

    好吧,本质上,Electron 只是 Chromium 浏览器的定制版本,它与 Nodejs 和一些非常酷的软件包一起打包,基本上允许您像运行本机平台应用程序一样运行定制浏览器。因此,创建 Electron 应用与创建具有 Nodejs 后端的 Web 应用非常相似。

    因此,从简单的“Hello World!”开始吧!应用程序,您只需运行以下 npm...

    npm install electron-prebuilt --save-dev
    

    安装 npm 后,您需要三个文件来运行 Electron 应用程序。

    1. 一个 package.json 文件
    2. 一个 javascript 文件(默认为 main.js)
    3. html 文件(默认为 index.html)

    请参阅此 GitHub 存储库以获取每个和更详细说明的快速复制/粘贴版本:https://github.com/mafintosh/electron-prebuilt

    之后,您就可以简单地运行您的应用了...

    $ electron .
    

    最后,打开终端窗口的一种方法是使用 html 中的 onclick 属性来触发 child_process,在函数中找到 here

    就是这样!您应该能够像编辑任何 web 应用程序一样编辑 html 和 javascript 文件,并利用 Electron 提供的附加功能。

    我还想查看这些资源以获取更多信息:

    Electron 工作原理的快速入门介绍 -- https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md

    Atom 论坛(因为 Atom 是用 Electron 构建的,并且可以破解,所以社区非常活跃) -- https://discuss.atom.io/c/electron

    一个很酷的回购,以跟上最新的信息。它包括当前使用 Electron 的应用程序的链接、教程、视频等—— https://github.com/sindresorhus/awesome-electron

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2019-08-15
      • 2016-07-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 2017-11-10
      • 2017-04-18
      • 2015-06-13
      • 2011-03-03
      相关资源
      最近更新 更多