From 7ecedd8e578bdf56849d7653dd7f64ab10682a97 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Fri, 29 May 2026 14:31:31 +0800 Subject: [PATCH] fix: restore clean go test baseline --- .gitignore | 2 ++ controller/pricing.go | 11 +++++------ web/dist/index.html | 11 +++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 web/dist/index.html diff --git a/.gitignore b/.gitignore index 5276e01..3dda40f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ build *.db-journal logs web/dist +!web/dist/ +!web/dist/index.html .env one-api new-api diff --git a/controller/pricing.go b/controller/pricing.go index 4d69b02..ea41bad 100644 --- a/controller/pricing.go +++ b/controller/pricing.go @@ -177,15 +177,14 @@ func formatDiscount(ratio float64) string { if ratio <= 0 { return "免费" } - discount := int(math.Round(ratio * 10)) - if discount >= 10 { + rawDiscount := math.Round(ratio*100) / 10 + if rawDiscount >= 10 { return "" } - remainder := int(math.Round(ratio*100)) % 10 - if remainder == 0 { - return fmt.Sprintf("%d折", discount) + if rawDiscount == math.Trunc(rawDiscount) { + return fmt.Sprintf("%.0f折", rawDiscount) } - return fmt.Sprintf("%.1f折", ratio*10) + return fmt.Sprintf("%.1f折", rawDiscount) } func ResetModelRatio(c *gin.Context) { diff --git a/web/dist/index.html b/web/dist/index.html new file mode 100644 index 0000000..b2d0d5b --- /dev/null +++ b/web/dist/index.html @@ -0,0 +1,11 @@ + + + + + + new-api + + +
Frontend assets are not built in this checkout.
+ +