yingclaw 1.4.0 → 1.5.0
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/bin/cli.js +30 -4
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -342,7 +342,7 @@ program
|
|
|
342
342
|
.description('查看当前配置和 Key 有效性')
|
|
343
343
|
.action(showStatus);
|
|
344
344
|
|
|
345
|
-
async function renderStatusBar() {
|
|
345
|
+
async function renderStatusBar(apiStatus) {
|
|
346
346
|
const chalk = (await import('chalk')).default;
|
|
347
347
|
const config = loadConfig();
|
|
348
348
|
const claudeInstalled = (() => {
|
|
@@ -355,7 +355,16 @@ async function renderStatusBar() {
|
|
|
355
355
|
let cfgPart;
|
|
356
356
|
if (config) {
|
|
357
357
|
const provName = PROVIDERS[config.provider]?.name || config.provider;
|
|
358
|
-
|
|
358
|
+
let dot;
|
|
359
|
+
if (apiStatus === true) dot = chalk.green('●');
|
|
360
|
+
else if (apiStatus === false) dot = chalk.red('●');
|
|
361
|
+
else if (apiStatus === null) dot = chalk.yellow('●');
|
|
362
|
+
else dot = chalk.dim('●'); // 未检测
|
|
363
|
+
const apiTag = apiStatus === true ? chalk.green(' API ✓')
|
|
364
|
+
: apiStatus === false ? chalk.red(' API ✘')
|
|
365
|
+
: apiStatus === null ? chalk.yellow(' 网络异常')
|
|
366
|
+
: '';
|
|
367
|
+
cfgPart = `${dot} ${chalk.white(provName)}${chalk.dim(' · ')}${chalk.yellow(config.model)}${apiTag}`;
|
|
359
368
|
} else {
|
|
360
369
|
cfgPart = chalk.red('●') + ' ' + chalk.dim('未配置');
|
|
361
370
|
}
|
|
@@ -365,14 +374,25 @@ async function renderStatusBar() {
|
|
|
365
374
|
|
|
366
375
|
async function runMenu() {
|
|
367
376
|
const chalk = (await import('chalk')).default;
|
|
377
|
+
const ora = (await import('ora')).default;
|
|
368
378
|
|
|
369
379
|
while (true) {
|
|
370
380
|
console.clear();
|
|
371
381
|
console.log(await getBanner());
|
|
372
|
-
console.log(await renderStatusBar());
|
|
373
|
-
console.log();
|
|
374
382
|
|
|
375
383
|
const config = loadConfig();
|
|
384
|
+
let apiStatus; // undefined = skipped, true/false/null = checked
|
|
385
|
+
if (config) {
|
|
386
|
+
const spinner = ora('正在检测 API 是否通畅...').start();
|
|
387
|
+
apiStatus = await validateKey(config);
|
|
388
|
+
if (apiStatus === true) spinner.succeed('API 连接正常');
|
|
389
|
+
else if (apiStatus === false) spinner.fail('API Key 无效或已过期');
|
|
390
|
+
else spinner.warn('网络异常,无法连接 API');
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
console.log(await renderStatusBar(apiStatus));
|
|
394
|
+
console.log();
|
|
395
|
+
|
|
376
396
|
const action = await select({
|
|
377
397
|
message: chalk.cyan('选择操作'),
|
|
378
398
|
choices: [
|
|
@@ -381,12 +401,18 @@ async function runMenu() {
|
|
|
381
401
|
{ name: config ? '⚙️ 重新配置(输入新的 API Key)' : '⚙️ 首次配置 API Key 和模型', value: 'setup' },
|
|
382
402
|
{ name: '🔄 切换厂商/模型(保留当前 Key)', value: 'switch', disabled: !config && '需先完成配置' },
|
|
383
403
|
{ name: '📊 查看当前配置', value: 'status', disabled: !config && '需先完成配置' },
|
|
404
|
+
{ name: '🔁 重新检测 API', value: 'recheck', disabled: !config && '需先完成配置' },
|
|
384
405
|
{ name: '退出', value: 'exit' },
|
|
385
406
|
],
|
|
386
407
|
});
|
|
387
408
|
|
|
388
409
|
if (action === 'exit') return;
|
|
389
410
|
|
|
411
|
+
if (action === 'recheck') {
|
|
412
|
+
// 仅刷新菜单,下次循环会重新检测
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
|
|
390
416
|
if (action === 'launch') {
|
|
391
417
|
const cfg = loadConfig();
|
|
392
418
|
if (!cfg) continue;
|