parent
ab0465a9a1
commit
7f846ef707
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
21
main.go
21
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("未检测到有效用户信息,将采用登录模式")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/xxqg/build/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/static/xxqg/build/logo192.png"/><link rel="manifest" href="/static/xxqg/build/manifest.json"/><title>Study XXQG</title><script defer="defer" src="/static/xxqg/build/static/js/main.34367272.js"></script><link href="/static/xxqg/build/static/css/main.6f1e3389.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/static/xxqg/build/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/static/xxqg/build/logo192.png"/><link rel="manifest" href="/static/xxqg/build/manifest.json"/><title>Study XXQG</title><script defer="defer" src="/static/xxqg/build/static/js/main.8720e9a4.js"></script><link href="/static/xxqg/build/static/css/main.6f1e3389.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -3,8 +3,9 @@ import './App.css';
|
|||
import {Button, Dialog, Divider, Form, Input, List, Modal, NavBar, Popup, TextArea, Toast,} from "antd-mobile";
|
||||
import {UnorderedListOutline} from "antd-mobile-icons";
|
||||
import {ListItem} from "antd-mobile/es/components/list/list-item";
|
||||
import {checkQrCode, getLog, getScore, getToken, getUsers, getLink, stopStudy, study, login, checkToken} from "./utils/api";
|
||||
import {checkQrCode, getLog, getScore, getToken, getUsers, getLink, stopStudy, study, login, checkToken,getAbout} from "./utils/api";
|
||||
import QrCode from 'qrcode.react';
|
||||
import * as util from "util";
|
||||
|
||||
|
||||
class App extends React.Component<any, any> {
|
||||
|
@ -95,12 +96,12 @@ class Login extends Component<any, any>{
|
|||
|
||||
onFinish = (value:string)=>{
|
||||
login(JSON.stringify(value)).then(resp => {
|
||||
console.log(resp)
|
||||
console.log(resp.message)
|
||||
if (resp.success){
|
||||
window.localStorage.setItem("xxqg_token",resp.data)
|
||||
this.props.parent.set_login()
|
||||
}else {
|
||||
Dialog.show(resp.message)
|
||||
Dialog.alert({content: resp.message,closeOnMaskClick:false})
|
||||
}
|
||||
|
||||
})
|
||||
|
@ -253,9 +254,26 @@ class Log extends Component<any, any>{
|
|||
}
|
||||
|
||||
class Help extends Component<any, any> {
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.state = {
|
||||
about: ""
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
getAbout().then((value)=>{
|
||||
this.setState({
|
||||
about:value.data
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
render() {
|
||||
return <>
|
||||
<h2 style={{margin:10}}>项目地址:<a href="https://github.com/johlanse/study_xxqg">https://github.com/johlanse/study_xxqg</a></h2>
|
||||
<br/><h2 style={{margin:10}}>{this.state.about}</h2>
|
||||
</>
|
||||
}
|
||||
}
|
||||
|
@ -366,6 +384,11 @@ class Users extends Component<any, any>{
|
|||
</>
|
||||
)
|
||||
}
|
||||
if (this.state.users.length === 0){
|
||||
elements.push(<>
|
||||
<span style={{color:"red"}}>未获取到有效用户</span>
|
||||
</>)
|
||||
}
|
||||
|
||||
return <List>{elements}</List>;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
module.exports = function(app) {
|
||||
app.use("/api",createProxyMiddleware({
|
||||
target: "http://127.0.0.1:8083",
|
||||
target: "http://127.0.0.1:8085",
|
||||
changeOrigin: true,
|
||||
pathRewrite:{
|
||||
"/api":"/"
|
||||
|
|
|
@ -28,6 +28,8 @@ export async function checkToken() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function login(data) {
|
||||
let responseData = await http.post(base+"/auth/login",data);
|
||||
return responseData.data;
|
||||
|
@ -46,6 +48,11 @@ export async function checkQrCode(code) {
|
|||
return resp.data
|
||||
}
|
||||
|
||||
export async function getAbout(){
|
||||
let resp = await http.get(base+"/about");
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
export async function getToken(code,sign){
|
||||
let resp = await http.post(base+"/user/",{
|
||||
"code":code,
|
||||
|
@ -55,7 +62,7 @@ export async function getToken(code,sign){
|
|||
}
|
||||
|
||||
export async function getUsers(){
|
||||
let resp = await http.get(base+"/user/");
|
||||
let resp = await http.get(base+"/user");
|
||||
return resp.data
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class Http {
|
|||
(value)=>{
|
||||
if (value.headers !== null){
|
||||
// @ts-ignore
|
||||
value.headers.xxqg_token = localStorage.getItem("xxqg_token")
|
||||
value.headers.Authorization = "Bearer "+localStorage.getItem("xxqg_token")
|
||||
}
|
||||
return value
|
||||
},()=>{
|
||||
|
|
Loading…
Reference in New Issue