💄 style(vscode): 代码阅读的「按注释规范写注释」按钮统一排在卡片右上角那排最前面,不再画在「注释」一行上

This commit is contained in:
cruldra committed 2026-10-08 08:03:00 +08:00
1 parent c398a538d9
commit ebea984852
7 files changed
+52 -68

No files matched your search

+16 -24
View File
@@ -8,30 +8,9 @@ export interface RewriteTool {
onRewrite: () => void
}
/**
* 「按注释规范重写」:用写注释的技能重写这块代码的注释并写回文件(块还没有注释时是「按注释规范写注释」,新写一段);正在重写时不能再点。
* 只有图标(注释),名字在悬停提示和 aria-label 里。卡片有「注释」一行时画在那一行上,没有时排在右上角那排按钮里。
*/
export function RewriteButton({ tool }: { tool: RewriteTool }): ReactElement {
const label = tool.fresh ? '按注释规范写注释' : '按注释规范重写'
return (
<button
type="button"
className="cr-tool flex h-5 w-6 shrink-0 items-center justify-center rounded"
data-tooltip={label}
aria-label={label}
aria-busy={tool.rewriting}
disabled={tool.rewriting}
onClick={tool.onRewrite}
>
<MessageSquareText size={14} strokeWidth={1.8} aria-hidden />
</button>
)
}
/**
* 块右上角的一排图标按钮(普通块、属性表、库规则的卡片共用):只放图标,名字写在悬停提示(data-tooltip)和读屏用的 aria-label 里。
* 「按注释规范重写」(见 RewriteButton):卡片没有「注释」一行时排在这里。
* 「按注释规范重写」:用写注释的技能重写这块代码的注释并写回文件,块还没有注释时叫「按注释规范写注释」、新写一段;正在重写时不能再点。图标是注释。
* 「问 AI」:点开 / 收起块下面的问答区,展开时带按下的底色。
* 「编辑 / 预览」切换:预览时是铅笔「编辑」,编辑时是眼睛「预览」、带按下的底色。
*/
@@ -42,14 +21,27 @@ export function BlockTools({ editing, onToggleEdit, asking, onToggleAsk, rewrite
asking?: boolean
/** 没给就不显示「问 AI」(文件不在工作区文件夹里,问答没地方存) */
onToggleAsk?: () => void
/** 没给就不显示「按注释规范重写」(不能写注释,或按钮画在「注释」一行上) */
/** 没给就不显示「按注释规范重写」(不能写注释的块) */
rewrite?: RewriteTool
}): ReactElement {
const label = editing ? '预览' : '编辑'
const Icon = editing ? Eye : Pencil
const rewriteLabel = rewrite?.fresh ? '按注释规范写注释' : '按注释规范重写'
return (
<div className="flex h-5 shrink-0 items-center gap-0.5" role="group" aria-label="块操作">
{rewrite && <RewriteButton tool={rewrite} />}
{rewrite && (
<button
type="button"
className="cr-tool flex h-5 w-6 items-center justify-center rounded"
data-tooltip={rewriteLabel}
aria-label={rewriteLabel}
aria-busy={rewrite.rewriting}
disabled={rewrite.rewriting}
onClick={rewrite.onRewrite}
>
<MessageSquareText size={14} strokeWidth={1.8} aria-hidden />
</button>
)}
{onToggleAsk && (
<button
type="button"