feat: 增强命令面板功能与AI助手集成

This commit is contained in:
Ray.Hao
2026-01-06 20:21:29 +08:00
parent 2953642e99
commit 4a8efc770e
6 changed files with 314 additions and 55 deletions

View File

@@ -65,19 +65,27 @@ export function useCommandPalette() {
results.value = menuItems.value.filter((item) => item.title.toLowerCase().includes(kw));
}
function getDisplayList() {
return results.value.length ? results.value : history.value;
}
function onSelect() {
if (results.value.length > 0 && activeIndex.value >= 0) {
onGo(results.value[activeIndex.value]);
}
const list = getDisplayList();
if (list.length === 0) return;
if (activeIndex.value < 0) return;
const item = list[activeIndex.value];
if (!item) return;
onGo(item);
}
function onNavigate(direction: "up" | "down") {
if (results.value.length === 0) return;
const list = getDisplayList();
if (list.length === 0) return;
if (direction === "up") {
activeIndex.value = activeIndex.value <= 0 ? results.value.length - 1 : activeIndex.value - 1;
activeIndex.value = activeIndex.value <= 0 ? list.length - 1 : activeIndex.value - 1;
} else {
activeIndex.value = activeIndex.value >= results.value.length - 1 ? 0 : activeIndex.value + 1;
activeIndex.value = activeIndex.value >= list.length - 1 ? 0 : activeIndex.value + 1;
}
}