refactor: ts path alias
This commit is contained in:
parent
bf0dafabe2
commit
f3341f201f
@ -2,9 +2,8 @@ import dayjs from "dayjs";
|
|||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { styled, ListItem, IconButton, ListItemText } from "@mui/material";
|
import { styled, ListItem, IconButton, ListItemText } from "@mui/material";
|
||||||
import { CloseRounded } from "@mui/icons-material";
|
import { CloseRounded } from "@mui/icons-material";
|
||||||
import { ApiType } from "../../services/types";
|
import { deleteConnection } from "@/services/api";
|
||||||
import { deleteConnection } from "../../services/api";
|
import parseTraffic from "@/utils/parse-traffic";
|
||||||
import parseTraffic from "../../utils/parse-traffic";
|
|
||||||
|
|
||||||
const Tag = styled("span")(({ theme }) => ({
|
const Tag = styled("span")(({ theme }) => ({
|
||||||
display: "inline-block",
|
display: "inline-block",
|
||||||
|
@ -4,13 +4,12 @@ import { useRecoilValue } from "recoil";
|
|||||||
import { Box, Typography } from "@mui/material";
|
import { Box, Typography } from "@mui/material";
|
||||||
import { ArrowDownward, ArrowUpward } from "@mui/icons-material";
|
import { ArrowDownward, ArrowUpward } from "@mui/icons-material";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { ApiType } from "../../services/types";
|
import { getInformation } from "@/services/api";
|
||||||
import { getInformation } from "../../services/api";
|
import { getVergeConfig } from "@/services/cmds";
|
||||||
import { getVergeConfig } from "../../services/cmds";
|
import { atomClashPort } from "@/services/states";
|
||||||
import { atomClashPort } from "../../services/states";
|
|
||||||
import TrafficGraph from "./traffic-graph";
|
import TrafficGraph from "./traffic-graph";
|
||||||
import useLogSetup from "./use-log-setup";
|
import useLogSetup from "./use-log-setup";
|
||||||
import parseTraffic from "../../utils/parse-traffic";
|
import parseTraffic from "@/utils/parse-traffic";
|
||||||
|
|
||||||
// setup the traffic
|
// setup the traffic
|
||||||
const LayoutTraffic = () => {
|
const LayoutTraffic = () => {
|
||||||
|
@ -13,8 +13,8 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { relaunch } from "@tauri-apps/api/process";
|
import { relaunch } from "@tauri-apps/api/process";
|
||||||
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
|
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
|
||||||
import { killSidecar, restartSidecar } from "../../services/cmds";
|
import { killSidecar, restartSidecar } from "@/services/cmds";
|
||||||
import { atomUpdateState } from "../../services/states";
|
import { atomUpdateState } from "@/services/states";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -3,9 +3,9 @@ import { useEffect, useMemo } from "react";
|
|||||||
import { useRecoilState } from "recoil";
|
import { useRecoilState } from "recoil";
|
||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
import { appWindow } from "@tauri-apps/api/window";
|
import { appWindow } from "@tauri-apps/api/window";
|
||||||
import { getVergeConfig } from "../../services/cmds";
|
import { getVergeConfig } from "@/services/cmds";
|
||||||
import { atomThemeMode } from "../../services/states";
|
import { atomThemeMode } from "@/services/states";
|
||||||
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
|
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* custome theme
|
* custome theme
|
||||||
|
@ -2,9 +2,8 @@ import dayjs from "dayjs";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { ApiType } from "../../services/types";
|
import { getInformation } from "@/services/api";
|
||||||
import { getInformation } from "../../services/api";
|
import { atomLogData } from "@/services/states";
|
||||||
import { atomLogData } from "../../services/states";
|
|
||||||
|
|
||||||
const MAX_LOG_NUM = 1000;
|
const MAX_LOG_NUM = 1000;
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { styled, Box } from "@mui/material";
|
import { styled, Box } from "@mui/material";
|
||||||
import { ApiType } from "../../services/types";
|
|
||||||
|
|
||||||
const Item = styled(Box)(({ theme }) => ({
|
const Item = styled(Box)(({ theme }) => ({
|
||||||
padding: "8px 0",
|
padding: "8px 0",
|
||||||
|
@ -24,8 +24,7 @@ import {
|
|||||||
enhanceProfiles,
|
enhanceProfiles,
|
||||||
changeProfileChain,
|
changeProfileChain,
|
||||||
changeProfileValid,
|
changeProfileValid,
|
||||||
} from "../../services/cmds";
|
} from "@/services/cmds";
|
||||||
import { CmdType } from "../../services/types";
|
|
||||||
import ProfileMore from "./profile-more";
|
import ProfileMore from "./profile-more";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { atomThemeMode } from "../../services/states";
|
import { atomThemeMode } from "@/services/states";
|
||||||
import { readProfileFile, saveProfileFile } from "../../services/cmds";
|
import { readProfileFile, saveProfileFile } from "@/services/cmds";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
|
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
|
||||||
|
@ -12,8 +12,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Settings } from "@mui/icons-material";
|
import { Settings } from "@mui/icons-material";
|
||||||
import { CmdType } from "../../services/types";
|
import { patchProfile } from "@/services/cmds";
|
||||||
import { patchProfile } from "../../services/cmds";
|
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -16,10 +16,9 @@ import {
|
|||||||
Menu,
|
Menu,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { RefreshRounded } from "@mui/icons-material";
|
import { RefreshRounded } from "@mui/icons-material";
|
||||||
import { CmdType } from "../../services/types";
|
import { atomLoadingCache } from "@/services/states";
|
||||||
import { atomLoadingCache } from "../../services/states";
|
import { updateProfile, deleteProfile, viewProfile } from "@/services/cmds";
|
||||||
import { updateProfile, deleteProfile, viewProfile } from "../../services/cmds";
|
import parseTraffic from "@/utils/parse-traffic";
|
||||||
import parseTraffic from "../../utils/parse-traffic";
|
|
||||||
import ProfileEdit from "./profile-edit";
|
import ProfileEdit from "./profile-edit";
|
||||||
import FileEditor from "./file-editor";
|
import FileEditor from "./file-editor";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
@ -11,9 +11,8 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
Menu,
|
Menu,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { CmdType } from "../../services/types";
|
import { viewProfile } from "@/services/cmds";
|
||||||
import { viewProfile } from "../../services/cmds";
|
import enhance from "@/services/enhance";
|
||||||
import enhance from "../../services/enhance";
|
|
||||||
import ProfileEdit from "./profile-edit";
|
import ProfileEdit from "./profile-edit";
|
||||||
import FileEditor from "./file-editor";
|
import FileEditor from "./file-editor";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
|
@ -15,7 +15,7 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { Settings } from "@mui/icons-material";
|
import { Settings } from "@mui/icons-material";
|
||||||
import { createProfile } from "../../services/cmds";
|
import { createProfile } from "@/services/cmds";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
import FileInput from "./file-input";
|
import FileInput from "./file-input";
|
||||||
|
|
||||||
|
@ -2,13 +2,12 @@ import useSWR, { useSWRConfig } from "swr";
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { ApiType } from "../../services/types";
|
import { updateProxy } from "@/services/api";
|
||||||
import { updateProxy } from "../../services/api";
|
import { getProfiles, patchProfile } from "@/services/cmds";
|
||||||
import { getProfiles, patchProfile } from "../../services/cmds";
|
import delayManager from "@/services/delay";
|
||||||
import useSortProxy from "./use-sort-proxy";
|
import useSortProxy from "./use-sort-proxy";
|
||||||
import useHeadState from "./use-head-state";
|
import useHeadState from "./use-head-state";
|
||||||
import useFilterProxy from "./use-filter-proxy";
|
import useFilterProxy from "./use-filter-proxy";
|
||||||
import delayManager from "../../services/delay";
|
|
||||||
import ProxyHead from "./proxy-head";
|
import ProxyHead from "./proxy-head";
|
||||||
import ProxyItem from "./proxy-item";
|
import ProxyItem from "./proxy-item";
|
||||||
|
|
||||||
|
@ -15,13 +15,12 @@ import {
|
|||||||
ExpandLessRounded,
|
ExpandLessRounded,
|
||||||
ExpandMoreRounded,
|
ExpandMoreRounded,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import { ApiType } from "../../services/types";
|
import { updateProxy } from "@/services/api";
|
||||||
import { updateProxy } from "../../services/api";
|
import { getProfiles, patchProfile } from "@/services/cmds";
|
||||||
import { getProfiles, patchProfile } from "../../services/cmds";
|
import delayManager from "@/services/delay";
|
||||||
import useSortProxy from "./use-sort-proxy";
|
import useSortProxy from "./use-sort-proxy";
|
||||||
import useHeadState from "./use-head-state";
|
import useHeadState from "./use-head-state";
|
||||||
import useFilterProxy from "./use-filter-proxy";
|
import useFilterProxy from "./use-filter-proxy";
|
||||||
import delayManager from "../../services/delay";
|
|
||||||
import ProxyHead from "./proxy-head";
|
import ProxyHead from "./proxy-head";
|
||||||
import ProxyItem from "./proxy-item";
|
import ProxyItem from "./proxy-item";
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
SortByAlphaRounded,
|
SortByAlphaRounded,
|
||||||
SortRounded,
|
SortRounded,
|
||||||
} from "@mui/icons-material";
|
} from "@mui/icons-material";
|
||||||
import delayManager from "../../services/delay";
|
import delayManager from "@/services/delay";
|
||||||
import type { HeadState } from "./use-head-state";
|
import type { HeadState } from "./use-head-state";
|
||||||
import type { ProxySortType } from "./use-sort-proxy";
|
import type { ProxySortType } from "./use-sort-proxy";
|
||||||
|
|
||||||
|
@ -12,8 +12,7 @@ import {
|
|||||||
SxProps,
|
SxProps,
|
||||||
Theme,
|
Theme,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { ApiType } from "../../services/types";
|
import delayManager from "@/services/delay";
|
||||||
import delayManager from "../../services/delay";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
groupName: string;
|
groupName: string;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { ApiType } from "../../services/types";
|
import delayManager from "@/services/delay";
|
||||||
import delayManager from "../../services/delay";
|
|
||||||
|
|
||||||
const regex1 = /delay([=<>])(\d+|timeout|error)/i;
|
const regex1 = /delay([=<>])(\d+|timeout|error)/i;
|
||||||
const regex2 = /type=(.*)/i;
|
const regex2 = /type=(.*)/i;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { useRecoilValue } from "recoil";
|
import { useRecoilValue } from "recoil";
|
||||||
import { atomCurrentProfile } from "../../services/states";
|
import { atomCurrentProfile } from "@/services/states";
|
||||||
import { ProxySortType } from "./use-sort-proxy";
|
import { ProxySortType } from "./use-sort-proxy";
|
||||||
|
|
||||||
export interface HeadState {
|
export interface HeadState {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { ApiType } from "../../services/types";
|
import delayManager from "@/services/delay";
|
||||||
import delayManager from "../../services/delay";
|
|
||||||
|
|
||||||
// default | delay | alpha
|
// default | delay | alpha
|
||||||
export type ProxySortType = 0 | 1 | 2;
|
export type ProxySortType = 0 | 1 | 2;
|
||||||
|
@ -10,8 +10,8 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { InfoRounded } from "@mui/icons-material";
|
import { InfoRounded } from "@mui/icons-material";
|
||||||
import { atomThemeMode } from "../../services/states";
|
import { atomThemeMode } from "../../../services/states";
|
||||||
import { getRunningConfig } from "../../services/cmds";
|
import { getRunningConfig } from "../../../services/cmds";
|
||||||
|
|
||||||
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
|
import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
|
||||||
import "monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js";
|
import "monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js";
|
@ -3,9 +3,9 @@ import { useState } from "react";
|
|||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { Menu, MenuItem } from "@mui/material";
|
import { Menu, MenuItem } from "@mui/material";
|
||||||
import { Settings } from "@mui/icons-material";
|
import { Settings } from "@mui/icons-material";
|
||||||
import { changeClashCore, getVergeConfig } from "../../services/cmds";
|
import { changeClashCore, getVergeConfig } from "@/services/cmds";
|
||||||
import { getVersion } from "../../services/api";
|
import { getVersion } from "@/services/api";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "@/components/base/base-notice";
|
||||||
|
|
||||||
const VALID_CORE = [
|
const VALID_CORE = [
|
||||||
{ name: "Clash", core: "clash" },
|
{ name: "Clash", core: "clash" },
|
@ -1,5 +1,5 @@
|
|||||||
import { cloneElement, isValidElement, ReactNode, useRef } from "react";
|
import { cloneElement, isValidElement, ReactNode, useRef } from "react";
|
||||||
import noop from "../../utils/noop";
|
import noop from "@/utils/noop";
|
||||||
|
|
||||||
interface Props<Value> {
|
interface Props<Value> {
|
||||||
value?: Value;
|
value?: Value;
|
@ -14,9 +14,9 @@ import {
|
|||||||
installService,
|
installService,
|
||||||
uninstallService,
|
uninstallService,
|
||||||
patchVergeConfig,
|
patchVergeConfig,
|
||||||
} from "../../services/cmds";
|
} from "@/services/cmds";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "@/components/base/base-notice";
|
||||||
import noop from "../../utils/noop";
|
import noop from "@/utils/noop";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { InfoRounded } from "@mui/icons-material";
|
import { InfoRounded } from "@mui/icons-material";
|
||||||
import { ClickAwayListener, Tooltip } from "@mui/material";
|
import { ClickAwayListener, Tooltip } from "@mui/material";
|
||||||
import { getSystemProxy } from "../../services/cmds";
|
import { getSystemProxy } from "@/services/cmds";
|
||||||
|
|
||||||
const SysproxyTooltip = () => {
|
const SysproxyTooltip = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
@ -1,6 +1,5 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Button, ButtonGroup } from "@mui/material";
|
import { Button, ButtonGroup } from "@mui/material";
|
||||||
import { CmdType } from "../../services/types";
|
|
||||||
|
|
||||||
type ThemeValue = CmdType.VergeConfig["theme_mode"];
|
type ThemeValue = CmdType.VergeConfig["theme_mode"];
|
||||||
|
|
@ -10,22 +10,18 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
Box,
|
Box,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { ApiType } from "../../services/types";
|
import { atomClashPort } from "@/services/states";
|
||||||
import { atomClashPort } from "../../services/states";
|
import { patchClashConfig } from "@/services/cmds";
|
||||||
import { patchClashConfig } from "../../services/cmds";
|
|
||||||
import { SettingList, SettingItem } from "./setting";
|
import { SettingList, SettingItem } from "./setting";
|
||||||
import { getClashConfig, getVersion, updateConfigs } from "../../services/api";
|
import { getClashConfig, getVersion, updateConfigs } from "@/services/api";
|
||||||
import Notice from "../base/base-notice";
|
import Notice from "../base/base-notice";
|
||||||
import GuardState from "./guard-state";
|
import GuardState from "./mods/guard-state";
|
||||||
import CoreSwitch from "./core-switch";
|
import CoreSwitch from "./mods/core-switch";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onError: (err: Error) => void;
|
onError: (err: Error) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const MULTI_CORE = !!import.meta.env.VITE_MULTI_CORE;
|
|
||||||
const MULTI_CORE = true;
|
|
||||||
|
|
||||||
const SettingClash = ({ onError }: Props) => {
|
const SettingClash = ({ onError }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
@ -136,14 +132,10 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
<SettingItem>
|
<SettingItem>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={
|
primary={
|
||||||
MULTI_CORE ? (
|
|
||||||
<Box sx={{ display: "flex", alignItems: "center" }}>
|
<Box sx={{ display: "flex", alignItems: "center" }}>
|
||||||
<span style={{ marginRight: 4 }}>{t("Clash Core")}</span>
|
<span style={{ marginRight: 4 }}>{t("Clash Core")}</span>
|
||||||
<CoreSwitch />
|
<CoreSwitch />
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
|
||||||
t("Clash Core")
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Typography sx={{ py: 1 }}>{clashVer}</Typography>
|
<Typography sx={{ py: 1 }}>{clashVer}</Typography>
|
||||||
|
@ -13,14 +13,13 @@ import {
|
|||||||
checkService,
|
checkService,
|
||||||
getVergeConfig,
|
getVergeConfig,
|
||||||
patchVergeConfig,
|
patchVergeConfig,
|
||||||
} from "../../services/cmds";
|
} from "@/services/cmds";
|
||||||
import { SettingList, SettingItem } from "./setting";
|
import { SettingList, SettingItem } from "./setting";
|
||||||
import { CmdType } from "../../services/types";
|
import getSystem from "@/utils/get-system";
|
||||||
import GuardState from "./guard-state";
|
import GuardState from "./mods/guard-state";
|
||||||
import ServiceMode from "./service-mode";
|
import ServiceMode from "./mods/service-mode";
|
||||||
import ConfigViewer from "./config-viewer";
|
import ConfigViewer from "./mods/config-viewer";
|
||||||
import SysproxyTooltip from "./sysproxy-tooltip";
|
import SysproxyTooltip from "./mods/sysproxy-tooltip";
|
||||||
import getSystem from "../../utils/get-system";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onError?: (err: Error) => void;
|
onError?: (err: Error) => void;
|
||||||
|
@ -15,8 +15,8 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
useTheme,
|
useTheme,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
|
import { getVergeConfig, patchVergeConfig } from "@/services/cmds";
|
||||||
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
|
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
|
@ -14,13 +14,12 @@ import {
|
|||||||
openAppDir,
|
openAppDir,
|
||||||
openLogsDir,
|
openLogsDir,
|
||||||
patchVergeConfig,
|
patchVergeConfig,
|
||||||
} from "../../services/cmds";
|
} from "@/services/cmds";
|
||||||
import { ArrowForward } from "@mui/icons-material";
|
import { ArrowForward } from "@mui/icons-material";
|
||||||
import { SettingList, SettingItem } from "./setting";
|
import { SettingList, SettingItem } from "./setting";
|
||||||
import { CmdType } from "../../services/types";
|
import { version } from "@root/package.json";
|
||||||
import { version } from "../../../package.json";
|
import ThemeModeSwitch from "./mods/theme-mode-switch";
|
||||||
import ThemeModeSwitch from "./theme-mode-switch";
|
import GuardState from "./mods/guard-state";
|
||||||
import GuardState from "./guard-state";
|
|
||||||
import SettingTheme from "./setting-theme";
|
import SettingTheme from "./setting-theme";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -10,16 +10,16 @@ import { alpha, List, Paper, ThemeProvider } from "@mui/material";
|
|||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { appWindow } from "@tauri-apps/api/window";
|
import { appWindow } from "@tauri-apps/api/window";
|
||||||
import { routers } from "./_routers";
|
import { routers } from "./_routers";
|
||||||
import { getAxios } from "../services/api";
|
import { getAxios } from "@/services/api";
|
||||||
import { atomCurrentProfile } from "../services/states";
|
import { atomCurrentProfile } from "@/services/states";
|
||||||
import { getVergeConfig, getProfiles } from "../services/cmds";
|
import { getVergeConfig, getProfiles } from "@/services/cmds";
|
||||||
import { ReactComponent as LogoSvg } from "../assets/image/logo.svg";
|
import { ReactComponent as LogoSvg } from "@/assets/image/logo.svg";
|
||||||
import LayoutItem from "../components/layout/layout-item";
|
import LayoutItem from "@/components/layout/layout-item";
|
||||||
import LayoutControl from "../components/layout/layout-control";
|
import LayoutControl from "@/components/layout/layout-control";
|
||||||
import LayoutTraffic from "../components/layout/layout-traffic";
|
import LayoutTraffic from "@/components/layout/layout-traffic";
|
||||||
import UpdateButton from "../components/layout/update-button";
|
import UpdateButton from "@/components/layout/update-button";
|
||||||
import useCustomTheme from "../components/layout/use-custom-theme";
|
import useCustomTheme from "@/components/layout/use-custom-theme";
|
||||||
import getSystem from "../utils/get-system";
|
import getSystem from "@/utils/get-system";
|
||||||
import "dayjs/locale/zh-cn";
|
import "dayjs/locale/zh-cn";
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
dayjs.extend(relativeTime);
|
||||||
|
@ -3,10 +3,9 @@ import { useLockFn } from "ahooks";
|
|||||||
import { Box, Button, Paper, TextField } from "@mui/material";
|
import { Box, Button, Paper, TextField } from "@mui/material";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { ApiType } from "../services/types";
|
import { closeAllConnections, getInformation } from "@/services/api";
|
||||||
import { closeAllConnections, getInformation } from "../services/api";
|
import BasePage from "@/components/base/base-page";
|
||||||
import BasePage from "../components/base/base-page";
|
import ConnectionItem from "@/components/connection/connection-item";
|
||||||
import ConnectionItem from "../components/connection/connection-item";
|
|
||||||
|
|
||||||
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
const initConn = { uploadTotal: 0, downloadTotal: 0, connections: [] };
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ import { useRecoilState } from "recoil";
|
|||||||
import { Box, Button, MenuItem, Paper, Select, TextField } from "@mui/material";
|
import { Box, Button, MenuItem, Paper, Select, TextField } from "@mui/material";
|
||||||
import { Virtuoso } from "react-virtuoso";
|
import { Virtuoso } from "react-virtuoso";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { atomLogData } from "../services/states";
|
import { atomLogData } from "@/services/states";
|
||||||
import BasePage from "../components/base/base-page";
|
import BasePage from "@/components/base/base-page";
|
||||||
import LogItem from "../components/log/log-item";
|
import LogItem from "@/components/log/log-item";
|
||||||
|
|
||||||
const LogPage = () => {
|
const LogPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -9,14 +9,14 @@ import {
|
|||||||
patchProfile,
|
patchProfile,
|
||||||
selectProfile,
|
selectProfile,
|
||||||
importProfile,
|
importProfile,
|
||||||
} from "../services/cmds";
|
} from "@/services/cmds";
|
||||||
import { getProxies, updateProxy } from "../services/api";
|
import { getProxies, updateProxy } from "@/services/api";
|
||||||
import { atomCurrentProfile } from "../services/states";
|
import { atomCurrentProfile } from "@/services/states";
|
||||||
import Notice from "../components/base/base-notice";
|
import Notice from "@/components/base/base-notice";
|
||||||
import BasePage from "../components/base/base-page";
|
import BasePage from "@/components/base/base-page";
|
||||||
import ProfileNew from "../components/profile/profile-new";
|
import ProfileNew from "@/components/profile/profile-new";
|
||||||
import ProfileItem from "../components/profile/profile-item";
|
import ProfileItem from "@/components/profile/profile-item";
|
||||||
import EnhancedMode from "../components/profile/enhanced";
|
import EnhancedMode from "@/components/profile/enhanced";
|
||||||
|
|
||||||
const ProfilePage = () => {
|
const ProfilePage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -3,12 +3,12 @@ import { useEffect } from "react";
|
|||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Button, ButtonGroup, List, Paper } from "@mui/material";
|
import { Button, ButtonGroup, List, Paper } from "@mui/material";
|
||||||
import { getClashConfig, updateConfigs } from "../services/api";
|
import { getClashConfig, updateConfigs } from "@/services/api";
|
||||||
import { patchClashConfig } from "../services/cmds";
|
import { patchClashConfig } from "@/services/cmds";
|
||||||
import { getProxies } from "../services/api";
|
import { getProxies } from "@/services/api";
|
||||||
import BasePage from "../components/base/base-page";
|
import BasePage from "@/components/base/base-page";
|
||||||
import ProxyGroup from "../components/proxy/proxy-group";
|
import ProxyGroup from "@/components/proxy/proxy-group";
|
||||||
import ProxyGlobal from "../components/proxy/proxy-global";
|
import ProxyGlobal from "@/components/proxy/proxy-global";
|
||||||
|
|
||||||
const ProxyPage = () => {
|
const ProxyPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { Paper } from "@mui/material";
|
import { Paper } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import Notice from "../components/base/base-notice";
|
import Notice from "@/components/base/base-notice";
|
||||||
import BasePage from "../components/base/base-page";
|
import BasePage from "@/components/base/base-page";
|
||||||
import SettingVerge from "../components/setting/setting-verge";
|
import SettingVerge from "@/components/setting/setting-verge";
|
||||||
import SettingClash from "../components/setting/setting-clash";
|
import SettingClash from "@/components/setting/setting-clash";
|
||||||
import SettingSystem from "../components/setting/setting-system";
|
import SettingSystem from "@/components/setting/setting-system";
|
||||||
|
|
||||||
const SettingPage = () => {
|
const SettingPage = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import axios, { AxiosInstance } from "axios";
|
import axios, { AxiosInstance } from "axios";
|
||||||
import { getClashInfo } from "./cmds";
|
import { getClashInfo } from "./cmds";
|
||||||
import { ApiType } from "./types";
|
|
||||||
|
|
||||||
let axiosIns: AxiosInstance = null!;
|
let axiosIns: AxiosInstance = null!;
|
||||||
let server = "";
|
let server = "";
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { invoke } from "@tauri-apps/api/tauri";
|
import { invoke } from "@tauri-apps/api/tauri";
|
||||||
import { ApiType, CmdType } from "./types";
|
import Notice from "@/components/base/base-notice";
|
||||||
import Notice from "../components/base/base-notice";
|
|
||||||
|
|
||||||
export async function getProfiles() {
|
export async function getProfiles() {
|
||||||
return invoke<CmdType.ProfilesConfig>("get_profiles");
|
return invoke<CmdType.ProfilesConfig>("get_profiles");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { emit, listen, Event } from "@tauri-apps/api/event";
|
import { emit, listen, Event } from "@tauri-apps/api/event";
|
||||||
import { appWindow } from "@tauri-apps/api/window";
|
import { appWindow } from "@tauri-apps/api/window";
|
||||||
import { CmdType } from "./types";
|
import ignoreCase from "@/utils/ignore-case";
|
||||||
import ignoreCase from "../utils/ignore-case";
|
|
||||||
|
|
||||||
const DEFAULT_FIELDS = [
|
const DEFAULT_FIELDS = [
|
||||||
"rules",
|
"rules",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import i18n from "i18next";
|
import i18n from "i18next";
|
||||||
import { initReactI18next } from "react-i18next";
|
import { initReactI18next } from "react-i18next";
|
||||||
import en from "../locales/en.json";
|
import en from "@/locales/en.json";
|
||||||
import zh from "../locales/zh.json";
|
import zh from "@/locales/zh.json";
|
||||||
|
|
||||||
const resources = {
|
const resources = {
|
||||||
en: { translation: en },
|
en: { translation: en },
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { atom } from "recoil";
|
import { atom } from "recoil";
|
||||||
import { ApiType } from "./types";
|
|
||||||
|
|
||||||
export const atomThemeMode = atom<"light" | "dark">({
|
export const atomThemeMode = atom<"light" | "dark">({
|
||||||
key: "atomThemeMode",
|
key: "atomThemeMode",
|
||||||
|
44
src/services/types.ts → src/services/types.d.ts
vendored
44
src/services/types.ts → src/services/types.d.ts
vendored
@ -1,8 +1,9 @@
|
|||||||
|
// declare global {
|
||||||
/**
|
/**
|
||||||
* Some interface for clash api
|
* Some interface for clash api
|
||||||
*/
|
*/
|
||||||
export namespace ApiType {
|
declare namespace ApiType {
|
||||||
export interface ConfigData {
|
interface ConfigData {
|
||||||
port: number;
|
port: number;
|
||||||
mode: string;
|
mode: string;
|
||||||
ipv6: boolean;
|
ipv6: boolean;
|
||||||
@ -15,13 +16,13 @@ export namespace ApiType {
|
|||||||
"tproxy-port": number;
|
"tproxy-port": number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RuleItem {
|
interface RuleItem {
|
||||||
type: string;
|
type: string;
|
||||||
payload: string;
|
payload: string;
|
||||||
proxy: string;
|
proxy: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProxyItem {
|
interface ProxyItem {
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
udp: boolean;
|
udp: boolean;
|
||||||
@ -33,22 +34,22 @@ export namespace ApiType {
|
|||||||
now?: string;
|
now?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ProxyGroupItem = Omit<ProxyItem, "all"> & {
|
type ProxyGroupItem = Omit<ProxyItem, "all"> & {
|
||||||
all: ProxyItem[];
|
all: ProxyItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface TrafficItem {
|
interface TrafficItem {
|
||||||
up: number;
|
up: number;
|
||||||
down: number;
|
down: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LogItem {
|
interface LogItem {
|
||||||
type: string;
|
type: string;
|
||||||
time?: string;
|
time?: string;
|
||||||
payload: string;
|
payload: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConnectionsItem {
|
interface ConnectionsItem {
|
||||||
id: string;
|
id: string;
|
||||||
metadata: {
|
metadata: {
|
||||||
network: string;
|
network: string;
|
||||||
@ -69,7 +70,7 @@ export namespace ApiType {
|
|||||||
curDownload?: number; // calculate
|
curDownload?: number; // calculate
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Connections {
|
interface Connections {
|
||||||
downloadTotal: number;
|
downloadTotal: number;
|
||||||
uploadTotal: number;
|
uploadTotal: number;
|
||||||
connections: ConnectionsItem[];
|
connections: ConnectionsItem[];
|
||||||
@ -79,17 +80,17 @@ export namespace ApiType {
|
|||||||
/**
|
/**
|
||||||
* Some interface for command
|
* Some interface for command
|
||||||
*/
|
*/
|
||||||
export namespace CmdType {
|
declare namespace CmdType {
|
||||||
export type ProfileType = "local" | "remote" | "merge" | "script";
|
type ProfileType = "local" | "remote" | "merge" | "script";
|
||||||
|
|
||||||
export interface ClashInfo {
|
interface ClashInfo {
|
||||||
status: string;
|
status: string;
|
||||||
port?: string;
|
port?: string;
|
||||||
server?: string;
|
server?: string;
|
||||||
secret?: string;
|
secret?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfileItem {
|
interface ProfileItem {
|
||||||
uid: string;
|
uid: string;
|
||||||
type?: ProfileType | string;
|
type?: ProfileType | string;
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -110,20 +111,20 @@ export namespace CmdType {
|
|||||||
option?: ProfileOption;
|
option?: ProfileOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfileOption {
|
interface ProfileOption {
|
||||||
user_agent?: string;
|
user_agent?: string;
|
||||||
with_proxy?: boolean;
|
with_proxy?: boolean;
|
||||||
update_interval?: number;
|
update_interval?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfilesConfig {
|
interface ProfilesConfig {
|
||||||
current?: string;
|
current?: string;
|
||||||
chain?: string[];
|
chain?: string[];
|
||||||
valid?: string[];
|
valid?: string[];
|
||||||
items?: ProfileItem[];
|
items?: ProfileItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VergeConfig {
|
interface VergeConfig {
|
||||||
language?: string;
|
language?: string;
|
||||||
clash_core?: string;
|
clash_core?: string;
|
||||||
theme_mode?: "light" | "dark" | "system";
|
theme_mode?: "light" | "dark" | "system";
|
||||||
@ -152,7 +153,7 @@ export namespace CmdType {
|
|||||||
|
|
||||||
type ClashConfigValue = any;
|
type ClashConfigValue = any;
|
||||||
|
|
||||||
export interface ProfileMerge {
|
interface ProfileMerge {
|
||||||
// clash config fields (default supports)
|
// clash config fields (default supports)
|
||||||
rules?: ClashConfigValue;
|
rules?: ClashConfigValue;
|
||||||
proxies?: ClashConfigValue;
|
proxies?: ClashConfigValue;
|
||||||
@ -179,7 +180,7 @@ export namespace CmdType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// partial of the clash config
|
// partial of the clash config
|
||||||
export type ProfileData = Partial<{
|
type ProfileData = Partial<{
|
||||||
rules: any[];
|
rules: any[];
|
||||||
proxies: any[];
|
proxies: any[];
|
||||||
"proxy-groups": any[];
|
"proxy-groups": any[];
|
||||||
@ -189,22 +190,23 @@ export namespace CmdType {
|
|||||||
[k: string]: any;
|
[k: string]: any;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export interface ChainItem {
|
interface ChainItem {
|
||||||
item: ProfileItem;
|
item: ProfileItem;
|
||||||
merge?: ProfileMerge;
|
merge?: ProfileMerge;
|
||||||
script?: string;
|
script?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EnhancedPayload {
|
interface EnhancedPayload {
|
||||||
chain: ChainItem[];
|
chain: ChainItem[];
|
||||||
valid: string[];
|
valid: string[];
|
||||||
current: ProfileData;
|
current: ProfileData;
|
||||||
callback: string;
|
callback: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EnhancedResult {
|
interface EnhancedResult {
|
||||||
data: ProfileData;
|
data: ProfileData;
|
||||||
status: string;
|
status: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// }
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||||
@ -14,7 +15,11 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "react-jsx"
|
"jsx": "react-jsx",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["src/*"],
|
||||||
|
"@root/*": ["./*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": ["./src"]
|
"include": ["./src"]
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
|
import path from "path";
|
||||||
import svgr from "vite-plugin-svgr";
|
import svgr from "vite-plugin-svgr";
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import monaco from "vite-plugin-monaco-editor";
|
import monaco from "vite-plugin-monaco-editor";
|
||||||
@ -15,4 +16,10 @@ export default defineConfig({
|
|||||||
outDir: "../dist",
|
outDir: "../dist",
|
||||||
emptyOutDir: true,
|
emptyOutDir: true,
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": path.resolve("./src"),
|
||||||
|
"@root": path.resolve("."),
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user