minimax-status 1.1.12 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.js +5 -5
- package/cli/status.js +57 -1
- package/package.json +1 -1
package/cli/index.js
CHANGED
|
@@ -138,8 +138,9 @@ program
|
|
|
138
138
|
if (options.compact) {
|
|
139
139
|
console.log(statusBar.renderCompact());
|
|
140
140
|
} else {
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
// 将 allModels 传入 StatusBar 内部渲染
|
|
142
|
+
const statusBarWithModels = new StatusBar(usageData, usageStats, api, allModels);
|
|
143
|
+
console.log("\n" + statusBarWithModels.render() + "\n");
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
if (options.watch) {
|
|
@@ -167,11 +168,10 @@ program
|
|
|
167
168
|
]);
|
|
168
169
|
const usageData = api.parseUsageData(apiData, subscriptionData);
|
|
169
170
|
const allModels = api.parseAllModels(apiData);
|
|
170
|
-
const statusBar = new StatusBar(usageData);
|
|
171
171
|
|
|
172
172
|
spinner.succeed("状态获取成功");
|
|
173
|
-
|
|
174
|
-
console.log(
|
|
173
|
+
const statusBarWithModels = new StatusBar(usageData, null, null, allModels);
|
|
174
|
+
console.log("\n" + statusBarWithModels.render() + "\n");
|
|
175
175
|
} catch (error) {
|
|
176
176
|
spinner.fail(chalk.red("获取状态失败"));
|
|
177
177
|
console.error(chalk.red(`错误: ${error.message}`));
|
package/cli/status.js
CHANGED
|
@@ -4,10 +4,11 @@ const { default: boxen } = require('boxen');
|
|
|
4
4
|
const { default: stringWidth } = require('string-width');
|
|
5
5
|
|
|
6
6
|
class StatusBar {
|
|
7
|
-
constructor(data, usageStats = null, api = null) {
|
|
7
|
+
constructor(data, usageStats = null, api = null, allModels = []) {
|
|
8
8
|
this.data = data;
|
|
9
9
|
this.usageStats = usageStats;
|
|
10
10
|
this.api = api;
|
|
11
|
+
this.allModels = allModels;
|
|
11
12
|
this.totalWidth = 63; // 总宽度包括边框
|
|
12
13
|
this.borderWidth = 4; // '│ ' (2) + ' │' (2) = 4
|
|
13
14
|
}
|
|
@@ -54,6 +55,56 @@ class StatusBar {
|
|
|
54
55
|
return lines.join('\n');
|
|
55
56
|
}
|
|
56
57
|
|
|
58
|
+
// 渲染所有模型额度区块
|
|
59
|
+
renderAllModelsSection() {
|
|
60
|
+
if (!this.allModels || this.allModels.length === 0) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const lines = [];
|
|
65
|
+
lines.push('');
|
|
66
|
+
lines.push(chalk.bold('📋 所有模型额度'));
|
|
67
|
+
|
|
68
|
+
// 简化模型名称映射
|
|
69
|
+
const shortName = (name) => {
|
|
70
|
+
if (name.includes('MiniMax-M')) return 'MiniMax-M*';
|
|
71
|
+
if (name.includes('speech')) return 'speech-hd';
|
|
72
|
+
if (name.includes('Hailuo-2.3-Fast')) return 'Hailuo';
|
|
73
|
+
if (name.includes('Hailuo-2.3')) return 'Hailuo-2.3';
|
|
74
|
+
if (name.includes('Hailuo')) return 'Hailuo';
|
|
75
|
+
if (name.includes('music')) return 'music';
|
|
76
|
+
if (name.includes('image')) return 'image';
|
|
77
|
+
return name.length > 15 ? name.substring(0, 12) + '...' : name;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// 获取状态颜色
|
|
81
|
+
const getStatusColor = (percentage) => {
|
|
82
|
+
if (percentage >= 85) return chalk.red;
|
|
83
|
+
if (percentage >= 60) return chalk.yellow;
|
|
84
|
+
return chalk.green;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// 显示状态
|
|
88
|
+
const getStatusText = (percentage) => {
|
|
89
|
+
if (percentage >= 85) return '⚠';
|
|
90
|
+
if (percentage >= 60) return '⚡';
|
|
91
|
+
return '✓';
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// 每行显示一个模型
|
|
95
|
+
for (const model of this.allModels) {
|
|
96
|
+
const short = shortName(model.name);
|
|
97
|
+
const color = getStatusColor(model.percentage);
|
|
98
|
+
const status = getStatusText(model.percentage);
|
|
99
|
+
const pct = `${model.percentage}%`;
|
|
100
|
+
const usedTotal = `${model.used}/${model.total}`;
|
|
101
|
+
|
|
102
|
+
lines.push(` ${color(short.padEnd(15))} ${color(pct.padEnd(5))} ${color(usedTotal.padEnd(12))} ${color(status)}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return lines.join('\n');
|
|
106
|
+
}
|
|
107
|
+
|
|
57
108
|
// 辅助函数:填充内容到正确长度,处理 chalk 代码和中文字符
|
|
58
109
|
padLine(leftContent, rightContent) {
|
|
59
110
|
// 移除 chalk 代码以便计算
|
|
@@ -141,6 +192,11 @@ class StatusBar {
|
|
|
141
192
|
contentLines.push(this.renderConsumptionStats());
|
|
142
193
|
}
|
|
143
194
|
|
|
195
|
+
// 添加所有模型额度(如果有数据)
|
|
196
|
+
if (this.allModels && this.allModels.length > 0) {
|
|
197
|
+
contentLines.push(this.renderAllModelsSection());
|
|
198
|
+
}
|
|
199
|
+
|
|
144
200
|
contentLines.push('');
|
|
145
201
|
|
|
146
202
|
// 状态行
|