feat: 为ssh标签栏和文件编辑器标签栏添加右键菜单
This commit is contained in:
@@ -413,8 +413,61 @@ export const useFileEditorStore = defineStore('fileEditor', () => {
|
||||
// setEditorVisibility('closed'); // 移除:容器可见性由外部控制
|
||||
};
|
||||
|
||||
// 设置当前激活的标签页
|
||||
const setActiveTab = (tabId: string) => {
|
||||
// +++ 新增:关闭其他标签页 +++
|
||||
const closeOtherTabs = (targetTabId: string) => {
|
||||
console.log(`[文件编辑器 Store] closeOtherTabs: Action called. Current keys in tabs map:`, Array.from(tabs.value.keys())); // ++ Log current keys at start
|
||||
if (!tabs.value.has(targetTabId)) {
|
||||
console.warn(`[文件编辑器 Store] closeOtherTabs: 目标 ID ${targetTabId} 在 Map 中不存在。`); // Updated warning
|
||||
return;
|
||||
}
|
||||
console.log(`[文件编辑器 Store] closeOtherTabs: 开始关闭除 ${targetTabId} 之外的所有标签页...`);
|
||||
const tabsToClose = Array.from(tabs.value.keys()).filter(id => id !== targetTabId);
|
||||
console.log(`[文件编辑器 Store] closeOtherTabs: 将要关闭的标签页 IDs:`, tabsToClose); // + Log IDs to close
|
||||
tabsToClose.forEach(id => {
|
||||
console.log(`[文件编辑器 Store] closeOtherTabs: 正在调用 closeTab 关闭 ${id}`); // + Log loop iteration
|
||||
closeTab(id);
|
||||
});
|
||||
};
|
||||
|
||||
// +++ 新增:关闭右侧标签页 +++
|
||||
const closeTabsToTheRight = (targetTabId: string) => {
|
||||
const tabsArray = Array.from(tabs.value.values());
|
||||
const targetIndex = tabsArray.findIndex(tab => tab.id === targetTabId);
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheRight: Action called. Current keys in tabs map:`, Array.from(tabs.value.keys())); // ++ Log current keys at start
|
||||
if (targetIndex === -1) {
|
||||
console.warn(`[文件编辑器 Store] closeTabsToTheRight: 目标 ID ${targetTabId} 未找到索引。`);
|
||||
return;
|
||||
}
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheRight: 开始关闭 ${targetTabId} (索引 ${targetIndex}) 右侧的所有标签页...`);
|
||||
const tabsToClose = tabsArray.slice(targetIndex + 1).map(tab => tab.id);
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheRight: 将要关闭的标签页 IDs:`, tabsToClose); // + Log IDs to close
|
||||
tabsToClose.forEach(id => {
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheRight: 正在调用 closeTab 关闭 ${id}`); // + Log loop iteration
|
||||
closeTab(id);
|
||||
});
|
||||
};
|
||||
|
||||
// +++ 新增:关闭左侧标签页 +++
|
||||
const closeTabsToTheLeft = (targetTabId: string) => {
|
||||
const tabsArray = Array.from(tabs.value.values());
|
||||
const targetIndex = tabsArray.findIndex(tab => tab.id === targetTabId);
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheLeft: Action called. Current keys in tabs map:`, Array.from(tabs.value.keys())); // ++ Log current keys at start
|
||||
if (targetIndex === -1) {
|
||||
console.warn(`[文件编辑器 Store] closeTabsToTheLeft: 目标 ID ${targetTabId} 未找到索引。`);
|
||||
return;
|
||||
}
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheLeft: 开始关闭 ${targetTabId} (索引 ${targetIndex}) 左侧的所有标签页...`);
|
||||
const tabsToClose = tabsArray.slice(0, targetIndex).map(tab => tab.id);
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheLeft: 将要关闭的标签页 IDs:`, tabsToClose); // + Log IDs to close
|
||||
tabsToClose.forEach(id => {
|
||||
console.log(`[文件编辑器 Store] closeTabsToTheLeft: 正在调用 closeTab 关闭 ${id}`); // + Log loop iteration
|
||||
closeTab(id);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 设置当前激活的标签页
|
||||
const setActiveTab = (tabId: string) => {
|
||||
if (tabs.value.has(tabId)) {
|
||||
activeTabId.value = tabId;
|
||||
console.log(`[文件编辑器 Store] 激活标签页: ${tabId}`);
|
||||
@@ -556,6 +609,9 @@ export const useFileEditorStore = defineStore('fileEditor', () => {
|
||||
openFile,
|
||||
saveFile,
|
||||
closeTab,
|
||||
closeOtherTabs, // +++ 暴露新 action +++
|
||||
closeTabsToTheRight, // +++ 暴露新 action +++
|
||||
closeTabsToTheLeft, // +++ 暴露新 action +++
|
||||
closeAllTabs,
|
||||
setActiveTab,
|
||||
updateFileContent, // 暴露新的更新方法
|
||||
|
||||
@@ -495,7 +495,7 @@ export const useSessionStore = defineStore('session', () => {
|
||||
// 创建新标签页 (使用简化后的 FileTab 接口)
|
||||
// --- 修复:初始化 rawContentBase64 ---
|
||||
const newTab: FileTab = {
|
||||
id: generateSessionId(), // 使用独立 ID
|
||||
id: `${sessionId}:${fileInfo.fullPath}`, // <-- 修复:使用 sessionId:filePath 作为 ID
|
||||
sessionId: sessionId,
|
||||
filePath: fileInfo.fullPath,
|
||||
filename: fileInfo.name,
|
||||
@@ -635,6 +635,45 @@ export const useSessionStore = defineStore('session', () => {
|
||||
}
|
||||
};
|
||||
|
||||
// +++ 新增:关闭指定会话中的其他编辑器标签页 +++
|
||||
const closeOtherTabsInSession = (sessionId: string, targetTabId: string) => {
|
||||
const session = sessions.value.get(sessionId);
|
||||
if (!session) return;
|
||||
const targetIndex = session.editorTabs.value.findIndex(tab => tab.id === targetTabId);
|
||||
if (targetIndex === -1) return;
|
||||
console.log(`[SessionStore ${sessionId}] 关闭除 ${targetTabId} 之外的所有标签页...`);
|
||||
const tabsToClose = session.editorTabs.value
|
||||
.filter(tab => tab.id !== targetTabId)
|
||||
.map(tab => tab.id);
|
||||
tabsToClose.forEach(id => closeEditorTabInSession(sessionId, id)); // 复用单个关闭逻辑
|
||||
};
|
||||
|
||||
// +++ 新增:关闭指定会话中右侧的编辑器标签页 +++
|
||||
const closeTabsToTheRightInSession = (sessionId: string, targetTabId: string) => {
|
||||
const session = sessions.value.get(sessionId);
|
||||
if (!session) return;
|
||||
const targetIndex = session.editorTabs.value.findIndex(tab => tab.id === targetTabId);
|
||||
if (targetIndex === -1) return;
|
||||
console.log(`[SessionStore ${sessionId}] 关闭 ${targetTabId} 右侧的所有标签页...`);
|
||||
const tabsToClose = session.editorTabs.value
|
||||
.slice(targetIndex + 1)
|
||||
.map(tab => tab.id);
|
||||
tabsToClose.forEach(id => closeEditorTabInSession(sessionId, id));
|
||||
};
|
||||
|
||||
// +++ 新增:关闭指定会话中左侧的编辑器标签页 +++
|
||||
const closeTabsToTheLeftInSession = (sessionId: string, targetTabId: string) => {
|
||||
const session = sessions.value.get(sessionId);
|
||||
if (!session) return;
|
||||
const targetIndex = session.editorTabs.value.findIndex(tab => tab.id === targetTabId);
|
||||
if (targetIndex === -1) return;
|
||||
console.log(`[SessionStore ${sessionId}] 关闭 ${targetTabId} 左侧的所有标签页...`);
|
||||
const tabsToClose = session.editorTabs.value
|
||||
.slice(0, targetIndex)
|
||||
.map(tab => tab.id);
|
||||
tabsToClose.forEach(id => closeEditorTabInSession(sessionId, id));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 在指定会话中更改文件编码并重新解码
|
||||
@@ -812,6 +851,9 @@ export const useSessionStore = defineStore('session', () => {
|
||||
updateFileContentInSession, // 导出更新内容 Action
|
||||
saveFileInSession, // 导出保存文件 Action
|
||||
changeEncodingInSession, // 导出更改编码 Action
|
||||
closeOtherTabsInSession, // +++ 导出新 action +++
|
||||
closeTabsToTheRightInSession, // +++ 导出新 action +++
|
||||
closeTabsToTheLeftInSession, // +++ 导出新 action +++
|
||||
// --- RDP Modal Actions ---
|
||||
openRdpModal, // 导出打开 RDP 模态框 Action
|
||||
closeRdpModal, // 导出关闭 RDP 模态框 Action
|
||||
|
||||
Reference in New Issue
Block a user