fix(i18n): 回退到稳定的 32% 覆盖率状态 (tsc + Vite 构建通过)
批量转换脚本引入的语法错误已回退,保留稳定的 i18n 转换: - 翻译词典: 22 namespaces, 3600+ keys - 已接入: 145+ 文件 (Dashboard/Login/K8s 主页面/Monitor/System/Deploy) - 语言切换器在 Header 中可用 (🇨🇳/🇺🇸) - tsc 零错误, Vite 构建成功
This commit is contained in:
1 parent
ecec73989b
commit
72bfb0e12d
191 files changed
+5057
-7592
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
import { Key, Loader2 } from 'lucide-react';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { userApi } from '@/api';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
interface ResetPasswordDialogProps {
|
||||
user: { id: number | string; username?: string; nickname?: string; authSource?: string } | null;
|
||||
@@ -16,6 +17,7 @@ interface ResetPasswordDialogProps {
|
||||
}
|
||||
|
||||
export function ResetPasswordDialog({ user, onClose }: ResetPasswordDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const { toast } = useToast();
|
||||
const [password, setPassword] = useState('');
|
||||
const [confirm, setConfirm] = useState('');
|
||||
@@ -29,12 +31,12 @@ export function ResetPasswordDialog({ user, onClose }: ResetPasswordDialogProps)
|
||||
setSaving(true);
|
||||
try {
|
||||
await userApi.resetUserPassword(user.id, password);
|
||||
toast({ title: '密码已重置', description: `用户 ${user.nickname || user.username} 的新密码已生效` });
|
||||
toast({ title: t('system.passwordReset'), description: `用户 ${user.nickname || user.username} 的新密码已生效` });
|
||||
setPassword('');
|
||||
setConfirm('');
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
toast({ title: '重置失败', description: e?.message || String(e), variant: 'destructive' });
|
||||
toast({ title: t('system.resetFailed'), description: e?.message || String(e), variant: 'destructive' });
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
@@ -46,7 +48,7 @@ export function ResetPasswordDialog({ user, onClose }: ResetPasswordDialogProps)
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-[var(--dg-text-primary)] flex items-center gap-2">
|
||||
<Key className="h-5 w-5 text-[var(--dg-blue)]" />
|
||||
重置密码
|
||||
{t('system.resetPassword')}
|
||||
</DialogTitle>
|
||||
<DialogDescription className="text-[var(--dg-text-muted)]">
|
||||
{user ? `为「${user.nickname || user.username}」设置新密码` : ''}
|
||||
@@ -54,26 +56,26 @@ export function ResetPasswordDialog({ user, onClose }: ResetPasswordDialogProps)
|
||||
</DialogHeader>
|
||||
|
||||
{isLdap ? (
|
||||
<p className="text-sm dg-text-yellow/90 py-2">LDAP 用户请在 LDAP 目录中管理密码,不支持本地重置。</p>
|
||||
<p className="text-sm dg-text-yellow/90 py-2">{t('system.ldapResetHint')}</p>
|
||||
) : (
|
||||
<div className="space-y-3 py-1">
|
||||
<div>
|
||||
<Label className="text-xs text-[var(--dg-text-muted)]">新密码</Label>
|
||||
<Label className="text-xs text-[var(--dg-text-muted)]">{t('system.newPassword')}</Label>
|
||||
<Input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={e => setPassword(e.target.value)}
|
||||
placeholder="至少 6 位"
|
||||
placeholder={t('system.passwordMinLen')}
|
||||
className="mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label className="text-xs text-[var(--dg-text-muted)]">确认密码</Label>
|
||||
<Label className="text-xs text-[var(--dg-text-muted)]">{t('system.userConfirmPassword')}</Label>
|
||||
<Input
|
||||
type="password"
|
||||
value={confirm}
|
||||
onChange={e => setConfirm(e.target.value)}
|
||||
placeholder="再次输入新密码"
|
||||
placeholder={t('system.confirmNewPassword')}
|
||||
className="mt-1 h-9 bg-[var(--dg-bg-tertiary)] border-[var(--dg-border)]"
|
||||
/>
|
||||
</div>
|
||||
@@ -81,7 +83,7 @@ export function ResetPasswordDialog({ user, onClose }: ResetPasswordDialogProps)
|
||||
)}
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="outline" className="border-[var(--dg-border)]" onClick={onClose}>取消</Button>
|
||||
<Button variant="outline" className="border-[var(--dg-border)]" onClick={onClose}>{t('common.cancel')}</Button>
|
||||
{!isLdap && (
|
||||
<Button onClick={handleReset} disabled={!canSubmit || saving} className="bg-[var(--dg-blue)] hover:opacity-90">
|
||||
{saving ? <Loader2 className="h-4 w-4 animate-spin mr-1" /> : null}
|
||||
|
||||
Reference in new issue
Block a user