feat: 基础本地化支持与通用键补充(useConfirm/useChartConfig/format/apiStats 回退 + common.time/errors 等 i18n 键)

This commit is contained in:
Wangnov
2025-09-10 18:04:09 +08:00
parent 97b94eeff9
commit 5f5826ce56
7 changed files with 1274 additions and 30 deletions

View File

@@ -1,4 +1,5 @@
import { Chart } from 'chart.js/auto'
import i18n from '@/i18n'
export function useChartConfig() {
// 设置Chart.js默认配置
@@ -51,7 +52,9 @@ export function useChartConfig() {
label += ': '
}
if (context.parsed.y !== null) {
label += new Intl.NumberFormat('zh-CN').format(context.parsed.y)
const localeMap = { 'zh-cn': 'zh-CN', 'zh-tw': 'zh-TW', en: 'en-US' }
const currentLocale = localeMap[i18n.global.locale.value] || 'en-US'
label += new Intl.NumberFormat(currentLocale).format(context.parsed.y)
}
return label
}

View File

@@ -1,16 +1,22 @@
import { ref } from 'vue'
import i18n from '@/i18n'
const showConfirmModal = ref(false)
const confirmOptions = ref({
title: '',
message: '',
confirmText: '继续',
cancelText: '取消'
confirmText: i18n.global.t('common.confirmModal.continue'),
cancelText: i18n.global.t('common.confirmModal.cancel')
})
const confirmResolve = ref(null)
export function useConfirm() {
const showConfirm = (title, message, confirmText = '继续', cancelText = '取消') => {
const showConfirm = (
title,
message,
confirmText = i18n.global.t('common.confirmModal.continue'),
cancelText = i18n.global.t('common.confirmModal.cancel')
) => {
return new Promise((resolve) => {
confirmOptions.value = {
title,