mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
refactor: update profile menu
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import useSWR from "swr";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { Box, Grid } from "@mui/material";
|
||||
import { Box, Grid, IconButton, Stack } from "@mui/material";
|
||||
import { RestartAltRounded } from "@mui/icons-material";
|
||||
import {
|
||||
getProfiles,
|
||||
deleteProfile,
|
||||
@@ -22,7 +23,14 @@ const EnhancedMode = (props: Props) => {
|
||||
const { mutate } = useSWR("getProfiles", getProfiles);
|
||||
|
||||
// handler
|
||||
const onEnhance = useLockFn(enhanceProfiles);
|
||||
const onEnhance = useLockFn(async () => {
|
||||
try {
|
||||
await enhanceProfiles();
|
||||
Notice.success("Refresh clash config", 2000);
|
||||
} catch (err: any) {
|
||||
Notice.error(err.message || err.toString());
|
||||
}
|
||||
});
|
||||
|
||||
const onEnhanceEnable = useLockFn(async (uid: string) => {
|
||||
if (chain.includes(uid)) return;
|
||||
@@ -68,18 +76,39 @@ const EnhancedMode = (props: Props) => {
|
||||
|
||||
return (
|
||||
<Box sx={{ mt: 4 }}>
|
||||
<Stack
|
||||
spacing={1}
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
justifyContent="flex-end"
|
||||
sx={{ mb: 0.5 }}
|
||||
>
|
||||
<IconButton
|
||||
size="small"
|
||||
color="inherit"
|
||||
title="refresh enhanced profiles"
|
||||
onClick={onEnhance}
|
||||
>
|
||||
<RestartAltRounded />
|
||||
</IconButton>
|
||||
|
||||
{/* <IconButton size="small" color="inherit">
|
||||
<MenuRounded />
|
||||
</IconButton> */}
|
||||
</Stack>
|
||||
|
||||
<Grid container spacing={2}>
|
||||
{items.map((item) => (
|
||||
<Grid item xs={12} sm={6} key={item.file}>
|
||||
<ProfileMore
|
||||
selected={!!chain.includes(item.uid)}
|
||||
itemData={item}
|
||||
enableNum={chain.length}
|
||||
onEnable={() => onEnhanceEnable(item.uid)}
|
||||
onDisable={() => onEnhanceDisable(item.uid)}
|
||||
onDelete={() => onEnhanceDelete(item.uid)}
|
||||
onMoveTop={() => onMoveTop(item.uid)}
|
||||
onMoveEnd={() => onMoveEnd(item.uid)}
|
||||
onEnhance={onEnhance}
|
||||
/>
|
||||
</Grid>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user