From d5157a779c285bf02af9d52e5fb455955a39229a Mon Sep 17 00:00:00 2001 From: fengsilin Date: Thu, 23 Apr 2026 12:20:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(pricing):=20=E7=BB=9F=E4=B8=80=20sort=5Ford?= =?UTF-8?q?er=20=E6=8E=92=E5=BA=8F=E9=80=BB=E8=BE=91=EF=BC=8C=E6=9C=89=20m?= =?UTF-8?q?eta=20=E4=BD=86=E6=9C=AA=E8=AE=BE=E7=BD=AE=E7=9A=84=E4=B8=8D?= =?UTF-8?q?=E4=BC=98=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前有 meta 记录但 sort_order=999999 的模型排在没 meta 记录的模型前面, 导致部分"未设置排序"的模型仍然挤在前面。现在统一处理:不论是否有 meta 记录,sort_order=999999 的都视为未设置,排在后面。 Co-Authored-By: Claude Opus 4.7 --- model/pricing.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/model/pricing.go b/model/pricing.go index c38b3e6..b483f61 100644 --- a/model/pricing.go +++ b/model/pricing.go @@ -336,18 +336,20 @@ func updatePricing() { pricingMap = append(pricingMap, pricing) } - // 按 sort_order 排序 pricingMap + // 按 sort_order 排序 pricingMap,999999 视为未设置 sort.Slice(pricingMap, func(i, j int) bool { mi, okI := metaMap[pricingMap[i].ModelName] mj, okJ := metaMap[pricingMap[j].ModelName] - if okI && okJ { - if mi.SortOrder != mj.SortOrder { - return mi.SortOrder < mj.SortOrder - } - } else if okI { - return true - } else if okJ { - return false + si := 999999 + sj := 999999 + if okI { + si = mi.SortOrder + } + if okJ { + sj = mj.SortOrder + } + if si != sj { + return si < sj } return pricingMap[i].ModelName < pricingMap[j].ModelName })