This commit is contained in:
Baobhan Sith
2025-04-22 20:32:13 +08:00
parent f74c61a8bb
commit 08b55a2ce6
9 changed files with 918 additions and 24 deletions
@@ -66,6 +66,7 @@ const hoveredItemId = ref<number | null>(null);
const selectedIndex = ref<number>(-1); // -1 表示没有选中
const historyListRef = ref<HTMLUListElement | null>(null); // Ref for the history list UL
const searchInputRef = ref<HTMLInputElement | null>(null); // +++ Ref for the search input +++
let unregisterFocus: (() => void) | null = null; // +++ 保存注销函数 +++
// --- 从 Store 获取状态和 Getter ---
const searchTerm = computed(() => commandHistoryStore.searchTerm);
@@ -89,10 +90,14 @@ onMounted(() => {
// +++ 注册/注销自定义聚焦动作 +++
onMounted(() => {
focusSwitcherStore.registerFocusAction('commandHistorySearch', focusSearchInput);
// +++ 保存返回的注销函数 +++
unregisterFocus = focusSwitcherStore.registerFocusAction('commandHistorySearch', focusSearchInput);
});
onBeforeUnmount(() => {
focusSwitcherStore.unregisterFocusAction('commandHistorySearch');
// +++ 调用保存的注销函数 +++
if (unregisterFocus) {
unregisterFocus();
}
});
// --- 事件处理 ---
@@ -82,6 +82,7 @@ const commandToEdit = ref<QuickCommandFE | null>(null);
const selectedIndex = ref<number>(-1); // -1 表示没有选中
const commandListRef = ref<HTMLUListElement | null>(null); // Ref for the command list UL
const searchInputRef = ref<HTMLInputElement | null>(null); // +++ Ref for the search input +++
let unregisterFocus: (() => void) | null = null; // +++ 保存注销函数 +++
// --- 从 Store 获取状态和 Getter ---
const searchTerm = computed(() => quickCommandsStore.searchTerm);
@@ -101,10 +102,14 @@ onMounted(() => {
// +++ 注册/注销自定义聚焦动作 +++
onMounted(() => {
focusSwitcherStore.registerFocusAction('quickCommandsSearch', focusSearchInput);
// +++ 保存返回的注销函数 +++
unregisterFocus = focusSwitcherStore.registerFocusAction('quickCommandsSearch', focusSearchInput);
});
onBeforeUnmount(() => {
focusSwitcherStore.unregisterFocusAction('quickCommandsSearch');
// +++ 调用保存的注销函数 +++
if (unregisterFocus) {
unregisterFocus();
}
});
// --- 事件处理 ---