import { useEffect, useState } from 'react'; import { accountApi, type AccountDevice } from '@/core-bridge/account'; import { useAccount } from '@/store/account'; import { Button } from '@/ui/Button'; import styles from './AccountPanel.module.css'; export function AccountDevices() { const [devices, setDevices] = useState([]); const [names, setNames] = useState>({}); const [error, setError] = useState(''); const [busy, setBusy] = useState(false); const refreshAccount = useAccount((s) => s.refresh); async function refresh() { setDevices(await accountApi.devices()); } useEffect(() => { void refresh().catch(() => setError('设备清单读取失败')); }, []); async function change(device: AccountDevice, revoke: boolean) { setBusy(true); setError(''); try { if (revoke) { await accountApi.revokeDevice(device.id); await refreshAccount(); } else await accountApi.renameDevice(device.id, names[device.id] ?? device.name); await refresh(); } catch (cause) { setError(cause instanceof Error ? cause.message : '设备更新失败'); } finally { setBusy(false); } } return
我的设备

同一账号可登录多台设备。移除设备只会撤销它的登录,不影响账号在各空间里的成员身份。

{devices.map((device) =>
)} {error ?

{error}

: null}
; }