Files
kiss-translator/src/views/Selection/DictCont.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-10-26 23:55:05 +08:00
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import FavBtn from "./FavBtn";
2023-11-22 10:23:14 +08:00
import Typography from "@mui/material/Typography";
2023-10-26 23:55:05 +08:00
2024-01-18 15:26:37 +08:00
const phonicMap = {
en_phonic: "英",
us_phonic: "美",
2023-10-26 23:55:05 +08:00
};
export default function DictCont({ dictResult }) {
if (!dictResult) {
return;
}
return (
<Box>
<Stack
direction="row"
justifyContent="space-between"
alignItems="flex-start"
>
2023-11-22 10:23:14 +08:00
<Typography variant="subtitle1" style={{ fontWeight: "bold" }}>
2024-01-18 15:26:37 +08:00
{dictResult.src}
2023-11-22 10:23:14 +08:00
</Typography>
2024-01-18 15:26:37 +08:00
<FavBtn word={dictResult.src} />
2023-10-26 23:55:05 +08:00
</Stack>
2024-01-18 15:26:37 +08:00
<Typography component="div">
<Typography>
{dictResult.voice
2024-02-21 15:41:27 +08:00
?.map(Object.entries)
2024-01-18 15:26:37 +08:00
.map((item) => item[0])
.map(([key, val]) => `${phonicMap[key] || key} ${val}`)
.join(" ")}
2023-11-22 10:23:14 +08:00
</Typography>
2024-01-18 15:26:37 +08:00
<ul style={{ margin: "0.5em 0" }}>
{dictResult.content[0].mean.map(({ pre, cont }, idx) => (
<li key={idx}>
{pre && `[${pre}] `}
{Object.keys(cont).join("; ")}
</li>
2023-10-26 23:55:05 +08:00
))}
2024-01-18 15:26:37 +08:00
</ul>
</Typography>
2023-10-26 23:55:05 +08:00
</Box>
);
}