mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-24 07:47:13 +00:00
feat: 完成布局/仪表板/用户相关组件国际化与语言切换优化(TabBar/MainLayout/AppHeader、UsageTrend/ModelDistribution、User*、Common 组件、i18n/locale 增强)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { i18n, SUPPORTED_LOCALES } from '@/i18n'
|
||||
import { i18n, SUPPORTED_LOCALES, getSupportedLocalesWithI18n } from '@/i18n'
|
||||
|
||||
export const useLocaleStore = defineStore('locale', () => {
|
||||
const currentLocale = ref(i18n.global.locale.value)
|
||||
@@ -20,14 +20,19 @@ export const useLocaleStore = defineStore('locale', () => {
|
||||
document.documentElement.setAttribute('lang', locale)
|
||||
}
|
||||
|
||||
// 获取当前语言信息
|
||||
const getCurrentLocaleInfo = () => {
|
||||
// 获取当前语言信息(兼容i18n)
|
||||
const getCurrentLocaleInfo = (t = null) => {
|
||||
if (t) {
|
||||
const supportedLocales = getSupportedLocalesWithI18n(t)
|
||||
return supportedLocales[currentLocale.value] || supportedLocales['zh-cn']
|
||||
}
|
||||
return SUPPORTED_LOCALES[currentLocale.value] || SUPPORTED_LOCALES['zh-cn']
|
||||
}
|
||||
|
||||
// 获取所有支持的语言
|
||||
const getSupportedLocales = () => {
|
||||
return Object.entries(SUPPORTED_LOCALES).map(([key, value]) => ({
|
||||
// 获取所有支持的语言(兼容i18n)
|
||||
const getSupportedLocales = (t = null) => {
|
||||
const supportedLocales = t ? getSupportedLocalesWithI18n(t) : SUPPORTED_LOCALES
|
||||
return Object.entries(supportedLocales).map(([key, value]) => ({
|
||||
code: key,
|
||||
...value
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user