@@ -68,10 +68,9 @@ class GitHubOAuthService {
6868 try {
6969 // 检查是否在 Electron 环境中
7070 if ( this . isElectron ) {
71- // 在 Electron 中,打开远程 oauth-proxy 页面而不是直接重定向到 GitHub
72- // 远程 oauth-proxy 会处理回调并将结果传递回桌面应用
73- const proxyUrl = 'https://idyllic-kangaroo-a50663.netlify.app/' ;
74- window . open ( proxyUrl , '_blank' , 'width=600,height=800' ) ;
71+ // 在 Electron 中,使用 window.open 打开 oauth-proxy 页面
72+ // 它会被 handleWindowOpen 捕获并正确配置
73+ window . open ( 'https://idyllic-kangaroo-a50663.netlify.app/' , '_blank' , 'width=600,height=800' ) ;
7574
7675 // 启动轮询检查是否收到 token,并返回结果
7776 return await this . pollForToken ( ) ;
@@ -111,14 +110,14 @@ class GitHubOAuthService {
111110 */
112111 async pollForToken ( ) {
113112 return new Promise ( ( resolve , reject ) => {
114- const maxAttempts = 60 ; // 最多等待 30 秒 (60 次 * 500ms)
113+ const maxAttempts = 180 ; // 最多等待 90 秒 (180 次 * 500ms)
115114 let attempts = 0 ;
116115
117116 const poll = async ( ) => {
118117 attempts ++ ;
119118
120119 if ( attempts > maxAttempts ) {
121- reject ( new Error ( 'OAuth timeout: No token received within 30 seconds' ) ) ;
120+ reject ( new Error ( 'OAuth timeout: No token received within 90 seconds' ) ) ;
122121 return ;
123122 }
124123
@@ -149,6 +148,7 @@ class GitHubOAuthService {
149148 setTimeout ( poll , 500 ) ; // 每 500ms 检查一次
150149 } ;
151150
151+ // 立即开始轮询,然后定期检查
152152 poll ( ) ;
153153 } ) ;
154154 }
0 commit comments