diff --git a/lib/core.go b/lib/core.go index 49b5e69..18df8bf 100644 --- a/lib/core.go +++ b/lib/core.go @@ -240,7 +240,7 @@ func (c *Core) L(retryTimes int, pushID string) (*model.User, error) { } // 等待几分钟后重新执行 time.Sleep(time.Duration(conf.GetConfig().Retry.Intervals) * time.Minute) - c.Push(pushID, "text", fmt.Sprintf("登录超时,将进行第%d重新次登录", retryTimes)) + c.Push(pushID, "flush", fmt.Sprintf("登录超时,将进行第%d重新次登录", retryTimes)) return c.L(retryTimes-1, pushID) } diff --git a/main.go b/main.go index 5b87896..7c324f6 100644 --- a/main.go +++ b/main.go @@ -195,10 +195,7 @@ func do(m string) { getPush := push.GetPush(config) getPush("", "flush", "学习强国助手已上线") - failUser, _ := model.QueryFailUser() - for _, user := range failUser { - getPush(user.PushId, "flush", user.Nick+"的cookie已过期") - } + core := &lib.Core{ShowBrowser: config.ShowBrowser, Push: getPush} defer core.Quit() core.Init() @@ -241,6 +238,22 @@ func do(m string) { core2.Push(u.PushId, "flush", message) } + failUser, _ := model.QueryFailUser() + for _, user := range failUser { + go func(user2 *model.User) { + c := &lib.Core{Push: getPush, ShowBrowser: config.ShowBrowser} + getPush(user2.PushId, "flush", user2.Nick+"的cookie已过期") + newUser, err := c.L(config.Retry.Times, user2.PushId) + if err != nil { + c.Push(user2.PushId, "flush", "用户"+user2.Nick+"登录超时!") + return + } + c.Init() + defer c.Quit() + study(c, newUser) + }(user) + } + // 用户小于1时自动登录 if len(users) < 1 { log.Infoln("未检测到有效用户信息,将采用登录模式") diff --git a/web/controller.go b/web/controller.go index 8773037..884bcfd 100644 --- a/web/controller.go +++ b/web/controller.go @@ -229,8 +229,7 @@ func study() gin.HandlerFunc { user := model.Find(uid) core := &lib.Core{ ShowBrowser: conf.GetConfig().ShowBrowser, - Push: func(id string, kind, message string) { - }, + Push: push.GetPush(conf.GetConfig()), } core.Init() state.Store(uid, core) diff --git a/web/router.go b/web/router.go index b33bf31..ee2daec 100644 --- a/web/router.go +++ b/web/router.go @@ -5,6 +5,7 @@ package web import ( "embed" "net/http" + "strings" "github.com/gin-gonic/gin" @@ -32,7 +33,13 @@ func RouterInit() *gin.Engine { }) router.GET("/about", func(context *gin.Context) { - context.JSON(200, utils.GetAbout()) + context.JSON(200, Resp{ + Code: 200, + Message: "", + Data: utils.GetAbout(), + Success: true, + Error: "", + }) }) if utils.FileIsExist("./config/flutter_xxqg/") { @@ -78,10 +85,11 @@ func RouterInit() *gin.Engine { func check() gin.HandlerFunc { config := conf.GetConfig() return func(ctx *gin.Context) { - token := ctx.GetHeader("xxqg_token") + token := ctx.GetHeader("Authorization") + token = strings.Split(token, " ")[1] if token == "" || (utils.StrMd5(config.Web.Account+config.Web.Password) != token) { - ctx.JSON(403, Resp{ - Code: 403, + ctx.JSON(401, Resp{ + Code: 401, Message: "the auth fail", Data: nil, Success: false, diff --git a/web/xxqg/build/asset-manifest.json b/web/xxqg/build/asset-manifest.json index 3a2d30e..6d49057 100644 --- a/web/xxqg/build/asset-manifest.json +++ b/web/xxqg/build/asset-manifest.json @@ -1,15 +1,15 @@ { "files": { "main.css": "/static/xxqg/build/static/css/main.6f1e3389.css", - "main.js": "/static/xxqg/build/static/js/main.34367272.js", + "main.js": "/static/xxqg/build/static/js/main.8720e9a4.js", "static/js/787.273d6ce9.chunk.js": "/static/xxqg/build/static/js/787.273d6ce9.chunk.js", "index.html": "/static/xxqg/build/index.html", "main.6f1e3389.css.map": "/static/xxqg/build/static/css/main.6f1e3389.css.map", - "main.34367272.js.map": "/static/xxqg/build/static/js/main.34367272.js.map", + "main.8720e9a4.js.map": "/static/xxqg/build/static/js/main.8720e9a4.js.map", "787.273d6ce9.chunk.js.map": "/static/xxqg/build/static/js/787.273d6ce9.chunk.js.map" }, "entrypoints": [ "static/css/main.6f1e3389.css", - "static/js/main.34367272.js" + "static/js/main.8720e9a4.js" ] } \ No newline at end of file diff --git a/web/xxqg/build/home.html b/web/xxqg/build/home.html index c894729..66d2b03 100644 --- a/web/xxqg/build/home.html +++ b/web/xxqg/build/home.html @@ -1 +1 @@ -