@@ -38,9 +38,9 @@ class QRCodeHandler {
38
38
} else {
39
39
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( / [ x y ] / g, function ( c ) {
40
40
const r = ( Math . random ( ) * 16 ) | 0 ,
41
- v = c == 'x' ? r : ( r & 0x3 ) | 0x8 ;
41
+ v = c == 'x' ? r : ( r & 0x3 ) | 0x8 ;
42
42
return v . toString ( 16 ) ;
43
- } ) ;
43
+ } ) ;
44
44
}
45
45
}
46
46
@@ -57,32 +57,32 @@ class QRCodeHandler {
57
57
const result = [ ] ;
58
58
let currentCookie = '' ;
59
59
let inExpires = false ;
60
-
60
+
61
61
for ( let i = 0 ; i < cookieString . length ; i ++ ) {
62
62
const char = cookieString [ i ] ;
63
-
63
+
64
64
// 判断是否进入或退出 `expires` 属性
65
65
if ( cookieString . slice ( i , i + 8 ) . toLowerCase ( ) === 'expires=' ) {
66
- inExpires = true ;
66
+ inExpires = true ;
67
67
}
68
68
if ( inExpires && char === ';' ) {
69
- inExpires = false ;
69
+ inExpires = false ;
70
70
}
71
-
71
+
72
72
// 检测到逗号分隔符并且不在 `expires` 属性中,表示一个 Cookie 条目结束
73
73
if ( char === ',' && ! inExpires ) {
74
- result . push ( currentCookie . trim ( ) ) ;
75
- currentCookie = '' ;
74
+ result . push ( currentCookie . trim ( ) ) ;
75
+ currentCookie = '' ;
76
76
} else {
77
- currentCookie += char ;
77
+ currentCookie += char ;
78
78
}
79
79
}
80
-
80
+
81
81
// 添加最后一个 Cookie 条目
82
82
if ( currentCookie . trim ( ) ) {
83
83
result . push ( currentCookie . trim ( ) ) ;
84
84
}
85
-
85
+
86
86
return result ;
87
87
} ;
88
88
@@ -172,7 +172,7 @@ class QRCodeHandler {
172
172
async _checkQuarkStatus ( ) {
173
173
const state = this . platformStates [ QRCodeHandler . PLATFORM_QUARK ] ;
174
174
if ( ! state ) {
175
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
175
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
176
176
}
177
177
178
178
try {
@@ -238,9 +238,9 @@ class QRCodeHandler {
238
238
} ;
239
239
} else if ( resData . data . status === 50004002 ) { // token过期
240
240
this . platformStates [ QRCodeHandler . PLATFORM_QUARK ] = null ;
241
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
241
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
242
242
} else {
243
- return { status : QRCodeHandler . STATUS_NEW } ;
243
+ return { status : QRCodeHandler . STATUS_NEW } ;
244
244
}
245
245
} catch ( e ) {
246
246
this . platformStates [ QRCodeHandler . PLATFORM_QUARK ] = null ;
@@ -291,7 +291,7 @@ class QRCodeHandler {
291
291
async _checkAliStatus ( ) {
292
292
const state = this . platformStates [ QRCodeHandler . PLATFORM_ALI ] ;
293
293
if ( ! state ) {
294
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
294
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
295
295
}
296
296
297
297
try {
@@ -325,29 +325,30 @@ class QRCodeHandler {
325
325
const resData = res . data ;
326
326
327
327
if ( ! resData . data . content || ! resData . data . content . data ) {
328
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
328
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
329
329
}
330
330
331
331
const status = resData . data . content . data . qrCodeStatus ;
332
332
333
333
if ( status === "CONFIRMED" ) {
334
334
if ( resData . data . content . data . bizExt ) {
335
335
const bizExt = JSON . parse ( atob ( resData . data . content . data . bizExt ) ) ;
336
+ console . log ( bizExt . pds_login_result ) ;
336
337
return {
337
338
status : QRCodeHandler . STATUS_CONFIRMED ,
338
339
token : bizExt . pds_login_result . refreshToken
339
340
} ;
340
341
}
341
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
342
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
342
343
} else if ( status === "SCANED" ) {
343
- return { status : QRCodeHandler . STATUS_SCANED } ;
344
+ return { status : QRCodeHandler . STATUS_SCANED } ;
344
345
} else if ( status === "CANCELED" ) {
345
346
this . platformStates [ QRCodeHandler . PLATFORM_ALI ] = null ;
346
- return { status : QRCodeHandler . STATUS_CANCELED } ;
347
+ return { status : QRCodeHandler . STATUS_CANCELED } ;
347
348
} else if ( status === "NEW" ) {
348
- return { status : QRCodeHandler . STATUS_NEW } ;
349
+ return { status : QRCodeHandler . STATUS_NEW } ;
349
350
} else {
350
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
351
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
351
352
}
352
353
} catch ( e ) {
353
354
this . platformStates [ QRCodeHandler . PLATFORM_ALI ] = null ;
@@ -401,7 +402,7 @@ class QRCodeHandler {
401
402
async _checkUCStatus ( ) {
402
403
const state = this . platformStates [ QRCodeHandler . PLATFORM_UC ] ;
403
404
if ( ! state ) {
404
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
405
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
405
406
}
406
407
407
408
try {
@@ -445,17 +446,35 @@ class QRCodeHandler {
445
446
const cookieResData = cookieRes . data ;
446
447
const cookies = cookieResData . headers [ 'set-cookie' ] ;
447
448
const cookies2array = this . formatCookiesToList ( cookies ) ;
448
- const mainCookies = this . formatCookie ( cookies2array ) ;
449
+ let mainCookies = this . formatCookie ( cookies2array ) ;
450
+ const cookieSelfRes = await axios ( {
451
+ url : "/http" ,
452
+ method : "POST" ,
453
+ data : {
454
+ url : "https://pc-api.uc.cn/1/clouddrive/config?pr=UCBrowser&fr=pc" ,
455
+ headers : {
456
+ ...QRCodeHandler . HEADERS ,
457
+ Origin : 'https://drive.uc.cn' ,
458
+ Referer : 'https://drive.uc.cn/' ,
459
+ Cookie : mainCookies
460
+ }
461
+ }
462
+ } ) ;
463
+ const cookieResDataSelf = cookieSelfRes . data ;
464
+ const cookiesSelf = Array . isArray ( cookieResDataSelf . headers [ 'set-cookie' ] ) ? cookieResDataSelf . headers [ 'set-cookie' ] . join ( '; ' ) : cookieResDataSelf . headers [ 'set-cookie' ] ;
465
+ const cookies2arraySelf = this . formatCookiesToList ( cookiesSelf ) ;
466
+ const mainCookiesSelf = this . formatCookie ( cookies2arraySelf ) ;
467
+ if ( mainCookiesSelf ) mainCookies += ';' + mainCookiesSelf ;
449
468
this . platformStates [ QRCodeHandler . PLATFORM_UC ] = null ;
450
469
return {
451
470
status : QRCodeHandler . STATUS_CONFIRMED ,
452
471
cookie : mainCookies
453
472
} ;
454
473
} else if ( resData . data . status === 50004002 ) { // token过期
455
474
this . platformStates [ QRCodeHandler . PLATFORM_UC ] = null ;
456
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
475
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
457
476
} else {
458
- return { status : QRCodeHandler . STATUS_NEW } ;
477
+ return { status : QRCodeHandler . STATUS_NEW } ;
459
478
}
460
479
} catch ( e ) {
461
480
this . platformStates [ QRCodeHandler . PLATFORM_UC ] = null ;
@@ -505,7 +524,7 @@ class QRCodeHandler {
505
524
async _checkBiliStatus ( ) {
506
525
const state = this . platformStates [ QRCodeHandler . PLATFORM_BILI ] ;
507
526
if ( ! state ) {
508
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
527
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
509
528
}
510
529
511
530
try {
@@ -530,9 +549,9 @@ class QRCodeHandler {
530
549
}
531
550
532
551
if ( resData . data . data . code === 86101 ) { // 未扫码
533
- return { status : QRCodeHandler . STATUS_NEW } ;
552
+ return { status : QRCodeHandler . STATUS_NEW } ;
534
553
} else if ( resData . data . data . code === 86090 ) { // 已扫码未确认
535
- return { status : QRCodeHandler . STATUS_SCANED } ;
554
+ return { status : QRCodeHandler . STATUS_SCANED } ;
536
555
} else if ( resData . data . data . code === 0 ) { // 已确认
537
556
const url = resData . data . data . url ;
538
557
let cookie = "" ;
@@ -547,7 +566,7 @@ class QRCodeHandler {
547
566
} ;
548
567
} else { // 二维码过期
549
568
this . platformStates [ QRCodeHandler . PLATFORM_BILI ] = null ;
550
- return { status : QRCodeHandler . STATUS_EXPIRED } ;
569
+ return { status : QRCodeHandler . STATUS_EXPIRED } ;
551
570
}
552
571
} catch ( e ) {
553
572
this . platformStates [ QRCodeHandler . PLATFORM_BILI ] = null ;
0 commit comments