diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 7798064..91b44da 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -200,7 +200,7 @@ try {
-
diff --git a/internal/api/api.go b/internal/api/api.go
index 7ab9eeb..61adeb7 100644
--- a/internal/api/api.go
+++ b/internal/api/api.go
@@ -64,7 +64,19 @@ func UploadDataToServer(ctx context.Context, data string) error {
secUserId := strings.Split(data, "----")[1]
hasVideo, err := CheckHasVideo(secUserId)
if err != nil {
- return err
+ for err != nil {
+ fmt.Println("抖音请求api重试")
+ //定时器定时100毫秒
+ ticker := time.NewTicker(100 * time.Millisecond)
+
+ select {
+ case <-ctx.Done():
+ return err
+ case <-ticker.C:
+ ticker.Stop()
+ hasVideo, err = CheckHasVideo(secUserId)
+ }
+ }
}
if hasVideo {
params.Set("token", config.APPConfig.HasVideoToken)
@@ -97,8 +109,9 @@ func UploadDataToServer(ctx context.Context, data string) error {
return err
}
+var douYinClient = &http.Client{}
+
func CheckHasVideo(secUserId string) (bool, error) {
- client := &http.Client{}
req, err := http.NewRequest(
"GET",
"https://imdesktop.douyin.com/aweme/v1/web/user/profile/other/?sec_user_id="+secUserId,
@@ -114,7 +127,7 @@ func CheckHasVideo(secUserId string) (bool, error) {
req.Header.Add("Host", "imdesktop.douyin.com")
req.Header.Add("Connection", "keep-alive")
- res, err := client.Do(req)
+ res, err := douYinClient.Do(req)
if err != nil {
fmt.Println(err)
return false, err
diff --git a/main.go b/main.go
index 47d9eae..c4c4121 100644
--- a/main.go
+++ b/main.go
@@ -30,7 +30,7 @@ func main() {
},
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
OnStartup: app.startup,
- Bind: []interface{}{
+ Bind: []any{
app,
},
})