第一版

This commit is contained in:
yinsx
2025-12-16 16:21:26 +08:00
parent 0c73ef2547
commit 8ba7e635f5
15 changed files with 1006 additions and 30 deletions

31
lib/poem.js Normal file
View File

@ -0,0 +1,31 @@
import boxen from "boxen";
import color from "picocolors";
/**
* 显示带边框的古诗(固定在顶部居中)
* @param {string[]} lines - 诗句数组
* @param {number} perLine - 每行显示几句默认2
*/
export function showPoem(lines, perLine = 2) {
// 合并诗句
const merged = [];
for (let i = 0; i < lines.length; i += perLine) {
merged.push(lines.slice(i, i + perLine).join(""));
}
const content = merged.join("\n");
console.log(
boxen(color.yellow(content), {
padding: { top: 1, bottom: 1, left: 4, right: 4 },
margin: { top: 1, bottom: 1, left: 0, right: 0 },
borderStyle: "double",
borderColor: "cyan",
textAlignment: "center",
float: "center",
})
);
}
// 默认古诗
export const defaultPoem = ["你我皆牛马", "生在人世间", "终日奔波苦", "一刻不得闲"];