diff --git a/web/index.html b/web/index.html index 67059d1..797802d 100644 --- a/web/index.html +++ b/web/index.html @@ -2,35 +2,36 @@
- +Claude API
+Claude API
OpenAI API
+OpenAI API
模型列表
+模型列表
暂无账号,请添加
'; + container.innerHTML = '暂无账号
'; return; } container.innerHTML = accountsData.map(a => { @@ -280,7 +315,7 @@ const usageClass = usagePercent > 90 ? 'critical' : usagePercent > 70 ? 'high' : ''; return `点击加载按钮获取模型列表
点击加载按钮获取
无可用模型
'; + container.innerHTML = d.models.map(m => `无可用模型
'; } else { container.innerHTML = '加载失败: ' + (d.error || '未知错误') + '
'; } @@ -427,32 +448,22 @@ try { const res = await fetch('/admin/api/generate-machine-id', { headers: { 'X-Admin-Password': password } }); const d = await res.json(); - if (d.machineId) { - document.getElementById('machineIdInput').value = d.machineId; - } + if (d.machineId) document.getElementById('machineIdInput').value = d.machineId; } catch (e) { alert('生成失败'); } } async function saveMachineId(id) { const machineId = document.getElementById('machineIdInput').value.trim(); - // UUID 格式或 32位十六进制 if (machineId && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(machineId) && !/^[0-9a-f]{32}$/i.test(machineId)) { - alert('机器码格式错误,需要 UUID 格式 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) 或 32位十六进制'); - return; + alert('机器码格式错误'); return; } try { const res = await fetch('/admin/api/accounts/' + id, { - method: 'PUT', - headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, + method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, body: JSON.stringify({ machineId }) }); const d = await res.json(); - if (d.success) { - alert('已保存'); - loadAccounts(); - } else { - alert('保存失败: ' + d.error); - } + if (d.success) { alert('已保存'); loadAccounts(); } else { alert('保存失败: ' + d.error); } } catch (e) { alert('保存失败'); } } @@ -465,8 +476,7 @@ async function saveSettings() { await fetch('/admin/api/settings', { - method: 'POST', - headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, + method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, body: JSON.stringify({ requireApiKey: document.getElementById('requireApiKey').checked, apiKey: document.getElementById('apiKeyInput').value }) }); alert('已保存'); @@ -476,8 +486,7 @@ const newPwd = document.getElementById('newPassword').value; if (!newPwd) return alert('请输入新密码'); await fetch('/admin/api/settings', { - method: 'POST', - headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, + method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, body: JSON.stringify({ password: newPwd }) }); password = newPwd; @@ -500,8 +509,7 @@ async function toggleAccount(id, enabled) { await fetch('/admin/api/accounts/' + id, { - method: 'PUT', - headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, + method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-Admin-Password': password }, body: JSON.stringify({ enabled }) }); loadAccounts(); @@ -532,7 +540,7 @@ if (type === 'credentials') { title.textContent = '导入凭证'; body.innerHTML = ` - + `; } else if (type === 'sso') { @@ -547,7 +555,7 @@请在浏览器中完成登录,然后粘贴回调 URL
+请在浏览器中完成登录,然后粘贴回调 URL