diff --git a/AGENTS.md b/AGENTS.md index 9e7abca..bfd6591 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,6 +5,7 @@ Electron + electron-vite + React 终端工具(本地终端 / SSH / SFTP)。 ## 常用命令 - 开发:`npm run dev`(主进程改动不热重建,需重启) +- dev 实例使用独立用户数据目录 `%APPDATA%\OpenTerminal-dev` 与独立单实例锁(`src/main/index.ts` 顶部 `!app.isPackaged` 分支),窗口标题带 `(dev)`:**可与已安装的正式版同时运行,互不干扰**,也不会把测试设置/会话写进真实配置 - 类型检查:`npx tsc --noEmit -p tsconfig.web.json` - 打包:`npm run dist`,产物在 `release/`(msi + exe + latest.yml + blockmap) - 国内网络需镜像:`ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/ npm run dist` diff --git a/src/main/index.ts b/src/main/index.ts index 82cd3ca..31c40e3 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -20,6 +20,15 @@ function showOrCreate(): void { } } +// Dev runs get their own userData directory (settings, session snapshot, +// command history, logs) *and* their own single-instance lock — both are keyed +// on that path. Without this a dev instance fights the installed build: it +// takes the lock, so the other side is refused / must be killed, and it writes +// test data straight into the real profile. Must run before the lock below. +if (!app.isPackaged) { + app.setPath('userData', join(app.getPath('appData'), 'OpenTerminal-dev')) +} + // Single instance: a second launch just surfaces the existing window (pulls // it out of the tray if hidden there) instead of starting another process. const gotSingleInstanceLock = app.requestSingleInstanceLock() @@ -64,6 +73,15 @@ function createWindow(): void { win.on('ready-to-show', () => win.show()) + // Dev window wears a "(dev)" tag so it is never confused with the installed + // build sitting next to it (they no longer share userData — see above). + if (!app.isPackaged) { + win.on('page-title-updated', (e) => { + e.preventDefault() + win.setTitle('OpenTerminal (dev)') + }) + } + // Close button → tray / exit per the closeAction setting (ask by default). win.on('close', (e) => { void onMainWindowClose(win, e, showOrCreate)