fix: 修复打包后模块无法加载的问题,改用静态模块加载

This commit is contained in:
2026-03-11 01:32:06 +08:00
parent 1fa17f7c9d
commit bbd33339a5
4 changed files with 63 additions and 54 deletions

View File

@@ -13,16 +13,6 @@ log.initialize();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
process.env.NOTEBOOK_ROOT = path.join(app.getPath('documents'), 'XCDesktop');
if (!fs.existsSync(process.env.NOTEBOOK_ROOT)) {
try {
fs.mkdirSync(process.env.NOTEBOOK_ROOT, { recursive: true });
} catch (err) {
log.error('Failed to create notebook directory:', err);
}
}
electronState.setDevelopment(!app.isPackaged);
let opencodeProcess: ChildProcess | null = null;
@@ -443,6 +433,16 @@ async function startServer() {
}
app.whenReady().then(async () => {
process.env.NOTEBOOK_ROOT = path.join(app.getPath('documents'), 'XCDesktop');
if (!fs.existsSync(process.env.NOTEBOOK_ROOT)) {
try {
fs.mkdirSync(process.env.NOTEBOOK_ROOT, { recursive: true });
} catch (err) {
log.error('Failed to create notebook directory:', err);
}
}
await startServer();
await createWindow();