This commit is contained in:
Baobhan Sith
2025-04-22 11:12:04 +08:00
parent ca828cefe1
commit 8f98868ed3
2 changed files with 25 additions and 7 deletions
@@ -110,13 +110,20 @@ const focusActiveEditor = (): boolean => {
defineExpose({ focusActiveEditor }); defineExpose({ focusActiveEditor });
// +++ 注册/注销自定义聚焦动作 +++ // +++ 注册/注销自定义聚焦动作 +++
let unregisterFocusFn: (() => void) | null = null; // 保存注销函数
onMounted(() => { onMounted(() => {
focusSwitcherStore.registerFocusAction('fileEditorActive', focusActiveEditor); // 注册动作并保存返回的注销函数
unregisterFocusFn = focusSwitcherStore.registerFocusAction('fileEditorActive', focusActiveEditor);
// +++ 添加键盘事件监听器 +++ // +++ 添加键盘事件监听器 +++
window.addEventListener('keydown', handleKeyDown); window.addEventListener('keydown', handleKeyDown);
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
focusSwitcherStore.unregisterFocusAction('fileEditorActive'); // 调用保存的注销函数(如果存在)
if (unregisterFocusFn) {
unregisterFocusFn();
}
// +++ 移除键盘事件监听器 +++ // +++ 移除键盘事件监听器 +++
window.removeEventListener('keydown', handleKeyDown); window.removeEventListener('keydown', handleKeyDown);
}); });
@@ -910,12 +910,23 @@ onMounted(() => {
color: var(--text-color-primary, #333); 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) { :deep(.sidebar-pane-content) {
flex-grow: 1; flex-grow: 1; /* Allow the component to fill the wrapper */
overflow-y: auto; /* Allow scrolling within the panel */ /* overflow-y: auto; */ /* Let the component manage its own scroll if needed */
padding: 1rem; /* Add some padding */ /* padding: 1rem; */ /* Padding might interfere with component layout, apply inside component if needed */
padding-top: 2.5rem; /* Add padding to avoid close button overlap */ /* 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 */ /* Resize Handle Styles */