portable done
This commit is contained in:
parent
a87c4fba7e
commit
6b57cfb189
@ -1,14 +0,0 @@
|
||||
; NSIS 脚本配置 - 最小化版本
|
||||
|
||||
; 仅保留必要的Unicode支持
|
||||
Unicode true
|
||||
|
||||
; 移除所有可能导致警告的自定义文本定义
|
||||
|
||||
; 确保应用数据目录存在的最小化实现
|
||||
!macro preInit
|
||||
SetOutPath $INSTDIR
|
||||
; 创建应用数据目录 - 不使用任何未定义的变量
|
||||
SetShellVarContext current
|
||||
CreateDirectory "$APPDATA\统计技能考试系统\data"
|
||||
!macroend
|
@ -1,91 +0,0 @@
|
||||
const path = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
|
||||
// 创建一个兼容Node.js 12的删除文件夹函数
|
||||
function deleteFolderRecursive(dir) {
|
||||
if (fs.existsSync(dir)) {
|
||||
const files = fs.readdirSync(dir);
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const curPath = path.join(dir, file);
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
// 递归删除子文件夹
|
||||
deleteFolderRecursive(curPath);
|
||||
} else {
|
||||
// 删除文件
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
}
|
||||
// 删除空文件夹
|
||||
fs.rmdirSync(dir);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建打包前的准备工作
|
||||
function prepareForBuild() {
|
||||
console.log('开始准备Windows 7安装版应用打包...');
|
||||
|
||||
try {
|
||||
// 清理之前的构建文件 - 使用兼容Node.js 12的方法
|
||||
const buildDir = path.join(__dirname, 'dist_electron');
|
||||
if (fs.existsSync(buildDir)) {
|
||||
console.log('清理之前的构建文件...');
|
||||
deleteFolderRecursive(buildDir);
|
||||
}
|
||||
|
||||
// 确保data目录存在
|
||||
const dataDir = path.join(__dirname, 'data');
|
||||
if (!fs.existsSync(dataDir)) {
|
||||
fs.mkdirSync(dataDir);
|
||||
fs.writeFileSync(path.join(dataDir, '.gitignore'), '*\n!.gitignore');
|
||||
console.log('创建data目录完成');
|
||||
}
|
||||
|
||||
console.log('准备工作完成');
|
||||
} catch (error) {
|
||||
console.error('准备工作失败:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 执行打包命令
|
||||
function buildInstallerApp() {
|
||||
console.log('开始构建Windows 7安装版应用...');
|
||||
|
||||
try {
|
||||
// 完全删除签名环境变量
|
||||
delete process.env.WIN_CSC_LINK;
|
||||
delete process.env.WIN_CSC_KEY_PASSWORD;
|
||||
// 设置环境变量明确禁用签名相关功能
|
||||
process.env.ELECTRON_BUILDER_SKIP_NOTARIZATION = 'true';
|
||||
process.env.ELECTRON_SKIP_NOTARIZE = 'true';
|
||||
|
||||
// 执行安装包构建命令
|
||||
execSync(
|
||||
'npm run electron:build -- --win nsis --ia32 --x64 --publish never',
|
||||
{ stdio: 'inherit' }
|
||||
);
|
||||
|
||||
console.log('Windows 7安装版应用构建完成!');
|
||||
console.log('构建产物位于 dist_electron 目录');
|
||||
|
||||
} catch (error) {
|
||||
console.error('构建失败:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// 主函数
|
||||
function main() {
|
||||
console.log('==== Windows 7安装版应用打包工具 ====');
|
||||
console.log('Node.js版本:', process.version);
|
||||
console.log('Electron版本: 11.5.0');
|
||||
console.log('Vue版本: 2.6.11');
|
||||
|
||||
prepareForBuild();
|
||||
buildInstallerApp();
|
||||
}
|
||||
|
||||
// 执行主函数
|
||||
main();
|
@ -10,7 +10,6 @@
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"build:win7-portable": "node package-windows-portable.js",
|
||||
"build:win7-installer": "node package-windows-installer.js",
|
||||
"electron:build": "vue-cli-service electron:build",
|
||||
"electron:serve": "vue-cli-service electron:serve",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
|
@ -62,16 +62,12 @@ module.exports = {
|
||||
|
||||
// Windows构建配置 - 修改输出目录结构
|
||||
win: {
|
||||
// 架构设置 - 添加nsis安装包类型
|
||||
// 架构设置
|
||||
target: [
|
||||
{
|
||||
target: "portable",
|
||||
arch: ["ia32", "x64"],
|
||||
},
|
||||
{
|
||||
target: "nsis",
|
||||
arch: ["ia32", "x64"],
|
||||
}
|
||||
],
|
||||
icon: "public/favicon.ico",
|
||||
// 明确禁用签名的多种配置
|
||||
@ -95,29 +91,6 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
|
||||
// 添加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: {
|
||||
// 使用更简单的文件名,避免编码问题
|
||||
|
Loading…
Reference in New Issue
Block a user