iter(g270): 新增代码块组件

This commit is contained in:
HIsheR
2026-10-26 22:54:55 +08:00
parent 02d7eb3c4d
commit b8f90b8e0d
12 changed files with 272 additions and 11 deletions
+19
View File
@@ -24,6 +24,7 @@ import {
cascader,
checkbox,
checkboxGroup,
codeBlock,
colorPicker,
timePicker,
commandPalette,
@@ -1765,6 +1766,24 @@ const content = h(
].join('\n'),
}),
),
section(
'sec-code',
'代码块',
'codeBlock:等宽多行 + 行号列 + 头部标题,右上角一键复制原文;行号是装饰、不进剪贴板,只做展示不高亮。',
codeBlock({
title: 'sum.ts',
lang: 'ts',
maxHeight: 200,
code: [
'export function sum(a: number, b: number): number {',
' if (typeof a !== \'number\') throw new TypeError(\'a 必须是数字\');',
' return a + b;',
'}',
'',
'// 用法:sum(1, 2) === 3',
].join('\n'),
}),
),
);
// 悬浮按钮:fixed 定位,挂 body 不参与页面布局