or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
在 electron APP 中使用 vue
tags :
w3HexSchool
.electron
github : https://github.com/andrew781026/cypress-hahow/tree/master/vue-proj
上期 利用 electron.js 建立桌面 APP ( Windows )
我們製作桌面 APP 並借用 APP 中按鈕的開啟瀏覽器來顯示我們製作的 vue 頁面
但是 , 如果我們想要做一個完整的桌面 APP 時該如何實現呢 ?
這次我們來更加深入的整合與使用 vue & electron
建立 vue 專案
首先我們藉由 vue-cli 建立一個基礎 vue 模板
參照官方的 vue-cli 安裝指南
Tree 整理出了建立步驟如下
vue create
建立新專案安裝
vue-cli
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →然後 , 我們就可以安裝今天的文章主角
vue-cli-plugin-electron-builder
讓我們偷看一下插件官網教學 , 了解如何安裝
vue-cli-plugin-electron-builder
原來安裝的方法很簡單 , 只要
vue add electron-builder
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →讓我們施加魔幻大法吧 !
查看施法結果如何 ?
太棒了 ! 我們建立桌面一個 APP 了呢 !
使用 Node.js 相關的 API
需要轉換成桌面 APP 最關鍵的原因在於有些行為瀏覽器是不允許執行的
例 :
不過 , 我們需要如何使用 Node API 呢 ?
方法一 : preloader.js
在 new BrowserWindow() 時 , 設定一個 JS 檔 , 讓其可以執行 Node API 也可以取得 html 中的 window 物件 , 並將函式註冊到 window 上以利 vue 開發時使用
如果想查看完整程式碼 , 可以查看我的 Github
方法二 : ipcMain . ipcRender
在 html 中使用 ipcRender
在 background.js 中使用 ipcMain
並且 ipcRender 與 ipcMain 利用 .send / .on 方法在同名的頻道中進行溝通
參考資料