feat: Backend i18n

This commit is contained in:
fit2cloud-chenyw
2025-07-07 14:16:05 +08:00
parent cd26d6594e
commit 17fd6ffbf7
8 changed files with 124 additions and 9 deletions
+11
View File
@@ -9,6 +9,7 @@ import axios, {
} from 'axios'
import { useCache } from '@/utils/useCache'
import { getLocale } from './utils'
const { wsCache } = useCache()
// Response data structure
export interface ApiResponse<T = unknown> {
@@ -69,6 +70,16 @@ class HttpService {
if (token && config.headers) {
config.headers['X-SQLBOT-TOKEN'] = `Bearer ${token}`
}
const locale = getLocale()
if (locale) {
/* const mapping = {
'zh-CN': 'zh-CN',
en: 'en-US',
tw: 'zh-TW',
} */
/* const val = mapping[locale] || locale */
config.headers['Accept-Language'] = locale
}
if (config.url?.includes('/xpack_static/') && config.baseURL) {
config.baseURL = config.baseURL.replace('/api/v1', '')
// Skip auth for xpack_static requests