vue中如何添加electron,代码是什么
Admin 2022-07-07 群英技术资讯 1195 次浏览
很多朋友都对“vue中如何添加electron,代码是什么”的内容比较感兴趣,对此小编整理了相关的知识分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获,那么感兴趣的朋友就继续往下看吧!"main": "electron.js",
在 “scripts”: {添加:
"package": "electron-packager ./ appName --overwrite"
在"dependencies": {添加:
"electron-share-memory": "^1.0.1", "node-gyp-build": "^4.3.0", "vue-photo-preview": "^1.1.3",
在 “devDependencies”: {添加:
"electron": "^15.3.1", "electron-packager": "^15.4.0",
在devServer: {修改:
// open: true,(之前是没有注释掉的,现在把他注释掉)
在proxy: {修改
'/api': {
target: "electron-renderer",(只改了这个地方,之前是 target: 'http://localhost',)
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
import preview from 'vue-photo-preview' import 'vue-photo-preview/dist/skin.css' Vue.use(preview) // 解决electron 报错 process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'TRUE'
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
const path = require('path')
function createWindow () {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 1889,
height: 1000,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
// and load the index.html of the app.
// mainWindow.loadFile('./dist/index.html')
mainWindow.loadURL('http://172.16.1.155:7890/xjbd')
// Open the DevTools.
mainWindow.webContents.openDevTools()
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
npm run dev
然后在运行
npm run package


免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要给大家分享用jQuery怎样做一个九宫格抽奖功能的示例,九宫格抽奖功能在很多营销活动页面都能看到,还是比较常用的一个抽奖功能, 这篇主要是使用jQuery来实现的,文中代码具有一定的借鉴价值,感兴趣的朋友可以参考,希望大家阅读完这篇文章能有所收获,下面我们一起来学习一下吧。
这篇文章主要给大家分享JS实现sleep睡眠函数的内容,我们知道JavaScript因为是单线程运行,所以没有内置的sleep函数,因此这些朋友就不太了解JavaScript sleep睡眠函数的实现,对此下面小编就给大家来介绍一下。
本篇文章整理总结了一些基于jQuery的前端面试来分享给大家,里面jQuery的常见面试问题,以及移动端常见问题,希望对大家有所帮助!
jquery初始化方法通常是下面这四种,使用非常的普遍,js初始化是在界面加载完成后执行的一些函数,在使用jquery初始化之前需要在head标签内引入jquery包,例如: scripttype=text/javascriptsrc=./js/jquery.min.js/script Jquery初始化方法一: scripttype=
方法:1、利用index()和parent()方法来获取当前元素的行位置,语法为“元素对象.parent().index()+1;”;2、利用index()方法来获取当前元素的列位置,语法为“元素对象.index()+1;”。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008