小店商品列表shujuok

This commit is contained in:
yml2213
2026-08-08 17:40:16 +08:00
parent 22dc50196f
commit 379a9d58d3
12 changed files with 2733 additions and 27 deletions
+3
View File
@@ -79,6 +79,9 @@ func (a *App) SaveSettings(cfg types.Config) types.SimpleResult {
if cfg.TraceMaxBody < 0 {
cfg.TraceMaxBody = 0
}
if cfg.XiaodianPageSize <= 0 || cfg.XiaodianPageSize > 200 {
cfg.XiaodianPageSize = 200
}
// 校验
if cfg.Concurrency <= 0 {
+17 -1
View File
@@ -1,6 +1,8 @@
package app
import (
"fmt"
"strings"
"time"
"douyu_go/internal/constants"
@@ -12,7 +14,21 @@ import (
// LoadProducts 刷新商品列表。refresh=true 时从斗鱼实时拉取。
func (a *App) LoadProducts(refresh bool) types.ProductPayload {
if refresh {
products, err := a.getClient().Products()
cfg := a.getCfg()
options := types.XiaodianProductListOptions{PageSize: cfg.XiaodianPageSize}
var products []types.Product
err := fmt.Errorf("没有可用账号 Cookie")
accounts := a.scheduler.AccountSnapshot()
for _, account := range accounts {
if strings.TrimSpace(account.Cookie) == "" {
continue
}
products, err = a.getClient().Products(account.Cookie, options)
if err == nil {
break
}
logger.LogEvent("商品", "warn", "账号 %s 获取和平小店角色失败,尝试下一个账号: %v", account.Name, err)
}
if err != nil {
logger.LogEvent("商品", "error", "商品刷新失败: %v", err)
return types.ProductPayload{Success: false}