feat: 为命令输入组件添加打开编辑器按钮

This commit is contained in:
Baobhan Sith
2025-05-13 08:53:15 +08:00
parent e886d13ed3
commit 33a7028295
4 changed files with 36 additions and 2 deletions
@@ -9,7 +9,8 @@ import { useQuickCommandsStore } from '../stores/quickCommands.store';
import { useCommandHistoryStore } from '../stores/commandHistory.store';
import QuickCommandsModal from './QuickCommandsModal.vue'; // +++ Import the modal component +++
import SuspendedSshSessionsModal from './SuspendedSshSessionsModal.vue'; // +++ Import the new modal +++
import { useWorkspaceEventEmitter } from '../composables/workspaceEvents';
import { useFileEditorStore } from '../stores/fileEditor.store'; // +++ Import File Editor Store +++
import { useWorkspaceEventEmitter } from '../composables/workspaceEvents';
// Disable attribute inheritance as this component has multiple root nodes (div + modal)
defineOptions({ inheritAttrs: false });
@@ -23,9 +24,10 @@ const settingsStore = useSettingsStore();
const quickCommandsStore = useQuickCommandsStore();
const commandHistoryStore = useCommandHistoryStore();
const sessionStore = useSessionStore(); // +++ 初始化 Session Store +++
const fileEditorStore = useFileEditorStore(); // +++ Initialize File Editor Store +++
// Get reactive setting from store
const { commandInputSyncTarget, showPopupFileManagerBoolean } = storeToRefs(settingsStore); // +++ Import showPopupFileManagerBoolean +++
const { commandInputSyncTarget, showPopupFileManagerBoolean, showPopupFileEditorBoolean } = storeToRefs(settingsStore); // +++ Import showPopupFileEditorBoolean +++
// Get reactive state and actions from quick commands store
const { selectedIndex: quickCommandsSelectedIndex, flatVisibleCommands: quickCommandsFiltered } = storeToRefs(quickCommandsStore);
const { resetSelection: resetQuickCommandsSelection } = quickCommandsStore;
@@ -309,6 +311,17 @@ const openFileManagerModal = () => {
}
};
// +++ Function to request opening the file editor modal +++
const openFileEditorModal = () => {
if (activeSessionId.value) {
console.log(`[CommandInputBar] Triggering popup editor for session: ${activeSessionId.value}`);
fileEditorStore.triggerPopup('', activeSessionId.value); // Call store action directly
} else {
console.warn('[CommandInputBar] Cannot open file editor modal: No active session ID.');
// Optionally, show a notification to the user
}
};
// +++ Handler for command execution from the modal +++
const handleQuickCommandExecute = (command: string) => {
console.log(`[CommandInputBar] Executing quick command: ${command}`);
@@ -420,6 +433,15 @@ const handleQuickCommandExecute = (command: string) => {
>
<i class="fas fa-folder text-base"></i>
</button>
<!-- File Editor Button -->
<button
v-if="showPopupFileEditorBoolean"
@click="openFileEditorModal"
class="flex-shrink-0 flex items-center justify-center w-8 h-8 border border-border/50 rounded-lg text-text-secondary transition-colors duration-200 hover:bg-border hover:text-foreground"
:title="t('fileEditor.title', '文件编辑器')"
>
<i class="fas fa-edit text-base"></i>
</button>
<!-- Search navigation buttons (Hide on mobile when searching) -->
<template v-if="isSearching && !props.isMobile"> <!-- +++ Add !props.isMobile condition +++ -->
+6
View File
@@ -302,6 +302,12 @@
"reconnectingMsg": "Attempting to reconnect..."
}
},
"fileEditor": {
"title": "File Editor"
},
"fileEditor": {
"title": "File Editor"
},
"fileManager": {
"currentPath": "Current Path",
"loading": "Loading directory...",
+3
View File
@@ -312,6 +312,9 @@
},
"waitingForSsh": "SSH接続を待機中..."
},
"fileEditor": {
"title": "ファイルエディタ"
},
"fileManager": {
"actions": {
"cancel": "キャンセル",
+3
View File
@@ -301,6 +301,9 @@
"reconnectingMsg": "正在尝试重新连接..."
}
},
"fileEditor": {
"title": "文件编辑器"
},
"fileManager": {
"currentPath": "当前路径",
"loading": "正在加载目录...",