refactor: debugLog for frontend (#5587)

This commit is contained in:
Sline
2025-11-25 10:01:04 +08:00
committed by GitHub
parent 64727ad660
commit caca8b2bc4
24 changed files with 181 additions and 99 deletions
+5 -4
View File
@@ -9,6 +9,7 @@ import {
import { useProfiles } from "@/hooks/use-profiles";
import { useVerge } from "@/hooks/use-verge";
import { syncTrayProxySelection } from "@/services/cmds";
import { debugLog } from "@/utils/debug";
// 缓存连接清理
const cleanupConnections = async (previousProxy: string) => {
@@ -20,7 +21,7 @@ const cleanupConnections = async (previousProxy: string) => {
if (cleanupPromises.length > 0) {
await Promise.allSettled(cleanupPromises);
console.log(`[ProxySelection] 清理了 ${cleanupPromises.length} 个连接`);
debugLog(`[ProxySelection] 清理了 ${cleanupPromises.length} 个连接`);
}
} catch (error) {
console.warn("[ProxySelection] 连接清理失败:", error);
@@ -57,7 +58,7 @@ export const useProxySelection = (options: ProxySelectionOptions = {}) => {
previousProxy?: string,
skipConfigSave: boolean = false,
) => {
console.log(`[ProxySelection] 代理切换: ${groupName} -> ${proxyName}`);
debugLog(`[ProxySelection] 代理切换: ${groupName} -> ${proxyName}`);
try {
if (current && !skipConfigSave) {
@@ -77,7 +78,7 @@ export const useProxySelection = (options: ProxySelectionOptions = {}) => {
await selectNodeForGroup(groupName, proxyName);
await syncTrayProxySelection();
console.log(
debugLog(
`[ProxySelection] 代理和状态同步完成: ${groupName} -> ${proxyName}`,
);
@@ -100,7 +101,7 @@ export const useProxySelection = (options: ProxySelectionOptions = {}) => {
await selectNodeForGroup(groupName, proxyName);
await syncTrayProxySelection();
onSuccess?.();
console.log(
debugLog(
`[ProxySelection] 代理切换回退成功: ${groupName} -> ${proxyName}`,
);
} catch (fallbackError) {