简介
vue-cli-electron是 vue2 基于vue-cli3&4的版本
环境
一个简单的表格是这么创建的:
开发环境 | 版本 |
---|
node版本 | >=14.0.0 推荐v16 | Electron版本 | ^13.0.0 | vue版本 | ^2.0x | vue-cli | v3和v4 |
安装依赖
https://npmmirror.com/mirrors/node/v16.14.2/node-v16.14.2-x64.msi
npm install -g @vue/cli
npm install -g yarn
yarn add vue-cli-plugin-electron-builder -D
执行
vue create vue-electron-pro
cd vue-electron-pro
npm install
vue add electron-builder
yarn electron:serve
关闭工具栏
import { app, protocol, BrowserWindow, Menu } from "electron";
async function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 800,
icon: `@/assets/imgs/favicon.ico`,
webPreferences: {
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
},
});
Menu.setApplicationMenu(null);
if (process.env.WEBPACK_DEV_SERVER_URL) {
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL);
} else {
createProtocol("app");
win.loadURL('app://./index.html');
}
}
|