src/background移至background
This commit is contained in:
parent
cc9dd60a16
commit
5952c096f0
@ -49,41 +49,17 @@ function prepareForBuild() {
|
||||
}
|
||||
}
|
||||
|
||||
// 临时修改package.json的main字段
|
||||
function updatePackageJson() {
|
||||
const packageJsonPath = path.join(__dirname, 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
// 删除之前添加的临时修改package.json的逻辑,因为现在路径已经正确
|
||||
|
||||
// 保存原始的main字段值
|
||||
const originalMain = packageJson.main;
|
||||
|
||||
// 修改main字段为正确的路径
|
||||
packageJson.main = 'src/background/main.js';
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||
|
||||
console.log('已临时修改package.json的main字段为: src/background/main.js');
|
||||
|
||||
// 返回恢复函数
|
||||
return function restorePackageJson() {
|
||||
packageJson.main = originalMain;
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
||||
console.log('已恢复package.json的main字段为原始值');
|
||||
};
|
||||
}
|
||||
|
||||
// 执行打包命令
|
||||
function buildPortableApp() {
|
||||
console.log('开始构建Windows 7便携应用...');
|
||||
|
||||
// 临时修改package.json
|
||||
const restorePackageJson = updatePackageJson();
|
||||
|
||||
try {
|
||||
// 设置构建环境变量
|
||||
process.env.WIN_CSC_LINK = '';
|
||||
process.env.WIN_CSC_KEY_PASSWORD = '';
|
||||
|
||||
// 执行构建命令
|
||||
// 执行构建命令 - 移除不兼容的--no-compress选项
|
||||
execSync(
|
||||
'npm run electron:build -- --win portable --ia32 --x64 --publish never',
|
||||
{ stdio: 'inherit' }
|
||||
@ -93,12 +69,7 @@ function buildPortableApp() {
|
||||
console.log('构建产物位于 dist_electron 目录');
|
||||
} catch (error) {
|
||||
console.error('构建失败:', error);
|
||||
// 确保即使构建失败也恢复package.json
|
||||
restorePackageJson();
|
||||
process.exit(1);
|
||||
} finally {
|
||||
// 无论构建成功与否,都恢复package.json
|
||||
restorePackageJson();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
"private": true,
|
||||
"description": "统计技能考试系统",
|
||||
"author": "抚顺市统计局",
|
||||
"main": "background/main.js",
|
||||
"scripts": {
|
||||
"start": "vue-cli-service electron:serve",
|
||||
"serve": "vue-cli-service serve",
|
||||
@ -16,7 +17,6 @@
|
||||
"rebuild-deps": "electron-builder install-app-deps",
|
||||
"rebuild-sqlite3": "npm_config_runtime=electron npm_config_target=11.5.0 npm_config_disturl=https://electronjs.org/headers npm_config_build_from_source=true node-pre-gyp rebuild --target=11.5.0 --runtime=electron --fallback-to-build --directory=./node_modules/sqlite3/ --dist-url=https://electronjs.org/headers"
|
||||
},
|
||||
"main": "background/main.js",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-svg-core": "1.2.36",
|
||||
"@fortawesome/free-brands-svg-icons": "5.15.4",
|
||||
|
@ -246,7 +246,9 @@ export default {
|
||||
}
|
||||
).then(() => {
|
||||
// 完全清除store中的数据
|
||||
this.$store.commit('clearExaminee')
|
||||
this.$store.commit('clearUser') // 修改为已定义的mutation
|
||||
// 同时清除试卷信息
|
||||
this.$store.commit('clearPaper')
|
||||
// 重定向到欢迎页
|
||||
this.$router.push('/')
|
||||
}).catch(() => {
|
||||
|
@ -11,7 +11,7 @@ module.exports = {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
preload: "src/preload.js",
|
||||
mainProcessFile: "src/background/main.js",
|
||||
mainProcessFile: "background/main.js",
|
||||
lintPreloadFiles: false,
|
||||
// 添加这段配置确保构建路径正确
|
||||
outputDir: 'dist_electron',
|
||||
@ -54,7 +54,7 @@ module.exports = {
|
||||
// 针对Windows 7的特殊配置
|
||||
extraResources: [
|
||||
{
|
||||
from: "src/background/font",
|
||||
from: "background/font", // 更新为新路径
|
||||
to: "font",
|
||||
filter: ["**/*"],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user