refactor(frontend): modularize i18n architecture

This commit is contained in:
elky
2026-06-30 17:01:39 +08:00
parent bf29129a4b
commit 9f138d09e6
118 changed files with 11940 additions and 5368 deletions
@@ -1,4 +1,5 @@
import type { EndpointHealthDetail } from '@/api/endpoints'
import { defaultLocale, translateLegacyText, type Locale } from '@/i18n/messages'
// 端点状态枚举
export type EndpointStatus = 'disabled' | 'no_keys' | 'keys_disabled' | 'available'
@@ -75,23 +76,24 @@ export function getEndpointDotColor(endpoint: EndpointHealthDetail): string {
/**
* 端点提示文本
*/
export function getEndpointTooltip(endpoint: EndpointHealthDetail): string {
export function getEndpointTooltip(endpoint: EndpointHealthDetail, locale: Locale = defaultLocale): string {
const format = endpoint.api_format
const status = getEndpointStatus(endpoint)
const t = (value: string) => translateLegacyText(value, locale)
switch (status) {
case 'disabled':
return `${format}: 端点禁用`
return `${format}: ${t('端点禁用')}`
case 'no_keys':
return `${format}: 未配置密钥`
return `${format}: ${t('未配置密钥')}`
case 'keys_disabled':
return `${format}: 无可用密钥`
return `${format}: ${t('无可用密钥')}`
case 'available': {
const score = endpoint.health_score
if (score === undefined || score === null) {
return `${format}: 暂无健康数据`
return `${format}: ${t('暂无健康数据')}`
}
return `${format}: 健康度 ${(score * 100).toFixed(0)}%`
return `${format}: ${t('健康度')} ${(score * 100).toFixed(0)}%`
}
}
}
@@ -1,5 +1,6 @@
import { ref, computed, watch } from 'vue'
import type { ProviderSummaryQuery } from '@/api/endpoints'
import { useI18n } from '@/i18n'
export interface FilterOption {
value: string
@@ -9,20 +10,21 @@ export interface FilterOption {
export function useProviderFilters(
globalModels: () => { id: string; name: string }[],
) {
const { legacyT } = useI18n()
// 搜索与筛选
const searchQuery = ref('')
const filterStatus = ref('all')
const filterApiFormat = ref('all')
const filterModel = ref('all')
const statusFilters: FilterOption[] = [
{ value: 'all', label: '全部状态' },
{ value: 'active', label: '活跃' },
{ value: 'inactive', label: '停用' },
]
const statusFilters = computed<FilterOption[]>(() => [
{ value: 'all', label: legacyT('全部状态') },
{ value: 'active', label: legacyT('活跃') },
{ value: 'inactive', label: legacyT('停用') },
])
const apiFormatFilters: FilterOption[] = [
{ value: 'all', label: '全部格式' },
const apiFormatFilters = computed<FilterOption[]>(() => [
{ value: 'all', label: legacyT('全部格式') },
{ value: 'claude:messages', label: 'Claude Messages' },
{ value: 'openai:chat', label: 'OpenAI Chat' },
{ value: 'openai:responses', label: 'OpenAI Responses' },
@@ -35,13 +37,13 @@ export function useProviderFilters(
{ value: 'jina:rerank', label: 'Jina Rerank' },
{ value: 'doubao:embedding', label: 'Doubao Embedding' },
{ value: 'aliyun:multimodal_embedding', label: 'Aliyun Multimodal Embedding' },
]
])
const modelFilters = computed<FilterOption[]>(() => {
const items = globalModels()
.map(m => ({ value: m.id, label: m.name }))
.sort((a, b) => a.label.localeCompare(b.label))
return [{ value: 'all', label: '全部模型' }, ...items]
return [{ value: 'all', label: legacyT('全部模型') }, ...items]
})
const hasActiveFilters = computed(() => {