This repository was archived by the owner on Mar 4, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -24,16 +24,22 @@ export const defaultQbittorrentConfig: QbittorrentTorrentClientConfig = {
2424
2525export default class Qbittorrent implements TorrentClient {
2626 isLogin : boolean | null = null ;
27- lastLoginAt : number = 0 ;
27+ lastCheckLoginAt : number = 0 ;
2828 config : QbittorrentTorrentClientConfig ;
2929
3030 constructor ( options : Partial < QbittorrentTorrentClientConfig > = { } ) {
3131 this . config = { ...defaultQbittorrentConfig , ...options }
3232 }
3333
3434 async ping ( ) : Promise < boolean > {
35- const pong = await this . login ( ) ;
36- return pong . data === 'Ok.'
35+ try {
36+ const pong = await this . login ( ) ;
37+ this . isLogin = pong . data === 'Ok.'
38+ this . lastCheckLoginAt = Date . now ( )
39+ return this . isLogin
40+ } catch ( e ) {
41+ return false
42+ }
3743 }
3844
3945 async login ( ) : Promise < AxiosResponse > {
@@ -52,9 +58,8 @@ export default class Qbittorrent implements TorrentClient {
5258 headers ?: any ) : Promise < AxiosResponse > {
5359 // qbt 默认Session时长 3600s,这里取 600s
5460 // FIXME 是否每次操作都login一下好些?就像PTPP一样
55- if ( this . isLogin === null || Date . now ( ) + 600 * 1e3 > this . lastLoginAt ) {
56- await this . login ( )
57- this . lastLoginAt = Date . now ( )
61+ if ( this . isLogin === null || Date . now ( ) - 600 * 1e3 > this . lastCheckLoginAt ) {
62+ await this . ping ( )
5863 }
5964
6065 return await axios . request ( {
Original file line number Diff line number Diff line change 1818 <el-tag class =" demonstration" >
1919 支付宝
2020 </el-tag >
21- <!-- suppress NpmUsedModulesInstalled, HtmlUnknownTarget -->
22- <el-image class =" donate-img" src =" /assets/donate/Rhilip/alipay.jpg" />
21+ <el-image class =" donate-img" src =" /assets/donate/Rhilip/alipay.jpg" lazy />
2322 </el-col >
2423 <el-col :span =" 12" >
2524 <el-tag class =" demonstration" >
2625 微信支付
2726 </el-tag >
28- <!-- suppress NpmUsedModulesInstalled, HtmlUnknownTarget -->
29- <el-image class =" donate-img" src =" /assets/donate/Rhilip/wechat.png" />
27+ <el-image class =" donate-img" src =" /assets/donate/Rhilip/wechat.png" lazy />
3028 </el-col >
3129 </el-row >
3230 </div >
4139 <el-tag class =" demonstration" >
4240 微信赞赏码
4341 </el-tag >
44- <!-- suppress NpmUsedModulesInstalled, HtmlUnknownTarget -->
45- <el-image class =" donate-img" src =" /assets/donate/ledccn/wechat.png" />
42+ <el-image class =" donate-img" src =" /assets/donate/ledccn/wechat.png" lazy />
4643 </el-col >
4744 </el-row >
4845 </div >
Original file line number Diff line number Diff line change 4444 </div >
4545 <div >
4646 <el-scrollbar >
47- <div style =" height : 295 px " >
47+ <div style =" height : 285 px " >
4848 <pre v-if =" logId !== ''" >{{ formatLogs(logs) }}</pre >
4949 </div >
5050 </el-scrollbar >
You can’t perform that action at this time.
0 commit comments