feat: support clash meta memory usage display

This commit is contained in:
GyDi
2023-08-05 19:40:23 +08:00
parent cb1955c217
commit 15cf9be90d
9 changed files with 189 additions and 61 deletions

View File

@@ -5,6 +5,7 @@ export type WsMsgFn = (event: MessageEvent<any>) => void;
export interface WsOptions {
errorCount?: number; // default is 5
retryInterval?: number; // default is 2500
onError?: () => void;
}
export const useWebsocket = (onMessage: WsMsgFn, options?: WsOptions) => {
@@ -38,6 +39,9 @@ export const useWebsocket = (onMessage: WsMsgFn, options?: WsOptions) => {
if (errorCount >= 0) {
timerRef.current = setTimeout(connectHelper, 2500);
} else {
disconnect();
options?.onError?.();
}
});
};