feat: 支持 RPC 节点启用/禁用功能
- 后端:更新 RpcNodeService,确保禁用的节点被忽略 - getAllNodesWithDefault() 只返回启用的节点 - checkAllNodesHealth() 只检查启用的节点 - getAvailableNode() 已正确实现,只查询启用的节点 - 前端:添加启用/禁用开关功能 - 在 RpcNodeSettings 页面添加启用列,使用 Switch 组件 - 添加 handleToggleEnabled 函数处理启用/禁用切换 - 添加多语言支持(中文简体、繁体、英文)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Card, Table, Button, Space, Badge, message, Popconfirm, Tag } from 'antd'
|
||||
import { Card, Table, Button, Space, Badge, message, Popconfirm, Tag, Switch } from 'antd'
|
||||
import { UpOutlined, DownOutlined, DeleteOutlined, ReloadOutlined, PlusOutlined, ApiOutlined } from '@ant-design/icons'
|
||||
import { apiService } from '../services/api'
|
||||
import type { RpcNodeConfig } from '../types'
|
||||
@@ -92,6 +92,20 @@ const RpcNodeSettings: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleToggleEnabled = async (id: number, enabled: boolean) => {
|
||||
try {
|
||||
const response = await apiService.rpcNodes.update({ id, enabled })
|
||||
if (response.data.code === 0) {
|
||||
message.success(enabled ? t('rpcNodeSettings.enableSuccess') : t('rpcNodeSettings.disableSuccess'))
|
||||
fetchNodes()
|
||||
} else {
|
||||
message.error(response.data.msg || t('rpcNodeSettings.updateFailed'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
message.error(error.message || t('rpcNodeSettings.updateFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t('rpcNodeSettings.priority'),
|
||||
@@ -126,6 +140,17 @@ const RpcNodeSettings: React.FC = () => {
|
||||
dataIndex: 'name',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: t('rpcNodeSettings.enabled'),
|
||||
dataIndex: 'enabled',
|
||||
width: 100,
|
||||
render: (enabled: boolean, record: RpcNodeConfig) => (
|
||||
<Switch
|
||||
checked={enabled}
|
||||
onChange={(checked) => handleToggleEnabled(record.id, checked)}
|
||||
/>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: t('rpcNodeSettings.status'),
|
||||
dataIndex: 'lastCheckStatus',
|
||||
|
||||
Reference in New Issue
Block a user