diff --git a/src/main/engine.ts b/src/main/engine.ts index c85ae380..4d0ea598 100644 --- a/src/main/engine.ts +++ b/src/main/engine.ts @@ -1,4 +1,4 @@ -import { ChildProcessWithoutNullStreams, spawn } from 'node:child_process'; +import { ChildProcessWithoutNullStreams } from 'node:child_process'; import path from 'node:path'; import dotenv from 'dotenv'; @@ -13,7 +13,7 @@ import { IpcEvents } from '../ipc-events'; * enginePort 现在存的是完整的 url */ export class TachybaseEngine { - private engineStatus = 'initialization'; + private engineStatus = 'ready'; private enginePort = ''; private child: ChildProcessWithoutNullStreams | null = null; @@ -22,13 +22,15 @@ export class TachybaseEngine { event.returnValue = this.engineStatus + '|' + this.enginePort; }); - ipcMainManager.handle( - IpcEvents.ENGINE_START, - (_: IpcMainEvent, env: string) => this.start.bind(this)(env), - ); + // ipcMainManager.handle( + // IpcEvents.ENGINE_START, + // (_: IpcMainEvent, env: string) => this.start.bind(this)(env), + // ); ipcMainManager.handle(IpcEvents.ENGINE_STOP, (_: IpcMainEvent) => this.stop.bind(this)(), ); + + this.start(''); } async start(rawEnvString: string) { @@ -59,7 +61,9 @@ export class TachybaseEngine { 'ENGINE_PATH, ENGINE_WORKING_DIR, and APP_PORT must be set', ); } - remoteUrl = `http://localhost:${appPort}`; + if (!remoteUrl) { + remoteUrl = `http://localhost:${appPort}/signin`; + } env.NODE_MODULES_PATH = path.join(workingDir, 'plugins/node_modules'); @@ -86,33 +90,33 @@ export class TachybaseEngine { } }; - await checkRunning(); - - this.child = spawn(enginePath, ['start', '--quickstart'], { - cwd: workingDir, - env, - stdio: 'pipe', - }); - this.child.stdout.on('data', (data) => { - ipcMainManager.send(IpcEvents.ENGINE_STDOUT, [data.toString()]); - }); - - this.child.stderr.on('data', (data) => { - ipcMainManager.send(IpcEvents.ENGINE_STDERR, [data.toString()]); - }); - - this.child.on('error', (error) => { - console.error(`[Engine]: Error starting engine: ${error.message}`); - }); - - this.child.on('exit', (code) => { - console.log(`[Engine]: engine exited with code ${code}`); - - if (this.engineStatus !== 'stopped') { - this.engineStatus = 'stopped'; - ipcMainManager.send(IpcEvents.ENGINE_STATUS_CHANGED, ['stopped']); - } - }); + // await checkRunning(); + + // this.child = spawn(enginePath, ['start', '--quickstart'], { + // cwd: workingDir, + // env, + // stdio: 'pipe', + // }); + // this.child.stdout.on('data', (data) => { + // ipcMainManager.send(IpcEvents.ENGINE_STDOUT, [data.toString()]); + // }); + + // this.child.stderr.on('data', (data) => { + // ipcMainManager.send(IpcEvents.ENGINE_STDERR, [data.toString()]); + // }); + + // this.child.on('error', (error) => { + // console.error(`[Engine]: Error starting engine: ${error.message}`); + // }); + + // this.child.on('exit', (code) => { + // console.log(`[Engine]: engine exited with code ${code}`); + + // if (this.engineStatus !== 'stopped') { + // this.engineStatus = 'stopped'; + // ipcMainManager.send(IpcEvents.ENGINE_STATUS_CHANGED, ['stopped']); + // } + // }); } async stop() { diff --git a/src/main/windows.ts b/src/main/windows.ts index 7eb8b145..896cdd81 100644 --- a/src/main/windows.ts +++ b/src/main/windows.ts @@ -60,6 +60,7 @@ export function getMainWindowOptions(): Electron.BrowserWindowConstructorOptions ? path.join(process.cwd(), './.webpack/renderer/main_window/preload.js') : MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY, }, + autoHideMenuBar: true, // 自动隐藏菜单栏,按Alt键显示 }; } diff --git a/src/renderer/components/commands-runner.tsx b/src/renderer/components/commands-runner.tsx index 5ad25364..3331e616 100644 --- a/src/renderer/components/commands-runner.tsx +++ b/src/renderer/components/commands-runner.tsx @@ -22,7 +22,7 @@ export const Runner = observer( case 'initialization': { props.text = 'Stop'; try { - window.ElectronFiddle.startEngine(engineEnv); + // window.ElectronFiddle.startEngine(engineEnv); } catch (err) { this.props.appState.pushError(err.message, err); } diff --git a/src/renderer/components/output.tsx b/src/renderer/components/output.tsx index 084823a1..ed6c91ac 100644 --- a/src/renderer/components/output.tsx +++ b/src/renderer/components/output.tsx @@ -230,7 +230,7 @@ export const Output = observer(
); }