Skip to content

Commit bc17c85

Browse files
committed
fix: 优化配置项
1 parent 294d2eb commit bc17c85

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@4xian/ccapi",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"author": "4xian (https://github.com/4xian)",
55
"description": "Claude Code settings.json中key自动配置工具,方便API_KEY、AUTH_TOKEN、多模型快速切换",
66
"repository": "https://github.com/4xian/claude-auto-api.git",

src/commands/list.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,31 @@ function formatConfigDisplay(name, config, currentInfo) {
7474
const isCurrent = name === currentInfo.name;
7575
const prefix = isCurrent ? chalk.green('* ') : ' ';
7676
const nameDisplay = isCurrent ? chalk.green.bold(`【${name}】`) : chalk.cyan(`【${name}】`);
77-
77+
7878
// 设置默认值
7979
config.model = config.model || 'claude-sonnet-4-20250514';
80-
config.fast = config.fast || 'claude-3-5-haiku-20241022';
81-
80+
// config.fast = config.fast || 'claude-3-5-haiku-20241022';
81+
8282
let details = [];
8383
details.push(`URL: ${chalk.cyan(config.url)}`);
84-
84+
8585
// 格式化模型显示
8686
const modelLines = formatModelDisplay(
87-
config.model,
88-
isCurrent ? currentInfo.modelIndex : -1,
87+
config.model,
88+
isCurrent ? currentInfo.modelIndex : -1,
8989
'Model'
9090
);
9191
details.push(...modelLines);
92-
92+
9393
// 格式化快速模型显示
94-
const fastLines = formatModelDisplay(
95-
config.fast,
96-
isCurrent ? currentInfo.fastIndex : -1,
97-
'Fast'
98-
);
99-
details.push(...fastLines);
94+
if (config.fast) {
95+
const fastLines = formatModelDisplay(
96+
config.fast,
97+
isCurrent ? currentInfo.fastIndex : -1,
98+
'Fast'
99+
);
100+
details.push(...fastLines);
101+
}
100102

101103
if (config.key) {
102104
const maskedKey = config.key.length > 15

src/commands/use.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@ function updateSettingsEnv(settingsData, targetConfig) {
3232
env[CLAUDE_ENV_KEYS.model] = targetConfig.model;
3333

3434
// 轻量模型(可选)
35-
env[CLAUDE_ENV_KEYS.fast] = targetConfig.fast;
35+
if (targetConfig.fast) {
36+
env[CLAUDE_ENV_KEYS.fast] = targetConfig.fast;
37+
} else {
38+
delete env[CLAUDE_ENV_KEYS.fast];
39+
}
3640

3741
// API请求超时时间(可选)
38-
env[CLAUDE_ENV_KEYS.timeout] = targetConfig.timeout;
42+
if (targetConfig.timeout) {
43+
env[CLAUDE_ENV_KEYS.timeout] = targetConfig.timeout;
44+
} else {
45+
delete env[CLAUDE_ENV_KEYS.timeout];
46+
}
47+
3948

4049
if (targetConfig.tokens) {
4150
env[CLAUDE_ENV_KEYS.tokens] = targetConfig.tokens;
@@ -128,8 +137,8 @@ async function useCommand(configName, options = {}) {
128137

129138
// 设置默认值
130139
targetConfig.model = targetConfig.model || 'claude-sonnet-4-20250514';
131-
targetConfig.fast = targetConfig.fast || 'claude-3-5-haiku-20241022';
132-
targetConfig.timeout = targetConfig.timeout || "600000";
140+
// targetConfig.fast = targetConfig.fast || 'claude-3-5-haiku-20241022';
141+
// targetConfig.timeout = targetConfig.timeout || "600000";
133142

134143
try {
135144
// 根据参数选择模型
@@ -142,7 +151,7 @@ async function useCommand(configName, options = {}) {
142151
const selectedFast = selectModel(
143152
targetConfig.fast,
144153
options.fast ? parseInt(options.fast) : 0,
145-
'claude-3-5-haiku-20241022'
154+
''
146155
);
147156

148157
// 更新目标配置为选中的具体模型
@@ -183,7 +192,9 @@ async function useCommand(configName, options = {}) {
183192
// 显示选中的模型信息
184193
console.log(` Model: ${chalk.cyan(targetConfig.model)}`);
185194

186-
console.log(` Fast: ${chalk.cyan(targetConfig.fast)}`);
195+
if (targetConfig.fast) {
196+
console.log(` Fast: ${chalk.cyan(targetConfig.fast)}`);
197+
}
187198

188199
if (targetConfig.key) {
189200
const maskedKey = targetConfig.key.length > 15

0 commit comments

Comments
 (0)