'use client' import {useEffect,useState} from 'react' import BrandLogo from '@/components/BrandLogo' import {DEFAULT_LOGIN_LOGO_URL} from '@/lib/brand-assets' import './authorize.css' export default function AuthorizeClient({account,request}:{account:{id:string;name:string};request:Record}){ const [busy,setBusy]=useState(false),[error,setError]=useState(''),[devices,setDevices]=useState<{id:string;deviceName:string;createdAt:string}[]>([]) useEffect(()=>{void fetch('/api/desktop/devices',{cache:'no-store'}).then(r=>r.json()).then(r=>setDevices(r.devices||[])).catch(()=>{})},[]) async function approve(){setBusy(true);setError('');try{const response=await fetch('/api/desktop/authorize',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(request)});const value=await response.json();if(!response.ok)throw new Error(value.error);window.location.assign(value.redirect)}catch(error){setError(error instanceof Error?error.message:'授权未完成,请重试');setBusy(false)}} function cancel(){const url=new URL(request.redirect_uri);url.searchParams.set('error','access_denied');url.searchParams.set('state',request.state);window.location.assign(url)} return
由壹点 · 素材库

授权详情页工作台

使用 {account.name} 的账户继续

授权只用于当前客户端。你可以随时撤销,客户端不会获取网页登录密码。

{error&&

{error}

}
{devices.length>0&&
已授权的客户端{devices.map(device=>
{device.deviceName}{new Date(device.createdAt).toLocaleDateString('zh-CN')}
)}
}
}