refacor: 重构目录架构

This commit is contained in:
2026-09-16 22:43:21 +08:00
parent b37cdb0d54
commit 2754ed1e45
2762 changed files with 0 additions and 1529 deletions
+72
View File
@@ -0,0 +1,72 @@
import boxen from 'boxen';
import chalk from 'chalk';
import Table from 'cli-table3';
import gradient from 'gradient-string';
import ora, { type Ora } from 'ora';
export function printBanner() {
const title = gradient.pastel('Ecom License TUI');
console.log(
boxen(`${title}\n${chalk.gray('授权管理平台 · 运营端')}`, {
padding: 1,
borderColor: 'cyan',
borderStyle: 'round',
}),
);
}
export function printSuccess(msg: string) {
console.log(chalk.green('✔'), msg);
}
export function printError(msg: string) {
console.error(chalk.red('✖'), msg);
}
export function printInfo(msg: string) {
console.log(chalk.blue('ℹ'), msg);
}
export function printBox(title: string, content: string, borderColor: 'green' | 'cyan' | 'yellow' = 'cyan') {
console.log(
boxen(content, {
title: chalk.bold(title),
padding: 1,
borderColor,
}),
);
}
export function printTable(headers: string[], rows: string[][]) {
const table = new Table({ head: headers.map((h) => chalk.cyan(h)) });
rows.forEach((r) => table.push(r));
console.log(table.toString());
}
export function printEmptyHint(hint: string) {
console.log(chalk.yellow('暂无数据。'), chalk.gray(hint));
}
let activeSpinner: Ora | null = null;
export async function runSpinner<T>(fn: () => Promise<T>, text: string): Promise<T> {
const spinner = ora(text).start();
activeSpinner = spinner;
try {
const result = await fn();
spinner.succeed();
return result;
} catch (e) {
spinner.fail();
throw e;
} finally {
activeSpinner = null;
}
}
export function failSpinner(msg: string) {
if (activeSpinner) {
activeSpinner.fail(msg);
activeSpinner = null;
}
}