fix(settings): 日志保留时间移出顶部并紧凑化
通用配置卡内顺序改为 主题 → 语言 → 日志保留时间;保留时间从嵌套整卡 压缩为单行分区(标签 + 两个数字输入 + 内联保存),与主题/语言分区同族, 删去 desc 与两条 hint 冗余文案(中英同步)。
This commit is contained in:
1 parent
cddd60045c
commit
231fa8e774
4 files changed
+36
-57
No files matched your search
@@ -2,7 +2,6 @@ import { memo, useCallback, useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { systemApi, type RetentionSettings } from '@/api/system'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
@@ -47,53 +46,39 @@ export const RetentionSection = memo(function RetentionSection() {
|
||||
}
|
||||
}, [settings, t])
|
||||
|
||||
// 紧凑单行分区(与主题/语言同族):标签 + 两个数字输入 + 内联保存,不再嵌套整卡
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-base">{t('retention.title')}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t('retention.desc')}</p>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div className="flex flex-col">
|
||||
<label className="text-sm font-medium" htmlFor="retention-alert">
|
||||
{t('retention.alertLabel')}
|
||||
</label>
|
||||
<Input
|
||||
id="retention-alert"
|
||||
type="number"
|
||||
min={1}
|
||||
max={365}
|
||||
className="mt-1"
|
||||
disabled={loading}
|
||||
value={settings.alertDeliveryDays}
|
||||
onChange={e => setSettings(s => ({ ...s, alertDeliveryDays: Number(e.target.value) || 0 }))}
|
||||
/>
|
||||
<p className="mt-1 min-h-4 text-xs text-muted-foreground">{t('retention.alertHint')}</p>
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<label className="text-sm font-medium" htmlFor="retention-audit">
|
||||
{t('retention.auditLabel')}
|
||||
</label>
|
||||
<Input
|
||||
id="retention-audit"
|
||||
type="number"
|
||||
min={1}
|
||||
max={3650}
|
||||
className="mt-1"
|
||||
disabled={loading}
|
||||
value={settings.auditLogDays}
|
||||
onChange={e => setSettings(s => ({ ...s, auditLogDays: Number(e.target.value) || 0 }))}
|
||||
/>
|
||||
<p className="mt-1 min-h-4 text-xs text-muted-foreground">{t('retention.auditHint')}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end">
|
||||
<Button onClick={() => void save()} disabled={saving || loading}>
|
||||
{saving ? t('retention.saving') : t('retention.save')}
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-border pt-3">
|
||||
<span className="min-w-14 shrink-0 text-sm text-muted-foreground">{t('retention.title')}</span>
|
||||
<label className="flex items-center gap-1.5 text-xs text-muted-foreground" htmlFor="retention-alert">
|
||||
{t('retention.alertLabel')}
|
||||
<Input
|
||||
id="retention-alert"
|
||||
type="number"
|
||||
min={1}
|
||||
max={365}
|
||||
className="h-8 w-20"
|
||||
disabled={loading}
|
||||
value={settings.alertDeliveryDays}
|
||||
onChange={e => setSettings(s => ({ ...s, alertDeliveryDays: Number(e.target.value) || 0 }))}
|
||||
/>
|
||||
</label>
|
||||
<label className="flex items-center gap-1.5 text-xs text-muted-foreground" htmlFor="retention-audit">
|
||||
{t('retention.auditLabel')}
|
||||
<Input
|
||||
id="retention-audit"
|
||||
type="number"
|
||||
min={1}
|
||||
max={3650}
|
||||
className="h-8 w-20"
|
||||
disabled={loading}
|
||||
value={settings.auditLogDays}
|
||||
onChange={e => setSettings(s => ({ ...s, auditLogDays: Number(e.target.value) || 0 }))}
|
||||
/>
|
||||
</label>
|
||||
<Button size="sm" variant="outline" className="ml-auto" onClick={() => void save()} disabled={saving || loading}>
|
||||
{saving ? t('retention.saving') : t('retention.save')}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
@@ -81,9 +81,9 @@ const SettingsPage = memo(function SettingsPage() {
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
<RetentionSection />
|
||||
<ThemeSection />
|
||||
<LanguageSection />
|
||||
<RetentionSection />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
Reference in new issue
Block a user