feat(ui):i18n (#352)

This commit is contained in:
wang-liang0615
2024-01-03 13:29:38 +08:00
committed by GitHub
parent 9ee2776bdd
commit ec884c92e1
15 changed files with 62 additions and 795 deletions

View File

@@ -1,4 +1,4 @@
/* eslint-dsiable */
/* eslint-dsiable */
import Vue from 'vue'
import axios from 'axios'
import { VueAxios } from './axios'
@@ -6,20 +6,22 @@ import message from 'ant-design-vue/es/message'
import notification from 'ant-design-vue/es/notification'
import { ACCESS_TOKEN } from '@/store/global/mutation-types'
import router from '@/router'
import store from '@/store'
// 创建 axios 实例
const service = axios.create({
baseURL: process.env.VUE_APP_API_BASE_URL, // api base_url
timeout: 6000, // 请求超时时间
withCredentials: true,
crossDomain: true
crossDomain: true,
})
const err = (error) => {
console.log(error)
const reg = /5\d{2}/g
if (error.response && reg.test(error.response.status)) {
message.error('服务端未知错误, 请联系管理员!')
const errorMsg = ((error.response || {}).data || {}).message || '服务端未知错误, 请联系管理员!'
message.error(errorMsg)
} else if (error.response.status === 412) {
let seconds = 5
notification.warning({
@@ -64,6 +66,7 @@ service.interceptors.request.use(config => {
if (token) {
config.headers['Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
}
config.headers['Accept-Language'] = store?.state?.locale ?? 'zh'
return config
}, err)