Skip to content

Commit

Permalink
refactor: ts path alias
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Aug 5, 2022
1 parent bf0dafa commit f3341f2
Show file tree
Hide file tree
Showing 44 changed files with 140 additions and 155 deletions.
5 changes: 2 additions & 3 deletions src/components/connection/connection-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import dayjs from "dayjs";
import { useLockFn } from "ahooks";
import { styled, ListItem, IconButton, ListItemText } from "@mui/material";
import { CloseRounded } from "@mui/icons-material";
import { ApiType } from "../../services/types";
import { deleteConnection } from "../../services/api";
import parseTraffic from "../../utils/parse-traffic";
import { deleteConnection } from "@/services/api";
import parseTraffic from "@/utils/parse-traffic";

const Tag = styled("span")(({ theme }) => ({
display: "inline-block",
Expand Down
9 changes: 4 additions & 5 deletions src/components/layout/layout-traffic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { useRecoilValue } from "recoil";
import { Box, Typography } from "@mui/material";
import { ArrowDownward, ArrowUpward } from "@mui/icons-material";
import { listen } from "@tauri-apps/api/event";
import { ApiType } from "../../services/types";
import { getInformation } from "../../services/api";
import { getVergeConfig } from "../../services/cmds";
import { atomClashPort } from "../../services/states";
import { getInformation } from "@/services/api";
import { getVergeConfig } from "@/services/cmds";
import { atomClashPort } from "@/services/states";
import TrafficGraph from "./traffic-graph";
import useLogSetup from "./use-log-setup";
import parseTraffic from "../../utils/parse-traffic";
import parseTraffic from "@/utils/parse-traffic";

// setup the traffic
const LayoutTraffic = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/update-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
} from "@mui/material";
import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { killSidecar, restartSidecar } from "../../services/cmds";
import { atomUpdateState } from "../../services/states";
import { killSidecar, restartSidecar } from "@/services/cmds";
import { atomUpdateState } from "@/services/states";
import Notice from "../base/base-notice";

interface Props {
Expand Down
6 changes: 3 additions & 3 deletions src/components/layout/use-custom-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useEffect, useMemo } from "react";
import { useRecoilState } from "recoil";
import { createTheme } from "@mui/material";
import { appWindow } from "@tauri-apps/api/window";
import { getVergeConfig } from "../../services/cmds";
import { atomThemeMode } from "../../services/states";
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
import { getVergeConfig } from "@/services/cmds";
import { atomThemeMode } from "@/services/states";
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";

/**
* custome theme
Expand Down
5 changes: 2 additions & 3 deletions src/components/layout/use-log-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import dayjs from "dayjs";
import { useEffect, useState } from "react";
import { useSetRecoilState } from "recoil";
import { listen } from "@tauri-apps/api/event";
import { ApiType } from "../../services/types";
import { getInformation } from "../../services/api";
import { atomLogData } from "../../services/states";
import { getInformation } from "@/services/api";
import { atomLogData } from "@/services/states";

const MAX_LOG_NUM = 1000;

Expand Down
1 change: 0 additions & 1 deletion src/components/log/log-item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { styled, Box } from "@mui/material";
import { ApiType } from "../../services/types";

const Item = styled(Box)(({ theme }) => ({
padding: "8px 0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/profile/enhanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import {
enhanceProfiles,
changeProfileChain,
changeProfileValid,
} from "../../services/cmds";
import { CmdType } from "../../services/types";
} from "@/services/cmds";
import ProfileMore from "./profile-more";
import Notice from "../base/base-notice";

Expand Down
4 changes: 2 additions & 2 deletions src/components/profile/file-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
DialogContent,
DialogTitle,
} from "@mui/material";
import { atomThemeMode } from "../../services/states";
import { readProfileFile, saveProfileFile } from "../../services/cmds";
import { atomThemeMode } from "@/services/states";
import { readProfileFile, saveProfileFile } from "@/services/cmds";
import Notice from "../base/base-notice";

import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
Expand Down
3 changes: 1 addition & 2 deletions src/components/profile/profile-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
TextField,
} from "@mui/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";

interface Props {
Expand Down
7 changes: 3 additions & 4 deletions src/components/profile/profile-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import {
Menu,
} from "@mui/material";
import { RefreshRounded } from "@mui/icons-material";
import { CmdType } from "../../services/types";
import { atomLoadingCache } from "../../services/states";
import { updateProfile, deleteProfile, viewProfile } from "../../services/cmds";
import parseTraffic from "../../utils/parse-traffic";
import { atomLoadingCache } from "@/services/states";
import { updateProfile, deleteProfile, viewProfile } from "@/services/cmds";
import parseTraffic from "@/utils/parse-traffic";
import ProfileEdit from "./profile-edit";
import FileEditor from "./file-editor";
import Notice from "../base/base-notice";
Expand Down
5 changes: 2 additions & 3 deletions src/components/profile/profile-more.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import {
MenuItem,
Menu,
} from "@mui/material";
import { CmdType } from "../../services/types";
import { viewProfile } from "../../services/cmds";
import enhance from "../../services/enhance";
import { viewProfile } from "@/services/cmds";
import enhance from "@/services/enhance";
import ProfileEdit from "./profile-edit";
import FileEditor from "./file-editor";
import Notice from "../base/base-notice";
Expand Down
2 changes: 1 addition & 1 deletion src/components/profile/profile-new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TextField,
} from "@mui/material";
import { Settings } from "@mui/icons-material";
import { createProfile } from "../../services/cmds";
import { createProfile } from "@/services/cmds";
import Notice from "../base/base-notice";
import FileInput from "./file-input";

Expand Down
7 changes: 3 additions & 4 deletions src/components/proxy/proxy-global.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import useSWR, { useSWRConfig } from "swr";
import { useEffect, useRef, useState } from "react";
import { useLockFn } from "ahooks";
import { Virtuoso } from "react-virtuoso";
import { ApiType } from "../../services/types";
import { updateProxy } from "../../services/api";
import { getProfiles, patchProfile } from "../../services/cmds";
import { updateProxy } from "@/services/api";
import { getProfiles, patchProfile } from "@/services/cmds";
import delayManager from "@/services/delay";
import useSortProxy from "./use-sort-proxy";
import useHeadState from "./use-head-state";
import useFilterProxy from "./use-filter-proxy";
import delayManager from "../../services/delay";
import ProxyHead from "./proxy-head";
import ProxyItem from "./proxy-item";

Expand Down
7 changes: 3 additions & 4 deletions src/components/proxy/proxy-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import {
ExpandLessRounded,
ExpandMoreRounded,
} from "@mui/icons-material";
import { ApiType } from "../../services/types";
import { updateProxy } from "../../services/api";
import { getProfiles, patchProfile } from "../../services/cmds";
import { updateProxy } from "@/services/api";
import { getProfiles, patchProfile } from "@/services/cmds";
import delayManager from "@/services/delay";
import useSortProxy from "./use-sort-proxy";
import useHeadState from "./use-head-state";
import useFilterProxy from "./use-filter-proxy";
import delayManager from "../../services/delay";
import ProxyHead from "./proxy-head";
import ProxyItem from "./proxy-item";

Expand Down
2 changes: 1 addition & 1 deletion src/components/proxy/proxy-head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
SortByAlphaRounded,
SortRounded,
} from "@mui/icons-material";
import delayManager from "../../services/delay";
import delayManager from "@/services/delay";
import type { HeadState } from "./use-head-state";
import type { ProxySortType } from "./use-sort-proxy";

Expand Down
3 changes: 1 addition & 2 deletions src/components/proxy/proxy-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
SxProps,
Theme,
} from "@mui/material";
import { ApiType } from "../../services/types";
import delayManager from "../../services/delay";
import delayManager from "@/services/delay";

interface Props {
groupName: string;
Expand Down
3 changes: 1 addition & 2 deletions src/components/proxy/use-filter-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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 regex2 = /type=(.*)/i;
Expand Down
2 changes: 1 addition & 1 deletion src/components/proxy/use-head-state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useState } from "react";
import { useRecoilValue } from "recoil";
import { atomCurrentProfile } from "../../services/states";
import { atomCurrentProfile } from "@/services/states";
import { ProxySortType } from "./use-sort-proxy";

export interface HeadState {
Expand Down
3 changes: 1 addition & 2 deletions src/components/proxy/use-sort-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useMemo } from "react";
import { ApiType } from "../../services/types";
import delayManager from "../../services/delay";
import delayManager from "@/services/delay";

// default | delay | alpha
export type ProxySortType = 0 | 1 | 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
DialogTitle,
} from "@mui/material";
import { InfoRounded } from "@mui/icons-material";
import { atomThemeMode } from "../../services/states";
import { getRunningConfig } from "../../services/cmds";
import { atomThemeMode } from "../../../services/states";
import { getRunningConfig } from "../../../services/cmds";

import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution.js";
import "monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useState } from "react";
import { useLockFn } from "ahooks";
import { Menu, MenuItem } from "@mui/material";
import { Settings } from "@mui/icons-material";
import { changeClashCore, getVergeConfig } from "../../services/cmds";
import { getVersion } from "../../services/api";
import Notice from "../base/base-notice";
import { changeClashCore, getVergeConfig } from "@/services/cmds";
import { getVersion } from "@/services/api";
import Notice from "@/components/base/base-notice";

const VALID_CORE = [
{ name: "Clash", core: "clash" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cloneElement, isValidElement, ReactNode, useRef } from "react";
import noop from "../../utils/noop";
import noop from "@/utils/noop";

interface Props<Value> {
value?: Value;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
installService,
uninstallService,
patchVergeConfig,
} from "../../services/cmds";
import Notice from "../base/base-notice";
import noop from "../../utils/noop";
} from "@/services/cmds";
import Notice from "@/components/base/base-notice";
import noop from "@/utils/noop";

interface Props {
open: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { InfoRounded } from "@mui/icons-material";
import { ClickAwayListener, Tooltip } from "@mui/material";
import { getSystemProxy } from "../../services/cmds";
import { getSystemProxy } from "@/services/cmds";

const SysproxyTooltip = () => {
const [open, setOpen] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useTranslation } from "react-i18next";
import { Button, ButtonGroup } from "@mui/material";
import { CmdType } from "../../services/types";

type ThemeValue = CmdType.VergeConfig["theme_mode"];

Expand Down
26 changes: 9 additions & 17 deletions src/components/setting/setting-clash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@ import {
Typography,
Box,
} from "@mui/material";
import { ApiType } from "../../services/types";
import { atomClashPort } from "../../services/states";
import { patchClashConfig } from "../../services/cmds";
import { atomClashPort } from "@/services/states";
import { patchClashConfig } from "@/services/cmds";
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 GuardState from "./guard-state";
import CoreSwitch from "./core-switch";
import GuardState from "./mods/guard-state";
import CoreSwitch from "./mods/core-switch";

interface Props {
onError: (err: Error) => void;
}

// const MULTI_CORE = !!import.meta.env.VITE_MULTI_CORE;
const MULTI_CORE = true;

const SettingClash = ({ onError }: Props) => {
const { t } = useTranslation();
const { mutate } = useSWRConfig();
Expand Down Expand Up @@ -136,14 +132,10 @@ const SettingClash = ({ onError }: Props) => {
<SettingItem>
<ListItemText
primary={
MULTI_CORE ? (
<Box sx={{ display: "flex", alignItems: "center" }}>
<span style={{ marginRight: 4 }}>{t("Clash Core")}</span>
<CoreSwitch />
</Box>
) : (
t("Clash Core")
)
<Box sx={{ display: "flex", alignItems: "center" }}>
<span style={{ marginRight: 4 }}>{t("Clash Core")}</span>
<CoreSwitch />
</Box>
}
/>
<Typography sx={{ py: 1 }}>{clashVer}</Typography>
Expand Down
13 changes: 6 additions & 7 deletions src/components/setting/setting-system.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import {
checkService,
getVergeConfig,
patchVergeConfig,
} from "../../services/cmds";
} from "@/services/cmds";
import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types";
import GuardState from "./guard-state";
import ServiceMode from "./service-mode";
import ConfigViewer from "./config-viewer";
import SysproxyTooltip from "./sysproxy-tooltip";
import getSystem from "../../utils/get-system";
import getSystem from "@/utils/get-system";
import GuardState from "./mods/guard-state";
import ServiceMode from "./mods/service-mode";
import ConfigViewer from "./mods/config-viewer";
import SysproxyTooltip from "./mods/sysproxy-tooltip";

interface Props {
onError?: (err: Error) => void;
Expand Down
4 changes: 2 additions & 2 deletions src/components/setting/setting-theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
TextField,
useTheme,
} from "@mui/material";
import { getVergeConfig, patchVergeConfig } from "../../services/cmds";
import { defaultTheme, defaultDarkTheme } from "../../pages/_theme";
import { getVergeConfig, patchVergeConfig } from "@/services/cmds";
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";

interface Props {
open: boolean;
Expand Down
9 changes: 4 additions & 5 deletions src/components/setting/setting-verge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import {
openAppDir,
openLogsDir,
patchVergeConfig,
} from "../../services/cmds";
} from "@/services/cmds";
import { ArrowForward } from "@mui/icons-material";
import { SettingList, SettingItem } from "./setting";
import { CmdType } from "../../services/types";
import { version } from "../../../package.json";
import ThemeModeSwitch from "./theme-mode-switch";
import GuardState from "./guard-state";
import { version } from "@root/package.json";
import ThemeModeSwitch from "./mods/theme-mode-switch";
import GuardState from "./mods/guard-state";
import SettingTheme from "./setting-theme";

interface Props {
Expand Down
20 changes: 10 additions & 10 deletions src/pages/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import { alpha, List, Paper, ThemeProvider } from "@mui/material";
import { listen } from "@tauri-apps/api/event";
import { appWindow } from "@tauri-apps/api/window";
import { routers } from "./_routers";
import { getAxios } from "../services/api";
import { atomCurrentProfile } from "../services/states";
import { getVergeConfig, getProfiles } from "../services/cmds";
import { ReactComponent as LogoSvg } from "../assets/image/logo.svg";
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 getSystem from "../utils/get-system";
import { getAxios } from "@/services/api";
import { atomCurrentProfile } from "@/services/states";
import { getVergeConfig, getProfiles } from "@/services/cmds";
import { ReactComponent as LogoSvg } from "@/assets/image/logo.svg";
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 getSystem from "@/utils/get-system";
import "dayjs/locale/zh-cn";

dayjs.extend(relativeTime);
Expand Down
Loading

0 comments on commit f3341f2

Please sign in to comment.