mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-18 16:30:32 +08:00
fix(nav): use ListItemButton as drag handle for navigation items
This commit is contained in:
parent
a0fd24bb90
commit
19a31450e5
@ -25,6 +25,7 @@
|
|||||||
- 修复更新时加载进度条异常
|
- 修复更新时加载进度条异常
|
||||||
- 升级内核失败导致内核不可用问题
|
- 升级内核失败导致内核不可用问题
|
||||||
- 修复 macOS 在安装和卸载服务时提示与操作不匹配
|
- 修复 macOS 在安装和卸载服务时提示与操作不匹配
|
||||||
|
- 修复菜单排序模式拖拽异常
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||||
|
|||||||
@ -37,9 +37,14 @@ export const LayoutItem = (props: Props) => {
|
|||||||
const match = useMatch({ path: resolved.pathname, end: true });
|
const match = useMatch({ path: resolved.pathname, end: true });
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { setNodeRef, attributes, listeners, style, isDragging } =
|
const { setNodeRef, attributes, listeners, style, isDragging, disabled } =
|
||||||
sortable ?? {};
|
sortable ?? {};
|
||||||
|
|
||||||
|
const draggable = Boolean(sortable) && !disabled;
|
||||||
|
const dragHandleProps = draggable
|
||||||
|
? { ...(attributes ?? {}), ...(listeners ?? {}) }
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
@ -51,6 +56,7 @@ export const LayoutItem = (props: Props) => {
|
|||||||
>
|
>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
selected={!!match}
|
selected={!!match}
|
||||||
|
{...(dragHandleProps ?? {})}
|
||||||
sx={[
|
sx={[
|
||||||
{
|
{
|
||||||
borderRadius: 2,
|
borderRadius: 2,
|
||||||
@ -58,7 +64,8 @@ export const LayoutItem = (props: Props) => {
|
|||||||
paddingLeft: 1,
|
paddingLeft: 1,
|
||||||
paddingRight: 1,
|
paddingRight: 1,
|
||||||
marginRight: 1.25,
|
marginRight: 1.25,
|
||||||
cursor: "pointer",
|
cursor: draggable ? "grab" : "pointer",
|
||||||
|
"&:active": draggable ? { cursor: "grabbing" } : {},
|
||||||
"& .MuiListItemText-primary": {
|
"& .MuiListItemText-primary": {
|
||||||
color: "text.primary",
|
color: "text.primary",
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
@ -84,20 +91,14 @@ export const LayoutItem = (props: Props) => {
|
|||||||
sx={{
|
sx={{
|
||||||
color: "text.primary",
|
color: "text.primary",
|
||||||
marginLeft: "6px",
|
marginLeft: "6px",
|
||||||
cursor: sortable && !sortable.disabled ? "grab" : "inherit",
|
cursor: draggable ? "grab" : "inherit",
|
||||||
}}
|
}}
|
||||||
{...(attributes ?? {})}
|
|
||||||
{...(listeners ?? {})}
|
|
||||||
>
|
>
|
||||||
{icon[0]}
|
{icon[0]}
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
)}
|
)}
|
||||||
{menu_icon === "colorful" && (
|
{menu_icon === "colorful" && (
|
||||||
<ListItemIcon
|
<ListItemIcon sx={{ cursor: draggable ? "grab" : "inherit" }}>
|
||||||
sx={{ cursor: sortable && !sortable.disabled ? "grab" : "inherit" }}
|
|
||||||
{...(attributes ?? {})}
|
|
||||||
{...(listeners ?? {})}
|
|
||||||
>
|
|
||||||
{icon[1]}
|
{icon[1]}
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user