From d465dc5bc81892eca244b8a3d4351d422dca79ea Mon Sep 17 00:00:00 2001 From: ranxi2001 Date: Sat, 21 Nov 2026 14:16:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E6=A8=A1=E5=9E=8B=E5=B9=BF?= =?UTF-8?q?=E5=9C=BA=E6=94=AF=E6=8C=81=E4=BA=BA=E6=B0=91=E5=B8=81=E7=BE=8E?= =?UTF-8?q?=E5=85=83=E5=88=87=E6=8D=A2=E4=B8=8E=E5=B1=95=E7=A4=BA=E6=B1=87?= =?UTF-8?q?=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 5 ++ .../internal/handler/admin/setting_handler.go | 1 + .../handler/admin/setting_handler_audit.go | 3 ++ .../handler/admin/setting_handler_update.go | 14 ++++-- backend/internal/handler/dto/settings.go | 9 ++-- .../internal/handler/model_plaza_handler.go | 12 +++-- .../handler/model_plaza_handler_test.go | 4 +- backend/internal/service/domain_constants.go | 3 +- .../internal/service/model_plaza_currency.go | 18 +++++++ .../service/model_plaza_currency_test.go | 36 ++++++++++++++ backend/internal/service/setting_parse.go | 2 + backend/internal/service/setting_public.go | 18 ++++--- .../service/setting_service_update_test.go | 16 +++++++ backend/internal/service/setting_update.go | 7 +++ backend/internal/service/settings_view.go | 9 ++-- frontend/src/api/admin/settings.ts | 2 + frontend/src/api/modelPlaza.ts | 4 ++ .../common/__tests__/NewFeatureBadge.spec.ts | 1 + .../modelPlaza/ModelPlazaContent.vue | 33 ++++++++++++- .../modelPlaza/PlazaGroupSection.vue | 3 ++ .../modelPlaza/PlazaModelPricingTable.vue | 19 ++++---- .../ModelPlazaContent.currency.spec.ts | 47 +++++++++++++++++++ .../__tests__/PlazaGroupSection.spec.ts | 8 ++++ .../__tests__/PlazaModelPricingTable.spec.ts | 16 +++++++ .../PlazaModelPricingTable.video.spec.ts | 12 ++++- frontend/src/constants/newFeatureNotices.ts | 1 + .../src/i18n/locales/en/admin/settings.ts | 2 + frontend/src/i18n/locales/en/dashboard.ts | 13 +++-- .../src/i18n/locales/zh/admin/settings.ts | 2 + frontend/src/i18n/locales/zh/dashboard.ts | 13 +++-- .../src/utils/__tests__/plazaCurrency.spec.ts | 22 +++++++++ .../__tests__/pricing.formatScaled.spec.ts | 4 ++ frontend/src/utils/plazaCurrency.ts | 21 +++++++++ frontend/src/utils/pricing.ts | 4 +- frontend/src/views/admin/SettingsView.vue | 12 +++++ 35 files changed, 355 insertions(+), 41 deletions(-) create mode 100644 backend/internal/service/model_plaza_currency.go create mode 100644 backend/internal/service/model_plaza_currency_test.go create mode 100644 frontend/src/components/modelPlaza/__tests__/ModelPlazaContent.currency.spec.ts create mode 100644 frontend/src/utils/__tests__/plazaCurrency.spec.ts create mode 100644 frontend/src/utils/plazaCurrency.ts diff --git a/Makefile b/Makefile index a455b210269c..455571efa514 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ .PHONY: build build-backend build-frontend test test-backend test-frontend test-frontend-critical FRONTEND_CRITICAL_VITEST := \ + src/utils/__tests__/plazaCurrency.spec.ts \ + src/components/modelPlaza/__tests__/ModelPlazaContent.currency.spec.ts \ + src/components/modelPlaza/__tests__/PlazaModelPricingTable.spec.ts \ + src/components/modelPlaza/__tests__/PlazaModelPricingTable.video.spec.ts \ + src/components/modelPlaza/__tests__/PlazaGroupSection.spec.ts \ src/components/common/__tests__/Select.spec.ts \ src/components/account/__tests__/AccountUsageCell.spec.ts \ src/views/admin/__tests__/ChannelsView.bedrockCompat.spec.ts \ diff --git a/backend/internal/handler/admin/setting_handler.go b/backend/internal/handler/admin/setting_handler.go index 18ddb5f6ebe2..80fccd8ce79b 100644 --- a/backend/internal/handler/admin/setting_handler.go +++ b/backend/internal/handler/admin/setting_handler.go @@ -428,6 +428,7 @@ func (h *SettingHandler) GetSettings(c *gin.Context) { ModelPlazaRequireAuth: settings.ModelPlazaRequireAuth, PluginManagementEnabled: settings.PluginManagementEnabled, ModelPlazaDescription: settings.ModelPlazaDescription, + ModelPlazaUSDToCNYRate: settings.ModelPlazaUSDToCNYRate, SupportTicketEnabled: settings.SupportTicketEnabled, SupportTicket: settings.SupportTicket, diff --git a/backend/internal/handler/admin/setting_handler_audit.go b/backend/internal/handler/admin/setting_handler_audit.go index 7b606e63e769..16e318e875a9 100644 --- a/backend/internal/handler/admin/setting_handler_audit.go +++ b/backend/internal/handler/admin/setting_handler_audit.go @@ -653,6 +653,9 @@ func diffSettings(before *service.SystemSettings, after *service.SystemSettings, if before.ModelPlazaRequireAuth != after.ModelPlazaRequireAuth { changed = append(changed, "model_plaza_require_auth") } + if before.ModelPlazaUSDToCNYRate != after.ModelPlazaUSDToCNYRate { + changed = append(changed, "model_plaza_usd_to_cny_rate") + } if before.ModelPlazaDescription != after.ModelPlazaDescription { changed = append(changed, "model_plaza_description") } diff --git a/backend/internal/handler/admin/setting_handler_update.go b/backend/internal/handler/admin/setting_handler_update.go index eefd0f7f95b7..c962b84b47ed 100644 --- a/backend/internal/handler/admin/setting_handler_update.go +++ b/backend/internal/handler/admin/setting_handler_update.go @@ -382,9 +382,10 @@ type UpdateSettingsRequest struct { SubscriptionEnabled *bool `json:"subscription_enabled"` // Model Plaza feature switches + description - ModelPlazaEnabled *bool `json:"model_plaza_enabled"` - ModelPlazaRequireAuth *bool `json:"model_plaza_require_auth"` - ModelPlazaDescription *string `json:"model_plaza_description"` + ModelPlazaEnabled *bool `json:"model_plaza_enabled"` + ModelPlazaRequireAuth *bool `json:"model_plaza_require_auth"` + ModelPlazaDescription *string `json:"model_plaza_description"` + ModelPlazaUSDToCNYRate *float64 `json:"model_plaza_usd_to_cny_rate" binding:"omitempty,gt=0"` // Plugin management menu visibility switch; plugin runtime is unaffected. PluginManagementEnabled *bool `json:"plugin_management_enabled"` @@ -2397,6 +2398,12 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) { } return previousSettings.ModelPlazaRequireAuth }(), + ModelPlazaUSDToCNYRate: func() float64 { + if req.ModelPlazaUSDToCNYRate != nil { + return *req.ModelPlazaUSDToCNYRate + } + return previousSettings.ModelPlazaUSDToCNYRate + }(), ModelPlazaDescription: func() string { if req.ModelPlazaDescription != nil { return *req.ModelPlazaDescription @@ -2890,6 +2897,7 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) { ModelPlazaEnabled: updatedSettings.ModelPlazaEnabled, ModelPlazaRequireAuth: updatedSettings.ModelPlazaRequireAuth, ModelPlazaDescription: updatedSettings.ModelPlazaDescription, + ModelPlazaUSDToCNYRate: updatedSettings.ModelPlazaUSDToCNYRate, PluginManagementEnabled: updatedSettings.PluginManagementEnabled, SupportTicketEnabled: updatedSettings.SupportTicketEnabled, diff --git a/backend/internal/handler/dto/settings.go b/backend/internal/handler/dto/settings.go index 60775ce8e330..816836de6333 100644 --- a/backend/internal/handler/dto/settings.go +++ b/backend/internal/handler/dto/settings.go @@ -358,10 +358,11 @@ type SystemSettings struct { SubscriptionEnabled bool `json:"subscription_enabled"` // Model Plaza feature (public group/model pricing showcase) - ModelPlazaEnabled bool `json:"model_plaza_enabled"` - ModelPlazaRequireAuth bool `json:"model_plaza_require_auth"` - ModelPlazaDescription string `json:"model_plaza_description"` - PluginManagementEnabled bool `json:"plugin_management_enabled"` + ModelPlazaEnabled bool `json:"model_plaza_enabled"` + ModelPlazaRequireAuth bool `json:"model_plaza_require_auth"` + ModelPlazaDescription string `json:"model_plaza_description"` + ModelPlazaUSDToCNYRate float64 `json:"model_plaza_usd_to_cny_rate"` + PluginManagementEnabled bool `json:"plugin_management_enabled"` // Support tickets ("网站工单") switch + form config SupportTicketEnabled bool `json:"support_ticket_enabled"` diff --git a/backend/internal/handler/model_plaza_handler.go b/backend/internal/handler/model_plaza_handler.go index 0dd524360a0e..0b8a2498a492 100644 --- a/backend/internal/handler/model_plaza_handler.go +++ b/backend/internal/handler/model_plaza_handler.go @@ -102,8 +102,10 @@ type modelPlazaGroup struct { // modelPlazaResponse 广场页响应。 type modelPlazaResponse struct { - Description string `json:"description"` - Groups []modelPlazaGroup `json:"groups"` + Description string `json:"description"` + USDToCNYRate float64 `json:"usd_to_cny_rate"` + CreditPerCNY float64 `json:"credit_per_cny"` + Groups []modelPlazaGroup `json:"groups"` } // Get 返回模型广场数据。 @@ -163,8 +165,10 @@ func (h *ModelPlazaHandler) Get(c *gin.Context) { c.Writer.Header().Add("Vary", "Accept-Language") out := toLocalizedModelPlazaGroups(visible, userRates, c.GetHeader("Accept-Language"), deniedModels) response.Success(c, modelPlazaResponse{ - Description: rt.Description, - Groups: out, + Description: rt.Description, + USDToCNYRate: rt.USDToCNYRate, + CreditPerCNY: rt.CreditPerCNY, + Groups: out, }) } diff --git a/backend/internal/handler/model_plaza_handler_test.go b/backend/internal/handler/model_plaza_handler_test.go index f70edb01e52e..2152d5f98caf 100644 --- a/backend/internal/handler/model_plaza_handler_test.go +++ b/backend/internal/handler/model_plaza_handler_test.go @@ -269,7 +269,7 @@ func TestFilterPlazaVisibleGroups_SubscribedExclusiveGroup(t *testing.T) { type plazaVarySettingRepo struct{ service.SettingRepository } func (plazaVarySettingRepo) GetMultiple(context.Context, []string) (map[string]string, error) { - return map[string]string{service.SettingKeyModelPlazaEnabled: "true"}, nil + return map[string]string{service.SettingKeyModelPlazaEnabled: "true", service.SettingKeyModelPlazaUSDToCNYRate: "7.2", service.SettingBalanceRechargeMult: "2"}, nil } type plazaVaryChannelRepo struct{ service.ChannelRepository } @@ -303,5 +303,7 @@ func TestModelPlazaHandler_VaryKeepsCORSOrigin(t *testing.T) { require.Equal(t, origin, w.Header().Get("Access-Control-Allow-Origin")) // 共享缓存需同时按来源与语言区分,否则 A 来源的响应可能被复用给 B。 require.Equal(t, []string{"Origin", "Accept-Language"}, w.Header().Values("Vary")) + require.Contains(t, w.Body.String(), `"usd_to_cny_rate":7.2`) + require.Contains(t, w.Body.String(), `"credit_per_cny":2`) } } diff --git a/backend/internal/service/domain_constants.go b/backend/internal/service/domain_constants.go index 821323431165..c9b38aedf8f7 100644 --- a/backend/internal/service/domain_constants.go +++ b/backend/internal/service/domain_constants.go @@ -592,7 +592,8 @@ const ( // SettingKeyModelPlazaDescription stores the Markdown blurb rendered at the top of // the Model Plaza page (global pricing notes, exchange rate, promotions, ...). - SettingKeyModelPlazaDescription = "model_plaza_description" + SettingKeyModelPlazaDescription = "model_plaza_description" + SettingKeyModelPlazaUSDToCNYRate = "model_plaza_usd_to_cny_rate" // SettingKeyPluginManagementEnabled controls sidebar visibility only; it does // not stop or otherwise change already loaded plugin runtimes. diff --git a/backend/internal/service/model_plaza_currency.go b/backend/internal/service/model_plaza_currency.go new file mode 100644 index 000000000000..7ae6dfc15e3d --- /dev/null +++ b/backend/internal/service/model_plaza_currency.go @@ -0,0 +1,18 @@ +package service + +import ( + "math" + "strconv" + "strings" +) + +// A configurable display reference, not a live FX quote or a billing rate. +const defaultModelPlazaUSDToCNYRate = 7.0 + +func modelPlazaUSDToCNYRate(raw string) float64 { + rate, err := strconv.ParseFloat(strings.TrimSpace(raw), 64) + if err != nil || rate <= 0 || math.IsNaN(rate) || math.IsInf(rate, 0) { + return defaultModelPlazaUSDToCNYRate + } + return rate +} diff --git a/backend/internal/service/model_plaza_currency_test.go b/backend/internal/service/model_plaza_currency_test.go new file mode 100644 index 000000000000..0d42c22fa866 --- /dev/null +++ b/backend/internal/service/model_plaza_currency_test.go @@ -0,0 +1,36 @@ +package service + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestModelPlazaCurrencyRuntime(t *testing.T) { + for _, tc := range []struct { + name, fx, credits string + wantFX, wantCredits float64 + }{ + {"legacy defaults", "", "", 7, 1}, + {"separate conversion rates", "7.2", "2", 7.2, 2}, + {"invalid stored values", "NaN", "-1", 7, 1}, + {"nonfinite stored values", "+Inf", "+Inf", 7, 1}, + {"zero", "0", "0", 7, 1}, + } { + t.Run(tc.name, func(t *testing.T) { + repo := &showcaseRuntimeSettingRepo{values: map[string]string{ + SettingKeyModelPlazaEnabled: "true", SettingKeyModelPlazaUSDToCNYRate: tc.fx, SettingBalanceRechargeMult: tc.credits, + }} + svc := &SettingService{settingRepo: repo} + got := svc.GetModelPlazaRuntime(context.Background()) + require.True(t, got.Enabled) + require.Equal(t, tc.wantFX, got.USDToCNYRate) + require.Equal(t, tc.wantCredits, got.CreditPerCNY) + require.Nil(t, repo.saved, "display lookup must not rewrite payment or pricing settings") + }) + } + svc := &SettingService{settingRepo: &showcaseRuntimeSettingRepo{readErr: errors.New("unavailable")}} + require.False(t, svc.GetModelPlazaRuntime(context.Background()).Enabled) +} diff --git a/backend/internal/service/setting_parse.go b/backend/internal/service/setting_parse.go index 41fe848f5c26..76d5161a75b4 100644 --- a/backend/internal/service/setting_parse.go +++ b/backend/internal/service/setting_parse.go @@ -237,6 +237,7 @@ func (s *SettingService) InitializeDefaultSettings(ctx context.Context) error { SettingKeyModelPlazaEnabled: "false", SettingKeyModelPlazaRequireAuth: "false", SettingKeyModelPlazaDescription: "", + SettingKeyModelPlazaUSDToCNYRate: strconv.FormatFloat(defaultModelPlazaUSDToCNYRate, 'f', -1, 64), SettingKeyPluginManagementEnabled: "false", // Support tickets (default disabled; opt-in). A missing config means the defaults. @@ -912,6 +913,7 @@ func (s *SettingService) parseSettings(settings map[string]string) *SystemSettin result.ModelPlazaEnabled = settings[SettingKeyModelPlazaEnabled] == "true" result.ModelPlazaRequireAuth = settings[SettingKeyModelPlazaRequireAuth] == "true" result.ModelPlazaDescription = settings[SettingKeyModelPlazaDescription] + result.ModelPlazaUSDToCNYRate = modelPlazaUSDToCNYRate(settings[SettingKeyModelPlazaUSDToCNYRate]) result.PluginManagementEnabled = settings[SettingKeyPluginManagementEnabled] == "true" // Support tickets (default: disabled; strict true). A corrupt config is shown as the diff --git a/backend/internal/service/setting_public.go b/backend/internal/service/setting_public.go index 9b5c9095f2b3..9bd07b982c64 100644 --- a/backend/internal/service/setting_public.go +++ b/backend/internal/service/setting_public.go @@ -563,9 +563,11 @@ func (s *SettingService) GetAvailableChannelsRuntime(ctx context.Context) Availa // ModelPlazaRuntime is the lightweight view of the model-plaza feature consumed // by the public plaza handler. type ModelPlazaRuntime struct { - Enabled bool - RequireAuth bool - Description string + Enabled bool + RequireAuth bool + Description string + USDToCNYRate float64 + CreditPerCNY float64 } // GetModelPlazaRuntime reads the model-plaza feature switches directly from the @@ -576,14 +578,18 @@ func (s *SettingService) GetModelPlazaRuntime(ctx context.Context) ModelPlazaRun SettingKeyModelPlazaEnabled, SettingKeyModelPlazaRequireAuth, SettingKeyModelPlazaDescription, + SettingKeyModelPlazaUSDToCNYRate, + SettingBalanceRechargeMult, }) if err != nil { return ModelPlazaRuntime{Enabled: false} } return ModelPlazaRuntime{ - Enabled: vals[SettingKeyModelPlazaEnabled] == "true", - RequireAuth: vals[SettingKeyModelPlazaRequireAuth] == "true", - Description: vals[SettingKeyModelPlazaDescription], + Enabled: vals[SettingKeyModelPlazaEnabled] == "true", + RequireAuth: vals[SettingKeyModelPlazaRequireAuth] == "true", + Description: vals[SettingKeyModelPlazaDescription], + USDToCNYRate: modelPlazaUSDToCNYRate(vals[SettingKeyModelPlazaUSDToCNYRate]), + CreditPerCNY: normalizeBalanceRechargeMultiplier(pcParseFloat(vals[SettingBalanceRechargeMult], defaultBalanceRechargeMultiplier)), } } diff --git a/backend/internal/service/setting_service_update_test.go b/backend/internal/service/setting_service_update_test.go index 79969f8154f7..e69976799b9f 100644 --- a/backend/internal/service/setting_service_update_test.go +++ b/backend/internal/service/setting_service_update_test.go @@ -928,3 +928,19 @@ func TestSettingService_StalePasskeyTrueWithoutConfigReportsDisabled(t *testing. require.NoError(t, err) require.False(t, settings.PasskeyEnabled) } + +func TestModelPlazaDisplayRateDoesNotWritePaymentSettings(t *testing.T) { + repo := &settingUpdateRepoStub{} + svc := NewSettingService(repo, &config.Config{}) + for _, rate := range []float64{7, 7.2} { + updates, err := svc.buildSystemSettingsUpdates(context.Background(), &SystemSettings{ModelPlazaUSDToCNYRate: rate}) + require.NoError(t, err) + require.Equal(t, strconv.FormatFloat(rate, 'f', -1, 64), updates[SettingKeyModelPlazaUSDToCNYRate]) + require.NotContains(t, updates, SettingBalanceRechargeMult) + require.NotContains(t, updates, SettingSubscriptionUSDToCNYRate) + } + for _, rate := range []float64{-1, math.NaN(), math.Inf(1)} { + _, err := svc.buildSystemSettingsUpdates(context.Background(), &SystemSettings{ModelPlazaUSDToCNYRate: rate}) + require.ErrorContains(t, err, "display rate") + } +} diff --git a/backend/internal/service/setting_update.go b/backend/internal/service/setting_update.go index 0c45cfa4d883..587644681eb6 100644 --- a/backend/internal/service/setting_update.go +++ b/backend/internal/service/setting_update.go @@ -527,6 +527,13 @@ func (s *SettingService) buildSystemSettingsUpdates(ctx context.Context, setting updates[SettingKeyModelPlazaEnabled] = strconv.FormatBool(settings.ModelPlazaEnabled) updates[SettingKeyModelPlazaRequireAuth] = strconv.FormatBool(settings.ModelPlazaRequireAuth) updates[SettingKeyModelPlazaDescription] = settings.ModelPlazaDescription + if settings.ModelPlazaUSDToCNYRate == 0 { + settings.ModelPlazaUSDToCNYRate = defaultModelPlazaUSDToCNYRate + } + if settings.ModelPlazaUSDToCNYRate < 0 || math.IsNaN(settings.ModelPlazaUSDToCNYRate) || math.IsInf(settings.ModelPlazaUSDToCNYRate, 0) { + return nil, infraerrors.BadRequest("INVALID_MODEL_PLAZA_DISPLAY_RATE", "model plaza USD to CNY display rate must be finite and positive") + } + updates[SettingKeyModelPlazaUSDToCNYRate] = strconv.FormatFloat(settings.ModelPlazaUSDToCNYRate, 'f', -1, 64) updates[SettingKeyPluginManagementEnabled] = strconv.FormatBool(settings.PluginManagementEnabled) // Support tickets switch + form config diff --git a/backend/internal/service/settings_view.go b/backend/internal/service/settings_view.go index f604961b8b44..3918c29eafbf 100644 --- a/backend/internal/service/settings_view.go +++ b/backend/internal/service/settings_view.go @@ -242,10 +242,11 @@ type SystemSettings struct { SubscriptionEnabled bool `json:"subscription_enabled"` // Model Plaza feature (public group/model pricing showcase) - ModelPlazaEnabled bool `json:"model_plaza_enabled"` - ModelPlazaRequireAuth bool `json:"model_plaza_require_auth"` - ModelPlazaDescription string `json:"model_plaza_description"` - PluginManagementEnabled bool `json:"plugin_management_enabled"` + ModelPlazaEnabled bool `json:"model_plaza_enabled"` + ModelPlazaRequireAuth bool `json:"model_plaza_require_auth"` + ModelPlazaDescription string `json:"model_plaza_description"` + ModelPlazaUSDToCNYRate float64 `json:"model_plaza_usd_to_cny_rate"` + PluginManagementEnabled bool `json:"plugin_management_enabled"` // Support tickets ("网站工单") switch + form config SupportTicketEnabled bool `json:"support_ticket_enabled"` diff --git a/frontend/src/api/admin/settings.ts b/frontend/src/api/admin/settings.ts index 79f4f693e2f2..4daa239b9149 100644 --- a/frontend/src/api/admin/settings.ts +++ b/frontend/src/api/admin/settings.ts @@ -777,6 +777,7 @@ export interface SystemSettings { model_plaza_enabled: boolean; model_plaza_require_auth: boolean; model_plaza_description: string; + model_plaza_usd_to_cny_rate?: number; plugin_management_enabled: boolean; // Support tickets (网站工单) switch + form config @@ -1139,6 +1140,7 @@ export interface UpdateSettingsRequest { model_plaza_enabled?: boolean; model_plaza_require_auth?: boolean; model_plaza_description?: string; + model_plaza_usd_to_cny_rate?: number; plugin_management_enabled?: boolean; // Support tickets (网站工单) switch + form config diff --git a/frontend/src/api/modelPlaza.ts b/frontend/src/api/modelPlaza.ts index a390107ce3c1..69c94e6fd9a2 100644 --- a/frontend/src/api/modelPlaza.ts +++ b/frontend/src/api/modelPlaza.ts @@ -83,6 +83,10 @@ export interface ModelPlazaGroup { } export interface ModelPlazaResponse { + /** Display reference only: CNY per real USD, independent of wallet credits. */ + usd_to_cny_rate?: number + /** Wallet credits received per CNY before recharge bonuses and fees. */ + credit_per_cny?: number /** 管理员配置的全局价格说明(Markdown)。 */ description: string groups: ModelPlazaGroup[] diff --git a/frontend/src/components/common/__tests__/NewFeatureBadge.spec.ts b/frontend/src/components/common/__tests__/NewFeatureBadge.spec.ts index 7f64a9cef5eb..af3d6a4b7f7f 100644 --- a/frontend/src/components/common/__tests__/NewFeatureBadge.spec.ts +++ b/frontend/src/components/common/__tests__/NewFeatureBadge.spec.ts @@ -23,6 +23,7 @@ describe('NewFeatureBadge', () => { it.each([ + ['model plaza currency', NEW_FEATURE_NOTICES.modelPlazaCurrency], ['image usage billing', NEW_FEATURE_NOTICES.imageUsageBilling], ['channel UltraFast pricing', NEW_FEATURE_NOTICES.channelUltrafastPricing], ['user live load', NEW_FEATURE_NOTICES.userLiveLoad], diff --git a/frontend/src/components/modelPlaza/ModelPlazaContent.vue b/frontend/src/components/modelPlaza/ModelPlazaContent.vue index 8ae7da49b551..8bfd43baac88 100644 --- a/frontend/src/components/modelPlaza/ModelPlazaContent.vue +++ b/frontend/src/components/modelPlaza/ModelPlazaContent.vue @@ -6,6 +6,26 @@

{{ t('modelPlaza.description') }}

+
+
+
+ {{ t('modelPlaza.currency.label') }} +
+ +
+
+ {{ t('modelPlaza.currency.reference', { rate: exchangeRateLabel }) }} +
+

+ {{ priceDisplay ? t('modelPlaza.currency.explanation', { credits: priceDisplay.creditPerCny }) : t('modelPlaza.currency.unavailable') }} +

+
+
- +
authStore.isAuthenticated) +const currency = ref('CNY') +const currencies: PlazaCurrency[] = ['CNY', 'USD'] +const priceDisplay = computed(() => { + const usdToCny = props.response?.usd_to_cny_rate + const creditPerCny = props.response?.credit_per_cny + if (!hasPlazaCurrencyRates(usdToCny, creditPerCny)) return undefined + return { currency: currency.value, usdToCny: usdToCny!, creditPerCny: creditPerCny! } +}) +const exchangeRateLabel = computed(() => priceDisplay.value?.usdToCny.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 6 })) + const selectedPlatform = ref('all') const selectedGroupId = ref('all') const selectedRate = ref('all') diff --git a/frontend/src/components/modelPlaza/PlazaGroupSection.vue b/frontend/src/components/modelPlaza/PlazaGroupSection.vue index f748781fccb8..ccbe4ca868f7 100644 --- a/frontend/src/components/modelPlaza/PlazaGroupSection.vue +++ b/frontend/src/components/modelPlaza/PlazaGroupSection.vue @@ -56,6 +56,7 @@ () const { t } = useI18n() diff --git a/frontend/src/components/modelPlaza/PlazaModelPricingTable.vue b/frontend/src/components/modelPlaza/PlazaModelPricingTable.vue index 2f149cd3531c..10bed0050278 100644 --- a/frontend/src/components/modelPlaza/PlazaModelPricingTable.vue +++ b/frontend/src/components/modelPlaza/PlazaModelPricingTable.vue @@ -23,7 +23,7 @@
- {{ t('modelPlaza.table.paidPrice') }} + {{ t('modelPlaza.table.paidPrice') }} · {{ paidCurrencyLabel }} {{ t('modelPlaza.table.unitPerMillion') }}
@@ -32,7 +32,7 @@ class="border-l border-gray-100 pt-2 text-center dark:border-dark-700/60" >
- {{ t('modelPlaza.table.officialPrice') }} + {{ t('modelPlaza.table.officialPrice') }} · {{ officialCurrencyLabel }} {{ t('modelPlaza.table.unitPerMillion') }}
@@ -80,7 +80,7 @@ - {{ t('imageUsage.minimumBadge', { amount: m.pricing?.image_minimum_charge }) }} + {{ t('modelPlaza.currency.minimumCharge', { amount: formatPlazaPrice(m.pricing?.image_minimum_charge, 1, 'credit', props.priceDisplay) }) }} props.priceDisplay?.currency ?? t('modelPlaza.currency.credits')) +const officialCurrencyLabel = computed(() => props.priceDisplay?.currency ?? 'USD') /** 表格行:每个模型一行标准价;配置了分时倍率的模型再按时段各加一行。 */ interface PlazaRow { @@ -460,7 +463,7 @@ function periodRate(period: PlazaTimePricingPeriod): number { function paidPerMillion(value: number | null | undefined, period: PlazaTimePricingPeriod | null = null): string { if (value == null) return '-' const rate = period ? periodRate(period) : effectiveRate.value - return formatScaled(value * rate, PER_MILLION, MIN_DECIMALS) + return formatPlazaPrice(value * rate, PER_MILLION, 'credit', props.priceDisplay) } /** 图片和视频分别使用对应的独立倍率开关。 */ @@ -482,13 +485,13 @@ function requestRate(m: PlazaModel): number { /** 非 token 单价乘该行生效倍率,不换算为每百万 token。 */ function paidRequestPrice(m: PlazaModel, value: number | null | undefined): string { if (value == null) return '-' - return formatScaled(value * requestRate(m), 1, MIN_DECIMALS) + return formatPlazaPrice(value * requestRate(m), 1, 'credit', props.priceDisplay) } /** 官方参考价不乘倍率。 */ function official(value: number | null | undefined): string { if (value == null) return '-' - return formatScaled(value, PER_MILLION, MIN_DECIMALS) + return formatPlazaPrice(value, PER_MILLION, 'usd', props.priceDisplay) } /** 非 token 计费的单位后缀:按图片 → “/ 张”,按视频 → “/ 秒”,按次 → “/ 次”。 */ diff --git a/frontend/src/components/modelPlaza/__tests__/ModelPlazaContent.currency.spec.ts b/frontend/src/components/modelPlaza/__tests__/ModelPlazaContent.currency.spec.ts new file mode 100644 index 000000000000..e972ac781a7f --- /dev/null +++ b/frontend/src/components/modelPlaza/__tests__/ModelPlazaContent.currency.spec.ts @@ -0,0 +1,47 @@ +import { describe, expect, it, vi } from 'vitest' +import { mount } from '@vue/test-utils' +import { createI18n } from 'vue-i18n' +import ModelPlazaContent from '../ModelPlazaContent.vue' +import PlazaGroupSection from '../PlazaGroupSection.vue' +import type { ModelPlazaResponse } from '@/api/modelPlaza' +import zh from '@/i18n/locales/zh/dashboard' +import en from '@/i18n/locales/en/dashboard' + +vi.mock('@/stores/auth', () => ({ useAuthStore: () => ({ isAuthenticated: false }) })) + +const response: ModelPlazaResponse = { + description: '', usd_to_cny_rate: 7, credit_per_cny: 1, + groups: [{ id: 1, name: 'Demo', description: '', platform: 'deepseek', subscription_type: 'standard', rate_multiplier: 0.5, + peak_rate_enabled: false, peak_start: '', peak_end: '', peak_rate_multiplier: 1, is_exclusive: false, + image_rate_independent: false, image_rate_multiplier: 1, video_rate_independent: false, video_rate_multiplier: 1, + long_context_pricing_enabled: false, models: [] }] +} + +function render(data = response, locale = 'zh') { + return mount(ModelPlazaContent, { props: { response: data, loading: false }, global: { + plugins: [createI18n({ legacy: false, locale, messages: { zh, en } })], + stubs: { PlazaGroupSection: true, PlazaFilterBar: true, Icon: true } + } }) +} + +describe('ModelPlazaContent currency selection', () => { + it.each(['zh', 'en'])('switches all groups together and shows the conversion basis in %s', async locale => { + const wrapper = render(response, locale) + expect(wrapper.get('[data-currency="CNY"]').attributes('aria-pressed')).toBe('true') + expect(wrapper.text()).toContain('1 USD = 7.00 CNY') + expect(wrapper.findComponent(PlazaGroupSection).props('priceDisplay')).toEqual({ currency: 'CNY', usdToCny: 7, creditPerCny: 1 }) + await wrapper.get('[data-currency="USD"]').trigger('click') + expect(wrapper.get('[data-currency="USD"]').attributes('aria-pressed')).toBe('true') + expect(wrapper.findComponent(PlazaGroupSection).props('priceDisplay').currency).toBe('USD') + await wrapper.setProps({ response: { ...response, usd_to_cny_rate: 7.2, credit_per_cny: 2 } }) + expect(wrapper.findComponent(PlazaGroupSection).props('priceDisplay')).toEqual({ currency: 'USD', usdToCny: 7.2, creditPerCny: 2 }) + wrapper.unmount() + }) + it('keeps an old backend in explicitly labelled native units', () => { + const wrapper = render({ ...response, usd_to_cny_rate: undefined, credit_per_cny: undefined }) + expect(wrapper.find('[data-currency]').exists()).toBe(false) + expect(wrapper.text()).toContain('客户价显示站内额度') + expect(wrapper.findComponent(PlazaGroupSection).props('priceDisplay')).toBeUndefined() + wrapper.unmount() + }) +}) diff --git a/frontend/src/components/modelPlaza/__tests__/PlazaGroupSection.spec.ts b/frontend/src/components/modelPlaza/__tests__/PlazaGroupSection.spec.ts index 45d21cc7914e..f4c5e80e57d3 100644 --- a/frontend/src/components/modelPlaza/__tests__/PlazaGroupSection.spec.ts +++ b/frontend/src/components/modelPlaza/__tests__/PlazaGroupSection.spec.ts @@ -92,6 +92,14 @@ function mountSection(g: ModelPlazaGroup) { const NOTE = 'modelPlaza.detail.longContextDisabledNote' describe('PlazaGroupSection 长上下文说明', () => { + it('passes display currency to the table without changing group rates', async () => { + const wrapper = mountSection(group({ rate_multiplier: 0.5 })) + const priceDisplay = { currency: 'CNY' as const, usdToCny: 7, creditPerCny: 1 } + await wrapper.setProps({ priceDisplay }) + expect(wrapper.findComponent(PlazaModelPricingTable).props()).toMatchObject({ priceDisplay, rateMultiplier: 0.5 }) + wrapper.unmount() + }) + it('passes video-specific rates to the pricing table', () => { const wrapper = mountSection(group({ video_rate_independent: true, video_rate_multiplier: 0 })) expect(wrapper.findComponent(PlazaModelPricingTable).props()).toMatchObject({ diff --git a/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.spec.ts b/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.spec.ts index 4ba9a7517887..ff824cc5ac42 100644 --- a/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.spec.ts +++ b/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.spec.ts @@ -52,6 +52,7 @@ function mountTable( rateMultiplier: number, userRateMultiplier?: number | null, extraProps?: { + priceDisplay?: import('@/utils/plazaCurrency').PlazaPriceDisplay imageRateIndependent?: boolean imageRateMultiplier?: number | null videoRateIndependent?: boolean @@ -66,6 +67,21 @@ function mountTable( } describe('PlazaModelPricingTable', () => { + it('converts base, time and tier prices without changing discounts or official source values', async () => { + const model = tokenModel({ time_pricing: { timezone: 'Asia/Shanghai', periods: [{ start_time: '09:00', end_time: '12:00', multiplier: 2 }] } }) + model.pricing!.intervals = [{ min_tokens: 0, max_tokens: null, input_price: 4e-6, output_price: 8e-6, cache_write_price: null, cache_read_price: null, per_request_price: null }] + const before = JSON.stringify(model) + const wrapper = mountTable([model], 0.5, 0.25, { priceDisplay: { currency: 'CNY', usdToCny: 7, creditPerCny: 2 } }) + const rows = wrapper.findAll('tbody tr') + expect(rows[0].findAll('td')[1].text()).toContain('¥0.50') + expect(rows[1].findAll('td')[1].text()).toContain('¥1.00') + expect(rows[0].findAll('td')[4].text()).toContain('¥21.00') + await wrapper.setProps({ priceDisplay: { currency: 'USD', usdToCny: 7, creditPerCny: 2 } }) + expect(wrapper.findAll('tbody tr')[0].findAll('td')[4].text()).toContain('$3.00') + expect(JSON.stringify(model)).toBe(before) + wrapper.unmount() + }) + it('does not multiply the final image floor by personal discounts', () => { const m = tokenModel({ name: 'gpt-image-2', platform: 'openai' }) m.pricing!.image_minimum_charge = 0.01 diff --git a/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.video.spec.ts b/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.video.spec.ts index 3aeb5c90da3c..8a016fb8588c 100644 --- a/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.video.spec.ts +++ b/frontend/src/components/modelPlaza/__tests__/PlazaModelPricingTable.video.spec.ts @@ -85,6 +85,16 @@ describe.each([ expect(wrapper.text()).not.toContain('modelPlaza.table.') }) + it.each(['image', 'video', 'per_request'] as const)('converts %s prices with its applicable media rate', (mode) => { + const wrapper = render(mediaModel(mode), { + imageRateIndependent: true, imageRateMultiplier: 2, + videoRateIndependent: true, videoRateMultiplier: 3, + priceDisplay: { currency: 'CNY', usdToCny: 7, creditPerCny: 2 } + }) + const price = wrapper.findAll('tbody td')[1].text() + expect(price).toContain(mode === 'image' ? '¥0.54' : mode === 'video' ? '¥0.81' : '¥0.135') + }) + it.each(['image', 'per_request'] as const)('preserves %s labels, units and prices', (mode) => { const cells = render(mediaModel(mode)).findAll('tbody td') expect(cells[0].text()).toContain(mode === 'image' ? language.imageLabel : language.requestLabel) @@ -108,7 +118,7 @@ describe.each([ expect(cells[2].text()).toBe('$2.00') expect(cells[3].text()).toContain('$1.00') expect(cells[3].text()).toContain('$0.25') - expect(wrapper.find('thead').text()).toContain(language.locale === 'zh' ? '$ / 1M token' : '$ / 1M tokens') + expect(wrapper.find('thead').text()).toContain(language.locale === 'zh' ? '/ 1M token' : '/ 1M tokens') expect(wrapper.find('tbody').text()).not.toContain(language.suffix) expect(cells[7].text()).toContain('0.25x') }) diff --git a/frontend/src/constants/newFeatureNotices.ts b/frontend/src/constants/newFeatureNotices.ts index 8d79ef796111..5ecd37a18d78 100644 --- a/frontend/src/constants/newFeatureNotices.ts +++ b/frontend/src/constants/newFeatureNotices.ts @@ -4,6 +4,7 @@ * browser; use a new ID to announce the feature again in a later release. */ export const NEW_FEATURE_NOTICES = { + modelPlazaCurrency: 'model-plaza-display-currency-20261121', exaSearch: 'exa-search-provider', claudeWindowCost: 'claude-window-cost-estimate', openaiVideos: 'openai-videos-endpoint-capability', diff --git a/frontend/src/i18n/locales/en/admin/settings.ts b/frontend/src/i18n/locales/en/admin/settings.ts index c70acfeb30d6..9aeef66a05cf 100644 --- a/frontend/src/i18n/locales/en/admin/settings.ts +++ b/frontend/src/i18n/locales/en/admin/settings.ts @@ -124,6 +124,8 @@ export default { enabledHint: 'When enabled, an entry appears in the header and the page is reachable at /model-plaza.', requireAuth: 'Require sign-in to access', requireAuthHint: 'When on, anonymous visitors are redirected to the login page; when off, the page is public and anonymous visitors only see non-exclusive groups.', + displayExchangeRate: 'Plaza USD/CNY display rate', + displayExchangeRateHint: 'CNY per USD, default 7.00. A fixed reference for plaza display only; recharge, subscriptions, channel prices and billing are unchanged.', priceDescription: 'Pricing notes (Markdown)', priceDescriptionHint: 'Rendered at the top of the plaza page. Use it for billing rules, exchange rates, promotions, etc.', }, diff --git a/frontend/src/i18n/locales/en/dashboard.ts b/frontend/src/i18n/locales/en/dashboard.ts index 10e3562ba1f0..8aa615b89a8c 100644 --- a/frontend/src/i18n/locales/en/dashboard.ts +++ b/frontend/src/i18n/locales/en/dashboard.ts @@ -798,6 +798,13 @@ export default { loadFailed: 'Failed to load model plaza', noSearchResult: 'No matching models', anonymousHint: 'Sign in to see your exclusive groups and personal rates', + currency: { + label: 'Display currency', CNY: 'CNY', USD: 'USD', credits: 'Wallet credits', + reference: 'Display reference: 1 USD = {rate} CNY', + explanation: 'Your price uses the CNY recharge baseline (¥1 = {credits} wallet credits), excluding recharge offers and fees. Official prices originate in USD. Currency selection changes display only, not billing.', + unavailable: 'Conversion settings are unavailable: your prices are in wallet credits and official references are in USD.', + minimumCharge: 'Minimum {amount} per request', + }, filters: { platformLabel: 'Platform', groupLabel: 'Group', @@ -838,10 +845,10 @@ export default { '; prices in this row exclude the peak-hour rate — where this period overlaps the peak hours {window}, the overlapping portion is additionally multiplied by ×{multiplier}', timePricingWeekdays: 'Weekdays', timePricingRateHint: 'Effective rate {rate} × period multiplier {multiplier}', - paidPrice: 'Your Price (Discounted)', - officialPrice: 'Official Price', + paidPrice: 'Your Reference Price (Discounted)', + officialPrice: 'Official Reference', rate: 'Rate', - unitPerMillion: '$ / 1M tokens', + unitPerMillion: '/ 1M tokens', perUnitRequest: '/ request', perUnitImage: '/ image', perUnitSecond: '/ second', diff --git a/frontend/src/i18n/locales/zh/admin/settings.ts b/frontend/src/i18n/locales/zh/admin/settings.ts index 86c51a7324a4..efda4b625d1c 100644 --- a/frontend/src/i18n/locales/zh/admin/settings.ts +++ b/frontend/src/i18n/locales/zh/admin/settings.ts @@ -124,6 +124,8 @@ export default { enabledHint: '开启后顶栏显示入口,页面可通过 /model-plaza 独立访问。', requireAuth: '需要登录才可访问', requireAuthHint: '开启后未登录访问将跳转登录页;关闭则公开可见,匿名访客仅展示非专属分组。', + displayExchangeRate: '广场美元/人民币展示汇率', + displayExchangeRateHint: '1 USD 对应的 CNY,默认 7.00。固定参考值,仅供广场币种切换;不修改充值、订阅、渠道价或扣费。', priceDescription: '价格说明(Markdown)', priceDescriptionHint: '展示在模型广场页面顶部,可用于说明计费规则、汇率、优惠活动等。', }, diff --git a/frontend/src/i18n/locales/zh/dashboard.ts b/frontend/src/i18n/locales/zh/dashboard.ts index 77638c6e66ad..c87a2c896584 100644 --- a/frontend/src/i18n/locales/zh/dashboard.ts +++ b/frontend/src/i18n/locales/zh/dashboard.ts @@ -803,6 +803,13 @@ export default { loadFailed: '加载模型广场失败', noSearchResult: '没有匹配的模型', anonymousHint: '登录后可查看你的专属分组与专属倍率', + currency: { + label: '显示币种', CNY: '人民币', USD: '美元', credits: '站内额度', + reference: '展示参考汇率:1 USD = {rate} CNY', + explanation: '客户价按人民币充值基准折算(¥1 = {credits} 站内额度),不含充值优惠和手续费;官方价来自美元目录。切换币种仅影响展示,实际扣费规则不变。', + unavailable: '暂未取得换算配置:客户价显示站内额度,官方参考价显示美元。', + minimumCharge: '单次最低 {amount}', + }, filters: { platformLabel: '平台', groupLabel: '分组', @@ -842,10 +849,10 @@ export default { timePricingRowHintPeak: ';本行价格未含高峰倍率,与高峰时段 {window} 重叠的部分实付再乘 ×{multiplier}', timePricingWeekdays: '工作日', timePricingRateHint: '生效倍率 {rate} × 时段倍率 {multiplier}', - paidPrice: '实付价格(折后)', - officialPrice: '官方价格', + paidPrice: '客户参考价(折后)', + officialPrice: '官方参考价', rate: '折扣倍率', - unitPerMillion: '$ / 1M token', + unitPerMillion: '/ 1M token', perUnitRequest: '/ 次', perUnitImage: '/ 张', perUnitSecond: '/ 秒', diff --git a/frontend/src/utils/__tests__/plazaCurrency.spec.ts b/frontend/src/utils/__tests__/plazaCurrency.spec.ts new file mode 100644 index 000000000000..78ae28acaf83 --- /dev/null +++ b/frontend/src/utils/__tests__/plazaCurrency.spec.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from 'vitest' +import { formatPlazaPrice, hasPlazaCurrencyRates } from '../plazaCurrency' + +describe('plaza display currency', () => { + it('separates real USD from wallet credits for either display currency', () => { + const cny = { currency: 'CNY' as const, usdToCny: 7, creditPerCny: 1 } + const usd = { ...cny, currency: 'USD' as const } + expect(formatPlazaPrice(2.25e-6, 1e6, 'credit', cny)).toBe('¥2.25') + expect(formatPlazaPrice(0.66e-6, 1e6, 'usd', cny)).toBe('¥4.62') + expect(formatPlazaPrice(2.25e-6, 1e6, 'credit', usd)).toBe('$0.3214285714') + expect(formatPlazaPrice(0.66e-6, 1e6, 'usd', usd)).toBe('$0.66') + expect(formatPlazaPrice(2.25e-6, 1e6, 'credit', { ...cny, creditPerCny: 2 })).toBe('¥1.125') + expect(formatPlazaPrice(0.01, 1, 'credit', cny)).toBe('¥0.01') + expect(formatPlazaPrice(0, 1, 'credit', usd)).toBe('$0.00') + expect(formatPlazaPrice(null, 1, 'credit', cny)).toBe('-') + }) + it.each([undefined, 0, -1, NaN, Infinity])('does not fabricate a conversion from %s', rate => { + expect(hasPlazaCurrencyRates(rate, 1)).toBe(false) + expect(hasPlazaCurrencyRates(7, rate)).toBe(false) + expect(formatPlazaPrice(2, 1, 'credit')).toBe('$2.00') + }) +}) diff --git a/frontend/src/utils/__tests__/pricing.formatScaled.spec.ts b/frontend/src/utils/__tests__/pricing.formatScaled.spec.ts index 6885061bee1a..905a80df70b9 100644 --- a/frontend/src/utils/__tests__/pricing.formatScaled.spec.ts +++ b/frontend/src/utils/__tests__/pricing.formatScaled.spec.ts @@ -2,6 +2,10 @@ import { describe, expect, it } from 'vitest' import { formatScaled } from '../pricing' describe('formatScaled', () => { + it('uses an explicit yuan symbol without changing the numeric value', () => { + expect(formatScaled(2.25e-6, 1e6, 2, '¥')).toBe('¥2.25') + expect(formatScaled(null, 1e6, 2, '¥')).toBe('-') + }) it.each([ [1e-10, 1, '$1e-10'], [1.25e-10, 1, '$1.25e-10'], diff --git a/frontend/src/utils/plazaCurrency.ts b/frontend/src/utils/plazaCurrency.ts new file mode 100644 index 000000000000..46b1bee7bc49 --- /dev/null +++ b/frontend/src/utils/plazaCurrency.ts @@ -0,0 +1,21 @@ +import { formatScaled } from './pricing' + +export type PlazaCurrency = 'CNY' | 'USD' +export interface PlazaPriceDisplay { + currency: PlazaCurrency + usdToCny: number + creditPerCny: number +} + +export function hasPlazaCurrencyRates(usdToCny?: number, creditPerCny?: number): boolean { + return typeof usdToCny === 'number' && Number.isFinite(usdToCny) && usdToCny > 0 && + typeof creditPerCny === 'number' && Number.isFinite(creditPerCny) && creditPerCny > 0 +} + +/** Pricing API amounts stay unchanged; only their presentation is converted. */ +export function formatPlazaPrice(value: number | null | undefined, scale: number, source: 'credit' | 'usd', display?: PlazaPriceDisplay): string { + if (value == null) return '-' + if (!display || !hasPlazaCurrencyRates(display.usdToCny, display.creditPerCny)) return formatScaled(value, scale, 2) + const cny = source === 'usd' ? value * display.usdToCny : value / display.creditPerCny + return formatScaled(display.currency === 'CNY' ? cny : cny / display.usdToCny, scale, 2, display.currency === 'CNY' ? '¥' : '$') +} diff --git a/frontend/src/utils/pricing.ts b/frontend/src/utils/pricing.ts index 0e42abc70c62..600c0e6e3eff 100644 --- a/frontend/src/utils/pricing.ts +++ b/frontend/src/utils/pricing.ts @@ -10,7 +10,7 @@ * Uses toPrecision(10) then strips trailing zeros to avoid IEEE 754 display noise. * `minFractionDigits` pads the result back up to a minimum number of decimals. */ -export function formatScaled(value: number | null, scale: number, minFractionDigits = 0): string { +export function formatScaled(value: number | null, scale: number, minFractionDigits = 0, symbol: '$' | '¥' = '$'): string { if (value == null) return '-' let s = Number((value * scale).toPrecision(10)).toString() if (minFractionDigits > 0 && !s.includes('e')) { @@ -20,7 +20,7 @@ export function formatScaled(value: number | null, scale: number, minFractionDig s = (dot === -1 ? `${s}.` : s) + '0'.repeat(minFractionDigits - digits) } } - return `$${s}` + return `${symbol}${s}` } import type { UserPricingInterval } from '@/api/channels' diff --git a/frontend/src/views/admin/SettingsView.vue b/frontend/src/views/admin/SettingsView.vue index 56d3d8a322c9..6c9870396345 100644 --- a/frontend/src/views/admin/SettingsView.vue +++ b/frontend/src/views/admin/SettingsView.vue @@ -7848,6 +7848,16 @@
+
+ +

{{ t('admin.settings.features.modelPlaza.displayExchangeRateHint') }}

+ +
+
- + - +