优化调整bug与加密
This commit is contained in:
+2
-24
@@ -663,31 +663,9 @@
|
||||
const path = require('path'), fs = require('fs'), remote = require('@electron/remote');
|
||||
const appPath = (() => { try { return remote.app.getAppPath(); } catch(e) { return __dirname || process.cwd(); } })();
|
||||
|
||||
// 读取模块映射配置
|
||||
let mappedName = 'design2';
|
||||
try {
|
||||
const moduleMapPath = path.join(appPath, 'lib', 'module-map.json');
|
||||
if (fs.existsSync(moduleMapPath)) {
|
||||
const moduleMap = JSON.parse(fs.readFileSync(moduleMapPath, 'utf8'));
|
||||
mappedName = moduleMap.mappings?.main?.design2 || 'design2';
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
const jscPath = path.join(appPath, 'lib', `${mappedName}.jsc`);
|
||||
const jsPath = path.join(appPath, 'lib', 'design2.js');
|
||||
|
||||
// 优先加载映射的 .jsc 文件
|
||||
try {
|
||||
require('bytenode');
|
||||
require.extensions['.dl'] = require.extensions['.jsc'];
|
||||
if (fs.existsSync(jscPath)) {
|
||||
require(jscPath);
|
||||
console.log(`[加载] ✅ design2 → ${mappedName}.jsc`);
|
||||
return;
|
||||
}
|
||||
} catch(e) { console.error('[加载] .jsc 加载失败:', e.message); }
|
||||
|
||||
// 回退到 .js 源文件
|
||||
// 加载 .js 源文件
|
||||
if (fs.existsSync(jsPath)) {
|
||||
try {
|
||||
require(jsPath);
|
||||
@@ -696,7 +674,7 @@
|
||||
alert('文件加载失败!\n\n错误: ' + e.message);
|
||||
}
|
||||
} else {
|
||||
alert('文件不存在!\n\n请检查:\n1. ' + jscPath + '\n2. ' + jsPath);
|
||||
alert('文件不存在!\n\n请检查:' + jsPath);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user