@@ -2,6 +2,7 @@ import { FC, memo, useCallback, useEffect, useState } from "react";
22import { Copy } from "lucide-react" ;
33import { useTranslation } from "react-i18next" ;
44import { v4 as uuidv4 } from "uuid" ;
5+ import { useDebounceFn } from "ahooks" ;
56
67import { UserProfile } from "./UserProfile" ;
78import { OpenURLWithBrowser } from "@/utils" ;
@@ -20,7 +21,6 @@ const ServiceAuth = memo(
2021 ( { setRefreshLoading, refreshClick } : ServiceAuthProps ) => {
2122 const { t } = useTranslation ( ) ;
2223
23- const language = useAppStore ( ( state ) => state . language ) ;
2424 const addError = useAppStore ( ( state ) => state . addError ) ;
2525 const ssoRequestID = useAppStore ( ( state ) => state . ssoRequestID ) ;
2626 const setSSORequestID = useAppStore ( ( state ) => state . setSSORequestID ) ;
@@ -61,19 +61,21 @@ const ServiceAuth = memo(
6161 [ logoutServer ]
6262 ) ;
6363
64+ const { run : debouncedAuthSuccess } = useDebounceFn ( ( event ) => {
65+ const { serverId } = event . payload ;
66+ if ( serverId ) {
67+ refreshClick ( serverId , ( ) => {
68+ setLoading ( false ) ;
69+ } ) ;
70+ addError ( t ( "cloud.connect.hints.loginSuccess" ) , "info" ) ;
71+ }
72+ } ) ;
73+
6474 // handle oauth success event
6575 useEffect ( ( ) => {
6676 const unlistenOAuth = platformAdapter . listenEvent (
6777 "oauth_success" ,
68- ( event ) => {
69- const { serverId } = event . payload ;
70- if ( serverId ) {
71- refreshClick ( serverId , ( ) => {
72- setLoading ( false ) ;
73- } ) ;
74- addError ( language === "zh" ? "登录成功" : "Login Success" , "info" ) ;
75- }
76- }
78+ debouncedAuthSuccess
7779 ) ;
7880
7981 return ( ) => {
0 commit comments