终端模块初版

This commit is contained in:
zhongluofeng committed 2026-09-18 18:28:13 +08:00
1 parent f6c1cc250e
commit b018abd922
63 files changed
+26695 -185

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
import type { ModuleConfig } from '@/types/module'
import type { SearchIndexItem } from '@/stores/searchIndex'
const searchItems: SearchIndexItem[] = [
{
title: '终端',
description: 'SSH 与本地 Shell 多会话终端',
keywords: ['终端', 'terminal', 'shell', '命令行', 'console', '控制台', 'bash', 'ssh'],
tab: 'terminal'
},
{
title: '新建本地会话',
description: '打开 PowerShell / cmd / Git Bash / WSL',
keywords: ['新建', '本地', 'powershell', 'pwsh', 'cmd', 'git bash', 'wsl', '会话', '标签'],
tab: 'terminal'
},
{
title: 'SSH 主机',
description: '管理 SSH 主机连接(含跳板机与自动登录)',
keywords: ['ssh', '主机', '服务器', '远程', '连接', 'host', '远程登录'],
tab: 'hosts'
},
{
title: 'SSH 密钥管理',
description: '生成、导入与管理 SSH 密钥,passphrase 存入系统凭据管理器',
keywords: ['密钥', 'key', '私钥', '公钥', 'ed25519', 'rsa', 'ecdsa', 'passphrase', '指纹'],
tab: 'keys'
},
{
title: '已知主机(known_hosts)',
description: '查看与清理主机密钥指纹记录,导出供审阅',
keywords: ['known_hosts', '指纹', '主机密钥', '信任', 'host key', '安全'],
tab: 'knownHosts'
},
{
title: '终端外观设置',
description: '主题、字体、光标、滚动缓冲与 GPU 渲染',
keywords: ['外观', '主题', '字体', '字号', '光标', '滚动', '颜色', '透明度'],
tab: 'settings'
},
{
title: '终端快捷键',
description: '自定义终端内快捷键(复制粘贴、标签、分屏、搜索)',
keywords: ['快捷键', '热键', 'shortcut', 'keybinding', '复制', '粘贴', '分屏'],
tab: 'settings'
},
{
title: '终端独立窗口',
description: '把会话拖出主窗口,独立窗口承载单个会话',
keywords: ['独立窗口', '分离', 'detach', '新窗口', '多屏'],
tab: 'settings'
}
]
export const moduleConfig: ModuleConfig = {
id: 'terminal',
name: '终端',
icon: 'terminal',
description: 'SSH 与本地 Shell 多会话终端(密钥管理 + 主机密钥校验 + 独立窗口)',
category: 'tool',
defaultEnabled: true,
loader: () => import('./TerminalModule.vue'),
searchItems,
lifecycle: {
// 模块启用:拉取一次会话列表(会话在 Rust 侧存活,模块被禁用期间不会中断)
onEnable: async () => {
// 动态导入避免 index.ts 直接依赖 store(会形成循环依赖,参见 music 模块的处理)
try {
const { useTerminalStore } = await import('@/stores/terminalStore')
const store = useTerminalStore()
await store.init()
} catch (e) {
console.error('[terminal] onEnable 初始化失败:', e)
}
},
onDisable: () => {
// 刻意**不**关闭会话:用户禁用模块通常是暂时的(排查冲突),
// 若此时杀掉正在跑长任务的 SSH 连接,代价远大于保留几个空闲会话。
// 真正的清理在应用退出时由 Rust 侧 cleanup_on_exit 统一处理。
}
},
// 排在音乐(15)之后、剪贴板(20)之前:终端是高频入口,应靠前
order: 18
}