diff --git a/frontend/src/components/channels/SupportedModelChip.vue b/frontend/src/components/channels/SupportedModelChip.vue index e64c28ebc1..f19ab08b18 100644 --- a/frontend/src/components/channels/SupportedModelChip.vue +++ b/frontend/src/components/channels/SupportedModelChip.vue @@ -135,6 +135,14 @@ :scale="1" /> + +
{ return t(prefixKey('billingModePerRequest')) case BILLING_MODE_IMAGE: return t(prefixKey('billingModeImage')) + case BILLING_MODE_VIDEO: + return t(prefixKey('billingModeVideo')) default: return '-' } @@ -246,6 +257,9 @@ function formatRange(min: number, max: number | null): string { } function formatInterval(iv: UserPricingInterval, pricing: UserSupportedModelPricing): string { + if (pricing.billing_mode === BILLING_MODE_VIDEO) { + return `${formatScaled(iv.per_request_price, 1)} ${t(prefixKey('unitPerSecond'))}` + } if (pricing.billing_mode === BILLING_MODE_PER_REQUEST || pricing.billing_mode === BILLING_MODE_IMAGE) { return formatScaled(iv.per_request_price, 1) } diff --git a/frontend/src/components/channels/__tests__/SupportedModelChip.spec.ts b/frontend/src/components/channels/__tests__/SupportedModelChip.spec.ts index b3799b697c..6da3674704 100644 --- a/frontend/src/components/channels/__tests__/SupportedModelChip.spec.ts +++ b/frontend/src/components/channels/__tests__/SupportedModelChip.spec.ts @@ -12,6 +12,61 @@ vi.mock('vue-i18n', async () => { }) describe('SupportedModelChip', () => { + it.each(['availableChannels.pricing', 'admin.availableChannels.pricing'])( + 'shows video prices per second using %s translations', + async (pricingKeyPrefix) => { + const wrapper = mount(SupportedModelChip, { + attachTo: document.body, + props: { + pricingKeyPrefix, + model: { + name: 'video-test', + platform: '', + pricing: { + billing_mode: 'video', + input_price: null, + output_price: null, + cache_write_price: null, + cache_read_price: null, + image_input_price: null, + image_output_price: null, + per_request_price: 0.05, + intervals: [ + { tier_label: '480p', min_tokens: 0, max_tokens: null, input_price: null, output_price: null, cache_write_price: null, cache_read_price: null, per_request_price: 0 }, + { tier_label: '720p', min_tokens: 0, max_tokens: null, input_price: null, output_price: null, cache_write_price: null, cache_read_price: null, per_request_price: 0.12 } + ] + } + } + } + }) + try { + await wrapper.find('[tabindex="0"]').trigger('mouseenter') + await nextTick() + const tooltip = document.body.querySelector('[role="tooltip"]') + expect(tooltip?.textContent).toContain(`${pricingKeyPrefix}.billingModeVideo`) + expect(tooltip?.textContent).toContain(`${pricingKeyPrefix}.videoPrice`) + expect(tooltip?.textContent).toContain(`$0.05 ${pricingKeyPrefix}.unitPerSecond`) + expect(tooltip?.textContent).toContain('480p') + expect(tooltip?.textContent).toContain(`$0 ${pricingKeyPrefix}.unitPerSecond`) + expect(tooltip?.textContent).toContain('720p') + expect(tooltip?.textContent).toContain(`$0.12 ${pricingKeyPrefix}.unitPerSecond`) + const model = wrapper.props('model') + await wrapper.setProps({ + model: { ...model, pricing: { ...model.pricing!, per_request_price: null } } + }) + expect(tooltip?.textContent).not.toContain(`${pricingKeyPrefix}.videoPrice`) + expect(tooltip?.textContent).toContain(`$0.12 ${pricingKeyPrefix}.unitPerSecond`) + await wrapper.setProps({ + model: { ...model, pricing: { ...model.pricing!, per_request_price: 0 } } + }) + expect(tooltip?.textContent).toContain(`${pricingKeyPrefix}.videoPrice`) + expect(wrapper.findComponent({ name: 'PricingRow' }).text()).toContain(`$0 ${pricingKeyPrefix}.unitPerSecond`) + } finally { + wrapper.unmount() + } + } + ) + it('仅配置区间倍率时按基础价展示 token 档位', async () => { const wrapper = mount(SupportedModelChip, { attachTo: document.body, diff --git a/frontend/src/i18n/locales/en/admin/channels.ts b/frontend/src/i18n/locales/en/admin/channels.ts index db867cfc6f..b0574f7159 100644 --- a/frontend/src/i18n/locales/en/admin/channels.ts +++ b/frontend/src/i18n/locales/en/admin/channels.ts @@ -27,6 +27,8 @@ export default { billingModePerRequest: 'Per Request', billingModeImage: 'Per Image', billingModeVideo: 'Per Video', + videoPrice: 'Video Price', + unitPerSecond: '/ second', inputPrice: 'Input', outputPrice: 'Output', cacheWritePrice: 'Cache Write', diff --git a/frontend/src/i18n/locales/en/dashboard.ts b/frontend/src/i18n/locales/en/dashboard.ts index 0a8d8d352a..7bc3894da9 100644 --- a/frontend/src/i18n/locales/en/dashboard.ts +++ b/frontend/src/i18n/locales/en/dashboard.ts @@ -620,6 +620,8 @@ export default { billingModePerRequest: 'Per Request', billingModeImage: 'Per Image', billingModeVideo: 'Per Video', + videoPrice: 'Video Price', + unitPerSecond: '/ second', inputPrice: 'Input', outputPrice: 'Output', cacheWritePrice: 'Cache Write', diff --git a/frontend/src/i18n/locales/zh/admin/channels.ts b/frontend/src/i18n/locales/zh/admin/channels.ts index 6d841f9323..592c3e63f1 100644 --- a/frontend/src/i18n/locales/zh/admin/channels.ts +++ b/frontend/src/i18n/locales/zh/admin/channels.ts @@ -27,6 +27,8 @@ export default { billingModePerRequest: '按次', billingModeImage: '按图片', billingModeVideo: '按视频', + videoPrice: '视频单价', + unitPerSecond: '/ 秒', inputPrice: '输入', outputPrice: '输出', cacheWritePrice: '缓存写入', diff --git a/frontend/src/i18n/locales/zh/dashboard.ts b/frontend/src/i18n/locales/zh/dashboard.ts index 7393964b0f..53c1eb895b 100644 --- a/frontend/src/i18n/locales/zh/dashboard.ts +++ b/frontend/src/i18n/locales/zh/dashboard.ts @@ -625,6 +625,8 @@ export default { billingModePerRequest: '按次', billingModeImage: '按图片', billingModeVideo: '按视频', + videoPrice: '视频单价', + unitPerSecond: '/ 秒', inputPrice: '输入', outputPrice: '输出', cacheWritePrice: '缓存写入',