https://github.com/electron/electron
Electron 是 Github 发布跨平台桌面应用开发工具,支持 Web 技术开发桌面应用开发,其本身是基于 C++ 开发的,GUI 核心来自于 Chrome,而 JavaScript 引擎使用 v8。
mac 安装node 6.10.3.pkg https://nodejs.org/
直接下一步,下一步安装即可。 This package will install Node.js v6.10.3 and npm v3.10.10 into /usr/local/. 然后 node 和 npm 命令就可以使用了。 创建第一个helloworld vi hello.js
var http = require('http'); http.createServer(function(req, res){ res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(8808, '127.0.0.1'); console.log('Server running at http://127.0.0.1:8808');node hello.js 然后访问 http://127.0.0.1:8808/ 就可以看到效果了。
nodejs的网站被屏蔽,可以使用淘宝的镜像。 修改 配置文件 ~/.bash_profile
#alias for cnpm alias cnpm="npm --registry=https://registry.npm.taobao.org \ --cache=$HOME/.npm/.cache/cnpm \ --disturl=https://npm.taobao.org/dist \ --userconfig=$HOME/.cnpmrc然后就可以使用 cnpm 命令了,(是china npm的意思吧) 以后都使用 cnpm 命令替换掉npm 命令。
官方已经提供了一个很简单的demo了。
# Clone this repository git clone https://github.com/electron/electron-quick-start # Go into the repository cd electron-quick-start # Install dependencies 注意是cnpm 命令!! cnpm install # Run the app npm start同时可以通过https://electron.atom.io/ 地址下载demo。也是集成了很多例子的。
已经开启视频支持。不需要确认直接调用。 在浏览器上面还要用户确认下,这个直接调用了。 对于用户来说就是一个app应用。
https://github.com/electron/electron/blob/master/docs/api/desktop-capturer.md
// In the renderer process. const {desktopCapturer} = require('electron') desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => { if (error) throw error for (let i = 0; i < sources.length; ++i) { if (i == 0) {//获得第一个。api变了。名字叫别的了。 navigator.webkitGetUserMedia({ audio: false, video: { mandatory: { chromeMediaSource: 'desktop', chromeMediaSourceId: sources[i].id, minWidth: 1280, maxWidth: 1280, minHeight: 720, maxHeight: 720 } } }, handleStream, handleError) return } } }) function handleStream (stream) { document.querySelector('video').src = URL.createObjectURL(stream) } function handleError (e) { console.log(e) }本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/71261179 未经博主允许不得转载。 博主地址是:http://blog.csdn.net/freewebsys
nodejs 类库,能做的事情还是很多的。功能非常强大。 之前认为这个只是一个前端同学学习的工具。 但后来认为,这个是一个新的框架体系。可以做的事情很多。 全栈工程师必须要学习的技术。使用好了,可以提高效率。 其实大多数的开发就是做应用开发的。 快速的将产品交付给用户使用就好了,然后回家睡觉。 真的不用纠结用啥技术。你应该不在乎,用户也不在乎。