chore: update

This commit is contained in:
huzibaca
2024-09-02 19:33:17 +08:00
parent d45929c604
commit 507d52bcb9
42 changed files with 16683 additions and 2013 deletions

View File

@@ -7,7 +7,8 @@ import {
ErrorRounded,
} from "@mui/icons-material";
import { useVerge } from "@/hooks/use-verge";
import { appWindow } from "@tauri-apps/api/window";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
const appWindow = getCurrentWebviewWindow();
interface InnerProps {
type: string;
duration?: number;

View File

@@ -1,5 +1,5 @@
import { Button, ButtonGroup } from "@mui/material";
import { appWindow } from "@tauri-apps/api/window";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import {
CloseRounded,
CropSquareRounded,
@@ -9,6 +9,7 @@ import {
PushPinRounded,
} from "@mui/icons-material";
import { useEffect, useState } from "react";
const appWindow = getCurrentWebviewWindow();
export const LayoutControl = () => {
const minWidth = 40;

View File

@@ -1,7 +1,7 @@
import useSWR from "swr";
import { useRef } from "react";
import { Button } from "@mui/material";
import { checkUpdate } from "@tauri-apps/api/updater";
import { check } from "@tauri-apps/plugin-updater";
import { UpdateViewer } from "../setting/mods/update-viewer";
import { DialogRef } from "../base";
import { useVerge } from "@/hooks/use-verge";
@@ -19,7 +19,7 @@ export const UpdateButton = (props: Props) => {
const { data: updateInfo } = useSWR(
auto_check_update || auto_check_update === null ? "checkUpdate" : null,
checkUpdate,
check,
{
errorRetryCount: 2,
revalidateIfStale: false,
@@ -27,7 +27,7 @@ export const UpdateButton = (props: Props) => {
}
);
if (!updateInfo?.shouldUpdate) return null;
if (!updateInfo?.available) return null;
return (
<>

View File

@@ -1,9 +1,10 @@
import { useEffect, useMemo } from "react";
import { alpha, createTheme, Shadows, Theme } from "@mui/material";
import { appWindow } from "@tauri-apps/api/window";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { useSetThemeMode, useThemeMode } from "@/services/states";
import { defaultTheme, defaultDarkTheme } from "@/pages/_theme";
import { useVerge } from "@/hooks/use-verge";
const appWindow = getCurrentWebviewWindow();
/**
* custom theme

View File

@@ -18,7 +18,7 @@ import {
import { useThemeMode } from "@/services/states";
import { Notice } from "@/components/base";
import { nanoid } from "nanoid";
import { appWindow } from "@tauri-apps/api/window";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import getSystem from "@/utils/get-system";
import debounce from "@/utils/debounce";
@@ -29,6 +29,7 @@ import { type JSONSchema7 } from "json-schema";
import metaSchema from "meta-json-schema/schemas/meta-json-schema.json";
import mergeSchema from "meta-json-schema/schemas/clash-verge-merge-json-schema.json";
import pac from "types-pac/pac.d.ts?raw";
const appWindow = getCurrentWebviewWindow();
type Language = "yaml" | "javascript" | "css";
type Schema<T extends Language> = LanguageSchemaMap[T];

View File

@@ -10,7 +10,7 @@ import { DeleteForeverRounded, UndoRounded } from "@mui/icons-material";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { downloadIconCache } from "@/services/cmds";
import { convertFileSrc } from "@tauri-apps/api/tauri";
import { convertFileSrc } from "@tauri-apps/api/core";
import { useEffect, useState } from "react";
interface Props {
type: "prepend" | "original" | "delete" | "append";

View File

@@ -30,7 +30,7 @@ import { EditorViewer } from "@/components/profile/editor-viewer";
import { ProfileBox } from "./profile-box";
import parseTraffic from "@/utils/parse-traffic";
import { ConfirmViewer } from "@/components/profile/confirm-viewer";
import { open } from "@tauri-apps/api/shell";
import { open } from "@tauri-apps/plugin-shell";
import { ProxiesEditorViewer } from "./proxies-editor-viewer";
const round = keyframes`
from { transform: rotate(0deg); }

View File

@@ -19,7 +19,7 @@ import type { IRenderItem } from "./use-render-list";
import { useVerge } from "@/hooks/use-verge";
import { useThemeMode } from "@/services/states";
import { useEffect, useMemo, useState } from "react";
import { convertFileSrc } from "@tauri-apps/api/tauri";
import { convertFileSrc } from "@tauri-apps/api/core";
import { downloadIconCache } from "@/services/cmds";
interface RenderProps {

View File

@@ -12,11 +12,11 @@ import {
import { useVerge } from "@/hooks/use-verge";
import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
import { GuardState } from "./guard-state";
import { open as openDialog } from "@tauri-apps/api/dialog";
import { convertFileSrc } from "@tauri-apps/api/tauri";
import { open as openDialog } from "@tauri-apps/plugin-dialog";
import { convertFileSrc } from "@tauri-apps/api/core";
import { copyIconFile, getAppDir } from "@/services/cmds";
import { join } from "@tauri-apps/api/path";
import { exists } from "@tauri-apps/api/fs";
import { exists } from "@tauri-apps/plugin-fs";
import getSystem from "@/utils/get-system";
const OS = getSystem();
@@ -186,7 +186,7 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
onChangeData({ common_tray_icon: false });
patchVerge({ common_tray_icon: false });
} else {
const path = await openDialog({
const selected = await openDialog({
directory: false,
multiple: false,
filters: [
@@ -196,8 +196,8 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
},
],
});
if (path?.length) {
await copyIconFile(`${path}`, "common");
if (selected?.path.length) {
await copyIconFile(`${selected.path}`, "common");
await initIconPath();
onChangeData({ common_tray_icon: true });
patchVerge({ common_tray_icon: true });
@@ -232,7 +232,7 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
onChangeData({ sysproxy_tray_icon: false });
patchVerge({ sysproxy_tray_icon: false });
} else {
const path = await openDialog({
const selected = await openDialog({
directory: false,
multiple: false,
filters: [
@@ -242,8 +242,8 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
},
],
});
if (path?.length) {
await copyIconFile(`${path}`, "sysproxy");
if (selected?.path.length) {
await copyIconFile(`${selected.path}`, "sysproxy");
await initIconPath();
onChangeData({ sysproxy_tray_icon: true });
patchVerge({ sysproxy_tray_icon: true });
@@ -276,7 +276,7 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
onChangeData({ tun_tray_icon: false });
patchVerge({ tun_tray_icon: false });
} else {
const path = await openDialog({
const selected = await openDialog({
directory: false,
multiple: false,
filters: [
@@ -286,8 +286,8 @@ export const LayoutViewer = forwardRef<DialogRef>((props, ref) => {
},
],
});
if (path?.length) {
await copyIconFile(`${path}`, "tun");
if (selected?.path.length) {
await copyIconFile(`${selected.path}`, "tun");
await initIconPath();
onChangeData({ tun_tray_icon: true });
patchVerge({ tun_tray_icon: true });

View File

@@ -4,7 +4,7 @@ import { BaseDialog, DialogRef, Notice } from "@/components/base";
import { getNetworkInterfacesInfo } from "@/services/cmds";
import { alpha, Box, Button, Chip, IconButton } from "@mui/material";
import { ContentCopyRounded } from "@mui/icons-material";
import { writeText } from "@tauri-apps/api/clipboard";
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
export const NetworkInterfaceViewer = forwardRef<DialogRef>((props, ref) => {
const { t } = useTranslation();

View File

@@ -3,13 +3,13 @@ import { forwardRef, useImperativeHandle, useState, useMemo } from "react";
import { useLockFn } from "ahooks";
import { Box, LinearProgress, Button } from "@mui/material";
import { useTranslation } from "react-i18next";
import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { relaunch } from "@tauri-apps/plugin-process";
import { check as checkUpdate } from "@tauri-apps/plugin-updater";
import { BaseDialog, DialogRef, Notice } from "@/components/base";
import { useUpdateState, useSetUpdateState } from "@/services/states";
import { listen, Event, UnlistenFn } from "@tauri-apps/api/event";
import { portableFlag } from "@/pages/_layout";
import { open as openUrl } from "@tauri-apps/api/shell";
import { open as openUrl } from "@tauri-apps/plugin-shell";
import ReactMarkdown from "react-markdown";
let eventListener: UnlistenFn | null = null;
@@ -38,17 +38,17 @@ export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
}));
const markdownContent = useMemo(() => {
if (!updateInfo?.manifest?.body) {
if (!updateInfo?.body) {
return "New Version is available";
}
return updateInfo?.manifest?.body;
return updateInfo?.body;
}, [updateInfo]);
const breakChangeFlag = useMemo(() => {
if (!updateInfo?.manifest?.body) {
if (!updateInfo?.body) {
return false;
}
return updateInfo?.manifest?.body.toLowerCase().includes("break change");
return updateInfo?.body.toLowerCase().includes("break change");
}, [updateInfo]);
const onUpdate = useLockFn(async () => {
@@ -56,7 +56,7 @@ export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
Notice.error(t("Portable Updater Error"));
return;
}
if (!updateInfo?.manifest?.body) return;
if (!updateInfo?.body) return;
if (breakChangeFlag) {
Notice.error(t("Break Change Update Error"));
return;
@@ -77,7 +77,7 @@ export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
}
);
try {
await installUpdate();
await updateInfo.install();
await relaunch();
} catch (err: any) {
Notice.error(err?.message || err.toString());
@@ -91,14 +91,14 @@ export const UpdateViewer = forwardRef<DialogRef>((props, ref) => {
open={open}
title={
<Box display="flex" justifyContent="space-between">
{`New Version v${updateInfo?.manifest?.version}`}
{`New Version v${updateInfo?.version}`}
<Box>
<Button
variant="contained"
size="small"
onClick={() => {
openUrl(
`https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/v${updateInfo?.manifest?.version}`
`https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/v${updateInfo?.version}`
);
}}
>

View File

@@ -1,14 +1,7 @@
import { useCallback, useRef } from "react";
import { useTranslation } from "react-i18next";
import { open } from "@tauri-apps/api/dialog";
import {
Button,
MenuItem,
Select,
Input,
Typography,
Box,
} from "@mui/material";
import { open } from "@tauri-apps/plugin-dialog";
import { Button, MenuItem, Select, Input, Typography } from "@mui/material";
import {
exitApp,
openAppDir,
@@ -17,7 +10,7 @@ import {
openDevTools,
copyClashEnv,
} from "@/services/cmds";
import { checkUpdate } from "@tauri-apps/api/updater";
import { check as checkUpdate } from "@tauri-apps/plugin-updater";
import { useVerge } from "@/hooks/use-verge";
import { version } from "@root/package.json";
import { DialogRef, Notice } from "@/components/base";
@@ -67,7 +60,7 @@ const SettingVerge = ({ onError }: Props) => {
const onCheckUpdate = async () => {
try {
const info = await checkUpdate();
if (!info?.shouldUpdate) {
if (!info?.available) {
Notice.success(t("Currently on the Latest Version"));
} else {
updateRef.current?.open();
@@ -191,7 +184,7 @@ const SettingVerge = ({ onError }: Props) => {
<>
<Button
onClick={async () => {
const path = await open({
const selected = await open({
directory: false,
multiple: false,
filters: [
@@ -201,9 +194,9 @@ const SettingVerge = ({ onError }: Props) => {
},
],
});
if (path?.length) {
onChangeData({ startup_script: `${path}` });
patchVerge({ startup_script: `${path}` });
if (selected?.path.length) {
onChangeData({ startup_script: `${selected.path}` });
patchVerge({ startup_script: `${selected.path}` });
}
}}
>

View File

@@ -19,7 +19,7 @@ import { TestBox } from "./test-box";
import delayManager from "@/services/delay";
import { cmdTestDelay, downloadIconCache } from "@/services/cmds";
import { listen, UnlistenFn } from "@tauri-apps/api/event";
import { convertFileSrc } from "@tauri-apps/api/tauri";
import { convertFileSrc } from "@tauri-apps/api/core";
interface Props {
id: string;