/* * Based on frontpage/atproto-browser * Copyright (c) 2025 The Frontpage Authors * MIT License */ import React, { useState, useEffect } from 'react' import { parseAtUri, getRecord } from '../lib/atproto.js' import AtUriJson from './AtUriJson.jsx' export default function AtUriViewer({ uri, onAtUriClick }) { const [record, setRecord] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { const loadRecord = async () => { if (!uri) return setLoading(true) setError(null) try { const atUri = parseAtUri(uri) if (!atUri) { throw new Error('Invalid AT URI') } const result = await getRecord(atUri.hostname, atUri.collection, atUri.rkey) if (!result.success) { throw new Error(result.error) } setRecord(result.data) } catch (err) { setError(err.message) } finally { setLoading(false) } } loadRecord() }, [uri]) if (loading) { return (
Loading...
) } if (error) { return (
Error: {error}
URI: {uri}
デバッグ情報: このAT URIは有効ではないか、レコードが存在しません。
) } if (!record) { return (
No record found
) } const atUri = parseAtUri(uri) return (

AT URI Record

{uri}
DID: {atUri.hostname} | Collection: {atUri.collection} | RKey: {atUri.rkey}

Record Data

) }