Opt: fast get bilibili user info

pull/31/head
zijiren233 3 years ago
parent d8fcd70857
commit 92e29eb3a7

@ -25,13 +25,19 @@ func Me(ctx *gin.Context) {
ctx.AbortWithStatusJSON(http.StatusInternalServerError, model.NewApiErrorResp(err))
return
}
if len(vendor.Cookies) == 0 {
ctx.JSON(http.StatusOK, model.NewApiDataResp(&MeResp{
IsLogin: false,
}))
return
}
cli := bilibili.NewClient(vendor.Cookies)
nav, err := cli.UserInfo()
if err != nil {
ctx.AbortWithStatusJSON(http.StatusInternalServerError, model.NewApiErrorResp(err))
return
}
ctx.JSON(http.StatusOK, model.NewApiDataResp(MeResp{
ctx.JSON(http.StatusOK, model.NewApiDataResp(&MeResp{
IsLogin: nav.Data.IsLogin,
Username: nav.Data.Uname,
Face: nav.Data.Face,

Loading…
Cancel
Save