fix: issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { MdCommanderCommand, MdCommanderCommandMap } from "../types";
|
||||
import { parseEmmet } from "../utils/emmetParser";
|
||||
import { addTrackerItem, removeTrackerItem, getTrackerItems } from "../stores";
|
||||
import type { MdCommanderCommand } from "../types";
|
||||
import { parseEmmet } from "../utils";
|
||||
import { addTrackerItem, removeTrackerItem, getTrackerItems, findTrackerItem } from "../stores";
|
||||
|
||||
export const trackCommand: MdCommanderCommand = {
|
||||
command: "track",
|
||||
@@ -42,24 +42,32 @@ export const trackCommand: MdCommanderCommand = {
|
||||
|
||||
export const untrackCommand: MdCommanderCommand = {
|
||||
command: "untrack",
|
||||
description: "移除一个追踪项目",
|
||||
description: "移除一个追踪项目 - 支持 Emmet 语法:untrack #g2 或 untrack goblin.warrior",
|
||||
parameters: [
|
||||
{
|
||||
name: "id",
|
||||
description: "追踪项目的 ID",
|
||||
name: "emmet",
|
||||
description: "Emmet 格式:#id 或 tag.class",
|
||||
type: "string",
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
handler: (args) => {
|
||||
const id = args.params.id;
|
||||
if (!id) {
|
||||
return { message: "错误:缺少 id 参数", type: "error" };
|
||||
const emmet = args.params.emmet;
|
||||
if (!emmet) {
|
||||
return { message: "错误:缺少 Emmet 参数", type: "error" };
|
||||
}
|
||||
|
||||
removeTrackerItem(id);
|
||||
const found = findTrackerItem(emmet);
|
||||
if (!found) {
|
||||
return { message: `未找到匹配的追踪项目:${emmet}`, type: "error" };
|
||||
}
|
||||
|
||||
return { message: `已移除追踪项目:${id}`, type: "success" };
|
||||
const success = removeTrackerItem(emmet);
|
||||
if (!success) {
|
||||
return { message: `移除失败:${emmet}`, type: "error" };
|
||||
}
|
||||
|
||||
return { message: `已移除追踪项目:${found.tag}${found.id ? '#' + found.id : ''}`, type: "success" };
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user