fix: youdao dict
This commit is contained in:
@@ -6,15 +6,16 @@ import { apiMicrosoftDict, apiYoudaoDict } from "../../apis";
|
||||
export const dictHandlers = {
|
||||
[OPT_DICT_BING]: {
|
||||
apiFn: apiMicrosoftDict,
|
||||
reWord: (data) => data?.word,
|
||||
toText: (data) =>
|
||||
data.trs?.map(({ pos, def }) => `${pos ? `[${pos}] ` : ""}${def}`) || [],
|
||||
data?.trs?.map(({ pos, def }) => `${pos ? `[${pos}] ` : ""}${def}`) || [],
|
||||
uiAudio: (data) => (
|
||||
<Typography component="div">
|
||||
{data?.aus.map(({ key, audio, phonetic }) => (
|
||||
{data?.aus?.map(({ key, audio, phonetic }) => (
|
||||
<Typography
|
||||
component="div"
|
||||
key={key}
|
||||
style={{ display: "inline-block" }}
|
||||
style={{ display: "inline-block", paddingRight: "1em" }}
|
||||
>
|
||||
<Typography component="span">{phonetic}</Typography>
|
||||
<AudioBtn src={audio} />
|
||||
@@ -35,11 +36,27 @@ export const dictHandlers = {
|
||||
},
|
||||
[OPT_DICT_YOUDAO]: {
|
||||
apiFn: apiYoudaoDict,
|
||||
reWord: (data) => data?.ec?.word?.["return-phrase"],
|
||||
toText: (data) =>
|
||||
data?.ec?.word?.trs?.map(
|
||||
({ pos, tran }) => `${pos ? `[${pos}] ` : ""}${tran}`
|
||||
) || [],
|
||||
uiAudio: () => null,
|
||||
uiAudio: (data) => (
|
||||
<Typography component="div">
|
||||
<Typography
|
||||
component="div"
|
||||
style={{ display: "inline-block", paddingRight: "1em" }}
|
||||
>
|
||||
<Typography component="span">{`UK [${data?.ec?.word?.ukphone}]`}</Typography>
|
||||
</Typography>
|
||||
<Typography
|
||||
component="div"
|
||||
style={{ display: "inline-block", paddingRight: "1em" }}
|
||||
>
|
||||
<Typography component="span">{`US [${data?.ec?.word?.usphone}]`}</Typography>
|
||||
</Typography>
|
||||
</Typography>
|
||||
),
|
||||
uiTrans: (data) => (
|
||||
<Typography component="ul">
|
||||
{data?.ec?.word?.trs?.map(({ pos, tran }, idx) => (
|
||||
|
||||
Reference in New Issue
Block a user