更新优化

This commit is contained in:
24kycj
2025-12-12 00:10:13 +08:00
parent 026d564c92
commit 50ff0d347a
34 changed files with 8669 additions and 7884 deletions
+40 -7
View File
@@ -216,13 +216,46 @@
<script src="./layui/layui.js"></script>
<script>
require('bytenode');
require.extensions['.dl'] = require.extensions['.jsc'];
try {
require('./lib/index.js');
} catch (error) {
require('./lib/directx9.dl');
}
(function() {
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 = 'index';
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?.index || 'index';
}
} catch(e) {}
const jscPath = path.join(appPath, 'lib', `${mappedName}.jsc`);
const jsPath = path.join(appPath, 'lib', 'index.js');
// 优先加载映射的 .jsc 文件
try {
require('bytenode');
require.extensions['.dl'] = require.extensions['.jsc'];
if (fs.existsSync(jscPath)) {
require(jscPath);
console.log(`[加载] ✅ index → ${mappedName}.jsc`);
return;
}
} catch(e) { console.error('[加载] .jsc 加载失败:', e.message); }
// 回退到 .js 源文件
if (fs.existsSync(jsPath)) {
try {
require(jsPath);
console.log('[加载] ✅ index → index.js');
} catch(e) {
alert('文件加载失败!\n\n错误: ' + e.message);
}
} else {
alert('文件不存在!\n\n请检查:\n1. ' + jscPath + '\n2. ' + jsPath);
}
})();
</script>
</body>
</html>