<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # node-webkit教程(11)Platform Service之shell > 作者:玄魂 > 來源:[node-webkit教程(11)Platform Service之shell](http://www.cnblogs.com/xuanhun/p/3685100.html) ## 目錄 + 11.1 Shell是什么 + 11.2 示例 + 11.3 小結 ## 11.1 Shell是什么 Shell是和桌面系統相關的一組API。通常在操作系統中,我們有“核”和“殼”的區分,“核”是操作系統的內核,“殼”是一個操作界面,提供給用戶輸入命令,解析并執行命令(調用“核”),這個用戶界面被稱作Shell(“殼”)。最常見的shell就是命令行(如windows下的CMD)。 Node-Webkit提供的shell功能很有限,現在能看到的只有三個api: + openExternal(URI) 用桌面系統默認的行為,在應用外部打開URI。這和我們在瀏覽器中打開一個[mailto:](http://www.cnblogs.com/mailto:)鏈接是一樣的,控制器會轉到桌面系統默認的郵件客戶端。 ![](img/241135319201514.png) + openItem(file_path) 以操作系統默認方式打開指定路徑。 + showItemInFolder(file_path) 在文件管理器中顯示“file_path”指定的文件。 ## 11.2 示例 新建shell.html和package.json文件。 shell.html 內容如下: ``` <html> <head> <title>shellDemo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body > <h1>shell 測試</h1> <button onclick="openInexplorer()">在默認瀏覽器中打開玄魂的電子書</button> <button onclick="openPdf()">打開pdf</button> <button onclick="showPdfInFloder()">打開pdf所在的文件夾</button> <script> // Load native UI library. var gui = require('nw.gui'); var shell = gui.Shell; function openInexplorer() { shell.openExternal('http://ebook.xuanhun521.com'); } function openPdf() { shell.openItem('D:\\101.pdf'); } function showPdfInFloder() { shell.showItemInFolder('D:\\學習資料\\技術類教程\\操作系統\\101-深入理解Linux內核(第三版 英文版)-1030頁-pdf-免費下載.pdf'); } </script> </body> </html> ``` package.json內容如下: ``` { "name": "shell-demo", "main": "shell.html", "nodejs":true, "window": { "title": "shellDemo", "toolbar": true, "width": 800, "height": 600, "resizable":true, "show_in_taskbar":true, "frame":true, "kiosk":false, "icon": "2655716405282662783.png" }, "webkit":{ "plugin":true } } ``` 在上面的代碼中,我們首先獲取shell對象, ``` // Load native UI library. var gui = require('nw.gui'); var shell = gui.Shell; ``` ![](img/241135394203223.png) 函數openInexplorer中,調用shell.openExternal方法,在默認瀏覽器中打開“[玄魂的電子書站點](http://ebook.xuanhun521.com/)”。運行效果如下: ![](img/241135444352889.jpg) 在函數openPdf中調用shell.openItem('D:\\101.pdf'),在系統默認的paf閱讀器中打開pdf文檔,效果如下: ![](img/241135498103214.png) 在函數showPdfInFloder中,調用shell.showItemInFolder方法,在文件夾中顯示并選中該文件。 ![](img/241135559981125.jpg) ## 11.3 小結 本文內容主要參考node-webkit的官方英文文檔,做了適當的調整([https://github.com/rogerwang/node-webkit/wiki/Shell](https://github.com/rogerwang/node-webkit/wiki/Shell))。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看