mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-03 11:20:50 +08:00
Compare commits
2 Commits
v0.1.14
...
v0.1.15-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a2d96725f | ||
|
|
8283e99909 |
48
app.js
48
app.js
@@ -2315,6 +2315,30 @@ class CLIProxyManager {
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
// 兼容服务端返回的数组结构
|
||||
normalizeArrayResponse(data, key) {
|
||||
if (Array.isArray(data)) {
|
||||
return data;
|
||||
}
|
||||
if (data && Array.isArray(data[key])) {
|
||||
return data[key];
|
||||
}
|
||||
if (data && Array.isArray(data.items)) {
|
||||
return data.items;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// 构造Codex配置,保持未展示的字段
|
||||
buildCodexConfig(apiKey, baseUrl, proxyUrl, original = {}) {
|
||||
return {
|
||||
...original,
|
||||
'api-key': apiKey,
|
||||
'base-url': baseUrl || '',
|
||||
'proxy-url': proxyUrl || ''
|
||||
};
|
||||
}
|
||||
|
||||
// 显示添加API密钥模态框
|
||||
showAddApiKeyModal() {
|
||||
const modal = document.getElementById('modal');
|
||||
@@ -2695,15 +2719,9 @@ class CLIProxyManager {
|
||||
|
||||
try {
|
||||
const data = await this.makeRequest('/codex-api-key');
|
||||
const currentKeys = data['codex-api-key'] || [];
|
||||
const currentKeys = this.normalizeArrayResponse(data, 'codex-api-key').map(item => ({ ...item }));
|
||||
|
||||
const newConfig = { 'api-key': apiKey };
|
||||
if (baseUrl) {
|
||||
newConfig['base-url'] = baseUrl;
|
||||
}
|
||||
if (proxyUrl) {
|
||||
newConfig['proxy-url'] = proxyUrl;
|
||||
}
|
||||
const newConfig = this.buildCodexConfig(apiKey, baseUrl, proxyUrl);
|
||||
|
||||
currentKeys.push(newConfig);
|
||||
|
||||
@@ -2761,14 +2779,16 @@ class CLIProxyManager {
|
||||
}
|
||||
|
||||
try {
|
||||
const newConfig = { 'api-key': apiKey };
|
||||
if (baseUrl) {
|
||||
newConfig['base-url'] = baseUrl;
|
||||
}
|
||||
if (proxyUrl) {
|
||||
newConfig['proxy-url'] = proxyUrl;
|
||||
const listResponse = await this.makeRequest('/codex-api-key');
|
||||
const currentList = this.normalizeArrayResponse(listResponse, 'codex-api-key');
|
||||
|
||||
if (!Array.isArray(currentList) || index < 0 || index >= currentList.length) {
|
||||
throw new Error('Invalid codex configuration index');
|
||||
}
|
||||
|
||||
const original = currentList[index] ? { ...currentList[index] } : {};
|
||||
const newConfig = this.buildCodexConfig(apiKey, baseUrl, proxyUrl, original);
|
||||
|
||||
await this.makeRequest('/codex-api-key', {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ index, value: newConfig })
|
||||
|
||||
17
styles.css
17
styles.css
@@ -1751,6 +1751,22 @@ input:checked+.slider:before {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 认证文件项的底部布局优化 - 确保状态标签和操作按钮垂直对齐 */
|
||||
.file-item .item-footer {
|
||||
align-items: center; /* 垂直居中对齐 */
|
||||
gap: 12px; /* 增加状态标签和按钮之间的间距 */
|
||||
}
|
||||
|
||||
.file-item .item-stats {
|
||||
align-items: center; /* 状态徽章垂直居中 */
|
||||
margin: 0; /* 移除默认外边距 */
|
||||
}
|
||||
|
||||
.file-item .item-actions {
|
||||
align-items: center; /* 操作按钮垂直居中 */
|
||||
gap: 6px; /* 按钮之间适当间距 */
|
||||
}
|
||||
|
||||
/* API Keys 和 AI Providers 的按钮组 - 绝对定位到右侧垂直居中 */
|
||||
.key-item .item-actions,
|
||||
.provider-item .item-actions {
|
||||
@@ -3642,6 +3658,7 @@ input:checked+.slider:before {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* 统计徽章基础样式 */
|
||||
|
||||
Reference in New Issue
Block a user