fix: rule page: show more button

This commit is contained in:
Gabe
2025-07-01 23:34:16 +08:00
parent d3e3b484bf
commit 165da4e559
2 changed files with 136 additions and 139 deletions

View File

@@ -874,6 +874,10 @@ export const I18N = {
zh: `更多`, zh: `更多`,
en: `More`, en: `More`,
}, },
less: {
zh: `更少`,
en: `Less`,
},
fixer_selector: { fixer_selector: {
zh: `网页修复选择器`, zh: `网页修复选择器`,
en: `Fixer Selector`, en: `Fixer Selector`,

View File

@@ -27,6 +27,7 @@ import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary"; import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails"; import AccordionDetails from "@mui/material/AccordionDetails";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
import { useRules } from "../../hooks/Rules"; import { useRules } from "../../hooks/Rules";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import Grid from "@mui/material/Grid"; import Grid from "@mui/material/Grid";
@@ -181,6 +182,30 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
</MenuItem> </MenuItem>
); );
const ShowMoreButton = showMore ? (
<Button
size="small"
variant="text"
onClick={() => {
setShowMore(false);
}}
startIcon={<ExpandLessIcon />}
>
{i18n("less")}
</Button>
) : (
<Button
size="small"
variant="text"
onClick={() => {
setShowMore(true);
}}
startIcon={<ExpandMoreIcon />}
>
{i18n("more")}
</Button>
);
return ( return (
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<Stack spacing={2}> <Stack spacing={2}>
@@ -343,8 +368,6 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
/> />
)} )}
{showMore && (
<>
<Box> <Box>
<Grid container spacing={2} columns={12}> <Grid container spacing={2} columns={12}>
<Grid item xs={12} sm={6} md={3} lg={2}> <Grid item xs={12} sm={6} md={3} lg={2}>
@@ -449,6 +472,8 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
</Grid> </Grid>
</Box> </Box>
{showMore && (
<>
<TextField <TextField
size="small" size="small"
label={i18n("fixer_selector")} label={i18n("fixer_selector")}
@@ -620,18 +645,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
{i18n("delete")} {i18n("delete")}
</Button> </Button>
)} )}
{!showMore && ( {ShowMoreButton}
<Button
size="small"
variant="text"
onClick={() => {
setShowMore(true);
}}
startIcon={<ExpandMoreIcon />}
>
{i18n("more")}
</Button>
)}
</> </>
) : ( ) : (
<> <>
@@ -651,18 +665,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
> >
{i18n("cancel")} {i18n("cancel")}
</Button> </Button>
{!showMore && ( {ShowMoreButton}
<Button
size="small"
variant="text"
onClick={() => {
setShowMore(true);
}}
startIcon={<ExpandMoreIcon />}
>
{i18n("more")}
</Button>
)}
</> </>
)} )}
</Stack> </Stack>
@@ -685,17 +688,7 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
> >
{i18n("cancel")} {i18n("cancel")}
</Button> </Button>
{!showMore && ( {ShowMoreButton}
<Button
size="small"
variant="text"
onClick={() => {
setShowMore(true);
}}
>
{i18n("more")}
</Button>
)}
</Stack> </Stack>
))} ))}
</Stack> </Stack>