import { useState } from 'react' import type { FormEvent } from 'react' import { getApiClient, resetApiClient } from '../lib/api-client' import { getRuntimeConfig, setRuntimeConfig, } from '../lib/runtime-config' import type { RuntimeConfig } from '../lib/runtime-config' import { reconnectSocket } from '../lib/socket-client' export default function WorkspacePage() { const [form, setForm] = useState(getRuntimeConfig()) const [health, setHealth] = useState('') async function onSave(e: FormEvent) { e.preventDefault() setRuntimeConfig(form) resetApiClient() reconnectSocket() setHealth('配置已保存') } async function checkHealth() { try { const res = await getApiClient().get('/healthz') setHealth(JSON.stringify(res.data)) } catch { setHealth('healthz 访问失败') } } return (

工作台

setForm((v) => ({ ...v, guildApiBase: e.target.value }))} placeholder="Guild API Base" /> setForm((v) => ({ ...v, guildSocketBase: e.target.value }))} placeholder="Guild Socket Base" /> setForm((v) => ({ ...v, apiKey: e.target.value }))} placeholder="API Key" />

{health}

) }