Skip to content

Commit a973855

Browse files
committed
feat: 调整表格打印样式
1 parent 8e40281 commit a973855

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/formatter/response-formatter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class ResponseFormatter {
4747
const title = language.console.titleResponse;
4848
printStyledTable(data, styles, title);
4949
const msgs = highlightJSON(responseContext.jsonpCallbackArguments);
50-
console.log(msgs);
51-
50+
// console.log(msgs);
5251

5352
}
5453

src/formatter/table-formatter.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ function printStyledTable(data, styles, title = '') {
5252

5353
// 如果有标题,添加标题行
5454
if (title) {
55-
const titlePadding = Math.floor((totalWidth - getStringWidth(title)) / 2);
56-
const paddedTitle = padString(title, totalWidth);
55+
const titleWidth = getStringWidth(title);
56+
const leftPadding = Math.floor((totalWidth - titleWidth) / 2);
57+
const rightPadding = totalWidth - titleWidth - leftPadding;
58+
const paddedTitle = ' '.repeat(leftPadding) + title + ' '.repeat(rightPadding);
5759
tableContent += '%c' + paddedTitle + '\n';
5860
}
5961

0 commit comments

Comments
 (0)