exam11/vue.config.js
2025-09-10 14:02:41 +08:00

139 lines
3.8 KiB
JavaScript

module.exports = {
// 添加应用标题配置
chainWebpack: (config) => {
config.plugin("html").tap((args) => {
args[0].title = "统计技能考试系统";
return args;
});
},
// 输出目录
outputDir: 'dist_electron',
pluginOptions: {
electronBuilder: {
// 基础配置
nodeIntegration: false,
contextIsolation: true,
// 更新preload路径为background目录下的preload.js
preload: "background/preload.js",
mainProcessFile: "background/main.js",
lintPreloadFiles: false,
externals: ["fontkit", "pdfkit"],
// 主进程webpack配置
chainWebpackMainProcess: (config) => {
config.module
.rule("babel")
.test(/\.js$/)
.use("babel-loader")
.loader("babel-loader")
.options({
presets: ["@babel/preset-env"],
plugins: [
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-class-properties",
],
})
.end();
// 添加对mjs文件的处理 - 兼容Electron 11
config.module
.rule("mjs")
.test(/\.mjs$/)
.include.add(/node_modules/)
.end()
.type("javascript/auto");
},
// 所有构建选项都放在这里
builderOptions: {
// 应用基本信息
appId: 'com.example.exam11',
productName: '统计技能考试系统',
// 压缩设置
compression: "store",
// 入口文件配置
extraMetadata: {
main: "background.js"
},
// Windows构建配置 - 修改输出目录结构
win: {
// 架构设置 - 添加nsis安装包类型
target: [
{
target: "portable",
arch: ["ia32", "x64"],
},
{
target: "nsis",
arch: ["ia32", "x64"],
}
],
icon: "public/favicon.ico",
// 明确禁用签名的多种配置
sign: false,
signingHashAlgorithms: [],
certificateFile: null,
certificatePassword: null,
// 额外资源配置 - 确保data目录被正确打包
extraResources: [
{
from: "data",
to: "data",
filter: ["**/*"], // 包含data目录中的所有内容
},
{
from: "background",
to: "background",
filter: ["**/*"],
},
],
},
// 添加nsis安装包特定配置
// 修改NSIS配置部分
nsis: {
// 安装包名称
artifactName: "installer/StatExamInstaller_${version}_${arch}.exe",
// 一键安装
oneClick: false,
// 允许用户选择安装目录
allowToChangeInstallationDirectory: true,
// 安装图标
installerIcon: "public/favicon.ico",
// 卸载图标
uninstallerIcon: "public/favicon.ico",
// 安装完毕后运行程序
runAfterFinish: true,
// 包含中文语言支持
include: "build/installer.nsh",
// 定义安装目录名
shortcutName: "统计技能考试系统",
// 修正:使用正确的属性名 menuCategory
menuCategory: "统计技能考试系统",
},
// 便携应用特定配置 - 修改输出结构
portable: {
// 使用更简单的文件名,避免编码问题
artifactName: "portable-app/StatExamPortable_${version}_${arch}.exe",
},
// 全局禁用签名配置
forceCodeSigning: false,
asar: true,
// 配置输出目录
directories: {
output: "dist_electron",
},
},
},
},
};