refactor: impl
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user