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
@@ -23,10 +23,8 @@ import PromDsFormDialog from './prometheus-ds/PromDsFormDialog';
|
||||
import { PageLoading } from '@/components/layout/PageLoading';
|
||||
import { PageEmpty } from '@/components/layout/PageEmpty';
|
||||
import { ContentPanel } from '@/components/layout/ContentPanel';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export default function PrometheusDatasourceManager() {
|
||||
const { t } = useTranslation();
|
||||
const _confirm = useConfirm();
|
||||
const { data: sources = [], isLoading, isError } = usePromDatasources();
|
||||
const { deleteMutation, setDefaultMutation } = usePromDatasourceMutations();
|
||||
@@ -35,7 +33,7 @@ export default function PrometheusDatasourceManager() {
|
||||
const [editingDs, setEditingDs] = useState<PromDS | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (isError) toast.error(t('monitor.prometheusdatasourcemanager.s45f817'));
|
||||
if (isError) toast.error('获取数据源列表失败');
|
||||
}, [isError]);
|
||||
|
||||
const openCreate = () => {
|
||||
@@ -50,25 +48,25 @@ export default function PrometheusDatasourceManager() {
|
||||
|
||||
const handleDelete = async (ds: PromDS) => {
|
||||
const ok = await _confirm({
|
||||
title: t('monitor.deleteDatasource'),
|
||||
description: t('monitor.prometheusdatasourcemanager.s623d90', { ds.name: ds.name }),
|
||||
title: '删除数据源',
|
||||
description: `确定删除数据源「${ds.name}」吗?此操作不可撤销。`,
|
||||
variant: 'destructive',
|
||||
});
|
||||
if (!ok) return;
|
||||
try {
|
||||
await deleteMutation.mutateAsync(ds.id);
|
||||
toast.success(t('alert.deleted'));
|
||||
toast.success('已删除');
|
||||
} catch {
|
||||
toast.error(t('common.deleteFailed'));
|
||||
toast.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
const handleSetDefault = async (ds: PromDS) => {
|
||||
try {
|
||||
await setDefaultMutation.mutateAsync(ds.id);
|
||||
toast.success(t('monitor.prometheusdatasourcemanager.sa8bcc7', { ds.name: ds.name }));
|
||||
toast.success(`已将「${ds.name}」设为默认数据源`);
|
||||
} catch {
|
||||
toast.error(t('monitor.prometheusdatasourcemanager.s9f9603'));
|
||||
toast.error('设置失败');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -96,8 +94,8 @@ export default function PrometheusDatasourceManager() {
|
||||
{sources.length === 0 ? (
|
||||
<PageEmpty
|
||||
icon={<Database className="h-12 w-12" />}
|
||||
title=t('monitor.prometheusdatasourcemanager.s99ed81')
|
||||
description=t('monitor.prometheusdatasourcemanager.sd9a356')
|
||||
title="暂无 Prometheus 数据源"
|
||||
description="添加数据源后可用于指标监控与监控大屏"
|
||||
action={(
|
||||
<Button onClick={openCreate} size="sm" className="dg-btn-primary">
|
||||
<Plus className="w-4 h-4 mr-1" />添加数据源
|
||||
@@ -109,11 +107,11 @@ export default function PrometheusDatasourceManager() {
|
||||
<table className="w-full">
|
||||
<thead className="border-b border-[var(--border-default)]">
|
||||
<tr className="text-xs dg-text-secondary">
|
||||
<th className="text-left py-3 px-4 font-medium">{t('common.name')}</th>
|
||||
<th className="text-left py-3 px-4 font-medium">名称</th>
|
||||
<th className="text-left py-3 px-4 font-medium">URL</th>
|
||||
<th className="text-left py-3 px-4 font-medium w-20">{t('approval.status.default')}</th>
|
||||
<th className="text-left py-3 px-4 font-medium w-16">{t('common.status')}</th>
|
||||
<th className="text-right py-3 px-4 font-medium w-36">{t('common.actions')}</th>
|
||||
<th className="text-left py-3 px-4 font-medium w-20">默认</th>
|
||||
<th className="text-left py-3 px-4 font-medium w-16">状态</th>
|
||||
<th className="text-right py-3 px-4 font-medium w-36">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -144,16 +142,16 @@ export default function PrometheusDatasourceManager() {
|
||||
</td>
|
||||
<td className="py-3 px-4">
|
||||
{ds.is_default ? (
|
||||
<span className="dg-badge-yellow"><Star className="w-3 h-3 mr-1 inline" />{t('approval.status.default')}</span>
|
||||
<span className="dg-badge-yellow"><Star className="w-3 h-3 mr-1 inline" />默认</span>
|
||||
) : (
|
||||
<span className="text-xs dg-text-muted">--</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-3 px-4">
|
||||
{ds.status === 1 ? (
|
||||
<span className="dg-status-running">{t('common.enable')}</span>
|
||||
<span className="dg-status-running">启用</span>
|
||||
) : (
|
||||
<span className="dg-badge-muted">{t('common.disable')}</span>
|
||||
<span className="dg-badge-muted">禁用</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-3 px-4">
|
||||
@@ -162,7 +160,7 @@ export default function PrometheusDatasourceManager() {
|
||||
variant="ghost" size="sm"
|
||||
className="h-8 px-2"
|
||||
onClick={() => handleTestQuick(ds)}
|
||||
title=t('aiops.llmTest')
|
||||
title="测试连接"
|
||||
>
|
||||
<Plug className="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
@@ -171,7 +169,7 @@ export default function PrometheusDatasourceManager() {
|
||||
variant="ghost" size="sm"
|
||||
className="h-8 px-2 dg-text-yellow"
|
||||
onClick={() => handleSetDefault(ds)}
|
||||
title=t('aiops.llmSetDefault')
|
||||
title="设为默认"
|
||||
>
|
||||
<Star className="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user