mirror of
https://github.com/wallace5303/ee-core.git
synced 2026-04-05 07:29:04 +08:00
Merge branch 'main' into dev_v4
This commit is contained in:
@@ -205,6 +205,35 @@ function getArgumentByName(name, args) {
|
||||
}
|
||||
}
|
||||
|
||||
function getExtraResourcesDir() {
|
||||
const dir = path.join(_basePath, "build", "extraResources")
|
||||
return dir;
|
||||
}
|
||||
|
||||
function getModuleNameFromPath(modulePath) {
|
||||
// 分割路径段(处理不同系统的分隔符)
|
||||
const segments = path.normalize(modulePath).split(path.sep);
|
||||
|
||||
// 从后往前查找 node_modules
|
||||
for (let i = segments.length - 1; i >= 0; i--) {
|
||||
if (segments[i] === 'node_modules') {
|
||||
// 普通模块:node_modules/dayjs
|
||||
if (i + 1 < segments.length) {
|
||||
return segments[i + 1];
|
||||
}
|
||||
|
||||
// 作用域模块:node_modules/@scope/module
|
||||
if (i + 2 < segments.length && segments[i + 1].startsWith('@')) {
|
||||
return `${segments[i + 1]}/${segments[i + 2]}`;
|
||||
}
|
||||
|
||||
break; // 找到 node_modules 但后面没有模块名
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
loadConfig,
|
||||
getElectronProgram,
|
||||
@@ -220,5 +249,7 @@ module.exports = {
|
||||
getPackage,
|
||||
readJsonSync,
|
||||
writeJsonSync,
|
||||
getArgumentByName
|
||||
getArgumentByName,
|
||||
getExtraResourcesDir,
|
||||
getModuleNameFromPath
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ class IncrUpdater {
|
||||
'win-ia32-unpacked',
|
||||
'linux-unpacked'
|
||||
];
|
||||
this.nodeModulesString = 'node_modules';
|
||||
this.asarUnpackedString = 'app.asar.unpacked';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,9 +103,26 @@ class IncrUpdater {
|
||||
const extraResDir = path.dirname(extraResPath);
|
||||
const index = extraResDir.indexOf('extraResources');
|
||||
const zipFileDir = extraResDir.substring(index);
|
||||
// 资源路径 extraResPath: D:\www\gofile\src\ee\ee-demo\build\extraResources\hello\c.txt
|
||||
// 文件在zip中的路径 zipFileDir: extraResources/hello
|
||||
zip.addLocalFile(extraResPath, zipFileDir);
|
||||
}
|
||||
}
|
||||
// 添加 asarUnpacked
|
||||
if (cfg.asarUnpacked && cfg.asarUnpacked.length > 0) {
|
||||
const modules = cfg.asarUnpacked;
|
||||
for (const moduleItem of modules) {
|
||||
const modulePath = path.normalize(path.join(homeDir, moduleItem));
|
||||
if (!fs.existsSync(modulePath)) {
|
||||
throw new Error(`${modulePath} is not exists!`);
|
||||
}
|
||||
|
||||
const zipDir = path.join(this.asarUnpackedString, moduleItem);
|
||||
// console.log('modulePath', modulePath);
|
||||
// console.log('zipDir', zipDir);
|
||||
zip.addLocalFolder(modulePath, zipDir);
|
||||
}
|
||||
}
|
||||
|
||||
zip.writeZip(asarZipPath, (err) => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user