diff --git a/frontend/public/locales/zh-CN/translation.json b/frontend/public/locales/zh-CN/translation.json index dcf2158..8e61724 100644 --- a/frontend/public/locales/zh-CN/translation.json +++ b/frontend/public/locales/zh-CN/translation.json @@ -935,5 +935,6 @@ "Failed to update user resource group": "更新用户资源组失败", "Failed to load simple resource groups": "获取简易资源组失败", "Failed to load resource group detail": "获取资源组详情失败", - "Resource Group Detail": "资源组详情" + "Resource Group Detail": "资源组详情", + "Current display time is UTC time": "当前显示时间为UTC时间" } diff --git a/frontend/src/components/mcp-services/ServiceEditPage.tsx b/frontend/src/components/mcp-services/ServiceEditPage.tsx index 6ccadfa..d16aadf 100644 --- a/frontend/src/components/mcp-services/ServiceEditPage.tsx +++ b/frontend/src/components/mcp-services/ServiceEditPage.tsx @@ -46,6 +46,19 @@ const isValidUrl = (url: string) => { } }; +// Helper function to validate domain format +const isValidDomain = (url: string) => { + if (!url) return false; + try { + const parsed = new URL(url); + const hostname = parsed.hostname; + const domainRegex = /^(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,})$/; + return domainRegex.test(hostname); + } catch { + return false; + } +}; + const validateServiceForm = (data: MCPServiceFormData, t: any) => { const errors: Record = {}; @@ -65,6 +78,8 @@ const validateServiceForm = (data: MCPServiceFormData, t: any) => { errors.base_url = t("API Endpoint is required"); } else if (!isValidUrl(data.base_url)) { errors.base_url = t("API Endpoint must be a valid HTTP/HTTPS URL"); + } else if (!isValidDomain(data.base_url)) { + errors.base_url = t("API Endpoint must contain a valid domain name"); } if (!data.short_description?.trim()) { diff --git a/frontend/src/components/resource-group/GroupServiceTable.tsx b/frontend/src/components/resource-group/GroupServiceTable.tsx index 5c6c8bf..d6d4777 100644 --- a/frontend/src/components/resource-group/GroupServiceTable.tsx +++ b/frontend/src/components/resource-group/GroupServiceTable.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, useMemo } from "react"; import { Button, Card, @@ -78,6 +78,12 @@ const GroupServiceTable: React.FC = ({ const urlGroupId = searchParams.get('groupId'); const currentGroupId = propGroupId || urlGroupId || null; + // 使用 useMemo 计算 showOptions,确保响应式更新 + const showOptions = useMemo(() => { + if (!resourceGroupDetail) return false; + return !['allow-all', 'deny-all'].includes(resourceGroupDetail.id); + }, [resourceGroupDetail]); + const getResourceGroup = async (groupId: string) => { const response = await fetchResourceGroupDetail(groupId); if (response) { @@ -100,7 +106,7 @@ const GroupServiceTable: React.FC = ({ {resourceGroupDetail?.name}
- {!['allow-all', 'deny-all'].includes(resourceGroupDetail?.id || '') && currentGroupId && <> + {showOptions && currentGroupId && <> -
+ { + showOptions && (<> +
+
+ +
-
-
+
+ + ) + } = ({ {t("API Endpoint")}{t("Status")}{t("Pricing")} - {t("Actions")} + {t("Actions")} = ({ loadingContent={} emptyContent={t("No services in this group")} > - {(service) => ( - - - {service.name} - - - {service.base_url} - - - - {t(service.enabled ? "Published" : "Unpublished")} - - - -
- -
-
- - - - - -
- )} + {t(service.enabled ? "Published" : "Unpublished")} + + + +
+ +
+
+ + + + + + + ); + }}
diff --git a/frontend/src/components/revenue-management/RevenueTable.tsx b/frontend/src/components/revenue-management/RevenueTable.tsx index 7d165a1..d214e68 100644 --- a/frontend/src/components/revenue-management/RevenueTable.tsx +++ b/frontend/src/components/revenue-management/RevenueTable.tsx @@ -10,11 +10,12 @@ import { TableCell, Pagination, Chip, - Spinner + Spinner, + Tooltip } from '@nextui-org/react'; import { useTranslation } from '@/shared/lib/useTranslation'; import { PaymentState, RevenueRecord } from '@/types/revenue'; -import { Calendar, CreditCard } from 'lucide-react'; +import { Calendar, CreditCard, HelpCircle } from 'lucide-react'; import { formatCurrency } from '@/shared/utils/currency'; interface RevenueTableProps { @@ -122,7 +123,19 @@ export const RevenueTable: React.FC = ({ {t('Account (Email)')} {t('Recharge Amount')} - {t('Recharge Time')} + +
+ {t('Recharge Time')} + + + +
+
{t('Payment Method')} {t('Transaction ID')} {t('Status')} diff --git a/frontend/src/components/user-management/UserTable.tsx b/frontend/src/components/user-management/UserTable.tsx index f72c1fc..b512f1d 100644 --- a/frontend/src/components/user-management/UserTable.tsx +++ b/frontend/src/components/user-management/UserTable.tsx @@ -17,7 +17,7 @@ import { } from "@nextui-org/react"; import { useTranslation } from "@/shared/lib/useTranslation"; import { User } from "@/types/user"; -import { Trash2, CreditCard } from "lucide-react"; +import { Trash2, CreditCard, Calendar, HelpCircle } from "lucide-react"; import { AdminRechargeModal } from "@/components/user-management/AdminRechargeModal"; import { fetchSimpleResourceGroups, updateUserResourceGroup } from "@/api/resourceGroup.api"; import toast from "react-hot-toast"; @@ -97,12 +97,23 @@ export const UserTable: React.FC = ({ fetchUsers(); } } - + + const formatDate = (dateString: string) => { + return ( +
+ + + {new Date(dateString).toLocaleString()} + +
+ ); + }; + // 初始加载简易资源组列表 useEffect(() => { loadSimpleResourceGroups(); }, [loadSimpleResourceGroups]); - + // 等待用户数据或资源组数据加载 if ((loading && users.length === 0) || groupsLoading) { return ( @@ -124,7 +135,19 @@ export const UserTable: React.FC = ({ {t("Email")} {t("Resource Group")} - {t("Register Date")} + +
+ {t("Register Date")} + + + +
+
{t("Balance")} {t("Actions")}
@@ -161,7 +184,7 @@ export const UserTable: React.FC = ({ )} - {user.created_at || "-"} + {formatDate(user.created_at)} {user.balance.toFixed(2) || "-"} diff --git a/frontend/src/shared/components/mcp-services/ResourceGroup.tsx b/frontend/src/shared/components/mcp-services/ResourceGroup.tsx index b769564..30187a3 100644 --- a/frontend/src/shared/components/mcp-services/ResourceGroup.tsx +++ b/frontend/src/shared/components/mcp-services/ResourceGroup.tsx @@ -14,9 +14,10 @@ import { Pagination, } from "@nextui-org/react"; import { useTranslation } from "@/shared/lib/useTranslation"; -import { Plus, SquareArrowOutUpRight, Trash2 } from "lucide-react"; +import { Calendar, Plus, Trash2, HelpCircle, Eye } from "lucide-react"; import { MCPServiceFormData } from "@/shared/types/mcp-service"; import toast from "react-hot-toast"; + import { GetMCPResourceGroupsParams } from "@/services/mcpService"; import DeleteServerModal from "@/components/resource-group/DeleteServerModal"; import { McpAddGroupModal } from "../modal/McpAddGroup"; @@ -97,6 +98,18 @@ const ResourceGroup: React.FC = ({ const onAddService = () => { setIsAddMcpGroupModalOpen(true); } + + const formatDate = (dateString: string) => { + return ( +
+ + + {new Date(dateString).toLocaleString()} + +
+ ); + }; + // 保存 MCP 服务 const handleSaveMcpServer = async (serverIds: string[]) => { if (!formData?.id) return; @@ -138,7 +151,7 @@ const ResourceGroup: React.FC = ({ const { pageSize, keyword } = resourceGroupsParams.current; loadResourceGroups(page, pageSize, keyword); } - + const openResourceGroupPage = (group: ResourceGroup) => { setResourceGroupDetailId(group.id); setIsResourceGroupDetailModalOpen(true); @@ -192,7 +205,19 @@ const ResourceGroup: React.FC = ({ > {t("Group Name")} - {t("Added Time")} + +
+ {t("Added Time")} + + + +
+
{t("Actions")}
= ({ {group.name}
- {group.join_at} + {formatDate(group.join_at)}
@@ -224,7 +249,7 @@ const ResourceGroup: React.FC = ({ color="primary" onPress={() => openResourceGroupPage(group)} > - + = ({ }, [onToggleStatus] ); - + const formatDate = (dateString: string) => { + return ( +
+ + + {new Date(dateString).toLocaleString()} + +
+ ); + }; if (loading && services.length === 0) { return (
@@ -117,6 +126,7 @@ const BaseServiceTable: React.FC = ({ + {t("Created_at")} {t("Actions")} = ({ />
+ {formatDate(service.created_at)}