refactor: improve code readability and consistency in proxy-chain and uri-parser utilities
refactor: add keys to icons in routers for improved rendering and performance refactor: optimize RegExp polyfill by using Object.prototype.hasOwnProperty.call refactor: reorder imports in chain-proxy-provider for consistency refactor: remove unused "obfs-opts" property from IProxySnellConfig interface refactor: reorganize imports and enhance refresh logic in app data provider refactor: re-enable prop-types linting for better type safety in BaseDialog component refactor: update dependencies in effect hooks for improved stability and performance
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
import {
|
||||
CheckCircleOutlined,
|
||||
AccessTimeOutlined,
|
||||
CancelOutlined,
|
||||
CheckCircleOutlined,
|
||||
HelpOutline,
|
||||
PendingOutlined,
|
||||
RefreshRounded,
|
||||
AccessTimeOutlined,
|
||||
} from "@mui/icons-material";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Divider,
|
||||
Typography,
|
||||
Chip,
|
||||
Tooltip,
|
||||
CircularProgress,
|
||||
Divider,
|
||||
Grid,
|
||||
Tooltip,
|
||||
Typography,
|
||||
alpha,
|
||||
useTheme,
|
||||
Grid,
|
||||
} from "@mui/material";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useLockFn } from "ahooks";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { BasePage, BaseEmpty } from "@/components/base";
|
||||
import { BaseEmpty, BasePage } from "@/components/base";
|
||||
import { showNotice } from "@/services/noticeService";
|
||||
|
||||
interface UnlockItem {
|
||||
@@ -45,9 +45,9 @@ const UnlockPage = () => {
|
||||
const [isCheckingAll, setIsCheckingAll] = useState(false);
|
||||
const [loadingItems, setLoadingItems] = useState<string[]>([]);
|
||||
|
||||
const sortItemsByName = (items: UnlockItem[]) => {
|
||||
const sortItemsByName = useCallback((items: UnlockItem[]) => {
|
||||
return [...items].sort((a, b) => a.name.localeCompare(b.name));
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 保存测试结果到本地存储
|
||||
const saveResultsToStorage = (items: UnlockItem[], time: string | null) => {
|
||||
@@ -82,6 +82,22 @@ const UnlockPage = () => {
|
||||
return { items: null, time: null };
|
||||
};
|
||||
|
||||
const getUnlockItems = useCallback(
|
||||
async (updateUI: boolean = true) => {
|
||||
try {
|
||||
const items = await invoke<UnlockItem[]>("get_unlock_items");
|
||||
const sortedItems = sortItemsByName(items);
|
||||
|
||||
if (updateUI) {
|
||||
setUnlockItems(sortedItems);
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error("Failed to get unlock items:", err);
|
||||
}
|
||||
},
|
||||
[sortItemsByName],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const { items: storedItems } = loadResultsFromStorage();
|
||||
|
||||
@@ -91,20 +107,7 @@ const UnlockPage = () => {
|
||||
} else {
|
||||
getUnlockItems(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const getUnlockItems = async (updateUI: boolean = true) => {
|
||||
try {
|
||||
const items = await invoke<UnlockItem[]>("get_unlock_items");
|
||||
const sortedItems = sortItemsByName(items);
|
||||
|
||||
if (updateUI) {
|
||||
setUnlockItems(sortedItems);
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error("Failed to get unlock items:", err);
|
||||
}
|
||||
};
|
||||
}, [getUnlockItems]);
|
||||
|
||||
const invokeWithTimeout = async <T,>(
|
||||
cmd: string,
|
||||
|
||||
Reference in New Issue
Block a user