update
This commit is contained in:
@@ -7,9 +7,9 @@ import { useSettingsStore } from '../stores/settings.store';
|
||||
import { useQuickCommandsStore } from '../stores/quickCommands.store';
|
||||
import { useCommandHistoryStore } from '../stores/commandHistory.store';
|
||||
|
||||
const emit = defineEmits(['send-command', 'search', 'find-next', 'find-previous', 'close-search']);
|
||||
const emit = defineEmits(['send-command', 'search', 'find-next', 'find-previous', 'close-search', 'clear-terminal']); // 添加 clear-terminal 事件
|
||||
const { t } = useI18n();
|
||||
const focusSwitcherStore = useFocusSwitcherStore();
|
||||
const focusSwitcherStore = useFocusSwitcherStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const quickCommandsStore = useQuickCommandsStore();
|
||||
const commandHistoryStore = useCommandHistoryStore();
|
||||
@@ -223,6 +223,14 @@ onBeforeUnmount(() => {
|
||||
<template>
|
||||
<div class="flex items-center px-2 py-1.5 bg-background gap-2"> <!-- Removed border-t and border-border/50 -->
|
||||
<div class="flex-grow flex items-center bg-transparent relative gap-2"> <!-- Adjusted gap -->
|
||||
<!-- Clear Terminal Button -->
|
||||
<button
|
||||
@click="emit('clear-terminal')"
|
||||
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('commandInputBar.clearTerminal', '清空终端')"
|
||||
>
|
||||
<i class="fas fa-eraser text-base"></i>
|
||||
</button>
|
||||
<!-- Focus Switcher Config Button -->
|
||||
<button
|
||||
@click="focusSwitcherStore.toggleConfigurator(true)"
|
||||
|
||||
@@ -64,9 +64,10 @@ const emit = defineEmits({
|
||||
'find-next': null, // ()
|
||||
'find-previous': null, // ()
|
||||
'close-search': null, // ()
|
||||
'clear-terminal': null, // () +++ 添加 clear-terminal 事件 +++
|
||||
// --- 移除 RDP 事件 ---
|
||||
});
|
||||
|
||||
|
||||
// --- Setup ---
|
||||
const layoutStore = useLayoutStore();
|
||||
const sessionStore = useSessionStore();
|
||||
@@ -214,6 +215,7 @@ const componentProps = computed(() => {
|
||||
onFindNext: () => emit('find-next'),
|
||||
onFindPrevious: () => emit('find-previous'),
|
||||
onCloseSearch: () => emit('close-search'),
|
||||
onClearTerminal: () => emit('clear-terminal'), // --- 移除日志 ---
|
||||
};
|
||||
case 'connections':
|
||||
// WorkspaceConnectionList 需要转发 connect-request 等事件
|
||||
@@ -507,6 +509,7 @@ onMounted(() => {
|
||||
@find-next="emit('find-next')"
|
||||
@find-previous="emit('find-previous')"
|
||||
@close-search="emit('close-search')"
|
||||
@clear-terminal="() => emit('clear-terminal')" <!-- --- 移除日志 --- -->
|
||||
class="flex-grow overflow-auto"
|
||||
/>
|
||||
</pane>
|
||||
|
||||
@@ -399,9 +399,14 @@ const clearSearch = () => {
|
||||
searchAddon?.clearDecorations();
|
||||
};
|
||||
|
||||
defineExpose({ write, findNext, findPrevious, clearSearch });
|
||||
|
||||
// +++ 添加 clear 方法 +++
|
||||
const clear = () => {
|
||||
terminal?.clear();
|
||||
};
|
||||
|
||||
defineExpose({ write, findNext, findPrevious, clearSearch, clear }); // 暴露 clear 方法
|
||||
|
||||
|
||||
// --- 应用终端背景 ---
|
||||
const applyTerminalBackground = () => {
|
||||
if (terminalRef.value) {
|
||||
|
||||
@@ -292,7 +292,24 @@ const handleCloseSearch = () => {
|
||||
console.warn(`[WorkspaceView] Cannot clear search, no active session manager.`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// +++ 新增:处理清空终端事件 +++
|
||||
const handleClearTerminal = () => {
|
||||
const currentSession = activeSession.value;
|
||||
if (!currentSession) {
|
||||
console.warn('[WorkspaceView] Cannot clear terminal, no active session.');
|
||||
return;
|
||||
}
|
||||
const terminalManager = currentSession.terminalManager as (SshTerminalInstance | undefined);
|
||||
// 调用 Terminal.vue 组件暴露的 clear 方法
|
||||
if (terminalManager && terminalManager.terminalInstance?.value && typeof terminalManager.terminalInstance.value.clear === 'function') {
|
||||
console.log(`[WorkspaceView] Clearing terminal for active session ${currentSession.sessionId}`);
|
||||
terminalManager.terminalInstance.value.clear();
|
||||
} else {
|
||||
console.warn(`[WorkspaceView] Cannot clear terminal for session ${currentSession.sessionId}, terminal manager, instance, or clear method not available.`);
|
||||
}
|
||||
};
|
||||
|
||||
// Removed computed properties for search results, will pass manager directly
|
||||
// --- 编辑器操作处理 (用于 FileEditorContainer) ---
|
||||
const handleCloseEditorTab = (tabId: string) => {
|
||||
@@ -415,6 +432,7 @@ const handleCloseEditorTab = (tabId: string) => {
|
||||
@find-next="handleFindNext"
|
||||
@find-previous="handleFindPrevious"
|
||||
@close-search="handleCloseSearch"
|
||||
@clear-terminal="handleClearTerminal"
|
||||
></LayoutRenderer> <!-- 修正:使用单独的结束标签 -->
|
||||
<div v-else class="pane-placeholder"> <!-- 确保 v-else 紧随 v-if -->
|
||||
{{ t('layout.loading', '加载布局中...') }}
|
||||
|
||||
Reference in New Issue
Block a user