修改打包为exe单文件
This commit is contained in:
parent
11b539eb56
commit
89440a531a
@ -18,7 +18,7 @@
|
|||||||
"@vitejs/plugin-vue": "^5.0.5",
|
"@vitejs/plugin-vue": "^5.0.5",
|
||||||
"@vue/tsconfig": "^0.5.1",
|
"@vue/tsconfig": "^0.5.1",
|
||||||
"electron": "^25.3.0",
|
"electron": "^25.3.0",
|
||||||
"electron-builder": "^24.4.0",
|
"electron-builder": "latest",
|
||||||
"npm-run-all2": "^6.2.0",
|
"npm-run-all2": "^6.2.0",
|
||||||
"typescript": "~5.4.0",
|
"typescript": "~5.4.0",
|
||||||
"vite": "^5.3.1",
|
"vite": "^5.3.1",
|
||||||
|
@ -31,21 +31,30 @@ export const ElectronBuildPlugin = (): Plugin => {
|
|||||||
fs.mkdirSync('dist/node_modules')
|
fs.mkdirSync('dist/node_modules')
|
||||||
|
|
||||||
electronBuilder.build({
|
electronBuilder.build({
|
||||||
config:{
|
config:{ // 通常是文件 electron-builder.yml
|
||||||
directories: {
|
directories: {
|
||||||
output: path.resolve(process.cwd(), 'release'),
|
output: path.resolve(process.cwd(), 'release'),
|
||||||
app: path.resolve(process.cwd(), 'dist'),
|
app: path.resolve(process.cwd(), 'dist'),
|
||||||
},
|
},
|
||||||
asar: true,
|
appId: 'com.c1.game.launcher',
|
||||||
appId: 'com.example.app',
|
productName: 'c1-game-launcher',
|
||||||
productName: 'vite-electron',
|
win: {
|
||||||
nsis:{
|
icon: path.resolve(process.cwd(), 'src/assets/test-icon.ico'), // 指定图标文件路径
|
||||||
oneClick: false, // 取消一键安装
|
target: [
|
||||||
allowToChangeInstallationDirectory: true, // 允许用户选择安装目录
|
{
|
||||||
|
target: 'portable',
|
||||||
|
arch: ['x64', 'ia32']
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
console.log('Build successful!')
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error during build:', error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,13 +31,14 @@ export const ElectronDevPlugin = (): Plugin => {
|
|||||||
const IP = `http://localhost:${addressInfo.port}`
|
const IP = `http://localhost:${addressInfo.port}`
|
||||||
|
|
||||||
// 进程传参发给electron IP地址
|
// 进程传参发给electron IP地址
|
||||||
let ElectronProcess = spawn(require('electron'), ['dist/background.js', IP])
|
let electronProcess = spawn(require('electron'), ['dist/background.js', IP])
|
||||||
fs.watchFile('src/background.ts', ()=>{
|
fs.watchFile('src/background.ts', ()=>{
|
||||||
ElectronProcess.kill()
|
console.log('提示', 'background.ts 文件发生改变,electronProcess 重新启动')
|
||||||
|
electronProcess.kill()
|
||||||
BuildBackground()
|
BuildBackground()
|
||||||
ElectronProcess = spawn(require('electron'), ['dist/background.js', IP])
|
electronProcess = spawn(require('electron'), ['dist/background.js', IP])
|
||||||
})
|
})
|
||||||
ElectronProcess.stderr.on('data', (data) => {
|
electronProcess.stderr.on('data', (data) => {
|
||||||
console.log('日志', data.toString())
|
console.log('日志', data.toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import TheWelcome from './components/TheWelcome.vue'
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<header>
|
<header>
|
||||||
|
<h1> Hello Soviby! </h1>
|
||||||
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
|
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" />
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
BIN
src/assets/test-icon.ico
Normal file
BIN
src/assets/test-icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 297 KiB |
@ -13,7 +13,6 @@ app.whenReady().then(()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
// win.webContents.openDevTools() // 开发环境打开控制台
|
// win.webContents.openDevTools() // 开发环境打开控制台
|
||||||
|
|
||||||
if(process.argv[2]) // 开发环境
|
if(process.argv[2]) // 开发环境
|
||||||
{
|
{
|
||||||
win.loadURL(process.argv[2])
|
win.loadURL(process.argv[2])
|
||||||
|
Loading…
Reference in New Issue
Block a user