diff --git a/packages/frontend/src/components/FileEditorContainer.vue b/packages/frontend/src/components/FileEditorContainer.vue index cd35b88..3d0b366 100644 --- a/packages/frontend/src/components/FileEditorContainer.vue +++ b/packages/frontend/src/components/FileEditorContainer.vue @@ -110,13 +110,20 @@ const focusActiveEditor = (): boolean => { defineExpose({ focusActiveEditor }); // +++ 注册/注销自定义聚焦动作 +++ +let unregisterFocusFn: (() => void) | null = null; // 保存注销函数 + onMounted(() => { - focusSwitcherStore.registerFocusAction('fileEditorActive', focusActiveEditor); + // 注册动作并保存返回的注销函数 + unregisterFocusFn = focusSwitcherStore.registerFocusAction('fileEditorActive', focusActiveEditor); // +++ 添加键盘事件监听器 +++ window.addEventListener('keydown', handleKeyDown); }); + onBeforeUnmount(() => { - focusSwitcherStore.unregisterFocusAction('fileEditorActive'); + // 调用保存的注销函数(如果存在) + if (unregisterFocusFn) { + unregisterFocusFn(); + } // +++ 移除键盘事件监听器 +++ window.removeEventListener('keydown', handleKeyDown); }); diff --git a/packages/frontend/src/components/LayoutRenderer.vue b/packages/frontend/src/components/LayoutRenderer.vue index 32e3b3b..df485f5 100644 --- a/packages/frontend/src/components/LayoutRenderer.vue +++ b/packages/frontend/src/components/LayoutRenderer.vue @@ -910,12 +910,23 @@ onMounted(() => { color: var(--text-color-primary, #333); } -/* Style for the content inside the sidebar panel */ +/* Style for the wrapper holding the dynamic sidebar component */ +.sidebar-content-wrapper { + flex-grow: 1; /* Allow this wrapper to fill the panel */ + display: flex; /* Make it a flex container for its child */ + flex-direction: column; /* Stack child vertically */ + overflow: hidden; /* Prevent content overflow */ + position: relative; /* For potential absolute children */ +} + +/* Style for the content inside the sidebar panel (the actual component) */ :deep(.sidebar-pane-content) { - flex-grow: 1; - overflow-y: auto; /* Allow scrolling within the panel */ - padding: 1rem; /* Add some padding */ - padding-top: 2.5rem; /* Add padding to avoid close button overlap */ + flex-grow: 1; /* Allow the component to fill the wrapper */ + /* overflow-y: auto; */ /* Let the component manage its own scroll if needed */ + /* padding: 1rem; */ /* Padding might interfere with component layout, apply inside component if needed */ + /* padding-top: 2.5rem; */ /* Padding might interfere, handle spacing differently if needed */ + display: flex; /* Ensure the component itself is a flex container if it needs internal growing elements */ + flex-direction: column; /* Assume column layout for the component */ } /* Resize Handle Styles */