const API_BASE = 'http://localhost:3001'; export async function fetchOnceCode() { const response = await fetch(`${API_BASE}/api/once-code`, { method: 'POST', headers: { 'Content-Type': 'application/json' } }); if (!response.ok) { const error = await response.json(); throw new Error(error.error_msg || '获取授权码失败'); } const data = await response.json(); return data.once_code; }