Files
Thing/src/modules/terminal/index.ts
T

136 lines
5.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { ModuleConfig } from '@/types/module'
import type { SearchIndexItem } from '@/stores/searchIndex'
/**
* 全局搜索索引。
*
* # `tab` 只能表达「哪个 tab」(现存取舍)
*
* 模块 Tabs 于 2026-09-20 由 7 项收敛为 5 项,2026-09-22 又收敛为 4 项
* (终端 / 主机 / 密钥 / 设置);2026-09-24 因文件管理器从「终端卡片里的面板」
* 升级为独立页而加回「文件」,现为 5 项(终端 / 文件 / 主机 / 密钥 / 设置):
*
* - 「已知主机」不再是一个 tab,而是主机页里的**信任徽标**(点开看指纹与
* 变更历史)与列表末尾的**孤儿记录区块**,因此它指向 `hosts`;
* - 「命令历史」「命令片段」变成终端页控制栏上的两个 popover,因此指向
* `terminal`;
* - 「文件管理器」现在确实是一页,因此指向 `files`(此前它只是终端卡片里的
* 面板,搜索项无从表达)。
*
* **已知的取舍**:`SearchIndexItem.tab` 只能表达「哪个 tab」,无法表达
* 「tab 里的哪一个 popover / 哪台主机」,所以搜「命令片段」会落在终端页、
* 还需要再点一下控制栏的按钮。要为一次点击去改 moduleTabsStore /
* useModuleTabs / TitleBar 三处共享基建,收益不抵成本,故不做。
*/
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: '文件管理器',
description: '双栏文件浏览与传输:两栏各自选择本地或已连接的 SSH 会话,支持上传 / 下载 / 远端间中继',
keywords: [
'文件',
'文件管理器',
'sftp',
'传输',
'上传',
'下载',
'中继',
'双栏',
'本地',
'file',
'manager'
],
tab: 'files'
},
{
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: 'hosts'
},
{
title: '终端外观设置',
description: '主题、字体、光标、滚动缓冲与 GPU 渲染',
keywords: ['外观', '主题', '字体', '字号', '光标', '滚动', '颜色', '透明度'],
tab: 'settings'
},
{
title: '终端快捷键',
description: '自定义终端内快捷键(复制粘贴、标签、分屏、搜索)',
keywords: ['快捷键', '热键', 'shortcut', 'keybinding', '复制', '粘贴', '分屏'],
tab: 'settings'
},
{
title: '终端独立窗口',
description: '把会话拖出主窗口,独立窗口承载单个会话;Alt+T 可直接唤起新建列表',
keywords: ['独立窗口', '分离', 'detach', '新窗口', '多屏', 'alt+t'],
tab: 'settings'
},
{
title: '命令历史',
description: '终端控制栏的「历史」按钮里按主机与会话检索已执行命令,支持收藏与再次填入',
keywords: ['历史', 'history', '命令', '收藏', '检索', '重放'],
tab: 'terminal'
},
{
title: '命令片段',
description: '终端控制栏的「片段」按钮里取用常用命令模板,支持占位符与危险命令二次确认',
keywords: ['片段', 'snippet', '模板', '占位符', '常用命令'],
tab: 'terminal'
}
]
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 统一处理。
}
},
// 默认第 4 位:音乐 / 代理 / 下载 / 终端 / 翻译 / 硬件监控 / 截图 / 剪贴板 / 快捷面板 / 开发工具
order: 40
}