1.yarn安装
yarn add -D electron
yarn add -D vue-cli-plugin-electron-builder
2.在main.js的同级目录中添加background.js
/** @format */
"use strict";
import {
app, protocol, BrowserWindow } from "electron";
// import {
// createProtocol,
// installVueDevtools,
// } from "vue-cli-plugin-electron-builder/lib";
const isDevelopment = process.env.NODE_ENV !== "production";
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([
{
scheme: "app",
privileges: {
secure: true,
standard: true
}
}
]);
function createWindow<

本文介绍了如何将Vue与Electron结合,通过yarn安装electron和vue-cli-plugin-electron-builder插件,创建background.js文件,并在package.json中配置相关执行命令,实现项目的构建和运行。
最低0.47元/天 解锁文章
1257





