优化调整bug与加密

This commit is contained in:
24kycj
2026-01-11 01:06:02 +08:00
parent f4aef8abaa
commit c26c4fa66e
19 changed files with 124 additions and 966 deletions
+4 -40
View File
@@ -484,57 +484,21 @@ ipcRenderer.send('get-scale-rate');
// 加载design2模块
const fs = require('fs');
let bytenode;
try {
bytenode = require('bytenode');
require.extensions['.dl'] = require.extensions['.jsc'];
} catch(e) {
}
const appPath = (() => { try { return remote.app.getAppPath(); } catch(e) { return __dirname || process.cwd(); } })();
// 读取模块映射配置
let moduleMap = {};
try {
const moduleMapPath = path.join(appPath, 'lib', 'module-map.json');
if (fs.existsSync(moduleMapPath)) {
moduleMap = JSON.parse(fs.readFileSync(moduleMapPath, 'utf8'));
}
} catch (e) {
}
// 获取映射后的文件名(跨平台兼容)
function getMappedFileName(moduleName) {
if (moduleMap.mappings && moduleMap.mappings.design2 && moduleMap.mappings.design2[moduleName]) {
return moduleMap.mappings.design2[moduleName];
}
return moduleName; // 默认使用原文件名
}
const loadModule = (moduleName) => {
const mappedName = getMappedFileName(moduleName);
const jscPath = path.join(appPath, 'lib', 'design2', `${mappedName}.jsc`);
const jsPath = path.join(appPath, 'lib', 'design2', `${moduleName}.js`);
// 优先加载映射的 .jsc 文件
if (fs.existsSync(jscPath) && bytenode) {
try {
require(jscPath);
return;
} catch (e) {
}
}
// 回退到 .js 源文件
// 加载 .js 文件
if (fs.existsSync(jsPath)) {
try {
eval(fs.readFileSync(jsPath, 'utf8'));
} catch (e) {
} catch (e) {
alert(`加载 ${moduleName} 失败!\n\n错误: ${e.message}`);
}
} else {
alert(`文件不存在!\n\n请检查:\n1. ${jscPath}\n2. ${jsPath}`);
}
alert(`文件不存在!\n\n请检查:${jsPath}`);
}
};
loadModule('output'); // 先加载 output,因为 core 中的 addBackground() 需要调用 output 中的 open()
loadModule('core');