Skip to content

Commit

Permalink
参考coderabbitai建议规范代码
Browse files Browse the repository at this point in the history
  • Loading branch information
code-october committed Oct 11, 2024
1 parent 6792d6e commit 8fd843d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
19 changes: 12 additions & 7 deletions app/components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()}
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ export function Settings() {
aria-label={Locale.Mask.Config.CodeFold.Title}
type="checkbox"
checked={config.enableCodeFold}
data-testid="enable-code-fold-checkbox"
onChange={(e) =>
updateConfig(
(config) => (config.enableCodeFold = e.currentTarget.checked),
Expand Down
4 changes: 2 additions & 2 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ const cn = {
SubTitle: "启用之后可以直接渲染HTML页面",
},
CodeFold: {
Title: "启用CodeFold",
SubTitle: "启用之后可以折叠/展开过长的代码块",
Title: "启用代码折叠",
SubTitle: "启用之后可以自动折叠/展开过长的代码块",
},
Share: {
Title: "分享此面具",
Expand Down
2 changes: 1 addition & 1 deletion app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ const en: LocaleType = {
CodeFold: {
Title: "Enable CodeFold",
SubTitle:
"Automatically collapse/expand overly long code block when enable CodeFold",
"Automatically collapse/expand overly long code blocks when CodeFold is enabled",
},
Share: {
Title: "Share This Mask",
Expand Down

0 comments on commit 8fd843d

Please sign in to comment.