feat(listing): 极品专区改为无门槛可见
This commit is contained in:
@@ -172,8 +172,6 @@ type PublicListQuery struct {
|
|||||||
MaxSecretKD *float64
|
MaxSecretKD *float64
|
||||||
ResourceRanges map[string]NumberRange
|
ResourceRanges map[string]NumberRange
|
||||||
DistributionSiteCode string
|
DistributionSiteCode string
|
||||||
ViewerUserID uint64
|
|
||||||
CanViewPremium bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NumberRange struct {
|
type NumberRange struct {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"hfb_sys/backend/internal/middleware"
|
|
||||||
filemodule "hfb_sys/backend/internal/modules/file"
|
filemodule "hfb_sys/backend/internal/modules/file"
|
||||||
"hfb_sys/backend/internal/sitecode"
|
"hfb_sys/backend/internal/sitecode"
|
||||||
"hfb_sys/backend/pkg/response"
|
"hfb_sys/backend/pkg/response"
|
||||||
@@ -14,7 +13,6 @@ import (
|
|||||||
|
|
||||||
func (h *Handler) ListPublic(c *gin.Context) {
|
func (h *Handler) ListPublic(c *gin.Context) {
|
||||||
query := parsePublicListQuery(c)
|
query := parsePublicListQuery(c)
|
||||||
query.ViewerUserID = optionalCurrentUserID(c)
|
|
||||||
items, err := h.service.ListPublic(c.Request.Context(), query)
|
items, err := h.service.ListPublic(c.Request.Context(), query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeListingError(c, err)
|
writeListingError(c, err)
|
||||||
@@ -29,7 +27,7 @@ func (h *Handler) FindPublic(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
siteCode := sitecode.FromRequest(c)
|
siteCode := sitecode.FromRequest(c)
|
||||||
item, err := h.service.FindPublic(c.Request.Context(), id, siteCode, optionalCurrentUserID(c))
|
item, err := h.service.FindPublic(c.Request.Context(), id, siteCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeListingError(c, err)
|
writeListingError(c, err)
|
||||||
return
|
return
|
||||||
@@ -37,15 +35,6 @@ func (h *Handler) FindPublic(c *gin.Context) {
|
|||||||
response.OK(c, item)
|
response.OK(c, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionalCurrentUserID(c *gin.Context) uint64 {
|
|
||||||
value, ok := c.Get(middleware.ContextUserID)
|
|
||||||
if !ok {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
userID, _ := value.(uint64)
|
|
||||||
return userID
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Handler) Cover(c *gin.Context) {
|
func (h *Handler) Cover(c *gin.Context) {
|
||||||
id, ok := parseID(c)
|
id, ok := parseID(c)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -2,34 +2,17 @@ package listing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hfb_sys/backend/internal/database"
|
"hfb_sys/backend/internal/database"
|
||||||
"hfb_sys/backend/internal/model"
|
"hfb_sys/backend/internal/model"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPremiumListingOnlyVisibleToPlatinumUsers(t *testing.T) {
|
func TestPremiumListingVisibleWithoutGrowthLevel(t *testing.T) {
|
||||||
db := database.NewTestDB()
|
db := database.NewTestDB()
|
||||||
if err := database.MigrateListingLifecycleTestSchema(db); err != nil {
|
if err := database.MigrateListingLifecycleTestSchema(db); err != nil {
|
||||||
t.Fatalf("migrate listing schema: %v", err)
|
t.Fatalf("migrate listing schema: %v", err)
|
||||||
}
|
}
|
||||||
if err := database.AutoMigrateIfMissing(db, &model.User{}, &model.SystemConfig{}); err != nil {
|
|
||||||
t.Fatalf("migrate user schema: %v", err)
|
|
||||||
}
|
|
||||||
users := []model.User{
|
|
||||||
{Phone: "13900001101", RenterGrowthLevel: "normal"},
|
|
||||||
{
|
|
||||||
Phone: "13900001102",
|
|
||||||
RenterGrowthLevel: "platinum",
|
|
||||||
RenterGrowthLevelOverride: "platinum",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if err := db.Create(&users).Error; err != nil {
|
|
||||||
t.Fatalf("create users: %v", err)
|
|
||||||
}
|
|
||||||
account := model.GameAccount{Title: "极品账号", GameName: "delta", Status: "active", HafCoinAmount: 100_000_000}
|
account := model.GameAccount{Title: "极品账号", GameName: "delta", Status: "active", HafCoinAmount: 100_000_000}
|
||||||
if err := db.Create(&account).Error; err != nil {
|
if err := db.Create(&account).Error; err != nil {
|
||||||
t.Fatalf("create account: %v", err)
|
t.Fatalf("create account: %v", err)
|
||||||
@@ -49,34 +32,23 @@ func TestPremiumListingOnlyVisibleToPlatinumUsers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
repo := NewRepository(db, nil)
|
repo := NewRepository(db, nil)
|
||||||
|
|
||||||
anonymous, err := repo.ListPublic(context.Background(), PublicListQuery{})
|
list, err := repo.ListPublic(context.Background(), PublicListQuery{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("anonymous ListPublic: %v", err)
|
t.Fatalf("ListPublic: %v", err)
|
||||||
}
|
}
|
||||||
if len(anonymous.Items) != 0 || anonymous.Total != 0 || anonymous.ZoneCounts["premium"] != 0 {
|
if len(list.Items) != 1 || list.Total != 1 || list.ZoneCounts["premium"] != 1 {
|
||||||
t.Fatalf("anonymous should not see premium listing: %+v", anonymous)
|
t.Fatalf("premium listing should be public: %+v", list)
|
||||||
}
|
}
|
||||||
|
|
||||||
regular, err := repo.ListPublic(context.Background(), PublicListQuery{ViewerUserID: users[0].ID})
|
premiumZone, err := repo.ListPublic(context.Background(), PublicListQuery{Zone: "premium"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("regular ListPublic: %v", err)
|
t.Fatalf("premium zone ListPublic: %v", err)
|
||||||
}
|
}
|
||||||
if len(regular.Items) != 0 || regular.Total != 0 {
|
if len(premiumZone.Items) != 1 || premiumZone.Total != 1 || premiumZone.ZoneCounts["premium"] != 1 {
|
||||||
t.Fatalf("regular user should not see premium listing: %+v", regular)
|
t.Fatalf("premium zone should be public: %+v", premiumZone)
|
||||||
}
|
}
|
||||||
|
|
||||||
platinum, err := repo.ListPublic(context.Background(), PublicListQuery{ViewerUserID: users[1].ID})
|
if _, err := repo.FindPublic(context.Background(), item.ID, ""); err != nil {
|
||||||
if err != nil {
|
t.Fatalf("premium detail should be public: %v", err)
|
||||||
t.Fatalf("platinum ListPublic: %v", err)
|
|
||||||
}
|
|
||||||
if len(platinum.Items) != 1 || platinum.Total != 1 || platinum.ZoneCounts["premium"] != 1 {
|
|
||||||
t.Fatalf("platinum user should see premium listing: %+v", platinum)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := repo.FindPublic(context.Background(), item.ID, "", users[0].ID); !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
t.Fatalf("regular detail error = %v, want record not found", err)
|
|
||||||
}
|
|
||||||
if _, err := repo.FindPublic(context.Background(), item.ID, "", users[1].ID); err != nil {
|
|
||||||
t.Fatalf("platinum should see premium detail: %v", err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ func filterPublicListings(items []ListingDTO, query PublicListQuery) []ListingDT
|
|||||||
}
|
}
|
||||||
|
|
||||||
func matchesPublicQuery(item ListingDTO, query PublicListQuery) bool {
|
func matchesPublicQuery(item ListingDTO, query PublicListQuery) bool {
|
||||||
if item.IsPremium && !query.CanViewPremium {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if !matchesPublicZone(item, query.Zone) {
|
if !matchesPublicZone(item, query.Zone) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ package listing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hfb_sys/backend/internal/database"
|
|
||||||
"hfb_sys/backend/internal/model"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFilterPublicListingsByRatio(t *testing.T) {
|
func TestFilterPublicListingsByRatio(t *testing.T) {
|
||||||
@@ -37,34 +34,10 @@ func TestMatchesPublicZonePremium(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPremiumListingRequiresPremiumLevelVisibility(t *testing.T) {
|
func TestPremiumListingMatchesPublicQueryWithoutAccessGate(t *testing.T) {
|
||||||
premium := ListingDTO{ID: 1, IsPremium: true}
|
premium := ListingDTO{ID: 1, IsPremium: true}
|
||||||
if matchesPublicQuery(premium, PublicListQuery{}) {
|
if !matchesPublicQuery(premium, PublicListQuery{}) {
|
||||||
t.Fatal("未授权用户不应匹配极品专区账号")
|
t.Fatal("极品专区账号应匹配公开查询")
|
||||||
}
|
|
||||||
if !matchesPublicQuery(premium, PublicListQuery{CanViewPremium: true}) {
|
|
||||||
t.Fatal("铂金及以上用户应匹配极品专区账号")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCanViewPremiumUsesEffectiveUserLevel(t *testing.T) {
|
|
||||||
db := database.NewTestDB()
|
|
||||||
if err := database.AutoMigrateIfMissing(db, &model.User{}, &model.SystemConfig{}); err != nil {
|
|
||||||
t.Fatalf("migrate failed: %v", err)
|
|
||||||
}
|
|
||||||
users := []model.User{
|
|
||||||
{Phone: "13900001001", RenterGrowthLevel: "normal"},
|
|
||||||
{Phone: "13900001002", RenterGrowthLevel: "platinum", RenterGrowthLevelOverride: "platinum"},
|
|
||||||
}
|
|
||||||
if err := db.Create(&users).Error; err != nil {
|
|
||||||
t.Fatalf("create users failed: %v", err)
|
|
||||||
}
|
|
||||||
repo := NewRepository(db, nil)
|
|
||||||
if allowed, err := repo.canViewPremium(t.Context(), users[0].ID); err != nil || allowed {
|
|
||||||
t.Fatalf("普通用户可见性 = %v, err = %v, want false", allowed, err)
|
|
||||||
}
|
|
||||||
if allowed, err := repo.canViewPremium(t.Context(), users[1].ID); err != nil || !allowed {
|
|
||||||
t.Fatalf("铂金用户可见性 = %v, err = %v, want true", allowed, err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hfb_sys/backend/internal/model"
|
"hfb_sys/backend/internal/model"
|
||||||
"hfb_sys/backend/internal/modules/rentergrowth"
|
|
||||||
"hfb_sys/backend/internal/tenancy"
|
"hfb_sys/backend/internal/tenancy"
|
||||||
|
|
||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
@@ -15,11 +14,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (r *Repository) ListPublic(ctx context.Context, query PublicListQuery) (*PublicListResult, error) {
|
func (r *Repository) ListPublic(ctx context.Context, query PublicListQuery) (*PublicListResult, error) {
|
||||||
canViewPremium, err := r.canViewPremium(ctx, query.ViewerUserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
query.CanViewPremium = canViewPremium
|
|
||||||
page, pageSize := normalizedPublicPage(query)
|
page, pageSize := normalizedPublicPage(query)
|
||||||
if canListPublicWithSQL(query) {
|
if canListPublicWithSQL(query) {
|
||||||
return r.listPublicPage(ctx, query, page, pageSize)
|
return r.listPublicPage(ctx, query, page, pageSize)
|
||||||
@@ -34,8 +28,7 @@ func (r *Repository) ListPublic(ctx context.Context, query PublicListQuery) (*Pu
|
|||||||
}
|
}
|
||||||
|
|
||||||
var rows []listingRow
|
var rows []listingRow
|
||||||
db = applyPremiumVisibility(db, query)
|
err := db.Order("l.published_at DESC, l.id DESC").
|
||||||
err = db.Order("l.published_at DESC, l.id DESC").
|
|
||||||
Scan(&rows).Error
|
Scan(&rows).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -81,7 +74,7 @@ func (r *Repository) ListPublic(ctx context.Context, query PublicListQuery) (*Pu
|
|||||||
func (r *Repository) listPublicPage(ctx context.Context, query PublicListQuery, page int, pageSize int) (*PublicListResult, error) {
|
func (r *Repository) listPublicPage(ctx context.Context, query PublicListQuery, page int, pageSize int) (*PublicListResult, error) {
|
||||||
var total int64
|
var total int64
|
||||||
countDB := applyTenantOfferVisibility(ctx, r.db.WithContext(ctx).Table("rental_listings AS l"))
|
countDB := applyTenantOfferVisibility(ctx, r.db.WithContext(ctx).Table("rental_listings AS l"))
|
||||||
if err := applyPremiumVisibility(countDB, query).
|
if err := countDB.
|
||||||
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
||||||
Count(&total).Error; err != nil {
|
Count(&total).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -90,7 +83,7 @@ func (r *Repository) listPublicPage(ctx context.Context, query PublicListQuery,
|
|||||||
var rows []listingRow
|
var rows []listingRow
|
||||||
offset := (page - 1) * pageSize
|
offset := (page - 1) * pageSize
|
||||||
dataDB := applyTenantOfferVisibility(ctx, r.baseQuery(ctx))
|
dataDB := applyTenantOfferVisibility(ctx, r.baseQuery(ctx))
|
||||||
err := applyPublicSQLSort(ctx, applyPremiumVisibility(dataDB, query), query.Sort).
|
err := applyPublicSQLSort(ctx, dataDB, query.Sort).
|
||||||
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
||||||
Limit(pageSize).
|
Limit(pageSize).
|
||||||
Offset(offset).
|
Offset(offset).
|
||||||
@@ -98,14 +91,10 @@ func (r *Repository) listPublicPage(ctx context.Context, query PublicListQuery,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
zoneCounts, nonPremiumTotal, err := r.publicZoneCountsCached(ctx)
|
zoneCounts, err := r.publicZoneCountsCached(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !query.CanViewPremium {
|
|
||||||
zoneCounts["all"] = nonPremiumTotal
|
|
||||||
zoneCounts["premium"] = 0
|
|
||||||
}
|
|
||||||
items := publicListings(rowsToDTO(rows))
|
items := publicListings(rowsToDTO(rows))
|
||||||
if err := r.applyTenantOfferPrices(ctx, items); err != nil {
|
if err := r.applyTenantOfferPrices(ctx, items); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -119,13 +108,6 @@ func (r *Repository) listPublicPage(ctx context.Context, query PublicListQuery,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyPremiumVisibility(tx *gorm.DB, query PublicListQuery) *gorm.DB {
|
|
||||||
if query.CanViewPremium {
|
|
||||||
return tx
|
|
||||||
}
|
|
||||||
return tx.Where("l.is_premium = ?", false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func normalizedPublicPage(query PublicListQuery) (int, int) {
|
func normalizedPublicPage(query PublicListQuery) (int, int) {
|
||||||
page := query.Page
|
page := query.Page
|
||||||
if page <= 0 {
|
if page <= 0 {
|
||||||
@@ -209,7 +191,7 @@ func publicShuffleSeed() int64 {
|
|||||||
return int64(now.Year()*366 + now.YearDay())
|
return int64(now.Year()*366 + now.YearDay())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) publicZoneCountsCached(ctx context.Context) (map[string]int64, int64, error) {
|
func (r *Repository) publicZoneCountsCached(ctx context.Context) (map[string]int64, error) {
|
||||||
if tenancy.IDFromContext(ctx) > 0 {
|
if tenancy.IDFromContext(ctx) > 0 {
|
||||||
return r.computePublicZoneCounts(ctx)
|
return r.computePublicZoneCounts(ctx)
|
||||||
}
|
}
|
||||||
@@ -217,22 +199,21 @@ func (r *Repository) publicZoneCountsCached(ctx context.Context) (map[string]int
|
|||||||
r.publicZoneCountsMu.Lock()
|
r.publicZoneCountsMu.Lock()
|
||||||
defer r.publicZoneCountsMu.Unlock()
|
defer r.publicZoneCountsMu.Unlock()
|
||||||
if r.publicZoneCounts.Counts != nil && now.Before(r.publicZoneCounts.ExpiresAt) {
|
if r.publicZoneCounts.Counts != nil && now.Before(r.publicZoneCounts.ExpiresAt) {
|
||||||
return copyPublicZoneCounts(r.publicZoneCounts.Counts), r.publicZoneCounts.NonPremiumTotal, nil
|
return copyPublicZoneCounts(r.publicZoneCounts.Counts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
counts, nonPremiumTotal, err := r.computePublicZoneCounts(ctx)
|
counts, err := r.computePublicZoneCounts(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r.publicZoneCounts = publicZoneCountCache{
|
r.publicZoneCounts = publicZoneCountCache{
|
||||||
Counts: copyPublicZoneCounts(counts),
|
Counts: copyPublicZoneCounts(counts),
|
||||||
NonPremiumTotal: nonPremiumTotal,
|
|
||||||
ExpiresAt: now.Add(publicZoneCountCacheTTL),
|
ExpiresAt: now.Add(publicZoneCountCacheTTL),
|
||||||
}
|
}
|
||||||
return counts, nonPremiumTotal, nil
|
return counts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) computePublicZoneCounts(ctx context.Context) (map[string]int64, int64, error) {
|
func (r *Repository) computePublicZoneCounts(ctx context.Context) (map[string]int64, error) {
|
||||||
var rows []publicZoneRow
|
var rows []publicZoneRow
|
||||||
query := applyTenantOfferVisibility(ctx, r.db.WithContext(ctx).Table("rental_listings AS l"))
|
query := applyTenantOfferVisibility(ctx, r.db.WithContext(ctx).Table("rental_listings AS l"))
|
||||||
err := query.
|
err := query.
|
||||||
@@ -241,7 +222,7 @@ func (r *Repository) computePublicZoneCounts(ctx context.Context) (map[string]in
|
|||||||
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
Where("l.status = ? AND l.review_status = ? AND l.in_transaction = ?", "published", "approved", false).
|
||||||
Scan(&rows).Error
|
Scan(&rows).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, err
|
||||||
}
|
}
|
||||||
counts := map[string]int64{
|
counts := map[string]int64{
|
||||||
"all": int64(len(rows)),
|
"all": int64(len(rows)),
|
||||||
@@ -252,7 +233,6 @@ func (r *Repository) computePublicZoneCounts(ctx context.Context) (map[string]in
|
|||||||
"highCoin": 0,
|
"highCoin": 0,
|
||||||
"premium": 0,
|
"premium": 0,
|
||||||
}
|
}
|
||||||
var nonPremiumTotal int64
|
|
||||||
for _, row := range rows {
|
for _, row := range rows {
|
||||||
summary := decodeAssetSummary(row.AssetSummary)
|
summary := decodeAssetSummary(row.AssetSummary)
|
||||||
if isAcceleratedSale(summary) {
|
if isAcceleratedSale(summary) {
|
||||||
@@ -272,11 +252,9 @@ func (r *Repository) computePublicZoneCounts(ctx context.Context) (map[string]in
|
|||||||
}
|
}
|
||||||
if row.IsPremium {
|
if row.IsPremium {
|
||||||
counts["premium"]++
|
counts["premium"]++
|
||||||
} else {
|
|
||||||
nonPremiumTotal++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return counts, nonPremiumTotal, nil
|
return counts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyPublicZoneCounts(counts map[string]int64) map[string]int64 {
|
func copyPublicZoneCounts(counts map[string]int64) map[string]int64 {
|
||||||
@@ -287,7 +265,7 @@ func copyPublicZoneCounts(counts map[string]int64) map[string]int64 {
|
|||||||
return copied
|
return copied
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) FindPublic(ctx context.Context, id uint64, siteCode string, viewerUserID uint64) (*ListingDTO, error) {
|
func (r *Repository) FindPublic(ctx context.Context, id uint64, siteCode string) (*ListingDTO, error) {
|
||||||
var row listingRow
|
var row listingRow
|
||||||
query := applyTenantOfferVisibility(ctx, r.baseQuery(ctx)).
|
query := applyTenantOfferVisibility(ctx, r.baseQuery(ctx)).
|
||||||
Where("l.id = ? AND l.status = ? AND l.review_status = ? AND l.in_transaction = ?", id, "published", "approved", false)
|
Where("l.id = ? AND l.status = ? AND l.review_status = ? AND l.in_transaction = ?", id, "published", "approved", false)
|
||||||
@@ -295,15 +273,6 @@ func (r *Repository) FindPublic(ctx context.Context, id uint64, siteCode string,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dto := row.toDTO()
|
dto := row.toDTO()
|
||||||
if dto.IsPremium {
|
|
||||||
canView, err := r.canViewPremium(ctx, viewerUserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !canView {
|
|
||||||
return nil, gorm.ErrRecordNotFound
|
|
||||||
}
|
|
||||||
}
|
|
||||||
applyPublicListingURLs(&dto)
|
applyPublicListingURLs(&dto)
|
||||||
items := []ListingDTO{dto}
|
items := []ListingDTO{dto}
|
||||||
if err := r.applyTenantOfferPrices(ctx, items); err != nil {
|
if err := r.applyTenantOfferPrices(ctx, items); err != nil {
|
||||||
@@ -356,30 +325,6 @@ func (r *Repository) applyTenantOfferPrices(ctx context.Context, items []Listing
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Repository) canViewPremium(ctx context.Context, userID uint64) (bool, error) {
|
|
||||||
if userID == 0 {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
var user model.User
|
|
||||||
if err := r.db.WithContext(ctx).
|
|
||||||
Select("id, renter_growth_points, renter_growth_level_override").
|
|
||||||
First(&user, userID).Error; err != nil {
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
cfg, err := rentergrowth.ConfigForTx(r.db.WithContext(ctx))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
level := rentergrowth.EffectiveLevelForUser(cfg, user.RenterGrowthPoints, user.RenterGrowthLevelOverride)
|
|
||||||
if !cfg.Enabled && user.RenterGrowthLevelOverride == "" {
|
|
||||||
level = rentergrowth.LevelForPoints(cfg, 0)
|
|
||||||
}
|
|
||||||
return rentergrowth.CanViewPremiumLevel(level.Code), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Repository) applyShelfMarkup(ctx context.Context, siteCode string, items []ListingDTO) error {
|
func (r *Repository) applyShelfMarkup(ctx context.Context, siteCode string, items []ListingDTO) error {
|
||||||
if siteCode == "" || len(items) == 0 {
|
if siteCode == "" || len(items) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ func (r *Repository) IsQualityOwner(ctx context.Context, userID uint64) (bool, e
|
|||||||
|
|
||||||
type publicZoneCountCache struct {
|
type publicZoneCountCache struct {
|
||||||
Counts map[string]int64
|
Counts map[string]int64
|
||||||
NonPremiumTotal int64
|
|
||||||
ExpiresAt time.Time
|
ExpiresAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ func (s *Service) ListMine(ctx context.Context, ownerID uint64, siteCode ...stri
|
|||||||
return s.repo.ListMine(ctx, ownerID, siteCode...)
|
return s.repo.ListMine(ctx, ownerID, siteCode...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) FindPublic(ctx context.Context, id uint64, siteCode string, viewerUserID uint64) (*ListingDTO, error) {
|
func (s *Service) FindPublic(ctx context.Context, id uint64, siteCode string) (*ListingDTO, error) {
|
||||||
if s.repo == nil {
|
if s.repo == nil {
|
||||||
return nil, ErrDependencyUnavailable
|
return nil, ErrDependencyUnavailable
|
||||||
}
|
}
|
||||||
return s.repo.FindPublic(ctx, id, siteCode, viewerUserID)
|
return s.repo.FindPublic(ctx, id, siteCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) FindPublicCoverKey(ctx context.Context, id uint64) (string, error) {
|
func (s *Service) FindPublicCoverKey(ctx context.Context, id uint64) (string, error) {
|
||||||
|
|||||||
@@ -1021,14 +1021,14 @@ func TestListPublicWithDistributionSiteCode(t *testing.T) {
|
|||||||
t.Fatalf("expected public price 12500 with ratio delta, got %d", res.Items[0].PriceCent)
|
t.Fatalf("expected public price 12500 with ratio delta, got %d", res.Items[0].PriceCent)
|
||||||
}
|
}
|
||||||
|
|
||||||
detail, err := repo.FindPublic(context.Background(), l1.ID, "site_alpha", 0)
|
detail, err := repo.FindPublic(context.Background(), l1.ID, "site_alpha")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("FindPublic err: %v", err)
|
t.Fatalf("FindPublic err: %v", err)
|
||||||
}
|
}
|
||||||
if detail.PriceCent != 12500 {
|
if detail.PriceCent != 12500 {
|
||||||
t.Fatalf("expected detail price 12500 with ratio delta, got %d", detail.PriceCent)
|
t.Fatalf("expected detail price 12500 with ratio delta, got %d", detail.PriceCent)
|
||||||
}
|
}
|
||||||
mainDetail, err := repo.FindPublic(context.Background(), l1.ID, "", 0)
|
mainDetail, err := repo.FindPublic(context.Background(), l1.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("FindPublic main err: %v", err)
|
t.Fatalf("FindPublic main err: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func TestPublicListingUsesCurrentTenantOffer(t *testing.T) {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if _, err := repo.FindPublic(listingTenantContext(jieyou.ID), listing.ID, "", 0); err == nil {
|
if _, err := repo.FindPublic(listingTenantContext(jieyou.ID), listing.ID, ""); err == nil {
|
||||||
t.Fatal("disabled tenant offer must hide listing detail")
|
t.Fatal("disabled tenant offer must hide listing detail")
|
||||||
}
|
}
|
||||||
if _, err := repo.FindPublicScreenshotKey(listingTenantContext(jieyou.ID), listing.ID, 0); err == nil {
|
if _, err := repo.FindPublicScreenshotKey(listingTenantContext(jieyou.ID), listing.ID, 0); err == nil {
|
||||||
@@ -206,7 +206,7 @@ func TestPublicListingSharedPoolUsesTenantOffers(t *testing.T) {
|
|||||||
if dachuiResult.Total != 1 || dachuiResult.Items[0].ID != listing.ID {
|
if dachuiResult.Total != 1 || dachuiResult.Items[0].ID != listing.ID {
|
||||||
t.Fatalf("linked distribution listing not visible to dachui: %+v", dachuiResult)
|
t.Fatalf("linked distribution listing not visible to dachui: %+v", dachuiResult)
|
||||||
}
|
}
|
||||||
if _, err := repo.FindPublic(listingTenantContext(dachui.ID), listing.ID, "", 0); err != nil {
|
if _, err := repo.FindPublic(listingTenantContext(dachui.ID), listing.ID, ""); err != nil {
|
||||||
t.Fatalf("linked distribution listing detail should be visible to dachui: %v", err)
|
t.Fatalf("linked distribution listing detail should be visible to dachui: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ func TestPublicListingSharedPoolUsesTenantOffers(t *testing.T) {
|
|||||||
if jieyouResult.Total != 1 || jieyouResult.Items[0].ID != listing.ID {
|
if jieyouResult.Total != 1 || jieyouResult.Items[0].ID != listing.ID {
|
||||||
t.Fatalf("shared distribution listing not visible to jieyou: %+v", jieyouResult)
|
t.Fatalf("shared distribution listing not visible to jieyou: %+v", jieyouResult)
|
||||||
}
|
}
|
||||||
if _, err := repo.FindPublic(listingTenantContext(jieyou.ID), listing.ID, "", 0); err != nil {
|
if _, err := repo.FindPublic(listingTenantContext(jieyou.ID), listing.ID, ""); err != nil {
|
||||||
t.Fatalf("shared distribution listing detail should be visible to jieyou: %v", err)
|
t.Fatalf("shared distribution listing detail should be visible to jieyou: %v", err)
|
||||||
}
|
}
|
||||||
if _, err := repo.FindTenantOffer(listingTenantContext(dachui.ID), listing.ID); err != nil {
|
if _, err := repo.FindTenantOffer(listingTenantContext(dachui.ID), listing.ID); err != nil {
|
||||||
@@ -241,7 +241,7 @@ func TestPublicListingSharedPoolUsesTenantOffers(t *testing.T) {
|
|||||||
if otherResult.Total != 0 {
|
if otherResult.Total != 0 {
|
||||||
t.Fatalf("distribution listing leaked to tenant without offer: %+v", otherResult)
|
t.Fatalf("distribution listing leaked to tenant without offer: %+v", otherResult)
|
||||||
}
|
}
|
||||||
if _, err := repo.FindPublic(listingTenantContext(other.ID), listing.ID, "", 0); err == nil {
|
if _, err := repo.FindPublic(listingTenantContext(other.ID), listing.ID, ""); err == nil {
|
||||||
t.Fatal("distribution listing detail must not be visible without tenant offer")
|
t.Fatal("distribution listing detail must not be visible without tenant offer")
|
||||||
}
|
}
|
||||||
if _, err := repo.UpdateTenantOffer(listingTenantContext(other.ID), listing.ID, UpdateTenantListingOfferRequest{
|
if _, err := repo.UpdateTenantOffer(listingTenantContext(other.ID), listing.ID, UpdateTenantListingOfferRequest{
|
||||||
|
|||||||
@@ -46,12 +46,8 @@ import HomeFilters from '../components/HomeFilters.vue'
|
|||||||
import HomeZones from '../components/HomeZones.vue'
|
import HomeZones from '../components/HomeZones.vue'
|
||||||
import ListingCard from '../components/ListingCard.vue'
|
import ListingCard from '../components/ListingCard.vue'
|
||||||
import { mapDistributionHomeBanners, useDistributionSiteStore } from '@/stores/distributionSite'
|
import { mapDistributionHomeBanners, useDistributionSiteStore } from '@/stores/distributionSite'
|
||||||
import { useSessionStore } from '@/stores/session'
|
|
||||||
import { canViewPremiumZone } from '@/shared/utils/growthLevel'
|
|
||||||
|
|
||||||
const siteStore = useDistributionSiteStore()
|
const siteStore = useDistributionSiteStore()
|
||||||
const session = useSessionStore()
|
|
||||||
const canViewPremium = computed(() => canViewPremiumZone(session.renterGrowthLevel))
|
|
||||||
|
|
||||||
const announcements = ref<string[]>(defaultHomeAnnouncements)
|
const announcements = ref<string[]>(defaultHomeAnnouncements)
|
||||||
const displayAnnouncements = computed(() => {
|
const displayAnnouncements = computed(() => {
|
||||||
@@ -169,14 +165,6 @@ const activeZone = ref('all')
|
|||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
watch(canViewPremium, allowed => {
|
|
||||||
if (!allowed && activeZone.value === 'premium') {
|
|
||||||
activeZone.value = 'all'
|
|
||||||
}
|
|
||||||
pcHomeCache.clearList()
|
|
||||||
void loadListingsPage(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
filters,
|
filters,
|
||||||
regionOptions,
|
regionOptions,
|
||||||
@@ -204,9 +192,6 @@ const {
|
|||||||
restoreSnapshot,
|
restoreSnapshot,
|
||||||
getSnapshot,
|
getSnapshot,
|
||||||
} = useListingQuery(filters, sortBy, activeZone)
|
} = useListingQuery(filters, sortBy, activeZone)
|
||||||
const visibleListings = computed(() =>
|
|
||||||
canViewPremium.value ? listings.value : listings.value.filter(item => !item.is_premium)
|
|
||||||
)
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.query,
|
() => route.query,
|
||||||
@@ -244,7 +229,7 @@ const statCards = computed(() => {
|
|||||||
hint: '交接更快',
|
hint: '交接更快',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
return canViewPremium.value ? cards : cards.filter(card => card.key !== 'premium')
|
return cards
|
||||||
})
|
})
|
||||||
|
|
||||||
const zoneOptions = computed(() => {
|
const zoneOptions = computed(() => {
|
||||||
@@ -292,7 +277,7 @@ const zoneOptions = computed(() => {
|
|||||||
count: zoneCount('highCoin'),
|
count: zoneCount('highCoin'),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
return canViewPremium.value ? zones : zones.filter(zone => zone.key !== 'premium')
|
return zones
|
||||||
})
|
})
|
||||||
|
|
||||||
async function loadHome() {
|
async function loadHome() {
|
||||||
@@ -387,7 +372,6 @@ function applyRouteQueryToHomeState() {
|
|||||||
function desktopHomeStateSignature() {
|
function desktopHomeStateSignature() {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
filters: buildDesktopHomeQueryValues(),
|
filters: buildDesktopHomeQueryValues(),
|
||||||
premiumAccess: canViewPremium.value,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +680,7 @@ if (!restored) {
|
|||||||
<el-empty v-else description="暂无展示图片" />
|
<el-empty v-else description="暂无展示图片" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<section v-if="canViewPremium" class="premium-spotlight" aria-label="优质号主精选">
|
<section class="premium-spotlight" aria-label="优质号主精选">
|
||||||
<div class="premium-spotlight-mark">
|
<div class="premium-spotlight-mark">
|
||||||
<el-icon :size="24"><Trophy /></el-icon>
|
<el-icon :size="24"><Trophy /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
@@ -755,16 +739,16 @@ if (!restored) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="!loading && visibleListings.length === 0" class="home-empty-state">
|
<div v-if="!loading && listings.length === 0" class="home-empty-state">
|
||||||
<strong>没有符合条件的账号</strong>
|
<strong>没有符合条件的账号</strong>
|
||||||
<span>可以放宽筛选条件或切回全部专区。</span>
|
<span>可以放宽筛选条件或切回全部专区。</span>
|
||||||
<button type="button" @click="handleResetFilters">重置条件</button>
|
<button type="button" @click="handleResetFilters">重置条件</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else v-loading="loading" class="enhanced-desktop-list">
|
<div v-else v-loading="loading" class="enhanced-desktop-list">
|
||||||
<ListingCard v-for="item in visibleListings" :key="item.id" :listing="item" />
|
<ListingCard v-for="item in listings" :key="item.id" :listing="item" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="!loading && visibleListings.length" class="infinite-load-state">
|
<div v-if="!loading && listings.length" class="infinite-load-state">
|
||||||
<span v-if="loadingMore">正在加载更多账号...</span>
|
<span v-if="loadingMore">正在加载更多账号...</span>
|
||||||
<span v-else-if="!hasMoreListings">已经到底了</span>
|
<span v-else-if="!hasMoreListings">已经到底了</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -75,12 +75,10 @@ import {
|
|||||||
import { buildMobileHomeListSignature, useMobileHomeCacheStore } from '@/stores/mobileHomeCache'
|
import { buildMobileHomeListSignature, useMobileHomeCacheStore } from '@/stores/mobileHomeCache'
|
||||||
import { mapDistributionHomeBanners, useDistributionSiteStore } from '@/stores/distributionSite'
|
import { mapDistributionHomeBanners, useDistributionSiteStore } from '@/stores/distributionSite'
|
||||||
import { useSessionStore } from '@/stores/session'
|
import { useSessionStore } from '@/stores/session'
|
||||||
import { canViewPremiumZone } from '@/shared/utils/growthLevel'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const session = useSessionStore()
|
const session = useSessionStore()
|
||||||
const canViewPremium = computed(() => canViewPremiumZone(session.renterGrowthLevel))
|
|
||||||
const siteStore = useDistributionSiteStore()
|
const siteStore = useDistributionSiteStore()
|
||||||
const homeCache = useMobileHomeCacheStore()
|
const homeCache = useMobileHomeCacheStore()
|
||||||
const { run: runBannerAction } = useBannerAction()
|
const { run: runBannerAction } = useBannerAction()
|
||||||
@@ -172,7 +170,7 @@ const sortOptions: MobileSortOption[] = [
|
|||||||
{ key: 'published', label: '最新发布', shortLabel: '最新发布' },
|
{ key: 'published', label: '最新发布', shortLabel: '最新发布' },
|
||||||
]
|
]
|
||||||
|
|
||||||
const allZoneOptions = [
|
const zoneOptions = [
|
||||||
{ key: 'all', label: '全部', hint: '当前可租' },
|
{ key: 'all', label: '全部', hint: '当前可租' },
|
||||||
{ key: 'premium', label: '极品', hint: '优质号主精选' },
|
{ key: 'premium', label: '极品', hint: '优质号主精选' },
|
||||||
{ key: 'sale', label: '特惠', hint: '价格更划算' },
|
{ key: 'sale', label: '特惠', hint: '价格更划算' },
|
||||||
@@ -181,9 +179,6 @@ const allZoneOptions = [
|
|||||||
{ key: 'password', label: '账密', hint: '交接更快' },
|
{ key: 'password', label: '账密', hint: '交接更快' },
|
||||||
{ key: 'highCoin', label: '高币', hint: '100M以上' },
|
{ key: 'highCoin', label: '高币', hint: '100M以上' },
|
||||||
]
|
]
|
||||||
const zoneOptions = computed(() =>
|
|
||||||
canViewPremium.value ? allZoneOptions : allZoneOptions.filter(zone => zone.key !== 'premium')
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 统一使用领域层导出的预设区间,保证与桌面端完全一致 */
|
/** 统一使用领域层导出的预设区间,保证与桌面端完全一致 */
|
||||||
const rangePresets = defaultRangePresets
|
const rangePresets = defaultRangePresets
|
||||||
@@ -328,33 +323,15 @@ const activeFilterCount = computed(() => {
|
|||||||
return chipCount + rangeCount
|
return chipCount + rangeCount
|
||||||
})
|
})
|
||||||
|
|
||||||
const displayListings = computed(() => {
|
|
||||||
return canViewPremium.value ? listings.value : listings.value.filter(item => !item.is_premium)
|
|
||||||
})
|
|
||||||
|
|
||||||
const visibleZoneOptions = computed(() =>
|
const visibleZoneOptions = computed(() =>
|
||||||
zoneOptions.value.map(zone => {
|
zoneOptions.map(zone => ({
|
||||||
const count =
|
|
||||||
!canViewPremium.value && zone.key === 'all'
|
|
||||||
? Math.max(Number(zoneCounts.value.all || 0) - Number(zoneCounts.value.premium || 0), 0)
|
|
||||||
: zoneCount(zone.key)
|
|
||||||
return {
|
|
||||||
...zone,
|
...zone,
|
||||||
count,
|
count: zoneCount(zone.key),
|
||||||
}
|
}))
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
applyRouteQueryToMobileState()
|
applyRouteQueryToMobileState()
|
||||||
|
|
||||||
watch(canViewPremium, allowed => {
|
|
||||||
homeCache.clearList()
|
|
||||||
if (!allowed && activeZone.value === 'premium') {
|
|
||||||
activeZone.value = 'all'
|
|
||||||
}
|
|
||||||
void loadListings(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
function currentListSignature() {
|
function currentListSignature() {
|
||||||
return buildMobileHomeListSignature({
|
return buildMobileHomeListSignature({
|
||||||
searchValue: searchValue.value,
|
searchValue: searchValue.value,
|
||||||
@@ -362,7 +339,6 @@ function currentListSignature() {
|
|||||||
activeZone: activeZone.value,
|
activeZone: activeZone.value,
|
||||||
selectedFilters: selectedFilters.value,
|
selectedFilters: selectedFilters.value,
|
||||||
rangeFilters: rangeFilters.value,
|
rangeFilters: rangeFilters.value,
|
||||||
premiumAccess: canViewPremium.value,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +675,7 @@ function applyRouteQueryToMobileState() {
|
|||||||
const nextSearch = readQueryString(query, 'keyword')
|
const nextSearch = readQueryString(query, 'keyword')
|
||||||
const nextSort = readQueryString(query, 'sort') || 'recommended'
|
const nextSort = readQueryString(query, 'sort') || 'recommended'
|
||||||
const requestedZone = readQueryString(query, 'zone') || 'all'
|
const requestedZone = readQueryString(query, 'zone') || 'all'
|
||||||
const nextZone = requestedZone === 'premium' && !canViewPremium.value ? 'all' : requestedZone
|
const nextZone = requestedZone
|
||||||
const nextFilters = normalizeSelectedFilters(
|
const nextFilters = normalizeSelectedFilters(
|
||||||
decodeHomeQueryJson<Record<string, unknown>>(query, 'filters', {})
|
decodeHomeQueryJson<Record<string, unknown>>(query, 'filters', {})
|
||||||
)
|
)
|
||||||
@@ -1042,7 +1018,6 @@ if (!restoreHomeConfigFromCache()) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="canViewPremium"
|
|
||||||
type="button"
|
type="button"
|
||||||
class="mobile-premium-spotlight"
|
class="mobile-premium-spotlight"
|
||||||
aria-label="进入优质号主极品专区"
|
aria-label="进入优质号主极品专区"
|
||||||
@@ -1115,7 +1090,7 @@ if (!restoreHomeConfigFromCache()) {
|
|||||||
text="接口暂不可用,请稍后刷新。"
|
text="接口暂不可用,请稍后刷新。"
|
||||||
/>
|
/>
|
||||||
<van-empty
|
<van-empty
|
||||||
v-else-if="displayListings.length === 0"
|
v-else-if="listings.length === 0"
|
||||||
class="mobile-empty"
|
class="mobile-empty"
|
||||||
image="search"
|
image="search"
|
||||||
description="没有符合条件的账号"
|
description="没有符合条件的账号"
|
||||||
@@ -1126,7 +1101,7 @@ if (!restoreHomeConfigFromCache()) {
|
|||||||
<!-- 列表卡片:现代结构化卡片(对齐PC首页体验) -->
|
<!-- 列表卡片:现代结构化卡片(对齐PC首页体验) -->
|
||||||
<div class="mobile-list">
|
<div class="mobile-list">
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-for="item in displayListings"
|
v-for="item in listings"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="mobile-card"
|
class="mobile-card"
|
||||||
:to="`/m/listings/${item.id}`"
|
:to="`/m/listings/${item.id}`"
|
||||||
@@ -1290,7 +1265,7 @@ if (!restoreHomeConfigFromCache()) {
|
|||||||
</div>
|
</div>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!loading && displayListings.length" class="mobile-load-state">
|
<div v-if="!loading && listings.length" class="mobile-load-state">
|
||||||
<span v-if="loadingMore">正在加载更多账号...</span>
|
<span v-if="loadingMore">正在加载更多账号...</span>
|
||||||
<span v-else-if="!hasMoreListings">已经到底了</span>
|
<span v-else-if="!hasMoreListings">已经到底了</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
import { describe, expect, it } from 'vitest'
|
|
||||||
|
|
||||||
import { canViewPremiumZone } from '../growthLevel'
|
|
||||||
|
|
||||||
describe('canViewPremiumZone', () => {
|
|
||||||
it('仅铂金及以上等级可以查看极品专区', () => {
|
|
||||||
expect(canViewPremiumZone('normal')).toBe(false)
|
|
||||||
expect(canViewPremiumZone('')).toBe(false)
|
|
||||||
expect(canViewPremiumZone('platinum')).toBe(true)
|
|
||||||
expect(canViewPremiumZone('diamond')).toBe(true)
|
|
||||||
expect(canViewPremiumZone('peak')).toBe(true)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
const premiumZoneLevels = new Set(['platinum', 'diamond', 'peak'])
|
|
||||||
|
|
||||||
export function canViewPremiumZone(levelCode: string | undefined | null) {
|
|
||||||
return premiumZoneLevels.has(String(levelCode || '').trim())
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,6 @@ export function buildMobileHomeListSignature(input: {
|
|||||||
activeZone: string
|
activeZone: string
|
||||||
selectedFilters: Record<string, string[]>
|
selectedFilters: Record<string, string[]>
|
||||||
rangeFilters: MobileHomeRangeFilters
|
rangeFilters: MobileHomeRangeFilters
|
||||||
premiumAccess: boolean
|
|
||||||
}) {
|
}) {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
keyword: input.searchValue.trim(),
|
keyword: input.searchValue.trim(),
|
||||||
@@ -32,7 +31,6 @@ export function buildMobileHomeListSignature(input: {
|
|||||||
zone: input.activeZone,
|
zone: input.activeZone,
|
||||||
selected: input.selectedFilters,
|
selected: input.selectedFilters,
|
||||||
ranges: input.rangeFilters,
|
ranges: input.rangeFilters,
|
||||||
premiumAccess: input.premiumAccess,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user