This commit is contained in:
Baobhan Sith
2025-04-28 19:03:50 +08:00
parent fa3cabc13d
commit bc08141982
4 changed files with 36 additions and 55 deletions
@@ -64,7 +64,7 @@ const emit = defineEmits({
'find-next': null, // ()
'find-previous': null, // ()
'close-search': null, // ()
'request-rdp-modal': null, // +++ 新增:转发 RDP 模态框请求事件 +++
// --- 移除 RDP 事件 ---
});
// --- Setup ---
@@ -224,8 +224,6 @@ const componentProps = computed(() => {
onOpenNewSession: (id: number) => emit('open-new-session', id),
// onRequestAddConnection: () => { ... }, // 移除,将在模板中处理
onRequestEditConnection: (conn: any) => emit('request-edit-connection', conn),
// --- 移除重复的 RDP 事件处理 prop,依赖模板监听 ---
// onRequestRdpModal: (conn: ConnectionInfo) => emit('request-rdp-modal', conn),
};
case 'commandHistory':
case 'quickCommands':
@@ -288,11 +286,6 @@ const sidebarProps = computed(() => (paneName: PaneName | null, side: 'left' | '
console.log(`[LayoutRenderer Sidebar] Forwarding 'request-add-connection'`);
emit('request-add-connection');
},
// +++ 新增:转发侧边栏的 RDP 模态框请求 +++
onRequestRdpModal: (conn: ConnectionInfo) => {
console.log(`[LayoutRenderer Sidebar] Forwarding 'request-rdp-modal' for ID: ${conn.id}`);
emit('request-rdp-modal', conn);
}
};
case 'fileManager':
// Only provide props if there's an active session
@@ -501,7 +494,6 @@ onMounted(() => {
@find-next="emit('find-next')"
@find-previous="emit('find-previous')"
@close-search="emit('close-search')"
@request-rdp-modal="emit('request-rdp-modal', $event)"
class="flex-grow overflow-auto"
/>
</pane>
@@ -571,7 +563,6 @@ onMounted(() => {
:is="currentMainComponent"
v-bind="componentProps"
@request-add-connection="() => emit('request-add-connection')"
@request-rdp-modal="emit('request-rdp-modal', $event)"
class="flex-grow overflow-auto"
/>
<component
@@ -38,8 +38,9 @@ const emit = defineEmits([
'close-session',
'open-layout-configurator',
'request-add-connection-from-popup', // 声明从弹窗发出的添加请求事件
'request-edit-connection-from-popup', // 新增:声明从弹窗发出的编辑请求事件
'request-rdp-modal-from-popup' // +++ 新增:声明从弹窗发出的 RDP 请求事件 +++
'request-edit-connection-from-popup' // 新增:声明从弹窗发出的编辑请求事件
// --- 移除 RDP 事件 ---
// 'request-rdp-modal-from-popup'
]);
const activateSession = (sessionId: string) => {
@@ -64,12 +65,20 @@ const togglePopup = () => {
// 处理从弹出列表中选择连接的事件
const handlePopupConnect = (connectionId: number) => {
console.log(`[TabBar] Popup connect request for ID: ${connectionId}`);
// +++ 修复:传递 ConnectionInfo 而不是 ID +++
const connectionInfo = connectionsStore.connections.find(c => c.id === connectionId);
if (connectionInfo) {
sessionStore.handleConnectRequest(connectionInfo);
} else {
if (!connectionInfo) {
console.error(`[TabBar] handlePopupConnect: 未找到 ID 为 ${connectionId} 的连接信息。`);
showConnectionListPopup.value = false; // 关闭弹出窗口
return;
}
// --- 修改:根据类型决定调用哪个 Action ---
if (connectionInfo.type === 'RDP') {
console.log(`[TabBar] Popup RDP connect request for ID: ${connectionId}. Calling sessionStore.openRdpModal.`);
sessionStore.openRdpModal(connectionInfo);
} else {
console.log(`[TabBar] Popup non-RDP connect request for ID: ${connectionId}. Calling sessionStore.handleConnectRequest.`);
sessionStore.handleConnectRequest(connectionInfo); // 非 RDP 保持原逻辑
}
showConnectionListPopup.value = false; // 关闭弹出窗口
};
@@ -89,13 +98,8 @@ const handleRequestEditFromPopup = (connection: any) => { // 假设 WorkspaceCon
emit('request-edit-connection-from-popup', connection);
};
// +++ 新增:处理从弹窗内部发出的 RDP 模态框请求 +++
const handleRequestRdpFromPopup = (connection: ConnectionInfo) => {
console.log('[TabBar] Received request-rdp-modal from popup component for connection:', connection.name);
showConnectionListPopup.value = false; // 关闭弹窗
// 向上发出事件,并携带连接信息
emit('request-rdp-modal-from-popup', connection);
};
// --- 移除 handleRequestRdpFromPopup 方法 ---
// const handleRequestRdpFromPopup = (connection: ConnectionInfo) => { ... };
// 新增:处理打开布局配置器的事件
const openLayoutConfigurator = () => {
@@ -214,7 +218,6 @@ const toggleButtonTitle = computed(() => {
@open-new-session="handlePopupConnect"
@request-add-connection="handleRequestAddFromPopup"
@request-edit-connection="handleRequestEditFromPopup"
@request-rdp-modal="handleRequestRdpFromPopup"
class="popup-connection-list"
/>
</div>
@@ -14,8 +14,9 @@ const emit = defineEmits([
'connect-request', // 左键单击 - 请求激活或替换当前标签
// 'open-new-session', // 中键单击 - 请求在新标签中打开 (已移除)
'request-add-connection', // 右键菜单 - 添加
'request-edit-connection', // 右键菜单 - 编辑
'request-rdp-modal' // +++ 新增:请求打开 RDP 模态框 +++
'request-edit-connection' // 右键菜单 - 编辑
// --- 移除 RDP 事件 ---
// 'request-rdp-modal'
]);
const { t } = useI18n();
@@ -171,9 +172,9 @@ const handleConnect = (connectionId: number, event?: MouseEvent | KeyboardEvent)
closeContextMenu(); // 关闭右键菜单
if (connection.type === 'RDP') {
console.log(`[WkspConnList] RDP connection clicked (ID: ${connectionId}). Emitting request-rdp-modal.`);
// --- 修改:不再本地处理,而是向上触发事件 ---
emit('request-rdp-modal', connection); // 传递整个连接对象
console.log(`[WkspConnList] RDP connection clicked (ID: ${connectionId}). Calling sessionStore.openRdpModal.`);
// --- 修改:调用 Store Action ---
sessionStore.openRdpModal(connection);
} else {
console.log(`[WkspConnList] Non-RDP connection clicked (ID: ${connectionId}, Type: ${connection.type}). Emitting connect-request.`);
// 对于非 RDP 连接,保持原有逻辑,发出事件给父组件处理