赞
踩
# 1. 安装nvm ## 官网 : https://github.com/nvm-sh/nvm ## csdn加速 : https://gitcode.net/mirrors/nvm-sh/nvm ## git 下载 git clone https://github.com/nvm-sh/nvm.git 或 git clone https://gitcode.net/mirrors/nvm-sh/nvm.git ## 安装 bash install.sh ## 如果无法clone ## 修改 LINE57 NVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git" ## 修改为 NVM_SOURCE_URL="https://gitcode.net/mirrors/${NVM_GITHUB_REPO}.git" ## 安装完成修改镜像地址 export NVM_NODEJS_ORG_MIRROR="https://npm.taobao.org/mirrors/node" export NVM_IOJS_ORG_MIRROR="https://npm.taobao.org/mirrors/iojs ## 如果nvm不在环境变量 vi ~/.profile source ~/.bashrc ## 查看nvm所有命令 nvm -help ## 查看nodejs版本 nvm list ## 安装nodejs nvm install stable ## 查看node/npm版本 node -version npm -verinon # 2. 安装nrm ## nrm 官网 https://www.npmjs.com/package/nrm npm install -g nrm --registry=https://registry.npmmirror.com nrm --version ## 查看nrm命令行 nrm -help ## 使用 nrm use cnpm # 4. electron 环境搭建 ## electron官网 https://www.electronjs.org/zh/docs/latest/tutorial/quick-start mkdir my-electron-app && cd my-electron-app npm init npm install --save-dev electron ## 按照要求添加main.js 代码如下 ## 运行查看效果 npm start # 5. 安装yarn ## yarn官网 ## https://www.npmjs.com/package/yarn npm install -g yarn # 6. 安装electron builder ## electron builder 官网 ## https://www.electron.build/#quick-setup-guide yarn add electron-builder --dev # 7. 设置builder的package.json ## 加入下方build内容 # 8. 输出所有内容 ./node_modules/.bin/electron-builder
const { app, BrowserWindow } = require('electron') const path = require('path') function createWindow() { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js') } }) win.loadURL('https://www.bilibili.com/') win.on('closed', () => { app.quit() }) } app.whenReady().then(() => { createWindow() })
"build": { "mac": { "target": [ { "target": "dmg", "arch": [ "x64", "arm64" ] }, { "target": "zip", "arch": [ "x64", "arm64" ] } ] }, "win": { "target": [ { "target": "nsis", "arch": [ "x64", "ia32" ] }, { "target": "zip", "arch": [ "x64", "ia32" ] } ] } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。