feat: 完善代理池与抢购链路,发布 0.5.0

This commit is contained in:
yml
2026-11-20 00:48:21 +08:00
parent 2f087ac7f1
commit 98b3dc4b16
28 changed files with 1522 additions and 204 deletions
+12 -4
View File
@@ -29,7 +29,11 @@ func (a *App) loadProducts(refresh bool, accountNames []string) types.ProductPay
options := types.XiaodianProductListOptions{PageSize: cfg.XiaodianPageSize}
var products []types.Product
err := fmt.Errorf("没有可用账号 Cookie")
accounts := productRefreshAccounts(a.scheduler.AccountSnapshot(), accountNames)
scheduler := a.getScheduler()
if scheduler == nil {
return types.ProductPayload{Success: false}
}
accounts := productRefreshAccounts(scheduler.AccountSnapshot(), accountNames)
for _, account := range accounts {
products, err = a.getClient().Products(account.Cookie, options)
if err == nil {
@@ -75,7 +79,11 @@ func productRefreshAccounts(accounts []types.Account, preferredNames []string) [
// GetAccounts 返回账号列表。
func (a *App) GetAccounts() []types.AccountView {
accounts := a.scheduler.AccountSnapshot()
scheduler := a.getScheduler()
if scheduler == nil {
return []types.AccountView{}
}
accounts := scheduler.AccountSnapshot()
list := make([]types.AccountView, 0, len(accounts))
for i, account := range accounts {
list = append(list, types.AccountView{
@@ -100,8 +108,8 @@ func (a *App) setProducts(products []types.Product, fetchedAt time.Time) {
a.products = products
a.productsAt = fetchedAt
a.productsMu.Unlock()
if a.scheduler != nil {
a.scheduler.UpdateProducts(products)
if scheduler := a.getScheduler(); scheduler != nil {
scheduler.UpdateProducts(products)
}
}