diff --git a/src/components/base/base-empty.tsx b/src/components/base/base-empty.tsx
index 420aa2f..c364a50 100644
--- a/src/components/base/base-empty.tsx
+++ b/src/components/base/base-empty.tsx
@@ -6,7 +6,7 @@ interface Props {
extra?: React.ReactNode;
}
-const BaseEmpty = (props: Props) => {
+export const BaseEmpty = (props: Props) => {
const { text = "Empty", extra } = props;
return (
@@ -27,5 +27,3 @@ const BaseEmpty = (props: Props) => {
);
};
-
-export default BaseEmpty;
diff --git a/src/components/base/base-error-boundary.tsx b/src/components/base/base-error-boundary.tsx
index c6fd123..584fd8a 100644
--- a/src/components/base/base-error-boundary.tsx
+++ b/src/components/base/base-error-boundary.tsx
@@ -9,12 +9,10 @@ function ErrorFallback({ error }: FallbackProps) {
);
}
-const BaseErrorBoundary: React.FC = (props) => {
+export const BaseErrorBoundary: React.FC = (props) => {
return (
{props.children}
);
};
-
-export default BaseErrorBoundary;
diff --git a/src/components/base/base-loading.tsx b/src/components/base/base-loading.tsx
index a1352d4..0fdbebf 100644
--- a/src/components/base/base-loading.tsx
+++ b/src/components/base/base-loading.tsx
@@ -37,7 +37,7 @@ const LoadingItem = styled("div")(({ theme }) => ({
background: theme.palette.text.secondary,
}));
-const BaseLoading = () => {
+export const BaseLoading = () => {
return (
@@ -46,5 +46,3 @@ const BaseLoading = () => {
);
};
-
-export default BaseLoading;
diff --git a/src/components/base/base-notice.tsx b/src/components/base/base-notice.tsx
index 39f1130..6d45496 100644
--- a/src/components/base/base-notice.tsx
+++ b/src/components/base/base-notice.tsx
@@ -69,7 +69,7 @@ interface NoticeInstance {
let parent: HTMLDivElement = null!;
// @ts-ignore
-const Notice: NoticeInstance = (props) => {
+export const Notice: NoticeInstance = (props) => {
if (!parent) {
parent = document.createElement("div");
document.body.appendChild(parent);
@@ -91,5 +91,3 @@ const Notice: NoticeInstance = (props) => {
setTimeout(() => Notice({ type, message, duration }), 0);
};
});
-
-export default Notice;
diff --git a/src/components/base/base-page.tsx b/src/components/base/base-page.tsx
index e69b0cf..fefaf82 100644
--- a/src/components/base/base-page.tsx
+++ b/src/components/base/base-page.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Typography } from "@mui/material";
-import BaseErrorBoundary from "./base-error-boundary";
+import { BaseErrorBoundary } from "./base-error-boundary";
interface Props {
title?: React.ReactNode; // the page title
@@ -8,7 +8,7 @@ interface Props {
contentStyle?: React.CSSProperties;
}
-const BasePage: React.FC = (props) => {
+export const BasePage: React.FC = (props) => {
const { title, header, contentStyle, children } = props;
return (
@@ -31,5 +31,3 @@ const BasePage: React.FC = (props) => {
);
};
-
-export default BasePage;
diff --git a/src/components/base/index.ts b/src/components/base/index.ts
index ef1eb46..3e0e324 100644
--- a/src/components/base/index.ts
+++ b/src/components/base/index.ts
@@ -1,2 +1,6 @@
export { BaseDialog, type DialogRef } from "./base-dialog";
+export { BasePage } from "./base-page";
+export { BaseEmpty } from "./base-empty";
+export { BaseLoading } from "./base-loading";
+export { BaseErrorBoundary } from "./base-error-boundary";
export { Notice } from "./base-notice";
diff --git a/src/components/layout/update-dialog.tsx b/src/components/layout/update-dialog.tsx
index e7f45f9..392e086 100644
--- a/src/components/layout/update-dialog.tsx
+++ b/src/components/layout/update-dialog.tsx
@@ -15,7 +15,7 @@ import {
import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { atomUpdateState } from "@/services/states";
-import Notice from "../base/base-notice";
+import { Notice } from "@/components/base";
interface Props {
open: boolean;
diff --git a/src/components/profile/enhanced.tsx b/src/components/profile/enhanced.tsx
index cb5ec60..2cc68c9 100644
--- a/src/components/profile/enhanced.tsx
+++ b/src/components/profile/enhanced.tsx
@@ -10,8 +10,8 @@ import {
patchProfilesConfig,
getRuntimeLogs,
} from "@/services/cmds";
+import { Notice } from "@/components/base";
import ProfileMore from "./profile-more";
-import Notice from "../base/base-notice";
interface Props {
items: IProfileItem[];
diff --git a/src/components/profile/file-editor.tsx b/src/components/profile/file-editor.tsx
index 1cc8a0f..5f9bab7 100644
--- a/src/components/profile/file-editor.tsx
+++ b/src/components/profile/file-editor.tsx
@@ -11,7 +11,7 @@ import {
} from "@mui/material";
import { atomThemeMode } from "@/services/states";
import { readProfileFile, saveProfileFile } from "@/services/cmds";
-import Notice from "../base/base-notice";
+import { Notice } from "@/components/base";
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
import "monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js";
@@ -26,7 +26,7 @@ interface Props {
onChange?: () => void;
}
-const FileEditor = (props: Props) => {
+export const FileEditor = (props: Props) => {
const { uid, open, mode, onClose, onChange } = props;
const { t } = useTranslation();
@@ -92,5 +92,3 @@ const FileEditor = (props: Props) => {
);
};
-
-export default FileEditor;
diff --git a/src/components/profile/info-editor.tsx b/src/components/profile/info-editor.tsx
index 950943e..f5c0fb0 100644
--- a/src/components/profile/info-editor.tsx
+++ b/src/components/profile/info-editor.tsx
@@ -17,7 +17,7 @@ import {
import { Settings } from "@mui/icons-material";
import { patchProfile } from "@/services/cmds";
import { version } from "@root/package.json";
-import Notice from "../base/base-notice";
+import { Notice } from "@/components/base";
interface Props {
open: boolean;
diff --git a/src/components/profile/log-viewer.tsx b/src/components/profile/log-viewer.tsx
index 949c57a..c3ba162 100644
--- a/src/components/profile/log-viewer.tsx
+++ b/src/components/profile/log-viewer.tsx
@@ -1,3 +1,4 @@
+import { Fragment } from "react";
import { useTranslation } from "react-i18next";
import {
Button,
@@ -9,8 +10,7 @@ import {
Divider,
Typography,
} from "@mui/material";
-import BaseEmpty from "../base/base-empty";
-import { Fragment } from "react";
+import { BaseEmpty } from "@/components/base";
interface Props {
open: boolean;
diff --git a/src/components/profile/profile-item.tsx b/src/components/profile/profile-item.tsx
index c721d77..a79e982 100644
--- a/src/components/profile/profile-item.tsx
+++ b/src/components/profile/profile-item.tsx
@@ -16,11 +16,11 @@ import {
import { RefreshRounded } from "@mui/icons-material";
import { atomLoadingCache } from "@/services/states";
import { updateProfile, deleteProfile, viewProfile } from "@/services/cmds";
+import { Notice } from "@/components/base";
import parseTraffic from "@/utils/parse-traffic";
import ProfileBox from "./profile-box";
import InfoEditor from "./info-editor";
-import FileEditor from "./file-editor";
-import Notice from "../base/base-notice";
+import { FileEditor } from "./file-editor";
const round = keyframes`
from { transform: rotate(0deg); }
diff --git a/src/components/profile/profile-more.tsx b/src/components/profile/profile-more.tsx
index e8cfba2..e46daae 100644
--- a/src/components/profile/profile-more.tsx
+++ b/src/components/profile/profile-more.tsx
@@ -13,11 +13,11 @@ import {
} from "@mui/material";
import { FeaturedPlayListRounded } from "@mui/icons-material";
import { viewProfile } from "@/services/cmds";
+import { Notice } from "@/components/base";
import InfoEditor from "./info-editor";
-import FileEditor from "./file-editor";
+import { FileEditor } from "./file-editor";
import ProfileBox from "./profile-box";
import LogViewer from "./log-viewer";
-import Notice from "../base/base-notice";
interface Props {
selected: boolean;
diff --git a/src/components/profile/profile-new.tsx b/src/components/profile/profile-new.tsx
index 05a7815..c75c6ec 100644
--- a/src/components/profile/profile-new.tsx
+++ b/src/components/profile/profile-new.tsx
@@ -20,7 +20,7 @@ import {
} from "@mui/material";
import { Settings } from "@mui/icons-material";
import { createProfile } from "@/services/cmds";
-import Notice from "../base/base-notice";
+import { Notice } from "@/components/base";
import FileInput from "./file-input";
interface Props {
diff --git a/src/components/proxy/proxy-item.tsx b/src/components/proxy/proxy-item.tsx
index d720682..c91991a 100644
--- a/src/components/proxy/proxy-item.tsx
+++ b/src/components/proxy/proxy-item.tsx
@@ -12,8 +12,8 @@ import {
SxProps,
Theme,
} from "@mui/material";
+import { BaseLoading } from "@/components/base";
import delayManager from "@/services/delay";
-import BaseLoading from "../base/base-loading";
interface Props {
groupName: string;
diff --git a/src/components/proxy/use-render-list.ts b/src/components/proxy/use-render-list.ts
index 843dc06..5fdf52e 100644
--- a/src/components/proxy/use-render-list.ts
+++ b/src/components/proxy/use-render-list.ts
@@ -16,7 +16,7 @@ export const useRenderList = (mode: string) => {
const { data: proxiesData, mutate: mutateProxies } = useSWR(
"getProxies",
getProxies,
- { refreshInterval: 45000, suspense: true }
+ { refreshInterval: 45000 }
);
const [headStates, setHeadState] = useHeadStateNew();
@@ -35,6 +35,7 @@ export const useRenderList = (mode: string) => {
}, [proxiesData, mode]);
const renderList: IRenderItem[] = useMemo(() => {
+ if (!proxiesData) return [];
const useRule = mode === "rule" || mode === "script";
const renderGroups =
(useRule ? proxiesData?.groups : [proxiesData?.global!]) || [];
diff --git a/src/components/setting/mods/clash-field-viewer.tsx b/src/components/setting/mods/clash-field-viewer.tsx
index bb1579f..d9bc09e 100644
--- a/src/components/setting/mods/clash-field-viewer.tsx
+++ b/src/components/setting/mods/clash-field-viewer.tsx
@@ -11,7 +11,7 @@ import {
} from "@/utils/clash-fields";
import { BaseDialog, DialogRef } from "@/components/base";
import { useProfiles } from "@/hooks/use-profiles";
-import Notice from "@/components/base/base-notice";
+import { Notice } from "@/components/base";
const fieldSorter = (a: string, b: string) => {
if (a.includes("-") === a.includes("-")) {
diff --git a/src/components/setting/mods/clash-port-viewer.tsx b/src/components/setting/mods/clash-port-viewer.tsx
index 36604cb..e09fe54 100644
--- a/src/components/setting/mods/clash-port-viewer.tsx
+++ b/src/components/setting/mods/clash-port-viewer.tsx
@@ -7,8 +7,7 @@ import { List, ListItem, ListItemText, TextField } from "@mui/material";
import { atomClashPort } from "@/services/states";
import { getClashConfig } from "@/services/api";
import { patchClashConfig } from "@/services/cmds";
-import { BaseDialog, DialogRef } from "@/components/base";
-import Notice from "@/components/base/base-notice";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
export const ClashPortViewer = forwardRef((props, ref) => {
const { t } = useTranslation();
diff --git a/src/components/setting/mods/controller-viewer.tsx b/src/components/setting/mods/controller-viewer.tsx
index 3a49c8d..d3d6a43 100644
--- a/src/components/setting/mods/controller-viewer.tsx
+++ b/src/components/setting/mods/controller-viewer.tsx
@@ -5,8 +5,7 @@ import { useTranslation } from "react-i18next";
import { List, ListItem, ListItemText, TextField } from "@mui/material";
import { getClashInfo, patchClashConfig } from "@/services/cmds";
import { getAxios } from "@/services/api";
-import { BaseDialog, DialogRef } from "@/components/base";
-import Notice from "@/components/base/base-notice";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
export const ControllerViewer = forwardRef((props, ref) => {
const { t } = useTranslation();
diff --git a/src/components/setting/mods/core-switch.tsx b/src/components/setting/mods/core-switch.tsx
index f578259..d54e678 100644
--- a/src/components/setting/mods/core-switch.tsx
+++ b/src/components/setting/mods/core-switch.tsx
@@ -5,7 +5,7 @@ import { Menu, MenuItem } from "@mui/material";
import { Settings } from "@mui/icons-material";
import { changeClashCore } from "@/services/cmds";
import { useVerge } from "@/hooks/use-verge";
-import Notice from "@/components/base/base-notice";
+import { Notice } from "@/components/base";
const VALID_CORE = [
{ name: "Clash", core: "clash" },
diff --git a/src/components/setting/mods/hotkey-viewer.tsx b/src/components/setting/mods/hotkey-viewer.tsx
index 9f41fde..22a2dac 100644
--- a/src/components/setting/mods/hotkey-viewer.tsx
+++ b/src/components/setting/mods/hotkey-viewer.tsx
@@ -3,9 +3,8 @@ import { useTranslation } from "react-i18next";
import { useLockFn } from "ahooks";
import { styled, Typography } from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
-import { BaseDialog, DialogRef } from "@/components/base";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
import { HotkeyInput } from "./hotkey-input";
-import Notice from "@/components/base/base-notice";
const ItemWrapper = styled("div")`
display: flex;
diff --git a/src/components/setting/mods/misc-viewer.tsx b/src/components/setting/mods/misc-viewer.tsx
index 89d2f99..81b235c 100644
--- a/src/components/setting/mods/misc-viewer.tsx
+++ b/src/components/setting/mods/misc-viewer.tsx
@@ -3,8 +3,7 @@ import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next";
import { List, ListItem, ListItemText, Switch, TextField } from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
-import { BaseDialog, DialogRef } from "@/components/base";
-import Notice from "@/components/base/base-notice";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
export const MiscViewer = forwardRef((props, ref) => {
const { t } = useTranslation();
diff --git a/src/components/setting/mods/service-viewer.tsx b/src/components/setting/mods/service-viewer.tsx
index 52c0ebb..9052559 100644
--- a/src/components/setting/mods/service-viewer.tsx
+++ b/src/components/setting/mods/service-viewer.tsx
@@ -9,8 +9,7 @@ import {
patchVergeConfig,
} from "@/services/cmds";
import { forwardRef, useState } from "react";
-import { BaseDialog, DialogRef } from "@/components/base";
-import Notice from "@/components/base/base-notice";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
interface Props {
enable: boolean;
diff --git a/src/components/setting/mods/sysproxy-viewer.tsx b/src/components/setting/mods/sysproxy-viewer.tsx
index edb5a8c..44682dc 100644
--- a/src/components/setting/mods/sysproxy-viewer.tsx
+++ b/src/components/setting/mods/sysproxy-viewer.tsx
@@ -14,8 +14,7 @@ import {
} from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
import { getSystemProxy } from "@/services/cmds";
-import { BaseDialog, DialogRef } from "@/components/base";
-import Notice from "@/components/base/base-notice";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
export const SysproxyViewer = forwardRef((props, ref) => {
const { t } = useTranslation();
diff --git a/src/components/setting/mods/theme-viewer.tsx b/src/components/setting/mods/theme-viewer.tsx
index 014decd..c68ada2 100644
--- a/src/components/setting/mods/theme-viewer.tsx
+++ b/src/components/setting/mods/theme-viewer.tsx
@@ -11,8 +11,7 @@ import {
} from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";
-import { BaseDialog, DialogRef } from "@/components/base";
-import Notice from "../../base/base-notice";
+import { BaseDialog, DialogRef, Notice } from "@/components/base";
export const ThemeViewer = forwardRef((props, ref) => {
const { t } = useTranslation();
diff --git a/src/components/setting/mods/web-ui-viewer.tsx b/src/components/setting/mods/web-ui-viewer.tsx
index cc0d679..bb47a99 100644
--- a/src/components/setting/mods/web-ui-viewer.tsx
+++ b/src/components/setting/mods/web-ui-viewer.tsx
@@ -5,10 +5,8 @@ import { useTranslation } from "react-i18next";
import { Button, Box, Typography } from "@mui/material";
import { useVerge } from "@/hooks/use-verge";
import { getClashInfo, openWebUrl } from "@/services/cmds";
+import { BaseDialog, BaseEmpty, DialogRef, Notice } from "@/components/base";
import { WebUIItem } from "./web-ui-item";
-import { BaseDialog, DialogRef } from "@/components/base";
-import BaseEmpty from "@/components/base/base-empty";
-import Notice from "@/components/base/base-notice";
export const WebUIViewer = forwardRef((props, ref) => {
const { t } = useTranslation();
diff --git a/src/pages/_layout.tsx b/src/pages/_layout.tsx
index 145eb31..c2ba2b0 100644
--- a/src/pages/_layout.tsx
+++ b/src/pages/_layout.tsx
@@ -15,13 +15,12 @@ import { atomCurrentProfile } from "@/services/states";
import { getProfiles } from "@/services/cmds";
import { useVerge } from "@/hooks/use-verge";
import { ReactComponent as LogoSvg } from "@/assets/image/logo.svg";
-import Notice from "@/components/base/base-notice";
+import { BaseErrorBoundary, Notice } from "@/components/base";
import LayoutItem from "@/components/layout/layout-item";
import LayoutControl from "@/components/layout/layout-control";
import LayoutTraffic from "@/components/layout/layout-traffic";
import UpdateButton from "@/components/layout/update-button";
import useCustomTheme from "@/components/layout/use-custom-theme";
-import BaseErrorBoundary from "@/components/base/base-error-boundary";
import getSystem from "@/utils/get-system";
import "dayjs/locale/zh-cn";
diff --git a/src/pages/connections.tsx b/src/pages/connections.tsx
index 059bd63..eefaa6a 100644
--- a/src/pages/connections.tsx
+++ b/src/pages/connections.tsx
@@ -15,8 +15,7 @@ import { useTranslation } from "react-i18next";
import { TableChartRounded, TableRowsRounded } from "@mui/icons-material";
import { closeAllConnections, getInformation } from "@/services/api";
import { atomConnectionSetting } from "@/services/states";
-import BasePage from "@/components/base/base-page";
-import BaseEmpty from "@/components/base/base-empty";
+import { BaseEmpty, BasePage } from "@/components/base";
import ConnectionItem from "@/components/connection/connection-item";
import ConnectionTable from "@/components/connection/connection-table";
diff --git a/src/pages/logs.tsx b/src/pages/logs.tsx
index 905c7a3..f7326f2 100644
--- a/src/pages/logs.tsx
+++ b/src/pages/logs.tsx
@@ -16,8 +16,7 @@ import {
PauseCircleOutlineRounded,
} from "@mui/icons-material";
import { atomEnableLog, atomLogData } from "@/services/states";
-import BasePage from "@/components/base/base-page";
-import BaseEmpty from "@/components/base/base-empty";
+import { BaseEmpty, BasePage } from "@/components/base";
import LogItem from "@/components/log/log-item";
const LogPage = () => {
diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx
index fad4434..15cd711 100644
--- a/src/pages/profiles.tsx
+++ b/src/pages/profiles.tsx
@@ -12,8 +12,7 @@ import {
} from "@/services/cmds";
import { getProxies, updateProxy } from "@/services/api";
import { atomCurrentProfile } from "@/services/states";
-import Notice from "@/components/base/base-notice";
-import BasePage from "@/components/base/base-page";
+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";
diff --git a/src/pages/proxies.tsx b/src/pages/proxies.tsx
index 6816bbc..67452cc 100644
--- a/src/pages/proxies.tsx
+++ b/src/pages/proxies.tsx
@@ -5,7 +5,7 @@ import { Button, ButtonGroup, Paper } from "@mui/material";
import { getClashConfig, updateConfigs } from "@/services/api";
import { patchClashConfig } from "@/services/cmds";
import { ProxyGroups } from "@/components/proxy/proxy-groups";
-import BasePage from "@/components/base/base-page";
+import { BasePage } from "@/components/base";
const ProxyPage = () => {
const { t } = useTranslation();
diff --git a/src/pages/rules.tsx b/src/pages/rules.tsx
index 0bc0139..86cbdfa 100644
--- a/src/pages/rules.tsx
+++ b/src/pages/rules.tsx
@@ -2,10 +2,9 @@ import useSWR from "swr";
import { useState, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { Virtuoso } from "react-virtuoso";
-import { Box, Button, MenuItem, Paper, Select, TextField } from "@mui/material";
+import { Box, Paper, TextField } from "@mui/material";
import { getRules } from "@/services/api";
-import BasePage from "@/components/base/base-page";
-import BaseEmpty from "@/components/base/base-empty";
+import { BaseEmpty, BasePage } from "@/components/base";
import RuleItem from "@/components/rule/rule-item";
const RulesPage = () => {
diff --git a/src/pages/settings.tsx b/src/pages/settings.tsx
index fcf7bd6..9904335 100644
--- a/src/pages/settings.tsx
+++ b/src/pages/settings.tsx
@@ -1,7 +1,6 @@
import { Paper } from "@mui/material";
import { useTranslation } from "react-i18next";
-import Notice from "@/components/base/base-notice";
-import BasePage from "@/components/base/base-page";
+import { BasePage, Notice } from "@/components/base";
import SettingVerge from "@/components/setting/setting-verge";
import SettingClash from "@/components/setting/setting-clash";
import SettingSystem from "@/components/setting/setting-system";
diff --git a/src/services/cmds.ts b/src/services/cmds.ts
index 168378e..b5a7d3d 100644
--- a/src/services/cmds.ts
+++ b/src/services/cmds.ts
@@ -1,5 +1,5 @@
import { invoke } from "@tauri-apps/api/tauri";
-import Notice from "@/components/base/base-notice";
+import { Notice } from "@/components/base";
export async function getClashLogs() {
const regex = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/;