fix: tranbox ui
This commit is contained in:
@@ -627,6 +627,10 @@ export const I18N = {
|
|||||||
zh: `点击外部关闭弹窗`,
|
zh: `点击外部关闭弹窗`,
|
||||||
en: `Click outside to close the pop-up window`,
|
en: `Click outside to close the pop-up window`,
|
||||||
},
|
},
|
||||||
|
use_simple_style: {
|
||||||
|
zh: `使用简洁界面`,
|
||||||
|
en: `Click outside to close the pop-up window`,
|
||||||
|
},
|
||||||
show: {
|
show: {
|
||||||
zh: `显示`,
|
zh: `显示`,
|
||||||
en: `Show`,
|
en: `Show`,
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export default function Tranbox() {
|
|||||||
btnOffsetY,
|
btnOffsetY,
|
||||||
hideTranBtn = false,
|
hideTranBtn = false,
|
||||||
hideClickAway = false,
|
hideClickAway = false,
|
||||||
|
simpleStyle = false,
|
||||||
} = tranboxSetting;
|
} = tranboxSetting;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -173,6 +174,18 @@ export default function Tranbox() {
|
|||||||
<MenuItem value={true}>{i18n("enable")}</MenuItem>
|
<MenuItem value={true}>{i18n("enable")}</MenuItem>
|
||||||
</TextField>
|
</TextField>
|
||||||
|
|
||||||
|
<TextField
|
||||||
|
select
|
||||||
|
size="small"
|
||||||
|
name="simpleStyle"
|
||||||
|
value={simpleStyle}
|
||||||
|
label={i18n("use_simple_style")}
|
||||||
|
onChange={handleChange}
|
||||||
|
>
|
||||||
|
<MenuItem value={false}>{i18n("disable")}</MenuItem>
|
||||||
|
<MenuItem value={true}>{i18n("enable")}</MenuItem>
|
||||||
|
</TextField>
|
||||||
|
|
||||||
{!isExt && (
|
{!isExt && (
|
||||||
<ShortcutInput
|
<ShortcutInput
|
||||||
value={tranboxShortcut}
|
value={tranboxShortcut}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default function AudioBtn({ text, lan = "uk" }) {
|
|||||||
if (error || !ready) {
|
if (error || !ready) {
|
||||||
return (
|
return (
|
||||||
<IconButton disabled size="small">
|
<IconButton disabled size="small">
|
||||||
<VolumeUpIcon />
|
<VolumeUpIcon fontSize="inherit" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -16,14 +16,14 @@ export default function AudioBtn({ text, lan = "uk" }) {
|
|||||||
if (playing) {
|
if (playing) {
|
||||||
return (
|
return (
|
||||||
<IconButton color="primary" size="small">
|
<IconButton color="primary" size="small">
|
||||||
<VolumeUpIcon />
|
<VolumeUpIcon fontSize="inherit" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton onClick={onPlay} size="small">
|
<IconButton onClick={onPlay} size="small">
|
||||||
<VolumeUpIcon />
|
<VolumeUpIcon fontSize="inherit" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import FavBtn from "./FavBtn";
|
import FavBtn from "./FavBtn";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
@@ -9,6 +8,7 @@ import Alert from "@mui/material/Alert";
|
|||||||
import { OPT_TRANS_BAIDU } from "../../config";
|
import { OPT_TRANS_BAIDU } from "../../config";
|
||||||
import { apiTranslate } from "../../apis";
|
import { apiTranslate } from "../../apis";
|
||||||
import { isValidWord } from "../../libs/utils";
|
import { isValidWord } from "../../libs/utils";
|
||||||
|
import CopyBtn from "./CopyBtn";
|
||||||
|
|
||||||
const phonicMap = {
|
const phonicMap = {
|
||||||
en_phonic: ["英", "uk"],
|
en_phonic: ["英", "uk"],
|
||||||
@@ -61,40 +61,60 @@ export default function DictCont({ text }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const copyText = [
|
||||||
|
dictResult.src,
|
||||||
|
dictResult.voice
|
||||||
|
?.map(Object.entries)
|
||||||
|
.map((item) => item[0])
|
||||||
|
.map(([key, val]) => `${phonicMap[key]?.[0] || key} ${val}`)
|
||||||
|
.join(" "),
|
||||||
|
dictResult.content[0].mean
|
||||||
|
.map(({ pre, cont }) => {
|
||||||
|
return `${pre ? `[${pre}] ` : ""}${Object.keys(cont).join("; ")}`;
|
||||||
|
})
|
||||||
|
.join("\n"),
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Stack spacing={1}>
|
||||||
<Stack
|
<Stack direction="row" justifyContent="space-between">
|
||||||
direction="row"
|
|
||||||
justifyContent="space-between"
|
|
||||||
alignItems="flex-start"
|
|
||||||
>
|
|
||||||
<Typography variant="subtitle1" style={{ fontWeight: "bold" }}>
|
<Typography variant="subtitle1" style={{ fontWeight: "bold" }}>
|
||||||
{dictResult.src}
|
{dictResult.src}
|
||||||
</Typography>
|
</Typography>
|
||||||
<FavBtn word={dictResult.src} />
|
<Stack direction="row" justifyContent="space-between">
|
||||||
|
<CopyBtn text={copyText} />
|
||||||
|
<FavBtn word={dictResult.src} />
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Typography component="div">
|
<Typography component="div">
|
||||||
<Stack direction="row">
|
<Typography component="div">
|
||||||
{dictResult.voice
|
{dictResult.voice
|
||||||
?.map(Object.entries)
|
?.map(Object.entries)
|
||||||
.map((item) => item[0])
|
.map((item) => item[0])
|
||||||
.map(([key, val]) => (
|
.map(([key, val]) => (
|
||||||
<span key={key}>
|
<Typography
|
||||||
<span>{`${phonicMap[key]?.[0] || key} ${val}`}</span>
|
component="div"
|
||||||
|
key={key}
|
||||||
|
style={{ display: "inline-block" }}
|
||||||
|
>
|
||||||
|
<Typography component="span">{`${
|
||||||
|
phonicMap[key]?.[0] || key
|
||||||
|
} ${val}`}</Typography>
|
||||||
<AudioBtn text={dictResult.src} lan={phonicMap[key]?.[1]} />
|
<AudioBtn text={dictResult.src} lan={phonicMap[key]?.[1]} />
|
||||||
</span>
|
</Typography>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Typography>
|
||||||
<ul style={{ margin: "0.5em 0" }}>
|
|
||||||
|
<Typography component="ul">
|
||||||
{dictResult.content[0].mean.map(({ pre, cont }, idx) => (
|
{dictResult.content[0].mean.map(({ pre, cont }, idx) => (
|
||||||
<li key={idx}>
|
<Typography component="li" key={idx}>
|
||||||
{pre && `[${pre}] `}
|
{pre && `[${pre}] `}
|
||||||
{Object.keys(cont).join("; ")}
|
{Object.keys(cont).join("; ")}
|
||||||
</li>
|
</Typography>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { apiBaiduSuggest } from "../../apis";
|
import { apiBaiduSuggest } from "../../apis";
|
||||||
|
import Stack from "@mui/material/Stack";
|
||||||
|
|
||||||
export default function SugCont({ text }) {
|
export default function SugCont({ text }) {
|
||||||
const [sugs, setSugs] = useState([]);
|
const [sugs, setSugs] = useState([]);
|
||||||
@@ -16,16 +16,20 @@ export default function SugCont({ text }) {
|
|||||||
})();
|
})();
|
||||||
}, [text]);
|
}, [text]);
|
||||||
|
|
||||||
|
if (sugs.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Stack spacing={1}>
|
||||||
{sugs.map(({ k, v }) => (
|
{sugs.map(({ k, v }) => (
|
||||||
<Typography component="div" key={k}>
|
<Typography component="div" key={k}>
|
||||||
<Typography>{k}</Typography>
|
<Typography>{k}</Typography>
|
||||||
<ul style={{ margin: "0" }}>
|
<Typography component="ul" style={{ margin: "0" }}>
|
||||||
<li>{v}</li>
|
<Typography component="li">{v}</Typography>
|
||||||
</ul>
|
</Typography>
|
||||||
</Typography>
|
</Typography>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function Header({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
<Stack direction="row" justifyContent="space-between" alignItems="center">
|
||||||
<DragIndicatorIcon />
|
<DragIndicatorIcon fontSize="small" />
|
||||||
|
|
||||||
<Stack direction="row" alignItems="center">
|
<Stack direction="row" alignItems="center">
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -42,7 +42,11 @@ function Header({
|
|||||||
setHideClickAway((pre) => !pre);
|
setHideClickAway((pre) => !pre);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{hideClickAway ? <PushPinOutlinedIcon /> : <PushPinIcon />}
|
{hideClickAway ? (
|
||||||
|
<PushPinOutlinedIcon fontSize="small" />
|
||||||
|
) : (
|
||||||
|
<PushPinIcon fontSize="small" />
|
||||||
|
)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
@@ -50,7 +54,11 @@ function Header({
|
|||||||
setSimpleStyle((pre) => !pre);
|
setSimpleStyle((pre) => !pre);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{simpleStyle ? <UnfoldMoreIcon /> : <UnfoldLessIcon />}
|
{simpleStyle ? (
|
||||||
|
<UnfoldMoreIcon fontSize="small" />
|
||||||
|
) : (
|
||||||
|
<UnfoldLessIcon fontSize="small" />
|
||||||
|
)}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
@@ -58,7 +66,7 @@ function Header({
|
|||||||
setShowPopup(false);
|
setShowPopup(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CloseIcon />
|
<CloseIcon fontSize="small" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export default function Slection({
|
|||||||
? 200
|
? 200
|
||||||
: limitNumber(window.innerHeight, 200, 400);
|
: limitNumber(window.innerHeight, 200, 400);
|
||||||
|
|
||||||
const [simpleStyle, setSimpleStyle] = useState(!!tranboxSetting.simpleStyle);
|
|
||||||
const [showBox, setShowBox] = useState(false);
|
const [showBox, setShowBox] = useState(false);
|
||||||
const [showBtn, setShowBtn] = useState(false);
|
const [showBtn, setShowBtn] = useState(false);
|
||||||
const [selectedText, setSelText] = useState("");
|
const [selectedText, setSelText] = useState("");
|
||||||
@@ -36,6 +35,7 @@ export default function Slection({
|
|||||||
x: (window.innerWidth - boxWidth) / 2,
|
x: (window.innerWidth - boxWidth) / 2,
|
||||||
y: (window.innerHeight - boxHeight) / 2,
|
y: (window.innerHeight - boxHeight) / 2,
|
||||||
});
|
});
|
||||||
|
const [simpleStyle, setSimpleStyle] = useState(!!tranboxSetting.simpleStyle);
|
||||||
const [hideClickAway, setHideClickAway] = useState(
|
const [hideClickAway, setHideClickAway] = useState(
|
||||||
!!tranboxSetting.hideClickAway
|
!!tranboxSetting.hideClickAway
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user