v2.0.0: 主题系统+SSH私钥解析修复+会话持久化+连接池优化+UI打磨

核心修复:
- ssh-service.ts: 新增 resolvePrivateKey(),将私钥文件路径(~/.ssh/id_rsa)解析为内容后传给 ssh2,
  解决 'Cannot parse privateKey: Unsupported key format' 错误
- useTerminalConnection.ts + sessionHelper.ts: 根据 authType 过滤字段,password/agent 认证不再传 privateKey
- sessionStore.ts: addSession() 现在先调用 sessionCreate() 持久化到 SQLite,解决恢复标签'无可用连接信息'问题
- database-service.ts: updateSession() 补充 private_key_path 字段持久化
- SessionDialog.tsx: 默认 username='root'、privateKey='~/.ssh/id_rsa'

UI/UX:
- 语义化主题系统(app-theme.ts),强制深色模式,全局无边框设计
- macOS 标题栏支持双击最大化(window:toggleMaximize IPC)
- macOS 菜单栏('OpsXShell' 应用菜单 + Settings Cmd+,)
- WelcomeView 4卡片布局,移除 Settings 按钮
- TabBar/TabItem 背景色统一(bg-dark-800/900),消除白色边框线

架构优化:
- SFTP 生命周期修复(useSFTP.ts useRef + autoConnectAttempted guard)
- 连接池竞态修复,支持快速多标签连接
- IPC 接口规范化,安全错误处理
- Vite 代码分割优化

质量: lint零错误 | tsc零错误 | build成功 | 49 tests pass
This commit is contained in:
Logan.Li committed 2026-04-22 11:15:41 +08:00
1 parent 37e65be823
commit 514d62644e
77 files changed
+2563 -931

No files matched your search

+13 -12
View File
@@ -6,10 +6,9 @@ import { darkColors, lightColors, type AppThemeMode, type ColorMap } from '../th
* Resolves the *effective* theme ('dark' | 'light') from the user preference,
* including the 'system' → prefers-color-scheme mapping.
*/
function resolveEffectiveTheme(preference: AppThemeMode): 'dark' | 'light' {
if (preference !== 'system') return preference
if (typeof window === 'undefined') return 'dark'
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
function resolveEffectiveTheme(_preference: AppThemeMode): 'dark' | 'light' {
// 当前版本固定使用 dark 主题,后续版本开放主题切换
return 'dark'
}
/**
@@ -32,26 +31,28 @@ function applyCSSVars(colors: ColorMap) {
*/
export function useTheme() {
const theme = useSettingsStore((s) => s.settings.theme)
const isLoaded = useSettingsStore((s) => s.isLoaded)
const effective = useMemo(() => resolveEffectiveTheme(theme), [theme])
// Apply theme to DOM whenever effective theme changes
useEffect(() => {
if (!isLoaded) return
const colors = effective === 'dark' ? darkColors : lightColors
// Set data attribute for potential direct CSS selectors
document.documentElement.setAttribute('data-theme', effective)
if (effective === 'dark') {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
// Apply CSS custom properties
applyCSSVars(colors)
// Update body bg & colour (mirrors index.css body rules but via vars)
document.body.style.backgroundColor = 'var(--color-dark-900)'
document.body.style.color = 'var(--color-text-primary)'
}, [effective, isLoaded])
document.body.style.backgroundColor = '#0f172a'
document.body.style.color = '#e2e8f0'
}, [effective])
// Listen for system colour-scheme changes when preference is 'system'
useEffect(() => {
@@ -64,8 +65,8 @@ export function useTheme() {
const colors = e.matches ? darkColors : lightColors
document.documentElement.setAttribute('data-theme', newEffective)
applyCSSVars(colors)
document.body.style.backgroundColor = 'var(--color-dark-900)'
document.body.style.color = 'var(--color-text-primary)'
document.body.style.backgroundColor = '#0f172a'
document.body.style.color = '#e2e8f0'
}
mql.addEventListener('change', handler)