Skip to content

Commit 163ff79

Browse files
committed
优化代码块组件,强制设置高亮主题为亮色模式,移除自定义高亮样式配置,简化代码逻辑。同时更新气泡提示内容的结构,提升用户体验。确保多语言支持的准确性和一致性。
1 parent 461c2f1 commit 163ff79

File tree

1 file changed

+9
-43
lines changed

1 file changed

+9
-43
lines changed

src/components/AITestDialog.tsx

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ const CodeBlock = ({
170170
className?: string;
171171
children: string;
172172
}) => {
173-
const { resolvedTheme } = useTheme();
174-
const isDark = resolvedTheme === "dark";
173+
const isDark = true;
175174
// 改进语言检测:从className中提取语言信息
176175
let language = className ? className.replace(/language-/, "") : "";
177176

@@ -195,35 +194,6 @@ const CodeBlock = ({
195194
setTimeout(() => setCopied(false), 1500);
196195
};
197196

198-
// 强制注入代码高亮样式 - 直接修改atomOneLight主题
199-
const customAtomOneLight = {
200-
...atomOneLight,
201-
hljs: {
202-
...atomOneLight.hljs,
203-
color: "#383a42",
204-
},
205-
"hljs-keyword": {
206-
...atomOneLight["hljs-keyword"],
207-
color: "#a626a4",
208-
},
209-
"hljs-string": {
210-
...atomOneLight["hljs-string"],
211-
color: "#50a14f",
212-
},
213-
"hljs-title": {
214-
...atomOneLight["hljs-title"],
215-
color: "#4078f2",
216-
},
217-
"hljs-built_in": {
218-
...atomOneLight["hljs-built_in"],
219-
color: "#c18401",
220-
},
221-
"hljs-comment": {
222-
...atomOneLight["hljs-comment"],
223-
color: "#a0a1a7",
224-
},
225-
};
226-
227197
// 使用修改后的高亮样式
228198
const highlightStyle = isDark ? atomOneDark : enhancedAtomOneLight;
229199

@@ -1725,19 +1695,15 @@ ${fileContents}`);
17251695
)
17261696
.replace(/\n/g, "<br>")
17271697
.replace(/(\d+\|)/g, '<span class="text-gray-500">$1</span>');
1728-
1729-
// 更新气泡提示内容
17301698
tooltipElement.innerHTML = `
1731-
<div class="keyword-tooltip-content bg-transparent">
1732-
<div class="text-sm whitespace-pre-wrap text-left font-mono">${formattedExplanation}</div>
1733-
${
1734-
position !== "center"
1735-
? `<div class="keyword-tooltip-arrow ${
1736-
position === "bottom" ? "top-arrow" : "bottom-arrow"
1737-
}"></div>`
1738-
: ""
1739-
}
1740-
</div>
1699+
<div class="text-sm whitespace-pre-wrap text-left font-mono">${formattedExplanation}</div>
1700+
${
1701+
position !== "center"
1702+
? `<div class="keyword-tooltip-arrow ${
1703+
position === "bottom" ? "top-arrow" : "bottom-arrow"
1704+
}"></div>`
1705+
: ""
1706+
}
17411707
`;
17421708
} catch (error) {
17431709
console.error("获取关键字信息出错:", error);

0 commit comments

Comments
 (0)