feat: 品牌统一 LokiStack + 全站中英 i18n + 用户批量删除 + 主题定时切换与浅色侧栏
- 品牌: Go 模块/数据文件/二进制/构建部署资产全部 opsx→lokistack;前端 localStorage 命名空间迁移(读旧写新,含按用户 id 前缀迁移);修复 nginx upstream 与 Makefile 引用已改名服务的断裂 - i18n: react-i18next 落地,common + 11 个页面域命名空间全站中英(菜单/顶栏/登录/列表页/表单/确认弹窗/状态徽章);设置页语言即时切换;修复词典自注册导致的循环导入白屏 - 用户管理: 批量删除(POST /users/batch-delete,不删自己/最后管理员,部分失败不阻断)+ 行复选/全选/批量工具条 - 主题: 浅色侧栏(中性灰激活态)、四态模式(浅色/深色/跟随系统/定时切换,按时区判定)、顶栏太阳月亮二态、设置页紧凑分段选择器 - UI: 登录记住用户名、CardActionButton 统一五页卡片操作钮、shadcn Badge 替换手写徽章、语义色修正 - 清理: 移除主机 Web 终端(前后端)、k8s-helm/Helm 遗留代码与字段、README 重写精简 - 修复: 侧栏与日志告警 order 重复、路由标题 i18n key 未翻译、词典双逗号等
This commit is contained in:
1 parent
02d1bd87a7
commit
f3733f0bfc
201 files changed
+5438
-2388
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { memo, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Server, Plus } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { clusterApi, deploymentApi, collectorApi } from '@/api'
|
||||
import { PageContainer } from '@/components/PageContainer'
|
||||
@@ -11,15 +12,23 @@ import { ConfirmDialog } from '@/components/ConfirmDialog'
|
||||
import { toast } from 'sonner'
|
||||
import { useListQuery } from '@/hooks/useListQuery'
|
||||
import type { Cluster } from '@/types'
|
||||
import i18n from '@/i18n'
|
||||
import zhClusters from '@/i18n/locales/zh/clusters'
|
||||
import enClusters from '@/i18n/locales/en/clusters'
|
||||
import { ClusterCard } from './components/ClusterCard'
|
||||
import { ClusterFormDialog } from './components/ClusterFormDialog'
|
||||
import { ClusterDetailDialog } from './components/ClusterDetailDialog'
|
||||
|
||||
// 注册本域命名空间(i18n/index.ts 只负责 common,域词典就近注册;页面为懒加载,渲染前必然已注册)
|
||||
i18n.addResourceBundle('zh', 'clusters', zhClusters)
|
||||
i18n.addResourceBundle('en', 'clusters', enClusters)
|
||||
|
||||
/**
|
||||
* 集群管理页 — 只做编排:数据走 useListQuery(取消+版本号),
|
||||
* 卡片/表单/详情/删除确认均为域内子组件。成功操作静默(列表刷新即反馈)。
|
||||
*/
|
||||
const ClustersPage = memo(function ClustersPage() {
|
||||
const { t } = useTranslation('clusters')
|
||||
const query = useListQuery<Cluster>((params, signal) =>
|
||||
clusterApi.list(params, { signal })
|
||||
)
|
||||
@@ -64,11 +73,11 @@ const ClustersPage = memo(function ClustersPage() {
|
||||
setDeleteTarget(null)
|
||||
query.refresh()
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : '删除集群失败')
|
||||
toast.error(err instanceof Error ? err.message : t('toast.deleteFailed'))
|
||||
} finally {
|
||||
setDeleting(false)
|
||||
}
|
||||
}, [deleteTarget, query])
|
||||
}, [deleteTarget, query, t])
|
||||
|
||||
const handleValidate = useCallback(
|
||||
async (id: number) => {
|
||||
@@ -77,25 +86,22 @@ const ClustersPage = memo(function ClustersPage() {
|
||||
await clusterApi.validate(id)
|
||||
timeoutsRef.current.push(setTimeout(() => query.refresh(), 3000))
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : '验证失败')
|
||||
toast.error(err instanceof Error ? err.message : t('toast.validateFailed'))
|
||||
} finally {
|
||||
timeoutsRef.current.push(setTimeout(() => setValidating(null), 3000))
|
||||
}
|
||||
},
|
||||
[query]
|
||||
[query, t]
|
||||
)
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
title="集群管理"
|
||||
description="管理用于 Loki 部署的 Kubernetes 集群"
|
||||
title={t('title')}
|
||||
description={t('description')}
|
||||
action={
|
||||
<Button
|
||||
className="bg-primary hover:bg-primary/90"
|
||||
onClick={() => setFormOpen(true)}
|
||||
>
|
||||
<Button onClick={() => setFormOpen(true)}>
|
||||
<Plus className="w-4 h-4 mr-1" />
|
||||
添加集群
|
||||
{t('actions.add')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
@@ -106,8 +112,8 @@ const ClustersPage = memo(function ClustersPage() {
|
||||
) : query.list.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={Server}
|
||||
title="暂无集群"
|
||||
description="添加第一个 Kubernetes 集群开始使用"
|
||||
title={t('empty.title')}
|
||||
description={t('empty.description')}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
@@ -141,7 +147,7 @@ const ClustersPage = memo(function ClustersPage() {
|
||||
setEditingTarget(null)
|
||||
}
|
||||
}}
|
||||
onCreated={query.refresh}
|
||||
onCreated={() => (editingTarget ? query.refresh() : query.reload())}
|
||||
editing={editingTarget}
|
||||
/>
|
||||
|
||||
@@ -151,7 +157,6 @@ const ClustersPage = memo(function ClustersPage() {
|
||||
onClose={() => setDetailCluster(null)}
|
||||
/>
|
||||
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteTarget !== null}
|
||||
onOpenChange={(open) => {
|
||||
@@ -161,7 +166,11 @@ const ClustersPage = memo(function ClustersPage() {
|
||||
loading={deleting}
|
||||
description={
|
||||
refCount.dep + refCount.col > 0
|
||||
? `确定要删除「${deleteTarget?.name}」吗?警告:仍有 ${refCount.dep} 个部署、${refCount.col} 个采集策略引用该集群,删除后它们将无法工作。`
|
||||
? t('delete.warning', {
|
||||
name: deleteTarget?.name ?? '',
|
||||
dep: refCount.dep,
|
||||
col: refCount.col,
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
onConfirm={handleDelete}
|
||||
|
||||
Reference in new issue
Block a user