From 66aaaa96e174bb2401f3e16409b13ed719ba5d85 Mon Sep 17 00:00:00 2001 From: hypercross Date: Sat, 28 Feb 2026 16:30:58 +0800 Subject: [PATCH] fix: details --- src/components/md-commander/CommanderInput.tsx | 12 ++++++------ src/components/md-commander/hooks/useCommander.ts | 6 +++--- src/components/md-commander/index.tsx | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/md-commander/CommanderInput.tsx b/src/components/md-commander/CommanderInput.tsx index e11bb1c..79755eb 100644 --- a/src/components/md-commander/CommanderInput.tsx +++ b/src/components/md-commander/CommanderInput.tsx @@ -1,4 +1,4 @@ -import { type Component, Show } from "solid-js"; +import {type Component, For, Show} from "solid-js"; import type { CompletionItem } from "./types"; export interface CommanderInputProps { @@ -39,16 +39,16 @@ export const CommanderInput: Component = (props) => { {/* 自动补全下拉框 */} 0}> -
- {props.completions().map((comp, idx) => ( +
+ {(comp, idx) => (
{ - props.onSelectCompletion(idx); + props.onSelectCompletion(idx()); props.onAcceptCompletion(); }} > @@ -70,7 +70,7 @@ export const CommanderInput: Component = (props) => { {comp.description}
- ))} + )}
diff --git a/src/components/md-commander/hooks/useCommander.ts b/src/components/md-commander/hooks/useCommander.ts index cd6d95c..41642dd 100644 --- a/src/components/md-commander/hooks/useCommander.ts +++ b/src/components/md-commander/hooks/useCommander.ts @@ -1,4 +1,4 @@ -import { createSignal, createMemo } from "solid-js"; +import { createSignal } from "solid-js"; import { MdCommanderCommand, CommanderEntry, @@ -146,7 +146,7 @@ export function getCompletions( .filter((cmd) => cmd.command.startsWith(parsed.command || "")) .map((cmd) => ({ label: cmd.command, - type: "command", + type: "command" as "command", description: cmd.description, insertText: cmd.command, })); @@ -162,7 +162,7 @@ export function getCompletions( const option = cmd.options[parsed.incompleteOption]; if (option?.type === "enum" && option.values) { return option.values - .filter((v) => v.startsWith(parsed.incompleteOption)) + .filter((v) => parsed.incompleteOption && v.startsWith(parsed.incompleteOption)) .map((v) => ({ label: v, type: "value", diff --git a/src/components/md-commander/index.tsx b/src/components/md-commander/index.tsx index c68dfbb..b474699 100644 --- a/src/components/md-commander/index.tsx +++ b/src/components/md-commander/index.tsx @@ -73,9 +73,12 @@ customElement( return (
+ {/* 命令执行结果 */} + + {/* 命令输入框 */}
( onAcceptCompletion={commander.acceptCompletion} />
- - {/* 命令执行结果 */} -
); },