修复检版本比较出现错误的问题

This commit is contained in:
johlanse 2022-08-21 22:36:36 +08:00
parent fa9849c081
commit ab0465a9a1
4 changed files with 12 additions and 12 deletions

View File

@ -39,10 +39,6 @@ jobs:
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: 1.18 go-version: 1.18
- name: Check snapshot
if: "!startsWith(github.ref, 'refs/tags/')"
id: snapshot
run: echo '::set-output name=ARG::--snapshot'
- name: Build binary file - name: Build binary file
env: env:
@ -54,7 +50,7 @@ jobs:
if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi if [ $GOOS = "windows" ]; then export BINARY_SUFFIX="$BINARY_SUFFIX.exe"; fi
if $IS_PR ; then echo $PR_PROMPT; fi if $IS_PR ; then echo $PR_PROMPT; fi
export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX" export BINARY_NAME="$BINARY_PREFIX$GOOS_$GOARCH$BINARY_SUFFIX"
export LD_FLAGS="-w -s -X main.VERSION=${{steps.snapshot.outputs.ARG}}" export LD_FLAGS="-w -s -X main.VERSION=unknown"
go mod tidy go mod tidy
go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./ go build -o "output/$BINARY_NAME" -trimpath -ldflags "$LD_FLAGS" ./
- name: Upload artifact - name: Upload artifact

View File

@ -17,7 +17,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: '1.17.2' go-version: '1.18'
- name: Run GoReleaser - name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2 uses: goreleaser/goreleaser-action@v2

View File

@ -3,12 +3,10 @@
package model package model
import ( import (
"math/rand"
"net/http" "net/http"
"sync" "sync"
"time" "time"
"github.com/imroc/req/v3"
"github.com/playwright-community/playwright-go" "github.com/playwright-community/playwright-go"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
@ -209,8 +207,6 @@ func AddUser(user *User) error {
* @return error * @return error
*/ */
func UpdateUser(user *User) error { func UpdateUser(user *User) error {
lock.Lock()
defer lock.Unlock()
ping() ping()
_, err := db.Exec("update user set token=?,login_time=?,push_id=?,status=1 where uid = ?", user.Token, user.LoginTime, user.PushId, user.UID) _, err := db.Exec("update user set token=?,login_time=?,push_id=?,status=1 where uid = ?", user.Token, user.LoginTime, user.PushId, user.UID)
if err != nil { if err != nil {
@ -311,7 +307,7 @@ func check() {
for { for {
users, _ := Query() users, _ := Query()
for _, user := range users { for _, user := range users {
response, _ := req.R().SetCookies(user.ToCookies()...).Get("https://pc-api.xuexi.cn/open/api/auth/check") response, _ := utils.GetClient().R().SetCookies(user.ToCookies()...).Get("https://pc-api.xuexi.cn/open/api/auth/check")
token := "" token := ""
for _, cookie := range response.Cookies() { for _, cookie := range response.Cookies() {
if cookie.Name == "token" { if cookie.Name == "token" {
@ -321,8 +317,9 @@ func check() {
if token != "" { if token != "" {
user.Token = token user.Token = token
_ = UpdateUser(user) _ = UpdateUser(user)
log.Infoln("用户" + user.Nick + "的ck已成功保活cookie")
} }
} }
time.Sleep(time.Hour * time.Duration(rand.Intn(2)+1)) time.Sleep(time.Hour * time.Duration(2))
} }
} }

View File

@ -87,6 +87,13 @@ func versionCompare(nowVersion, lastVersion string) bool {
if nowMainIntVersion < lastMainIntVersion { if nowMainIntVersion < lastMainIntVersion {
return true return true
} }
if strings.Contains(nowVersion, "SNAPSHOT") {
if nowMainIntVersion == lastMainIntVersion {
return false
} else {
return true
}
}
// 如果最新版本是beta // 如果最新版本是beta
if LastBeta { if LastBeta {
// 如果当前版本也是beta // 如果当前版本也是beta