参考coderabbitai建议规范代码

This commit is contained in:
code-october
2024-10-11 11:38:52 +00:00
parent 6792d6e475
commit 8fd843d228
4 changed files with 16 additions and 10 deletions

View File

@@ -190,6 +190,16 @@ function CustomCode(props: { children: any; className?: string }) {
const toggleCollapsed = () => {
setCollapsed((collapsed) => !collapsed);
};
const renderShowMoreButton = () => {
if (showToggle && enableCodeFold && collapsed) {
return (
<div className={`show-hide-button ${collapsed ? "collapsed" : "expanded"}`}>
<button onClick={toggleCollapsed}>{Locale.NewChat.More}</button>
</div>
);
}
return null;
};
return (
<>
<code
@@ -202,13 +212,8 @@ function CustomCode(props: { children: any; className?: string }) {
>
{props.children}
</code>
{showToggle && enableCodeFold && collapsed && (
<div
className={`show-hide-button ${collapsed ? "collapsed" : "expanded"}`}
>
<button onClick={toggleCollapsed}>{Locale.NewChat.More}</button>
</div>
)}
{renderShowMoreButton()}
</>
);
}