()
| 188 | } |
| 189 | |
| 190 | function GlossaryPanel() { |
| 191 | const [query, setQuery] = useState(""); |
| 192 | const q = query.trim().toLowerCase(); |
| 193 | const sections = useMemo(() => glossarySections |
| 194 | .map((section) => ({ |
| 195 | title: section.title, |
| 196 | terms: section.terms |
| 197 | .map(splitTerm) |
| 198 | .filter(({term, def}) => !q || term.toLowerCase().includes(q) || def.toLowerCase().includes(q)), |
| 199 | })) |
| 200 | .filter((section) => section.terms.length > 0), [q]); |
| 201 | |
| 202 | return ( |
| 203 | <Box> |
| 204 | <TextField |
| 205 | size="small" |
| 206 | placeholder="搜索缩写或释义…" |
| 207 | value={query} |
| 208 | onChange={(e) => setQuery(e.target.value)} |
| 209 | sx={{mb: 3, width: '100%', maxWidth: 360}} |
| 210 | InputProps={{startAdornment: <InputAdornment position="start"><SearchRounded fontSize="small"/></InputAdornment>}} |
| 211 | /> |
| 212 | {sections.length === 0 && <Typography color="text.secondary">未找到匹配的词条</Typography>} |
| 213 | {sections.map((section) => ( |
| 214 | <Box key={section.title} sx={{mb: 3.5}}> |
| 215 | <Typography sx={{fontWeight: 600, color: 'text.secondary', fontSize: 13, letterSpacing: '0.04em', mb: 1}}> |
| 216 | {section.title} |
| 217 | </Typography> |
| 218 | <Box sx={{display: 'grid', gridTemplateColumns: {xs: '1fr', md: '1fr 1fr'}, columnGap: 4, rowGap: 0}}> |
| 219 | {section.terms.map(({term, def}) => ( |
| 220 | <Box |
| 221 | key={term} |
| 222 | sx={{ |
| 223 | display: 'flex', |
| 224 | gap: 1.5, |
| 225 | alignItems: 'baseline', |
| 226 | py: 1, |
| 227 | borderBottom: '1px solid', |
| 228 | borderColor: 'divider', |
| 229 | }} |
| 230 | > |
| 231 | <Typography |
| 232 | component="span" |
| 233 | sx={{ |
| 234 | color: 'primary.main', |
| 235 | fontWeight: 600, |
| 236 | fontFamily: '"SF Mono", ui-monospace, Menlo, monospace', |
| 237 | fontSize: 13, |
| 238 | whiteSpace: 'nowrap', |
| 239 | flexShrink: 0, |
| 240 | minWidth: 56, |
| 241 | }} |
| 242 | > |
| 243 | {term} |
| 244 | </Typography> |
| 245 | <Typography component="span" variant="body2" sx={{color: 'text.secondary'}}> |
| 246 | {def} |
| 247 | </Typography> |
nothing calls this directly
no outgoing calls
no test coverage detected