From ca48d818cc0c6e7c9a50fa21eb7f9a03ec485582 Mon Sep 17 00:00:00 2001 From: hypercross Date: Sun, 1 Mar 2026 10:13:40 +0800 Subject: [PATCH] refactor: display --- src/components/md-commander/TrackerView.tsx | 73 +++++++------------ .../md-commander/utils/emmetParser.ts | 4 +- 2 files changed, 27 insertions(+), 50 deletions(-) diff --git a/src/components/md-commander/TrackerView.tsx b/src/components/md-commander/TrackerView.tsx index 332ab39..b27eb5c 100644 --- a/src/components/md-commander/TrackerView.tsx +++ b/src/components/md-commander/TrackerView.tsx @@ -22,6 +22,11 @@ export const TrackerView: Component = (props) => { return String(attr.value); }; + const formatAttributeShort = (name: string, attr: TrackerAttribute): string => { + const val = formatAttributeValue(attr); + return `${name}=${val}`; + }; + return (
= (props) => {
暂无追踪项目
} > -
+
{(item, index) => ( -
- {/* 头部:tag、id 和操作按钮 */} -
-
- {item.tag} +
+ {/* 第一行:tag#id.class + 操作按钮 */} +
+
+ {item.tag} - #{item.id} + #{item.id} + + 0}> + .{item.classes.join(".")} + + {/* 属性简写 */} + 0}> + + [{Object.entries(item.attributes).map(([k, v]) => formatAttributeShort(k, v)).join(" ")}] +
-
+
- - {/* Classes */} - 0}> -
- - {(cls) => ( - - {cls()} - - - )} - -
-
- - {/* Attributes */} -
- - {(attr: TrackerAttribute) => ( -
props.onEditAttribute?.(index(), attr.name, attr)} - > - {attr.name} - - {formatAttributeValue(attr)} - -
- )} -
-
)} diff --git a/src/components/md-commander/utils/emmetParser.ts b/src/components/md-commander/utils/emmetParser.ts index 5090962..cfb51dc 100644 --- a/src/components/md-commander/utils/emmetParser.ts +++ b/src/components/md-commander/utils/emmetParser.ts @@ -69,8 +69,8 @@ export function parseEmmet(input: string): ParsedEmmet { function parseAttributes(attrString: string): Record { const attributes: Record = {}; - // 匹配键值对:key=value 或 key="value with spaces" - const regex = /(\w+)=(?:"([^"]*)"|'([^']*)'|([^\s]+))/g; + // 匹配键值对:使用,分隔 + const regex = /(\w+)=(?:"([^"]*)"|'([^']*)'|([^,]+))/g; let match: RegExpExecArray | null; while ((match = regex.exec(attrString)) !== null) {