Skip to content

Commit 2c9f68e

Browse files
committed
更新类型定义,添加模块导入、变量和注释信息的支持,同时在相关组件中集成代码结构信息以提升功能完整性和用户体验。优化报告生成逻辑,确保多语言支持的准确性和一致性。
1 parent 0ed2423 commit 2c9f68e

9 files changed

Lines changed: 736 additions & 11 deletions

File tree

src/components/AITestDialog.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,8 @@ ${fileContents}`);
12821282
const jsonResult = await findRelevantFiles(
12831283
initialPrompt,
12841284
paths,
1285-
fileContents
1285+
fileContents,
1286+
currentScan?.codeStructure // 添加代码结构信息
12861287
);
12871288
const parsedResult = parseFilePathsResult(jsonResult);
12881289
const responseIndexedFiles = parsedResult.relevant_paths;
@@ -1959,16 +1960,26 @@ ${fileContents}`);
19591960
return `__CODE_BLOCK_${codeBlocks.length - 1}__`;
19601961
});
19611962

1963+
// 转义HTML标签,防止它们被直接渲染
1964+
processed = processed.replace(/</g, "&lt;").replace(/>/g, "&gt;");
1965+
19621966
// 然后处理单行反引号,使其可点击并显示气泡提示
19631967
let keywordCounter = 0;
19641968
processed = processed.replace(/`([^`]+)`/g, (match, keyword) => {
19651969
const id = `keyword-${keywordCounter++}`;
1966-
return `<span id="${id}" class="font-bold text-blue-600 dark:text-blue-400 underline cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/30 px-0.5 rounded transition-colors" data-keyword="${keyword}" data-tooltip-id="${id}-tooltip" data-tooltip-content="加载中...">${keyword}</span><div id="${id}-tooltip" class="keyword-tooltip" style="display:none;"></div>`;
1970+
// 确保关键词内部的HTML标签不会被错误解析
1971+
const escapedKeyword = keyword
1972+
.replace(/&lt;/g, "&amp;lt;")
1973+
.replace(/&gt;/g, "&amp;gt;");
1974+
return `<span id="${id}" class="font-bold text-blue-600 dark:text-blue-400 underline cursor-pointer hover:bg-blue-100 dark:hover:bg-blue-900/30 px-0.5 rounded transition-colors" data-keyword="${escapedKeyword}" data-tooltip-id="${id}-tooltip" data-tooltip-content="加载中...">${escapedKeyword}</span><div id="${id}-tooltip" class="keyword-tooltip" style="display:none;"></div>`;
19671975
});
19681976

1969-
// 最后,恢复代码块
1977+
// 最后,恢复代码块(但确保代码块内的内容正确转义)
19701978
codeBlocks.forEach((block, index) => {
1971-
processed = processed.replace(`__CODE_BLOCK_${index}__`, block);
1979+
processed = processed.replace(
1980+
`__CODE_BLOCK_${index}__`,
1981+
block.replace(/&lt;/g, "<").replace(/&gt;/g, ">")
1982+
);
19721983
});
19731984

19741985
return processed;

src/components/RssFeed.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ export default function RssFeed() {
7272
url: "https://www.geekpark.net/rss",
7373
title: "GeekPark",
7474
},
75+
{
76+
url: "https://www.woshipm.com/feed",
77+
title: "人人都是产品经理",
78+
},
79+
{
80+
url: "https://rsshub.app/aibase/topic/AI",
81+
title: "AIBase",
82+
},
7583
];
7684

7785
const englishRssSources = [
@@ -109,7 +117,9 @@ export default function RssFeed() {
109117

110118
const rssToJsonUrl = "https://api.rss2json.com/v1/api.json?rss_url=";
111119
const response = await fetch(
112-
`${rssToJsonUrl}${encodeURIComponent(selectedSource.url)}`,
120+
`${rssToJsonUrl}${encodeURIComponent(selectedSource.url)}` +
121+
"&seed=" +
122+
Math.random(),
113123
{
114124
cache: "no-store",
115125
}

src/components/VectorizeModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ export default function VectorizeModal({ onClose }: VectorizeModalProps) {
226226
const jsonResult = await findRelevantFiles(
227227
query,
228228
filePaths,
229-
enableContentMatching ? fileContentMap : undefined
229+
enableContentMatching ? fileContentMap : undefined,
230+
currentScan?.codeStructure
230231
);
231232
console.log("API返回结果:", jsonResult);
232233

src/lib/scanService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export async function buildDirectoryStructureCache(
7272
}
7373
}
7474

75-
console.log(`目录结构缓存已更新,共${directoryStructureCache.size}个目录`);
75+
// console.log(`目录结构缓存已更新,共${directoryStructureCache.size}个目录`);
7676
} catch (error) {
7777
console.error("构建目录结构缓存时出错:", error);
7878
}

0 commit comments

Comments
 (0)