diff --git a/src/components/profile/file-editor.tsx b/src/components/profile/editor-viewer.tsx
similarity index 98%
rename from src/components/profile/file-editor.tsx
rename to src/components/profile/editor-viewer.tsx
index 5f9bab7..ea15f5f 100644
--- a/src/components/profile/file-editor.tsx
+++ b/src/components/profile/editor-viewer.tsx
@@ -26,7 +26,7 @@ interface Props {
onChange?: () => void;
}
-export const FileEditor = (props: Props) => {
+export const EditorViewer = (props: Props) => {
const { uid, open, mode, onClose, onChange } = props;
const { t } = useTranslation();
diff --git a/src/components/profile/enhanced.tsx b/src/components/profile/enhanced.tsx
index 2cc68c9..6c20eb8 100644
--- a/src/components/profile/enhanced.tsx
+++ b/src/components/profile/enhanced.tsx
@@ -1,44 +1,29 @@
import useSWR from "swr";
import { useLockFn } from "ahooks";
-import { useTranslation } from "react-i18next";
-import { Box, Grid, IconButton, Stack } from "@mui/material";
-import { RestartAltRounded } from "@mui/icons-material";
+import { Grid } from "@mui/material";
import {
getProfiles,
deleteProfile,
- enhanceProfiles,
patchProfilesConfig,
getRuntimeLogs,
} from "@/services/cmds";
import { Notice } from "@/components/base";
-import ProfileMore from "./profile-more";
+import { ProfileMore } from "./profile-more";
interface Props {
items: IProfileItem[];
chain: string[];
}
-const EnhancedMode = (props: Props) => {
+export const EnhancedMode = (props: Props) => {
const { items, chain } = props;
- const { t } = useTranslation();
const { mutate: mutateProfiles } = useSWR("getProfiles", getProfiles);
const { data: chainLogs = {}, mutate: mutateLogs } = useSWR(
"getRuntimeLogs",
getRuntimeLogs
);
- // handler
- const onEnhance = useLockFn(async () => {
- try {
- await enhanceProfiles();
- mutateLogs();
- // Notice.success("Refresh clash config", 1000);
- } catch (err: any) {
- Notice.error(err.message || err.toString());
- }
- });
-
const onEnhanceEnable = useLockFn(async (uid: string) => {
if (chain.includes(uid)) return;
@@ -87,43 +72,22 @@ const EnhancedMode = (props: Props) => {
});
return (
-
-
-
-
-
-
-
-
- {items.map((item) => (
-
- onEnhanceEnable(item.uid)}
- onDisable={() => onEnhanceDisable(item.uid)}
- onDelete={() => onEnhanceDelete(item.uid)}
- onMoveTop={() => onMoveTop(item.uid)}
- onMoveEnd={() => onMoveEnd(item.uid)}
- />
-
- ))}
-
-
+
+ {items.map((item) => (
+
+ onEnhanceEnable(item.uid)}
+ onDisable={() => onEnhanceDisable(item.uid)}
+ onDelete={() => onEnhanceDelete(item.uid)}
+ onMoveTop={() => onMoveTop(item.uid)}
+ onMoveEnd={() => onMoveEnd(item.uid)}
+ />
+
+ ))}
+
);
};
-
-export default EnhancedMode;
diff --git a/src/components/profile/file-input.tsx b/src/components/profile/file-input.tsx
index d860709..5357224 100644
--- a/src/components/profile/file-input.tsx
+++ b/src/components/profile/file-input.tsx
@@ -7,7 +7,7 @@ interface Props {
onChange: (value: string) => void;
}
-const FileInput = (props: Props) => {
+export const FileInput = (props: Props) => {
const { onChange } = props;
const { t } = useTranslation();
@@ -59,5 +59,3 @@ const FileInput = (props: Props) => {
);
};
-
-export default FileInput;
diff --git a/src/components/profile/info-editor.tsx b/src/components/profile/info-viewer.tsx
similarity index 98%
rename from src/components/profile/info-editor.tsx
rename to src/components/profile/info-viewer.tsx
index f5c0fb0..54215a6 100644
--- a/src/components/profile/info-editor.tsx
+++ b/src/components/profile/info-viewer.tsx
@@ -27,7 +27,7 @@ interface Props {
// edit the profile item
// remote / local file / merge / script
-const InfoEditor = (props: Props) => {
+export const InfoViewer = (props: Props) => {
const { open, itemData, onClose } = props;
const { t } = useTranslation();
@@ -209,5 +209,3 @@ const InfoEditor = (props: Props) => {
);
};
-
-export default InfoEditor;
diff --git a/src/components/profile/log-viewer.tsx b/src/components/profile/log-viewer.tsx
index c3ba162..4792468 100644
--- a/src/components/profile/log-viewer.tsx
+++ b/src/components/profile/log-viewer.tsx
@@ -18,7 +18,7 @@ interface Props {
onClose: () => void;
}
-const LogViewer = (props: Props) => {
+export const LogViewer = (props: Props) => {
const { open, logInfo, onClose } = props;
const { t } = useTranslation();
@@ -67,5 +67,3 @@ const LogViewer = (props: Props) => {
);
};
-
-export default LogViewer;
diff --git a/src/components/profile/profile-box.tsx b/src/components/profile/profile-box.tsx
index 7b8d5e8..a0fc4a1 100644
--- a/src/components/profile/profile-box.tsx
+++ b/src/components/profile/profile-box.tsx
@@ -1,43 +1,43 @@
import { alpha, Box, styled } from "@mui/material";
-const ProfileBox = styled(Box)(({ theme, "aria-selected": selected }) => {
- const { mode, primary, text, grey, background } = theme.palette;
- const key = `${mode}-${!!selected}`;
+export const ProfileBox = styled(Box)(
+ ({ theme, "aria-selected": selected }) => {
+ const { mode, primary, text, grey, background } = theme.palette;
+ const key = `${mode}-${!!selected}`;
- const backgroundColor = {
- "light-true": alpha(primary.main, 0.2),
- "light-false": alpha(background.paper, 0.75),
- "dark-true": alpha(primary.main, 0.45),
- "dark-false": alpha(grey[700], 0.45),
- }[key]!;
+ const backgroundColor = {
+ "light-true": alpha(primary.main, 0.2),
+ "light-false": alpha(background.paper, 0.75),
+ "dark-true": alpha(primary.main, 0.45),
+ "dark-false": alpha(grey[700], 0.45),
+ }[key]!;
- const color = {
- "light-true": text.secondary,
- "light-false": text.secondary,
- "dark-true": alpha(text.secondary, 0.85),
- "dark-false": alpha(text.secondary, 0.65),
- }[key]!;
+ const color = {
+ "light-true": text.secondary,
+ "light-false": text.secondary,
+ "dark-true": alpha(text.secondary, 0.85),
+ "dark-false": alpha(text.secondary, 0.65),
+ }[key]!;
- const h2color = {
- "light-true": primary.main,
- "light-false": text.primary,
- "dark-true": primary.light,
- "dark-false": text.primary,
- }[key]!;
+ const h2color = {
+ "light-true": primary.main,
+ "light-false": text.primary,
+ "dark-true": primary.light,
+ "dark-false": text.primary,
+ }[key]!;
- return {
- width: "100%",
- display: "block",
- cursor: "pointer",
- textAlign: "left",
- borderRadius: theme.shape.borderRadius,
- boxShadow: theme.shadows[2],
- padding: "8px 16px",
- boxSizing: "border-box",
- backgroundColor,
- color,
- "& h2": { color: h2color },
- };
-});
-
-export default ProfileBox;
+ return {
+ width: "100%",
+ display: "block",
+ cursor: "pointer",
+ textAlign: "left",
+ borderRadius: theme.shape.borderRadius,
+ boxShadow: theme.shadows[2],
+ padding: "8px 16px",
+ boxSizing: "border-box",
+ backgroundColor,
+ color,
+ "& h2": { color: h2color },
+ };
+ }
+);
diff --git a/src/components/profile/profile-item.tsx b/src/components/profile/profile-item.tsx
index a79e982..2840017 100644
--- a/src/components/profile/profile-item.tsx
+++ b/src/components/profile/profile-item.tsx
@@ -17,10 +17,10 @@ import { RefreshRounded } from "@mui/icons-material";
import { atomLoadingCache } from "@/services/states";
import { updateProfile, deleteProfile, viewProfile } from "@/services/cmds";
import { Notice } from "@/components/base";
+import { InfoViewer } from "./info-viewer";
+import { EditorViewer } from "./editor-viewer";
+import { ProfileBox } from "./profile-box";
import parseTraffic from "@/utils/parse-traffic";
-import ProfileBox from "./profile-box";
-import InfoEditor from "./info-editor";
-import { FileEditor } from "./file-editor";
const round = keyframes`
from { transform: rotate(0deg); }
@@ -33,7 +33,7 @@ interface Props {
onSelect: (force: boolean) => void;
}
-const ProfileItem = (props: Props) => {
+export const ProfileItem = (props: Props) => {
const { selected, itemData, onSelect } = props;
const { t } = useTranslation();
@@ -298,13 +298,13 @@ const ProfileItem = (props: Props) => {
))}
- setEditOpen(false)}
/>
- {
+export const ProfileMore = (props: Props) => {
const {
selected,
itemData,
@@ -219,13 +219,13 @@ const ProfileMore = (props: Props) => {
))}
- setEditOpen(false)}
/>
- {
+export const ProfileNew = (props: Props) => {
const { open, onClose } = props;
const { t } = useTranslation();
@@ -210,5 +210,3 @@ const ProfileNew = (props: Props) => {
);
};
-
-export default ProfileNew;
diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx
index 15cd711..23ea7c1 100644
--- a/src/pages/profiles.tsx
+++ b/src/pages/profiles.tsx
@@ -2,20 +2,22 @@ import useSWR, { mutate } from "swr";
import { useLockFn } from "ahooks";
import { useEffect, useMemo, useState } from "react";
import { useSetRecoilState } from "recoil";
-import { Button, Grid, Stack, TextField } from "@mui/material";
+import { Box, Button, Grid, IconButton, Stack, TextField } from "@mui/material";
+import { CachedRounded } from "@mui/icons-material";
import { useTranslation } from "react-i18next";
import {
getProfiles,
patchProfile,
patchProfilesConfig,
importProfile,
+ enhanceProfiles,
} from "@/services/cmds";
import { getProxies, updateProxy } from "@/services/api";
import { atomCurrentProfile } from "@/services/states";
import { BasePage, Notice } from "@/components/base";
-import ProfileNew from "@/components/profile/profile-new";
-import ProfileItem from "@/components/profile/profile-item";
-import EnhancedMode from "@/components/profile/enhanced";
+import { ProfileNew } from "@/components/profile/profile-new";
+import { ProfileItem } from "@/components/profile/profile-item";
+import { EnhancedMode } from "@/components/profile/enhanced";
const ProfilePage = () => {
const { t } = useTranslation();
@@ -138,8 +140,32 @@ const ProfilePage = () => {
}
});
+ const onEnhance = useLockFn(async () => {
+ try {
+ await enhanceProfiles();
+ mutate("getRuntimeLogs");
+ // Notice.success("Refresh clash config", 1000);
+ } catch (err: any) {
+ Notice.error(err.message || err.toString(), 3000);
+ }
+ });
+
return (
-
+
+
+
+
+
+ }
+ >
{
-
- {regularItems.map((item) => (
-
- onSelect(item.uid, f)}
- />
-
- ))}
-
+
+
+ {regularItems.map((item) => (
+
+ onSelect(item.uid, f)}
+ />
+
+ ))}
+
+
{enhanceItems.length > 0 && (