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 = ["你我皆牛马", "生在人世间", "终日奔波苦", "一刻不得闲"];