Commit 1ac5fb6c authored by chenshouchao's avatar chenshouchao

feat: 新增MYMENU组件

parent 5f1d13aa
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
white-space: nowrap;
} }
.radioActive { .radioActive {
color: #1370ff; color: #1370ff;
......
import * as React from "react";
import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";
import { ThemeProvider, createTheme } from "@mui/material/styles";
type IOption = {
label: string;
value: string;
};
type IMyMenuProps = {
children: React.ReactNode;
options: Array<IOption>;
value: string;
};
const theme = createTheme({
components: {
// Name of the component
MuiMenuItem: {
styleOverrides: {
// Name of the slot
root: {
fontSize: "12px",
":hover": {
color: "red",
},
"&.Mui-selected": {
backgroundColor: "#2a68c9",
},
},
},
},
},
});
const MyMenu = (props: IMyMenuProps) => {
const { children, options, value } = props;
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = (value: string) => {
setAnchorEl(null);
console.log(value);
};
return (
<ThemeProvider theme={theme}>
<div>
<div onClick={handleClick}>{children}</div>
<Menu
id="basic-menu"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
MenuListProps={{
"aria-labelledby": "basic-button",
}}
>
{options.map((option, index) => {
return (
<MenuItem
onClick={() => handleClose(option.value)}
selected={value === option.value}
key={index}
>
{option.label}
{value}
</MenuItem>
);
})}
</Menu>
</div>
</ThemeProvider>
);
};
export default MyMenu;
...@@ -12,68 +12,82 @@ import { observer } from "mobx-react-lite"; ...@@ -12,68 +12,82 @@ import { observer } from "mobx-react-lite";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import projectImg from "@/assets/project/projectIconSmall.svg"; import projectImg from "@/assets/project/projectIconSmall.svg";
import MyMenu from "@/components/mui/MyMenu";
import WorkbenchTemplate from "./workbenchTemplate"; import WorkbenchTemplate from "./workbenchTemplate";
import WorkbenchList from "./workbenchList"; import WorkbenchList from "./workbenchList";
import Tabs from "@/components/mui/Tabs"; import Tabs from "@/components/mui/Tabs";
import usePass from "@/hooks/usePass"; import usePass from "@/hooks/usePass";
import Template from "@/assets/project/workbenchTemplate.svg" import Template from "@/assets/project/workbenchTemplate.svg";
import Template_select from "@/assets/project/workbenchTemplate_select.svg" import Template_select from "@/assets/project/workbenchTemplate_select.svg";
import List from "@/assets/project/workbenchList.svg" import List from "@/assets/project/workbenchList.svg";
import List_select from "@/assets/project/workbenchList_select.svg" import List_select from "@/assets/project/workbenchList_select.svg";
const ProjectWorkbench = observer(() => { const ProjectWorkbench = observer(() => {
const isPass = usePass(); const isPass = usePass();
const location: any = useLocation() const location: any = useLocation();
const tabList = useMemo(() => {
return [ const options = [
{ {
label: "工作流模版", value: "123",
value: "workbenchTemplate", label: "1234",
component: <WorkbenchTemplate />, },
hide: !isPass("PROJECT_WORKBENCH_FLOES"), {
icon: Template, value: "456",
iconed: Template_select, label: "4567",
}, },
{ ];
label: "任务列表", const tabList = useMemo(() => {
value: "workbenchList", return [
component: <WorkbenchList />, {
hide: !isPass("PROJECT_WORKBENCH_JOBS"), label: "工作流模版",
icon: List, value: "workbenchTemplate",
iconed: List_select, component: <WorkbenchTemplate />,
}, hide: !isPass("PROJECT_WORKBENCH_FLOES"),
// { icon: Template,
// label: "按钮组件", iconed: Template_select,
// value: "MUI_BUTTON", },
// component: <ButtonDemo />, {
// icon: List, label: "任务列表",
// iconed: List_select, value: "workbenchList",
// }, component: <WorkbenchList />,
// { hide: !isPass("PROJECT_WORKBENCH_JOBS"),
// label: "输入框组件", icon: List,
// value: "MUI_INPUT", iconed: List_select,
// component: <InputDemo />, },
// icon: List, // {
// iconed: List_select, // label: "按钮组件",
// }, // value: "MUI_BUTTON",
]; // component: <ButtonDemo />,
}, [isPass]); // icon: List,
// iconed: List_select,
// },
// {
// label: "输入框组件",
// value: "MUI_INPUT",
// component: <InputDemo />,
// icon: List,
// iconed: List_select,
// },
];
}, [isPass]);
return ( return (
<div style={{ padding: 24 }}> <div style={{ padding: 24 }}>
<div style={{ display: "flex", alignItems: "center" }}> <MyMenu options={options} value="123">
<img src={projectImg} alt="项目logo" /> <div>123123</div>
<span style={{ marginLeft: 12 }}> </MyMenu>
工作台 <div style={{ display: "flex", alignItems: "center" }}>
</span> <img src={projectImg} alt="项目logo" />
</div> <span style={{ marginLeft: 12 }}>工作台</span>
<Box sx={{ width: "100%", typography: "body1" }}> </div>
<Tabs tabList={tabList} defaultValue={location?.state?.type || 'workbenchTemplate'} /> <Box sx={{ width: "100%", typography: "body1" }}>
</Box> <Tabs
</div> tabList={tabList}
); defaultValue={location?.state?.type || "workbenchTemplate"}
/>
</Box>
</div>
);
}); });
export default memo(ProjectWorkbench); export default memo(ProjectWorkbench);
...@@ -72,10 +72,17 @@ const AddTemplate = observer((props: IAddTemplateProps) => { ...@@ -72,10 +72,17 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
/** 是否显示自定义模版编辑并带有参数 */ /** 是否显示自定义模版编辑并带有参数 */
const [customTemplateInfo, setCustomTemplateInfo] = useState<ICustomTemplate>( const [customTemplateInfo, setCustomTemplateInfo] = useState<ICustomTemplate>(
{ {
show: true, show: false,
} }
); );
// 显示新增、编辑自定义模板弹窗
const handleAddCustomTemplate = () => {
setCustomTemplateInfo({
show: true,
});
};
useEffect(() => { useEffect(() => {
getAddTemplateList({ getAddTemplateList({
projectId: projectId as string, projectId: projectId as string,
...@@ -182,6 +189,7 @@ const AddTemplate = observer((props: IAddTemplateProps) => { ...@@ -182,6 +189,7 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
[style.templateLi]: true, [style.templateLi]: true,
[style.addCustomTemplate]: true, [style.addCustomTemplate]: true,
})} })}
onClick={handleAddCustomTemplate}
> >
<AddIcon /> <AddIcon />
<span className={style.addCustomTemplateText}> <span className={style.addCustomTemplateText}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment