mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: Element Plus 语言随 i18n 切换;用户侧登录/禁用提示接入 i18n
This commit is contained in:
@@ -1,25 +1,39 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view />
|
||||
<el-config-provider :locale="elLocale">
|
||||
<router-view />
|
||||
|
||||
<!-- 全局组件 -->
|
||||
<ToastNotification ref="toastRef" />
|
||||
<ConfirmDialog ref="confirmRef" />
|
||||
<!-- 全局组件 -->
|
||||
<ToastNotification ref="toastRef" />
|
||||
<ConfirmDialog ref="confirmRef" />
|
||||
</el-config-provider>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onMounted, ref, computed } from 'vue'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useThemeStore } from '@/stores/theme'
|
||||
import ToastNotification from '@/components/common/ToastNotification.vue'
|
||||
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
|
||||
import i18n from '@/i18n'
|
||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||
import zhTw from 'element-plus/dist/locale/zh-tw.mjs'
|
||||
import en from 'element-plus/dist/locale/en.mjs'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const themeStore = useThemeStore()
|
||||
const toastRef = ref()
|
||||
const confirmRef = ref()
|
||||
|
||||
// Element Plus 语言随 i18n 切换
|
||||
const elLocale = computed(() => {
|
||||
const l = i18n.global.locale.value
|
||||
if (l === 'zh-tw') return zhTw
|
||||
if (l === 'en') return en
|
||||
return zhCn
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化主题
|
||||
themeStore.initTheme()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import axios from 'axios'
|
||||
import i18n from '@/i18n'
|
||||
import { showToast } from '@/utils/toast'
|
||||
|
||||
const API_BASE = '/users'
|
||||
@@ -40,7 +41,7 @@ export const useUserStore = defineStore('user', {
|
||||
|
||||
return response.data
|
||||
} else {
|
||||
throw new Error(response.data.message || 'Login failed')
|
||||
throw new Error(response.data.message || i18n.global.t('user.login.loginFailed'))
|
||||
}
|
||||
} catch (error) {
|
||||
this.clearAuth()
|
||||
@@ -115,7 +116,9 @@ export const useUserStore = defineStore('user', {
|
||||
this.clearAuth()
|
||||
// If it's a disabled account error, throw a specific error
|
||||
if (error.response?.status === 403) {
|
||||
throw new Error(error.response.data?.message || 'Your account has been disabled')
|
||||
throw new Error(
|
||||
error.response.data?.message || i18n.global.t('user.login.accountDisabled')
|
||||
)
|
||||
}
|
||||
}
|
||||
throw error
|
||||
|
||||
Reference in New Issue
Block a user