mirror of https://github.com/Xhofe/alist
perf(123): optimize login error
parent
ca9e739465
commit
f442185aa5
|
@ -7,18 +7,6 @@ import (
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
//type BaseResp struct {
|
|
||||||
// Code interface{} `json:"code"`
|
|
||||||
// Message string `json:"message"`
|
|
||||||
//}
|
|
||||||
|
|
||||||
type TokenResp struct {
|
|
||||||
//BaseResp
|
|
||||||
Data struct {
|
|
||||||
Token string `json:"token"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
FileName string `json:"FileName"`
|
FileName string `json:"FileName"`
|
||||||
Size int64 `json:"Size"`
|
Size int64 `json:"Size"`
|
||||||
|
|
|
@ -29,9 +29,7 @@ func (d *Pan123) login() error {
|
||||||
"password": d.Password,
|
"password": d.Password,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var resp TokenResp
|
|
||||||
res, err := base.RestyClient.R().
|
res, err := base.RestyClient.R().
|
||||||
SetResult(&resp).
|
|
||||||
SetBody(body).Post(url)
|
SetBody(body).Post(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -39,7 +37,7 @@ func (d *Pan123) login() error {
|
||||||
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
|
if utils.Json.Get(res.Body(), "code").ToInt() != 200 {
|
||||||
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
|
err = fmt.Errorf(utils.Json.Get(res.Body(), "message").ToString())
|
||||||
} else {
|
} else {
|
||||||
d.AccessToken = resp.Data.Token
|
d.AccessToken = utils.Json.Get(res.Body(), "data", "token").ToString()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue