File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -101,13 +101,25 @@ export async function oneToken(c: Context) {
101
101
// 执行请求 ===========================================================================
102
102
try {
103
103
const paramsString = new URLSearchParams ( params_all ) . toString ( ) ;
104
- const response : Response = await fetch ( client_url , {
105
- method : 'POST' ,
106
- headers : {
107
- 'Content-Type' : 'application/x-www-form-urlencoded' ,
108
- } ,
109
- body : paramsString ,
110
- } ) ;
104
+
105
+ let try_time : number = 5 ;
106
+ let response : Response | null = null ;
107
+ while ( try_time > 0 ) {
108
+ try {
109
+ response = await fetch ( client_url , {
110
+ method : 'POST' ,
111
+ headers : {
112
+ 'Content-Type' : 'application/x-www-form-urlencoded' ,
113
+ } ,
114
+ body : paramsString ,
115
+ } ) ;
116
+ break ;
117
+ } catch ( error ) {
118
+ try_time -= 1 ;
119
+ }
120
+ }
121
+ if ( ! try_time || ! response ) return c . redirect (
122
+ showErr ( "多次尝试获取Token失败" ) ) ;
111
123
if ( server_use == "false" ) {
112
124
local . deleteCookie ( c , 'client_uid' ) ;
113
125
local . deleteCookie ( c , 'client_key' ) ;
You can’t perform that action at this time.
0 commit comments