chore(dev): give dev builds their own userData and single-instance lock
A dev instance shared the installed build's userData directory and lock, so starting it demanded killing the real app and it wrote test settings and session snapshots into the live profile. Dev now uses OpenTerminal-dev and tags its window title '(dev)'; both instances run side by side.
This commit is contained in:
1 parent
4b336360f8
commit
77fd241b43
2 files changed
+19
No files matched your search
@@ -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`
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user