import { useState, useMemo } from 'react';
import { TextField, Stack, Box, Container, Typography, Paper } from '@mui/material';
import { useSnackbar } from '@/components/GlobalSnackbar';
import VpnKeyIcon from '@mui/icons-material/VpnKey';
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
import PageHeader from '@/components/PageHeader';
import { jwtPageStyles } from '@/config/pageTheme';
import { parseJwt, formatJson } from '@/utils/jwt';
import CopyButton from '@/components/CopyButton';
interface SectionProps {
title: string;
content: unknown;
raw: string;
color: string;
}
const Section = ({ title, content, color }: SectionProps) => (
{title}
{content ? formatJson(content) : '无法解析'}
);
export default function JwtPage() {
useSnackbar();
const [jwtInput, setJwtInput] = useState('');
const result = useMemo(() => {
if (!jwtInput.trim()) {
return null;
}
return parseJwt(jwtInput);
}, [jwtInput]);
return (
} />
{/* Input Area */}
{
// 自动去除 Bearer 前缀及首尾空白字符/换行
const val = e.target.value.replace(/^Bearer\s*/i, '').trim();
setJwtInput(val);
}}
fullWidth
sx={jwtPageStyles.INPUT_STYLE}
/>
{result?.error && (
{result.error}
)}
{result && !result.error && (
签名
{result.signature || 'No Signature'}
)}
);
}