refactor: impl

This commit is contained in:
2026-03-01 12:51:15 +08:00
parent 5d026dfd80
commit 62780e3e56
4 changed files with 56 additions and 95 deletions
+7 -9
View File
@@ -6,8 +6,8 @@ import { CommanderEntries } from "./CommanderEntries";
import { TrackerView } from "./TrackerView";
import { TabBar } from "./TabBar";
import type { MdCommanderProps } from "./types";
import { loadElementSrc, resolvePath } from "../utils/path";
import { initializeCommands, loadCommandTemplatesFromCSV } from "./stores/commandsStore";
import { loadElementSrc } from "../utils/path";
import { initializeCommands, loadCommandTemplatesFromCSV } from "./stores";
customElement<MdCommanderProps>(
"md-commander",
@@ -21,15 +21,13 @@ customElement<MdCommanderProps>(
const commander = useCommander(commands);
// 加载 CSV 模板
createEffect(
on(() => props.commandTemplates, async (csvPaths) => {
if (!csvPaths || !rawSrc) return;
await loadCommandTemplatesFromCSV(csvPaths, resolvePath, articlePath);
createEffect( async () => {
if (!rawSrc || !rawSrc) return;
await loadCommandTemplatesFromCSV(rawSrc, articlePath);
// 更新 commander 中的命令(从 store 获取)
const { getCommands } = await import("./stores/commandsStore");
const {getCommands} = await import("./stores/commandsStore");
commander.setCommands(getCommands());
}),
);
});
const handleKeyDown = (e: KeyboardEvent) => {
if (commander.showCompletions() && commander.completions().length > 0) {