feat:添加文件路径标签显示和rules需求文档

This commit is contained in:
Roe-xin
2026-03-03 16:45:23 +08:00
parent 3458f6fe23
commit 35c63802b5
5 changed files with 279 additions and 2 deletions

View File

@ -850,7 +850,26 @@ export function getMessageAreaScript(): string {
div.appendChild(actionsDiv);
} else {
div.textContent = text;
// 用户消息:解析文件路径并转换为标签
const parts = text.split(' ');
const filePaths = [];
const textParts = [];
parts.forEach(part => {
// 判断是否为文件路径:包含路径分隔符或文件扩展名
if (part.includes('/') || part.includes('\\\\') || /\\.[a-zA-Z0-9]+$/.test(part)) {
filePaths.push(part);
} else {
textParts.push(part);
}
});
if (filePaths.length > 0) {
div.innerHTML = filePaths.map(fp => window.createFilePathTag ? window.createFilePathTag(fp) : fp).join('') + ' ' + textParts.join(' ');
} else {
div.textContent = text;
}
// 当添加用户消息时,隐藏 header
hideHeaderIfNeeded();
}