Skip to content

Commit

Permalink
✨ Window可调整大小
Browse files Browse the repository at this point in the history
  • Loading branch information
neila-a committed Feb 15, 2024
1 parent 8e29255 commit 84bcd0f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/app/components/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function MouseOverPopover(props: {
if (isMobile) {
logger.log("检测到此设备为手机,停止显示弹出框");
} else {
setAnchorEl(event.currentTarget);
setAnchorEl(event.target);
}
},
handlePopoverClose = () => {
Expand Down
18 changes: 17 additions & 1 deletion src/app/components/window/Window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
Divider,
IconButton,
Typography,
Box
Box,
TextField
} from "@mui/material";
import {
CSSProperties,
Expand All @@ -29,6 +30,7 @@ import {
import {
Hex
} from "../../declare";
import { get } from "react-intl-universal";
export interface WindowOptions {
to: string;
name: string;
Expand Down Expand Up @@ -78,6 +80,20 @@ export default function Window(props: WindowOptions): JSX.Element {
alignItems: "center",
...realSx
}}>
{extended && <Box sx={{
display: "flex"
}}>
<TextField label={get('height')} type="number" InputLabelProps={{
shrink: true,
}} onChange={event => {
setSize(old => [Number(event.target.value), old[1]]);
}} value={size[0]} />
<TextField label={get('width')} type="number" InputLabelProps={{
shrink: true,
}} onChange={event => {
setSize(old => [old[0], Number(event.target.value)]);
}} value={size[1]} />
</Box>}
<Box sx={{
cursor: "move",
flex: 1,
Expand Down
4 changes: 3 additions & 1 deletion src/app/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,7 @@
"error": {
"cache": "清除缓存并重试",
"setting": "清除设置并重试"
}
},
"height": "高度",
"width": "宽度"
}
10 changes: 5 additions & 5 deletions src/app/tools/mathgen/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,26 @@ function MathGen(): JSX.Element {
<TextField margin="normal" label={get('上限')} type="number" InputLabelProps={{
shrink: true,
}} onChange={event => {
setMax(Number(event.currentTarget.value));
setMax(Number(event.target.value));
}} defaultValue={max} />
<TextField margin="normal" label={get('下限')} type="number" InputLabelProps={{
shrink: true,
}} onChange={event => {
setMin(Number(event.currentTarget.value));
setMin(Number(event.target.value));
}} defaultValue={min} />
<TextField margin="normal" label={get('个数')} type="number" InputLabelProps={{
shrink: true,
}} onChange={event => {
setItemCount(Number(event.currentTarget.value));
setItemCount(Number(event.target.value));
}} defaultValue={itemCount} />
<FormControlLabel label={get('mathgen.减数检查')} control={
<Checkbox checked={subtractionCheck} onChange={event => {
setSubtractionCheck(event.currentTarget.checked);
setSubtractionCheck(event.target.checked);
}} />
} />
<FormControlLabel label={get('mathgen.除数检查')} control={
<Checkbox checked={divisionCheck} onChange={event => {
setDivisionCheck(event.currentTarget.checked);
setDivisionCheck(event.target.checked);
}} />
} />
<Paper sx={{
Expand Down
2 changes: 1 addition & 1 deletion src/app/tools/mathgen/singleMath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function SingleMath(props: {
<TextField label={get('结果')} type="number" InputLabelProps={{
shrink: true,
}} error={isError} onChange={event => {
setError((event.currentTarget.value == math.replace(/.*=/g, "")) ? false : true);
setError((event.target.value == math.replace(/.*=/g, "")) ? false : true);
}} />
{showOut == true ? <Typography>{get('答案:')}{math.replace(/.*=/g, "")}</Typography> : <Fragment />}
</Box>
Expand Down

0 comments on commit 84bcd0f

Please sign in to comment.