Revert "Merge pull request #424 from Wangnov/feat/i18n"

This reverts commit 1d915d8327, reversing
changes made to 009f7c84f6.
This commit is contained in:
shaw
2025-09-12 09:21:53 +08:00
parent 1d915d8327
commit 9c4dc714f8
80 changed files with 7026 additions and 19087 deletions

View File

@@ -2,7 +2,6 @@ import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { apiClient } from '@/config/api'
import { showToast } from '@/utils/toast'
import i18n from '@/i18n'
export const useDashboardStore = defineStore('dashboard', () => {
// 状态
@@ -42,7 +41,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
realtimeTPM: 0,
metricsWindow: 5,
isHistoricalMetrics: false,
systemStatus: i18n.global.t('system.status.normal'),
systemStatus: '正常',
uptime: 0,
systemTimezone: 8 // 默认 UTC+8
})
@@ -69,9 +68,9 @@ export const useDashboardStore = defineStore('dashboard', () => {
customEnd: '',
customRange: null,
presetOptions: [
{ value: 'today', label: i18n.global.t('dashboard.today'), days: 1 },
{ value: '7days', label: i18n.global.t('dashboard.last7Days'), days: 7 },
{ value: '30days', label: i18n.global.t('dashboard.last30Days'), days: 30 }
{ value: 'today', label: '今日', days: 1 },
{ value: '7days', label: '7天', days: 7 },
{ value: '30days', label: '30天', days: 30 }
]
})
@@ -90,11 +89,11 @@ export const useDashboardStore = defineStore('dashboard', () => {
const minutes = Math.floor((seconds % 3600) / 60)
if (days > 0) {
return i18n.global.t('dashboard.uptimeFormat.daysHours', { days, hours })
return `${days}${hours}小时`
} else if (hours > 0) {
return i18n.global.t('dashboard.uptimeFormat.hoursMinutes', { hours, minutes })
return `${hours}小时 ${minutes}分钟`
} else {
return i18n.global.t('dashboard.uptimeFormat.minutes', { minutes })
return `${minutes}分钟`
}
})
@@ -199,9 +198,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
realtimeTPM: realtimeMetrics.tpm || 0,
metricsWindow: realtimeMetrics.windowMinutes || 5,
isHistoricalMetrics: realtimeMetrics.isHistorical || false,
systemStatus: systemHealth.redisConnected
? i18n.global.t('system.status.normal')
: i18n.global.t('system.status.abnormal'),
systemStatus: systemHealth.redisConnected ? '正常' : '异常',
uptime: systemHealth.uptime || 0,
systemTimezone: dashboardResponse.data.systemTimezone || 8
}
@@ -221,7 +218,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
}
}
} catch (error) {
console.error(i18n.global.t('common.errors.loadDashboardFailed'), error)
console.error('加载仪表板数据失败:', error)
} finally {
loading.value = false
}
@@ -309,7 +306,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
trendData.value = response.data
}
} catch (error) {
console.error(i18n.global.t('common.errors.loadUsageTrendFailed'), error)
console.error('加载使用趋势失败:', error)
}
}
@@ -400,7 +397,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
dashboardModelStats.value = response.data
}
} catch (error) {
console.error(i18n.global.t('common.errors.loadModelStatsFailed'), error)
console.error('加载模型统计失败:', error)
}
}
@@ -502,7 +499,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
}
}
} catch (error) {
console.error(i18n.global.t('common.errors.loadApiKeysTrendFailed'), error)
console.error('加载API Keys趋势失败:', error)
}
}
@@ -639,14 +636,14 @@ export const useDashboardStore = defineStore('dashboard', () => {
// 小时粒度:限制 24 小时
const hoursDiff = (end - start) / (1000 * 60 * 60)
if (hoursDiff > 24) {
showToast(i18n.global.t('dashboard.errors.rangeTooLongHour'), 'warning')
showToast('小时粒度下日期范围不能超过24小时', 'warning')
return
}
} else {
// 天粒度:限制 31 天
const daysDiff = Math.ceil((end - start) / (1000 * 60 * 60 * 24)) + 1
if (daysDiff > 31) {
showToast(i18n.global.t('dashboard.errors.rangeTooLongDay'), 'warning')
showToast('日期范围不能超过 31 天', 'warning')
return
}
}
@@ -665,13 +662,9 @@ export const useDashboardStore = defineStore('dashboard', () => {
// 根据粒度更新预设选项
if (granularity === 'hour') {
dateFilter.value.presetOptions = [
{
value: 'last24h',
label: i18n.global.t('dashboard.usageTrend.periodOptions.last24Hours'),
hours: 24
},
{ value: 'yesterday', label: i18n.global.t('dashboard.yesterday'), hours: 24 },
{ value: 'dayBefore', label: i18n.global.t('dashboard.dayBefore'), hours: 24 }
{ value: 'last24h', label: '近24小时', hours: 24 },
{ value: 'yesterday', label: '昨天', hours: 24 },
{ value: 'dayBefore', label: '前天', hours: 24 }
]
// 检查当前自定义日期范围是否超过24小时
@@ -684,7 +677,7 @@ export const useDashboardStore = defineStore('dashboard', () => {
const end = new Date(dateFilter.value.customRange[1])
const hoursDiff = (end - start) / (1000 * 60 * 60)
if (hoursDiff > 24) {
showToast(i18n.global.t('dashboard.errors.rangeTooLongHourSwitched'), 'warning')
showToast('小时粒度下日期范围不能超过24小时已切换到近24小时', 'warning')
setDateFilterPreset('last24h')
return
}
@@ -698,9 +691,9 @@ export const useDashboardStore = defineStore('dashboard', () => {
} else {
// 天粒度
dateFilter.value.presetOptions = [
{ value: 'today', label: i18n.global.t('dashboard.today'), days: 1 },
{ value: '7days', label: i18n.global.t('dashboard.last7Days'), days: 7 },
{ value: '30days', label: i18n.global.t('dashboard.last30Days'), days: 30 }
{ value: 'today', label: '今日', days: 1 },
{ value: '7days', label: '7天', days: 7 },
{ value: '30days', label: '30天', days: 30 }
]
// 如果当前是小时粒度的预设,切换到天粒度的默认预设