mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-27 19:29:52 +08:00
更新国际化支持:为用户卡片及相关组件添加多语言文本,提升用户体验
This commit is contained in:
@@ -7,6 +7,10 @@ import { useToast } from 'vue-toast-notification'
|
||||
import { useConfirm } from 'vuetify-use-dialog'
|
||||
import UserAddEditDialog from '@/components/dialog/UserAddEditDialog.vue'
|
||||
import { useDisplay } from 'vuetify'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
// 国际化
|
||||
const { t } = useI18n()
|
||||
|
||||
// 扩展User类型以包含昵称字段
|
||||
interface ExtendedUser extends User {
|
||||
@@ -77,21 +81,21 @@ async function fetchSubscriptions() {
|
||||
// 删除用户
|
||||
async function removeUser() {
|
||||
if (props.user.id === currentLoginUserId.value) {
|
||||
$toast.error('不能删除当前登录用户!')
|
||||
$toast.error(t('user.cannotDeleteCurrentUser'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
const isConfirmed = await createConfirm({
|
||||
title: '注意',
|
||||
content: `删除用户 ${props.user?.name} 的所有数据,是否确认?`,
|
||||
title: t('common.confirm'),
|
||||
content: t('user.confirmDeleteUser', { username: props.user?.name }),
|
||||
})
|
||||
if (!isConfirmed) return
|
||||
const result: { [key: string]: any } = await api.delete(`user/id/${props.user.id}`)
|
||||
if (result.success) {
|
||||
$toast.success('用户删除成功')
|
||||
$toast.success(t('user.deleteSuccess'))
|
||||
emit('remove')
|
||||
} else {
|
||||
$toast.error('用户删除失败!')
|
||||
$toast.error(t('user.deleteFailed'))
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
@@ -170,10 +174,12 @@ onMounted(() => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-1 overflow-auto">
|
||||
<VChip v-if="user.is_superuser" size="x-small" color="error" variant="outlined" label>管理员</VChip>
|
||||
<VChip v-else size="x-small" label>普通用户</VChip>
|
||||
<VChip v-if="user.is_superuser" size="x-small" color="error" variant="outlined" label>{{
|
||||
t('user.admin')
|
||||
}}</VChip>
|
||||
<VChip v-else size="x-small" label>{{ t('user.normal') }}</VChip>
|
||||
<VChip size="x-small" :color="user.is_active ? 'success' : 'grey'" variant="tonal" label>
|
||||
{{ user.is_active ? '激活' : '已停用' }}
|
||||
{{ user.is_active ? t('user.active') : t('user.inactive') }}
|
||||
</VChip>
|
||||
<VChip v-if="user.is_otp" size="x-small" color="info" variant="tonal" label>2FA</VChip>
|
||||
</div>
|
||||
@@ -226,7 +232,7 @@ onMounted(() => {
|
||||
|
||||
<VCardText class="d-flex align-center py-2 px-4 text-medium-emphasis">
|
||||
<VIcon icon="mdi-email-outline" size="small" color="primary" class="mr-2 opacity-70" />
|
||||
<span class="text-body-2 truncate">{{ user.email || '未设置邮箱' }}</span>
|
||||
<span class="text-body-2 truncate">{{ user.email || t('user.noEmail') }}</span>
|
||||
</VCardText>
|
||||
|
||||
<!-- PC端显示订阅统计信息 -->
|
||||
@@ -246,7 +252,7 @@ onMounted(() => {
|
||||
</VAvatar>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="text-lg text-medium-emphasis font-weight-bold">{{ movieSubscriptions }}</span>
|
||||
<span class="text-caption text-medium-emphasis">电影订阅</span>
|
||||
<span class="text-caption text-medium-emphasis">{{ t('user.movieSubscriptions') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-center gap-3">
|
||||
@@ -263,7 +269,7 @@ onMounted(() => {
|
||||
</VAvatar>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="text-lg text-medium-emphasis">{{ tvShowSubscriptions }}</span>
|
||||
<span class="text-caption text-medium-emphasis">剧集订阅</span>
|
||||
<span class="text-caption text-medium-emphasis">{{ t('user.tvSubscriptions') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -194,8 +194,17 @@ export default {
|
||||
bangumi: 'Bangumi',
|
||||
},
|
||||
user: {
|
||||
admin: 'Administrator',
|
||||
normalUser: 'Regular User',
|
||||
admin: 'Admin',
|
||||
normal: 'Normal User',
|
||||
active: 'Active',
|
||||
inactive: 'Inactive',
|
||||
noEmail: 'No Email',
|
||||
movieSubscriptions: 'Movie Subscriptions',
|
||||
tvSubscriptions: 'TV Show Subscriptions',
|
||||
cannotDeleteCurrentUser: 'Cannot delete the currently logged in user!',
|
||||
confirmDeleteUser: 'Are you sure you want to delete all data of user {username}?',
|
||||
deleteSuccess: 'User deleted successfully',
|
||||
deleteFailed: 'Failed to delete user!',
|
||||
profile: 'Profile',
|
||||
systemSettings: 'System Settings',
|
||||
siteAuth: 'User Authentication',
|
||||
|
||||
@@ -195,7 +195,16 @@ export default {
|
||||
},
|
||||
user: {
|
||||
admin: '管理员',
|
||||
normalUser: '普通用户',
|
||||
normal: '普通用户',
|
||||
active: '激活',
|
||||
inactive: '已停用',
|
||||
noEmail: '未设置邮箱',
|
||||
movieSubscriptions: '电影订阅',
|
||||
tvSubscriptions: '剧集订阅',
|
||||
cannotDeleteCurrentUser: '不能删除当前登录用户!',
|
||||
confirmDeleteUser: '删除用户 {username} 的所有数据,是否确认?',
|
||||
deleteSuccess: '用户删除成功',
|
||||
deleteFailed: '用户删除失败!',
|
||||
profile: '个人信息',
|
||||
systemSettings: '系统设定',
|
||||
siteAuth: '用户认证',
|
||||
|
||||
@@ -195,7 +195,16 @@ export default {
|
||||
},
|
||||
user: {
|
||||
admin: '管理員',
|
||||
normalUser: '普通用戶',
|
||||
normal: '普通用戶',
|
||||
active: '激活',
|
||||
inactive: '已停用',
|
||||
noEmail: '未設置郵箱',
|
||||
movieSubscriptions: '電影訂閱',
|
||||
tvSubscriptions: '劇集訂閱',
|
||||
cannotDeleteCurrentUser: '不能刪除當前登入用戶!',
|
||||
confirmDeleteUser: '刪除用戶 {username} 的所有數據,是否確認?',
|
||||
deleteSuccess: '用戶刪除成功',
|
||||
deleteFailed: '用戶刪除失敗!',
|
||||
profile: '個人信息',
|
||||
systemSettings: '系統設定',
|
||||
siteAuth: '用戶認證',
|
||||
|
||||
Reference in New Issue
Block a user