feat: add Codex API headless authentication and proxy configuration UI.

This commit is contained in:
2026-02-03 07:01:22 +08:00
parent f2757cf313
commit 87b9b72a0e
2 changed files with 13 additions and 7 deletions

View File

@@ -492,6 +492,7 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) {
verifyHeaders["OpenAI-Sentinel-Token"] = c.getSentinelHeader("password_verify") verifyHeaders["OpenAI-Sentinel-Token"] = c.getSentinelHeader("password_verify")
passwordPayload := map[string]string{ passwordPayload := map[string]string{
"username": c.email,
"password": c.password, "password": c.password,
} }
@@ -500,6 +501,7 @@ func (c *CodexAPIAuth) ObtainAuthorizationCode() (string, error) {
c.logError(StepInputPassword, "密码验证失败: %d - %s", resp.StatusCode, string(body[:min(200, len(body))])) c.logError(StepInputPassword, "密码验证失败: %d - %s", resp.StatusCode, string(body[:min(200, len(body))]))
return "", fmt.Errorf("密码验证失败: %d", resp.StatusCode) return "", fmt.Errorf("密码验证失败: %d", resp.StatusCode)
} }
c.logStep(StepInputPassword, "密码验证成功")
// 解析密码验证响应 // 解析密码验证响应
json.Unmarshal(body, &data) json.Unmarshal(body, &data)

View File

@@ -51,8 +51,10 @@ export default function CodexProxyConfig() {
const [batchInput, setBatchInput] = useState('') const [batchInput, setBatchInput] = useState('')
// 获取代理列表 // 获取代理列表
const fetchProxies = useCallback(async () => { const fetchProxies = useCallback(async (showLoading = true) => {
if (showLoading) {
setLoading(true) setLoading(true)
}
try { try {
const res = await fetch('/api/codex-proxy') const res = await fetch('/api/codex-proxy')
const data = await res.json() const data = await res.json()
@@ -63,8 +65,10 @@ export default function CodexProxyConfig() {
} catch (error) { } catch (error) {
console.error('获取代理列表失败:', error) console.error('获取代理列表失败:', error)
} finally { } finally {
if (showLoading) {
setLoading(false) setLoading(false)
} }
}
}, []) }, [])
const fetchConfig = useCallback(async () => { const fetchConfig = useCallback(async () => {
@@ -183,8 +187,8 @@ export default function CodexProxyConfig() {
if (data.code === 0) { if (data.code === 0) {
toast.success(`成功添加 ${data.data.added}/${data.data.total} 个代理`) toast.success(`成功添加 ${data.data.added}/${data.data.total} 个代理`)
setBatchInput('') setBatchInput('')
// 批量添加后需要刷新列表获取新的代理ID // 批量添加后需要刷新列表获取新的代理ID(不显示全局加载状态)
fetchProxies() fetchProxies(false)
} else { } else {
toast.error(data.message || '添加失败') toast.error(data.message || '添加失败')
} }
@@ -346,8 +350,8 @@ export default function CodexProxyConfig() {
}) })
} }
// 刷新列表获取最新数据 // 刷新列表获取最新数据(不显示全局加载状态)
await fetchProxies() await fetchProxies(false)
setTestingAll(false) setTestingAll(false)
// 使用 toast 提示结果 // 使用 toast 提示结果