Skip to content

Commit 3cdeab2

Browse files
committed
Update README.md
1 parent 3d63ac0 commit 3cdeab2

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,32 @@ const {session} = remote
7777
details.requestHeaders['Referer'] = `https://leetcode-cn.com/problems/${questionSlug}/submissions/`
7878
callback({ cancel: false, requestHeaders: details.requestHeaders })
7979
})
80+
//...
81+
}
82+
```
83+
84+
在给出的实例化的对象中,所有的函数方法都会返回 [**axios**](https://www.axios-http.cn/) 对象。所以,你可以从函数的 **then** 回调中获取数据,例如:
85+
In the given instantiated object, all function methods return [**axios**](https://www.axios-http.cn/) objects. So, you can get data from the function's **then** callback, for example:
86+
87+
```javascript
88+
import { remote } from "electron"
89+
const { session } = remote,
90+
$leetcode = new $Leetcode(),
91+
leetcodeUserStatus = null
92+
93+
;function someFn(questionSlug){
94+
session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ['https://leetcode-cn.com/problems/*'] }, (details, callback) => {
95+
details.requestHeaders['Referer'] = `https://leetcode-cn.com/problems/${questionSlug}/submissions/`
96+
callback({ cancel: false, requestHeaders: details.requestHeaders })
97+
})
98+
$leetcode.getUserStatus().then((response)=>{
99+
if(response.status == 200){
100+
const { userStatus } = response.data.data
101+
// leetcodeUserStatus = userStatus
102+
}
103+
else
104+
console.log(response)
105+
})
80106
}
81107
```
82108

@@ -94,7 +120,7 @@ The Cookie items mentioned in the table below refer to the **LEETCODE_SESSION**
94120
### 用户状态
95121

96122
```javascript
97-
$Leetcode.getUserStatus() // with cookie
123+
$Leetcode.getUserStatus() // with cookie [LEETCODE_SESSION,x-csrftoken]
98124
```
99125

100126
请求数据项:

0 commit comments

Comments
 (0)