vue中如何添加electron,代码是什么
Admin 2022-07-07 群英技术资讯 1102 次浏览
很多朋友都对“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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
JWT简单的原理介绍JWT(JsonWebToken)是一种身份验证及授权方案,简单的说就是调用端调用api时,附带上一个由api端颁发的token,以此来验证调用者的授权信息。通过一种加密规则(如HS256)+secret生成一串字符串(token),token字符串中一般含有过期时间和签名信息,根据签名和过期时间,就可以判断当前token是否有效。//new
这篇文章主要给大家分享的是关于react的setstate的内容,对于setstate是同步还是异步的问题,一些朋友可能不是理解,对此我们通过示例来了解一下,感兴趣的朋友就继续往下看吧。
这篇文章主要为大家介绍了Three.js创建文字初体验,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助
这篇文章主要为大家详细介绍了JavaScript实现密码框验证信息,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
这篇文章我们来了解用jQuery如何获取ul下li的个数,下文示例对新手学习jQuery有一定的参考价值,有这方面学习需要的朋友接下来就跟随小编来一起学习一下吧!
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
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