Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sunyihao
bkunyun
Commits
a5a80933
Commit
a5a80933
authored
Jul 08, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增菜单下拉选择组件
parent
1ac5fb6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
23 deletions
+29
-23
MyMenu.tsx
src/components/mui/MyMenu.tsx
+29
-9
index.tsx
src/views/Project/ProjectWorkbench/index.tsx
+0
-14
No files found.
src/components/mui/MyMenu.tsx
View file @
a5a80933
import
*
as
React
from
"react"
;
import
*
as
React
from
"react"
;
import
Menu
from
"@mui/material/Menu"
;
import
Menu
from
"@mui/material/Menu"
;
import
MenuItem
from
"@mui/material/MenuItem"
;
import
MenuItem
from
"@mui/material/MenuItem"
;
import
CheckIcon
from
"@mui/icons-material/Check"
;
import
{
ThemeProvider
,
createTheme
}
from
"@mui/material/styles"
;
import
{
ThemeProvider
,
createTheme
}
from
"@mui/material/styles"
;
type
IOption
=
{
type
IOption
=
{
...
@@ -12,30 +13,49 @@ type IMyMenuProps = {
...
@@ -12,30 +13,49 @@ type IMyMenuProps = {
children
:
React
.
ReactNode
;
children
:
React
.
ReactNode
;
options
:
Array
<
IOption
>
;
options
:
Array
<
IOption
>
;
value
:
string
;
value
:
string
;
setValue
?:
any
;
};
};
const
theme
=
createTheme
({
const
theme
=
createTheme
({
components
:
{
components
:
{
// Name of the component
MuiMenu
:
{
styleOverrides
:
{
root
:
{
maxHeight
:
"260px"
,
overflowY
:
"scroll"
,
},
},
},
MuiMenuItem
:
{
MuiMenuItem
:
{
styleOverrides
:
{
styleOverrides
:
{
// Name of the slot
root
:
{
root
:
{
fontSize
:
"12px"
,
fontSize
:
"14px"
,
lineHeight
:
"36px"
,
display
:
"flex"
,
justifyContent
:
"space-between"
,
":hover"
:
{
":hover"
:
{
color
:
"r
ed
"
,
color
:
"r
gba(19, 112, 255, 1)
"
,
},
},
"&.Mui-selected"
:
{
"&.Mui-selected"
:
{
backgroundColor
:
"#2a68c9"
,
backgroundColor
:
"#fff"
,
color
:
"rgba(19, 112, 255, 1)"
,
},
},
},
},
},
},
},
},
MuiSvgIcon
:
{
styleOverrides
:
{
root
:
{
width
:
"16px"
,
height
:
"16px"
,
},
},
},
},
},
});
});
const
MyMenu
=
(
props
:
IMyMenuProps
)
=>
{
const
MyMenu
=
(
props
:
IMyMenuProps
)
=>
{
const
{
children
,
options
,
value
}
=
props
;
const
{
children
,
options
,
value
,
setValue
}
=
props
;
const
[
anchorEl
,
setAnchorEl
]
=
React
.
useState
<
null
|
HTMLElement
>
(
null
);
const
[
anchorEl
,
setAnchorEl
]
=
React
.
useState
<
null
|
HTMLElement
>
(
null
);
const
open
=
Boolean
(
anchorEl
);
const
open
=
Boolean
(
anchorEl
);
const
handleClick
=
(
event
:
React
.
MouseEvent
<
HTMLDivElement
>
)
=>
{
const
handleClick
=
(
event
:
React
.
MouseEvent
<
HTMLDivElement
>
)
=>
{
...
@@ -43,7 +63,7 @@ const MyMenu = (props: IMyMenuProps) => {
...
@@ -43,7 +63,7 @@ const MyMenu = (props: IMyMenuProps) => {
};
};
const
handleClose
=
(
value
:
string
)
=>
{
const
handleClose
=
(
value
:
string
)
=>
{
setAnchorEl
(
null
);
setAnchorEl
(
null
);
console
.
log
(
value
);
setValue
&&
setValue
(
value
);
};
};
return
(
return
(
...
@@ -66,8 +86,8 @@ const MyMenu = (props: IMyMenuProps) => {
...
@@ -66,8 +86,8 @@ const MyMenu = (props: IMyMenuProps) => {
selected=
{
value
===
option
.
value
}
selected=
{
value
===
option
.
value
}
key=
{
index
}
key=
{
index
}
>
>
{
option
.
label
}
<
span
>
{
option
.
label
}
</
span
>
{
value
}
{
value
===
option
.
value
&&
<
CheckIcon
/>
}
</
MenuItem
>
</
MenuItem
>
);
);
})
}
})
}
...
...
src/views/Project/ProjectWorkbench/index.tsx
View file @
a5a80933
...
@@ -12,7 +12,6 @@ import { observer } from "mobx-react-lite";
...
@@ -12,7 +12,6 @@ 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"
;
...
@@ -26,16 +25,6 @@ const ProjectWorkbench = observer(() => {
...
@@ -26,16 +25,6 @@ const ProjectWorkbench = observer(() => {
const
isPass
=
usePass
();
const
isPass
=
usePass
();
const
location
:
any
=
useLocation
();
const
location
:
any
=
useLocation
();
const
options
=
[
{
value
:
"123"
,
label
:
"1234"
,
},
{
value
:
"456"
,
label
:
"4567"
,
},
];
const
tabList
=
useMemo
(()
=>
{
const
tabList
=
useMemo
(()
=>
{
return
[
return
[
{
{
...
@@ -73,9 +62,6 @@ const ProjectWorkbench = observer(() => {
...
@@ -73,9 +62,6 @@ const ProjectWorkbench = observer(() => {
return
(
return
(
<
div
style=
{
{
padding
:
24
}
}
>
<
div
style=
{
{
padding
:
24
}
}
>
<
MyMenu
options=
{
options
}
value=
"123"
>
<
div
>
123123
</
div
>
</
MyMenu
>
<
div
style=
{
{
display
:
"flex"
,
alignItems
:
"center"
}
}
>
<
div
style=
{
{
display
:
"flex"
,
alignItems
:
"center"
}
}
>
<
img
src=
{
projectImg
}
alt=
"项目logo"
/>
<
img
src=
{
projectImg
}
alt=
"项目logo"
/>
<
span
style=
{
{
marginLeft
:
12
}
}
>
工作台
</
span
>
<
span
style=
{
{
marginLeft
:
12
}
}
>
工作台
</
span
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment