update
This commit is contained in:
@@ -92,8 +92,19 @@ const handleDelete = async (pathItem: FavoritePathItem) => {
|
||||
};
|
||||
|
||||
const handleSendToTerminal = (pathItem: FavoritePathItem) => {
|
||||
emitWorkspaceEvent('favoritePath:sendToActiveTerminal', { path: pathItem.path });
|
||||
closeModal(); // Optionally close modal after sending
|
||||
const activeSession = sessionStore.activeSession;
|
||||
if (activeSession && activeSession.terminalManager) {
|
||||
const escapedPath = `"${pathItem.path.replace(/"/g, '\\"')}"`;
|
||||
const command = `cd ${escapedPath}\n`;
|
||||
try {
|
||||
activeSession.terminalManager.sendData(command);
|
||||
} catch (error) {
|
||||
console.error('[FavoritePathsModal] Failed to send command to active terminal:', error);
|
||||
}
|
||||
} else {
|
||||
console.warn('[FavoritePathsModal] No active session with a terminal manager found to send path to.');
|
||||
}
|
||||
closeModal();
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
@@ -102,8 +113,6 @@ const closeModal = () => {
|
||||
|
||||
const updatePosition = () => {
|
||||
if (!props.isVisible || !props.triggerElement || !modalContentRef.value) {
|
||||
// If not visible or refs not available, do nothing or hide.
|
||||
// v-if handles DOM presence, so style isn't applied when not isVisible.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -571,15 +571,6 @@ onMounted(() => {
|
||||
terminalRef.value.addEventListener('touchcancel', handleTouchEnd, { passive: false }); // Also handle cancel
|
||||
}
|
||||
|
||||
// Listen for favorite path to send to terminal
|
||||
subscribeToWorkspaceEvent('favoritePath:sendToActiveTerminal', ({ path }) => {
|
||||
if (terminal && props.isActive && sessionStore.activeSessionId === props.sessionId) {
|
||||
// Ensure path is quoted to handle spaces or special characters
|
||||
const command = `cd "${path.replace(/"/g, '\\"')}"\n`; // Escape existing quotes in path
|
||||
emitWorkspaceEvent('terminal:input', { sessionId: props.sessionId, data: command });
|
||||
terminal.focus(); // Focus terminal after sending command
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
@@ -624,7 +615,6 @@ onBeforeUnmount(() => {
|
||||
terminalRef.value.removeEventListener('touchcancel', handleTouchEnd);
|
||||
}
|
||||
|
||||
unsubscribeFromWorkspaceEvent('favoritePath:sendToActiveTerminal');
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -53,7 +53,6 @@ export type WorkspaceEventPayloads = {
|
||||
|
||||
// Suspended SSH Session Events
|
||||
'suspendedSession:actionCompleted': void; // Emitted when a resume/remove action is completed
|
||||
'favoritePath:sendToActiveTerminal': { path: string }; // Event to send a path to the active terminal
|
||||
};
|
||||
|
||||
// 创建 mitt 事件发射器实例
|
||||
|
||||
Reference in New Issue
Block a user