diff --git a/frontend/public/locales/en/translation.json b/frontend/public/locales/en/translation.json index 27d58ea..a5be8bc 100644 --- a/frontend/public/locales/en/translation.json +++ b/frontend/public/locales/en/translation.json @@ -40,6 +40,7 @@ "Featured Packages": "Featured Packages", "Individual Tools": "Individual Tools", "Details": "Details", + "Copy code": "Copy code", "excel": "Excel", "data": "Data", "analysis": "Analysis", @@ -198,6 +199,27 @@ "Tool name": "Tool name", "Tool description": "Tool description", "Take Offline": "Take Offline", + "Platform Domain": "Platform Domain", + "Enter platform domain (e.g., example.com)": "Enter platform domain (e.g., example.com)", + "The domain name of your platform": "The domain name of your platform", + "MCP Server Domain": "MCP Server Domain", + "Enter MCP server domain (e.g., api.example.com)": "Enter MCP server domain (e.g., api.example.com)", + "The domain for MCP server API calls": "The domain for MCP server API calls", + "Featured in the XPack showcase": "Featured in the XPack showcase", + "Enable this option to feature your site in the XPack global showcase and reach users worldwide.": "Enable this option to feature your site in the XPack global showcase and reach users worldwide.", + "Please enter a platform domain before enabling showcase": "Please enter a platform domain before enabling showcase", + "FAQ Management": "FAQ Management", + "Configure frequently asked questions for your users": "Configure frequently asked questions for your users", + "FAQ List": "FAQ List", + "Edit questions and answers directly in the table below": "Edit questions and answers directly in the table below", + "Save All": "Save All", + "Order": "Order", + "Question": "Question", + "Answer": "Answer", + "No FAQ items available.": "No FAQ items available.", + "Enter question": "Enter question", + "Enter answer": "Enter answer", + "Insert below": "Insert below", "Bring Online": "Bring Online", "Short Description": "Short Description", "Long Description": "Long Description", @@ -234,6 +256,8 @@ "Failed to parse OpenAPI document": "Failed to parse OpenAPI document", "OpenAPI document parsed successfully": "OpenAPI document parsed successfully", "Please enter a valid URL": "Please enter a valid URL", + "Please enter a valid URL with http:// or https://": "Please enter a valid URL with http:// or https://", + "Please fix validation errors before saving": "Please fix validation errors before saving", "Please select a file": "Please select a file", "File uploaded successfully": "File uploaded successfully", "Failed to upload file": "Failed to upload file", @@ -306,6 +330,14 @@ "All Roles": "All Roles", "Ban User": "Ban User", "Unban User": "Unban User", + "Recharge User": "Recharge User", + "Current Balance": "Current Balance", + "User recharged successfully": "User recharged successfully", + "Please enter a valid amount": "Please enter a valid amount", + "Minimum recharge amount is $1": "Minimum recharge amount is $1", + "User not selected": "User not selected", + "Recharge failed": "Recharge failed", + "Network error, please try again": "Network error, please try again", "Delete User": "Delete User", "View Profile": "View Profile", "Edit User": "Edit User", @@ -386,12 +418,20 @@ "Failed to test Google auth": "Failed to test Google auth", "Failed to fetch Stripe config": "Failed to fetch Stripe config", "Failed to save Stripe config": "Failed to save Stripe config", + "Failed to save Alipay config": "Failed to save Alipay config", + "Failed to save WeChat config": "Failed to save WeChat config", "Stripe connection test failed": "Stripe connection test failed", "Stripe connection test successful": "Stripe connection test successful", + "Alipay connection test successful": "Alipay connection test successful", + "Alipay connection test failed": "Alipay connection test failed", + "WeChat connection test successful": "WeChat connection test successful", + "WeChat connection test failed": "WeChat connection test failed", "Connection test failed": "Connection test failed", "Unknown error": "Unknown error", "Secret Key cannot be empty": "Secret Key cannot be empty", "Stripe Configuration": "Stripe Configuration", + "Alipay Configuration": "Alipay Configuration", + "WeChat Configuration": "WeChat Configuration", "Google Login Settings": "Google Login Settings", "Enable Google Login": "Enable Google Login", "Administrator Account": "Administrator Account", @@ -533,8 +573,19 @@ "Billing Mode": "Billing Mode", "Enable free quota": "Enable free quota", "Configure Stripe payment interface": "Configure Stripe payment interface", + "Configure Alipay payment interface": "Configure Alipay payment interface", + "Configure WeChat payment interface": "Configure WeChat payment interface", "Secret Key": "Secret Key", "Stripe secret key for server-side API calls": "Stripe secret key for server-side API calls", + "App ID": "App ID", + "Alipay App ID": "Alipay App ID", + "App Private Key": "App Private Key", + "Alipay App Private Key": "Alipay App Private Key", + "Alipay Public Key": "Alipay Public Key", + "Alipay public key for verification": "Alipay public key for verification", + "WeChat App ID": "WeChat App ID", + "Merchant ID": "Merchant ID", + "WeChat Merchant ID": "WeChat Merchant ID", "Webhook Secret": "Webhook Secret", "Test Connection": "Test Connection", "Monitor platform revenue and view user recharge history": "Monitor platform revenue and view user recharge history", @@ -593,6 +644,7 @@ "Confirm": "Confirm", "Recharge Account": "Recharge Account", "Funds will be added to your account balance": "Funds will be added to your account balance", + "Please select a payment method": "Please select a payment method", "Manage your balance and recharge history": "Manage your balance and recharge history", "Build incredible AI agents together": "Build incredible AI agents together", "Balance: {{amount}}": "Balance: {{amount}}", @@ -633,6 +685,12 @@ "Total Revenue": "Total Revenue", "Failed to save stripe config": "Failed to save stripe config", "Stripe config saved successfully": "Stripe config saved successfully", + "Alipay config saved successfully": "Alipay config saved successfully", + "WeChat config saved successfully": "WeChat config saved successfully", + "Failed to save {{channelName}} config": "Failed to save {{channelName}} config", + "{{channelName}} config saved successfully": "{{channelName}} config saved successfully", + "{{channelName}} connection test failed": "{{channelName}} connection test failed", + "{{channelName}} connection test successful": "{{channelName}} connection test successful", "Login successful": "Login successful", "Logged out successfully": "Logged out successfully", "Configure email settings": "Configure email settings", @@ -727,5 +785,91 @@ "Theme changed successfully": "Theme changed successfully", "Failed to change theme": "Failed to change theme", "About page saved successfully": "About page saved successfully", - "Failed to save about page": "Failed to save about page" + "Failed to save about page": "Failed to save about page", + "General": "General", + "Homepage": "Homepage", + "Homepage content and theme settings": "Homepage content and theme settings", + "About Page": "About Page", + "About page content configuration": "About page content configuration", + "Email & Admin": "Email & Admin", + "Email and administrator settings": "Email and administrator settings", + "Embedded HTML": "Embedded HTML", + "Configure custom HTML content for global injection": "Configure custom HTML content for global injection", + "Enable Custom HTML": "Enable Custom HTML", + "Toggle to enable or disable custom HTML injection": "Toggle to enable or disable custom HTML injection", + "Show Preview": "Show Preview", + "Hide Preview": "Hide Preview", + "Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n\n\n": "Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n\n\n", + "This HTML will be injected globally into the application. You can include script tags, CSS styles, or any valid HTML.": "This HTML will be injected globally into the application. You can include script tags, CSS styles, or any valid HTML.", + "Preview": "Preview", + "Note: This is a text preview. The actual HTML will be rendered when saved and enabled.": "Note: This is a text preview. The actual HTML will be rendered when saved and enabled.", + "Usage Instructions": "Usage Instructions", + "You can include Google Analytics, custom CSS, or any tracking scripts": "You can include Google Analytics, custom CSS, or any tracking scripts", + "The HTML will be injected into the document head section": "The HTML will be injected into the document head section", + "Make sure your code is valid to avoid breaking the application": "Make sure your code is valid to avoid breaking the application", + "Changes take effect immediately after saving and enabling": "Changes take effect immediately after saving and enabling", + "Welcome to Your Platform": "Welcome to Your Platform", + "Let's set up your platform with some basic information": "Let's set up your platform with some basic information", + "Information needed": "Information needed", + "Fields marked with * are required": "Fields marked with * are required", + "Website title is required": "Website title is required", + "Headline is required": "Headline is required", + "Subheadline is required": "Subheadline is required", + "Please fill in all required fields": "Please fill in all required fields", + "Setup failed. Please try again.": "Setup failed. Please try again.", + "Complete Setup": "Complete Setup", + "Platform setup completed successfully!": "Platform setup completed successfully!", + "Welcome to the famous five-minute platform setup process! Just fill in the information below and you'll be on your way to using the most extendable and powerful platform.": "Welcome to the famous five-minute platform setup process! Just fill in the information below and you'll be on your way to using the most extendable and powerful platform.", + "Please provide the following information. Do not worry, you can always change these settings later in the admin panel.": "Please provide the following information. Do not worry, you can always change these settings later in the admin panel.", + "Failed to update homepage config": "Failed to update homepage config", + "Homepage config updated successfully": "Homepage config updated successfully", + "Failed to load homepage config": "Failed to load homepage config", + "FAQ updated successfully": "FAQ updated successfully", + "Navigation updated successfully": "Navigation updated successfully", + "Embedded HTML updated successfully": "Embedded HTML updated successfully", + "Payment channels updated successfully": "Payment channels updated successfully", + "Manage frequently asked questions": "Manage frequently asked questions", + "Add FAQ Item": "Add FAQ Item", + "Remove FAQ Item": "Remove FAQ Item", + "Top Navigation": "Top Navigation", + "Manage top navigation links": "Manage top navigation links", + "Title": "Title", + "Link": "Link", + "Target": "Target", + "Add Navigation Item": "Add Navigation Item", + "Remove Navigation Item": "Remove Navigation Item", + "Enter title": "Enter title", + "Enter link URL": "Enter link URL", + "Same window": "Same window", + "New window": "New window", + "Custom HTML injection": "Custom HTML injection", + "Enable embedded HTML": "Enable embedded HTML", + "HTML Content": "HTML Content", + "Enter custom HTML code": "Enter custom HTML code", + "Manage payment methods": "Manage payment methods", + "Channel ID": "Channel ID", + "Display Name": "Display Name", + "Add Payment Channel": "Add Payment Channel", + "Remove Payment Channel": "Remove Payment Channel", + "Enter channel ID": "Enter channel ID", + "Enter display name": "Enter display name", + "Installation Status": "Installation Status", + "First time installation": "First time installation", + "System installed": "System installed", + "Configure top navigation menu items and links": "Configure top navigation menu items and links", + "Per Million Tokens": "Per Million Tokens", + "Price per million tokens consumed": "Price per million tokens consumed", + "Price per million tokens": "Price per million tokens", + "Price per API call": "Price per API call", + "Payment channel disabled successfully": "Payment channel disabled successfully", + "Failed to disable payment channel": "Failed to disable payment channel", + "Payment channel enabled successfully": "Payment channel enabled successfully", + "Failed to enable payment channel": "Failed to enable payment channel", + "Input Token Price": "Input Token Price", + "Output Token Price": "Output Token Price", + "Price per million input tokens": "Price per million input tokens", + "Price per million output tokens": "Price per million output tokens", + "Input": "Input", + "Output": "Output", + "1M tokens": "1M tokens" } diff --git a/frontend/public/locales/zh-CN/translation.json b/frontend/public/locales/zh-CN/translation.json index 8cf41e9..993b599 100644 --- a/frontend/public/locales/zh-CN/translation.json +++ b/frontend/public/locales/zh-CN/translation.json @@ -40,6 +40,7 @@ "Featured Packages": "精选工具包", "Individual Tools": "单个工具", "Details": "详情", + "Copy code": "复制代码", "excel": "Excel", "data": "数据", "analysis": "分析", @@ -199,6 +200,27 @@ "Tool name": "工具名称", "Tool description": "工具描述", "Take Offline": "下线", + "Platform Domain": "平台域名", + "Enter platform domain (e.g., example.com)": "输入平台域名(例如:example.com)", + "The domain name of your platform": "您平台的域名", + "MCP Server Domain": "MCP 服务器域名", + "Enter MCP server domain (e.g., api.example.com)": "输入 MCP 服务器域名(例如:api.example.com)", + "The domain for MCP server API calls": "用于 MCP 服务器 API 调用的域名", + "Featured in the XPack showcase": "展示在 XPack 的全球案例榜单", + "Enable this option to feature your site in the XPack global showcase and reach users worldwide.": "当开启选项,你的网站会展示在 XPack 的全球案例榜单来获得全球用户的关注。", + "Please enter a platform domain before enabling showcase": "启用展示功能前请先输入平台域名", + "FAQ Management": "FAQ管理", + "Configure frequently asked questions for your users": "为您的用户配置常见问题", + "FAQ List": "FAQ列表", + "Edit questions and answers directly in the table below": "在下方表格中直接编辑问题和答案", + "Save All": "保存全部", + "Order": "排序", + "Question": "问题", + "Answer": "答案", + "No FAQ items available.": "暂无FAQ项目。", + "Enter question": "输入问题", + "Enter answer": "输入答案", + "Insert below": "在下方插入", "Bring Online": "上线", "Short Description": "简短描述", "Long Description": "详细描述", @@ -235,6 +257,8 @@ "Failed to parse OpenAPI document": "解析 OpenAPI 文档失败", "OpenAPI document parsed successfully": "OpenAPI 文档解析成功", "Please enter a valid URL": "请输入有效的 URL", + "Please enter a valid URL with http:// or https://": "请输入有效的 URL,需要包含 http:// 或 https://", + "Please fix validation errors before saving": "请修复验证错误后再保存", "Please select a file": "请选择文件", "File uploaded successfully": "文件上传成功", "Failed to upload file": "文件上传失败", @@ -307,6 +331,14 @@ "All Roles": "所有角色", "Ban User": "封禁用户", "Unban User": "解封用户", + "Recharge User": "为用户充值", + "Current Balance": "当前余额", + "User recharged successfully": "用户充值成功", + "Please enter a valid amount": "请输入有效金额", + "Minimum recharge amount is $1": "最低充值金额为 $1", + "User not selected": "未选择用户", + "Recharge failed": "充值失败", + "Network error, please try again": "网络错误,请重试", "Delete User": "删除用户", "View Profile": "查看资料", "Edit User": "编辑用户", @@ -387,12 +419,20 @@ "Failed to test Google auth": "测试Google认证失败", "Failed to fetch Stripe config": "获取Stripe配置失败", "Failed to save Stripe config": "保存Stripe配置失败", + "Failed to save Alipay config": "保存支付宝配置失败", + "Failed to save WeChat config": "保存微信配置失败", "Stripe connection test failed": "Stripe连接测试失败", "Stripe connection test successful": "Stripe连接测试成功", + "Alipay connection test successful": "支付宝连接测试成功", + "Alipay connection test failed": "支付宝连接测试失败", + "WeChat connection test successful": "微信连接测试成功", + "WeChat connection test failed": "微信连接测试失败", "Connection test failed": "连接测试失败", "Unknown error": "未知错误", "Secret Key cannot be empty": "密钥不能为空", "Stripe Configuration": "Stripe配置", + "Alipay Configuration": "支付宝配置", + "WeChat Configuration": "微信配置", "Google Login Settings": "Google登录设置", "Enable Google Login": "启用Google登录", "Administrator Account": "管理员账户", @@ -535,6 +575,17 @@ "Billing Mode": "计费模式", "Enable free quota": "启用免费配额", "Configure Stripe payment interface": "配置Stripe支付接口", + "Configure Alipay payment interface": "配置支付宝支付接口", + "Configure WeChat payment interface": "配置微信支付接口", + "App ID": "应用ID", + "Alipay App ID": "支付宝应用ID", + "App Private Key": "应用私钥", + "Alipay App Private Key": "支付宝应用私钥", + "Alipay Public Key": "支付宝公钥", + "Alipay public key for verification": "支付宝公钥用于验证", + "WeChat App ID": "微信应用ID", + "Merchant ID": "商户号", + "WeChat Merchant ID": "微信商户号", "Secret Key": "密钥", "Stripe secret key for server-side API calls": "用于服务端API调用的Stripe密钥", "Webhook Secret": "Webhook密钥", @@ -594,7 +645,8 @@ "WeChat Pay": "微信支付", "Confirm": "确认", "Recharge Account": "充值账户", - "Funds will be added to your account balance": "资金将添加到您的账户余额", + "Funds will be added to your account balance": "资金将添加到您的账户余额中", + "Please select a payment method": "请选择支付方式", "Manage your balance and recharge history": "管理您的余额和充值历史", "Build incredible AI agents together": "一起构建强大的 AI 代理", "Balance: {{amount}}": "余额: {{amount}}", @@ -609,6 +661,10 @@ "Failed to toggle service status": "切换服务状态失败", "Stripe configuration saved successfully": "Stripe 配置保存成功", "Failed to save Stripe configuration": "保存 Stripe 配置失败", + "Failed to save {{channelName}} config": "保存{{channelName}}配置失败", + "{{channelName}} config saved successfully": "{{channelName}}配置保存成功", + "{{channelName}} connection test failed": "{{channelName}}连接测试失败", + "{{channelName}} connection test successful": "{{channelName}}连接测试成功", "System config updated successfully": "系统配置更新成功", "Failed to update system config": "更新系统配置失败", "Confirm Purchase": "确认购买", @@ -635,6 +691,8 @@ "Total Revenue": "总收入", "Failed to save stripe config": "保存 Stripe 配置失败", "Stripe config saved successfully": "Stripe 配置保存成功", + "Alipay config saved successfully": "支付宝配置保存成功", + "WeChat config saved successfully": "微信配置保存成功", "Login successful": "登录成功", "Logged out successfully": "退出登录成功", "Configure email settings": "配置邮箱设置", @@ -729,5 +787,91 @@ "Theme changed successfully": "主题切换成功", "Failed to change theme": "主题切换失败", "About page saved successfully": "关于页面保存成功", - "Failed to save about page": "关于页面保存失败" + "Failed to save about page": "关于页面保存失败", + "General": "常规设置", + "Homepage": "首页设置", + "Homepage content and theme settings": "首页内容和主题设置", + "About Page": "关于页面", + "About page content configuration": "关于页面内容配置", + "Email & Admin": "邮箱与管理员", + "Email and administrator settings": "邮箱和管理员设置", + "Embedded HTML": "嵌入式HTML", + "Configure custom HTML content for global injection": "配置自定义HTML内容进行全局注入", + "Enable Custom HTML": "启用自定义HTML", + "Toggle to enable or disable custom HTML injection": "切换启用或禁用自定义HTML注入", + "Show Preview": "显示预览", + "Hide Preview": "隐藏预览", + "Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n\n\n": "在此输入您的自定义HTML、CSS或JavaScript代码...\n\n示例:\n\n\n", + "This HTML will be injected globally into the application. You can include script tags, CSS styles, or any valid HTML.": "此HTML将全局注入到应用程序中。您可以包含脚本标签、CSS样式或任何有效的HTML。", + "Preview": "预览", + "Note: This is a text preview. The actual HTML will be rendered when saved and enabled.": "注意:这是文本预览。实际的HTML将在保存并启用后渲染。", + "Usage Instructions": "使用说明", + "You can include Google Analytics, custom CSS, or any tracking scripts": "您可以包含Google Analytics、自定义CSS或任何跟踪脚本", + "The HTML will be injected into the document head section": "HTML将注入到文档头部分", + "Make sure your code is valid to avoid breaking the application": "确保您的代码有效,以避免破坏应用程序", + "Changes take effect immediately after saving and enabling": "更改在保存并启用后立即生效", + "Welcome to Your Platform": "欢迎使用您的平台", + "Let's set up your platform with some basic information": "让我们用一些基本信息来设置您的平台", + "Fields marked with * are required": "标有 * 的字段为必填项", + "Website title is required": "网站标题为必填项", + "Headline is required": "标题为必填项", + "Subheadline is required": "副标题为必填项", + "Please fill in all required fields": "请填写所有必填字段", + "Setup failed. Please try again.": "设置失败,请重试。", + "Complete Setup": "完成设置", + "Platform setup completed successfully!": "平台设置成功完成!", + "Welcome to the famous five-minute platform setup process! Just fill in the information below and you'll be on your way to using the most extendable and powerful platform.": "欢迎使用著名的五分钟平台设置流程!只需填写下面的信息,您就可以开始使用最具扩展性和功能强大的平台了。", + "Information needed": "所需信息", + "Please provide the following information. Do not worry, you can always change these settings later in the admin panel.": "请提供以下信息。不用担心,您随时可以在管理面板中更改这些设置。", + "Failed to update homepage config": "更新主页配置失败", + "Homepage config updated successfully": "主页配置更新成功", + "Failed to load homepage config": "加载主页配置失败", + "FAQ updated successfully": "常见问题更新成功", + "Navigation updated successfully": "导航更新成功", + "Embedded HTML updated successfully": "嵌入HTML更新成功", + "Payment channels updated successfully": "支付渠道更新成功", + "Manage frequently asked questions": "管理常见问题", + "Add FAQ Item": "添加常见问题", + "Remove FAQ Item": "删除常见问题", + "Top Navigation": "顶部导航", + "Manage top navigation links": "管理顶部导航链接", + "Title": "标题", + "Link": "链接", + "Target": "目标", + "Add Navigation Item": "添加导航项", + "Remove Navigation Item": "删除导航项", + "Enter title": "输入标题", + "Enter link URL": "输入链接地址", + "Same window": "当前窗口", + "New window": "新窗口", + "Custom HTML injection": "自定义HTML注入", + "Enable embedded HTML": "启用嵌入HTML", + "HTML Content": "HTML内容", + "Enter custom HTML code": "输入自定义HTML代码", + "Manage payment methods": "管理支付方式", + "Channel ID": "渠道ID", + "Display Name": "显示名称", + "Add Payment Channel": "添加支付渠道", + "Remove Payment Channel": "删除支付渠道", + "Enter channel ID": "输入渠道ID", + "Enter display name": "输入显示名称", + "Installation Status": "安装状态", + "First time installation": "首次安装", + "System installed": "系统已安装", + "Configure top navigation menu items and links": "配置顶部导航菜单项和链接", + "Per Million Tokens": "每百万Token", + "Price per million tokens consumed": "每百万Token消耗的价格", + "Price per million tokens": "每百万Token价格", + "Price per API call": "每次API调用价格", + "Payment channel disabled successfully": "支付渠道禁用成功", + "Failed to disable payment channel": "禁用支付渠道失败", + "Payment channel enabled successfully": "支付渠道启用成功", + "Failed to enable payment channel": "启用支付渠道失败", + "Input Token Price": "输入Token价格", + "Output Token Price": "输出Token价格", + "Price per million input tokens": "每百万输入Token价格", + "Price per million output tokens": "每百万输出Token价格", + "Input": "输入", + "Output": "输出", + "1M tokens": "1M tokens" } diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index 9f6571a..59e1931 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -32,6 +32,13 @@ export default async function RootLayout({ `, }} /> + {platformConfig?.embeded_html?.is_enabled && platformConfig?.embeded_html?.html && ( +
+ )} diff --git a/frontend/src/components/console/LoginSettingsContent.tsx b/frontend/src/components/console/LoginSettingsContent.tsx index 4e6ee4e..47dd0d8 100644 --- a/frontend/src/components/console/LoginSettingsContent.tsx +++ b/frontend/src/components/console/LoginSettingsContent.tsx @@ -1,38 +1,33 @@ "use client"; -import React from "react"; +import React, { useState } from "react"; import { EmailConfigForm } from "@/components/login-setting/EmailConfigForm"; import { GoogleAuthConfigForm } from "@/components/login-setting/GoogleAuthConfigForm"; -import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement"; import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; import { LoginConfig, GoogleAuthConfig } from "@/shared/types/system"; import { TabKey } from "@/shared/types/dashboard"; import { useTranslation } from "@/shared/lib/useTranslation"; import { toast } from "react-hot-toast"; +import { EmailConfig } from "@/types/system"; interface LoginSettingsContentProps { onTabNavigate?: (tab: TabKey) => void; + loginConfig: LoginConfig; + saveLoginConfig: (config: LoginConfig) => Promise; + emailConfig: EmailConfig; } export const LoginSettingsContent: React.FC = ({ onTabNavigate, + loginConfig, + saveLoginConfig, + emailConfig, }) => { + const [googleSubmitLoading, setGoogleSubmitLoading] = useState(false); + const [emailSubmitLoading, setEmailSubmitLoading] = useState(false); const { t } = useTranslation(); const { updateClientConfig } = usePlatformConfig(); - const { - // login config - loginConfig, - loginLoading, - saveLoginConfig, - - // email config - emailConfig, - - // platform config - platformConfig, - } = useSystemConfigManagement(); - // 验证至少有一种登录方式启用 const validateLoginMethods = (config: LoginConfig): boolean => { const isGoogleEnabled = @@ -57,12 +52,13 @@ export const LoginSettingsContent: React.FC = ({ return; } + setEmailSubmitLoading(true); const result = await saveLoginConfig(config); if (!result) return; updateClientConfig({ - platform: platformConfig, login: config, }); + setEmailSubmitLoading(false); }; // save google auth config @@ -76,22 +72,23 @@ export const LoginSettingsContent: React.FC = ({ return; } + setGoogleSubmitLoading(true); const result = await saveLoginConfig(updatedLoginConfig); if (!result) return; updateClientConfig({ - platform: platformConfig, login: updatedLoginConfig, }); + setGoogleSubmitLoading(false); }; return ( -
+
{/* email config */} @@ -99,7 +96,7 @@ export const LoginSettingsContent: React.FC = ({
); diff --git a/frontend/src/components/console/Main.tsx b/frontend/src/components/console/Main.tsx index d8f4d4b..49a3fbc 100644 --- a/frontend/src/components/console/Main.tsx +++ b/frontend/src/components/console/Main.tsx @@ -4,7 +4,6 @@ import React, { useEffect, useState, Suspense } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { useTranslation } from "react-i18next"; import { useAdminStore } from "@/store/admin"; -import DashboardSidebar from "@/shared/components/DashboardSidebar"; import DashboardDemoContent from "@/shared/components/DashboardDemoContent"; import ConsoleStats from "@/components/console/ConsoleStats"; import PaymentChannelsContent from "@/components/console/PaymentChannelsContent"; @@ -15,17 +14,16 @@ import { MCPServicesManagement } from "@/components/mcp-services/MCPServicesMana import UserManagement from "@/components/user-management/UserManagement"; import RevenueManagement from "@/components/revenue-management/RevenueManagement"; import { - Cog, CreditCard, DollarSign, Home, Settings, Users, LogIn, + ServerIcon, } from "lucide-react"; import { LoginSettingsContent } from "@/components/console/LoginSettingsContent"; -import { Button } from "@nextui-org/react"; -import { FaDiscord } from "react-icons/fa"; +import ConsoleSidebar from "./Sidebar"; const ConsoleContent: React.FC = () => { const { t } = useTranslation(); @@ -33,6 +31,8 @@ const ConsoleContent: React.FC = () => { const searchParams = useSearchParams(); const [admin_token] = useAdminStore((state) => [state.admin_token]); + const _DefaultSubTab = "general"; + const getInitialTab = (): TabKey => { const tabFromUrl = searchParams.get("tab") as TabKey; if ( @@ -51,49 +51,79 @@ const ConsoleContent: React.FC = () => { return TabKey.CONSOLE; }; + const getInitialSubTab = (): string | undefined => { + const subTabFromUrl = searchParams.get("subtab"); + return subTabFromUrl || _DefaultSubTab; + }; + const [activeTab, setActiveTab] = useState(getInitialTab); + const [activeSubTab, setActiveSubTab] = useState( + getInitialSubTab + ); const sidebarItems: SidebarItem[] = [ { key: TabKey.CONSOLE, - icon: , + icon: , label: t("Dashboard"), description: t("Overview and analytics"), }, { key: TabKey.MCP_SERVICES, - icon: , + icon: , label: t("MCP Services"), description: t("Manage MCP services and API tools"), }, { key: TabKey.USER_MANAGEMENT, - icon: , + icon: , label: t("User Management"), description: t("Manage registered users"), }, { key: TabKey.REVENUE_MANAGEMENT, - icon: , + icon: , label: t("Revenue Management"), description: t("View user recharge history"), }, { key: TabKey.PAYMENT_CHANNELS, - icon: , + icon: , label: t("Payment Channels"), description: t("Configure payment channels"), }, - { - key: TabKey.LOGIN_SETTINGS, - icon: , - label: t("Login Settings"), - description: t("Configure authentication methods"), - }, { key: TabKey.SYSTEM_SETTINGS, - icon: , + icon: , label: t("System Settings"), description: t("Platform basic configuration"), + // Sub-menu items for System Settings + subItems: [ + { + key: "general", + label: "General", + description: "Platform basic configuration", + }, + { + key: "login-settings", + label: "Login Settings", + description: "Configure authentication methods", + }, + { + key: "homepage", + label: "Homepage", + description: "Homepage content and theme settings", + }, + { + key: "about-page", + label: "About Page", + description: "About page content configuration", + }, + { + key: "email-admin", + label: "Email & Admin", + description: "Email and administrator settings", + }, + ], }, ]; @@ -104,8 +134,10 @@ const ConsoleContent: React.FC = () => { } }, [admin_token, router]); - const handleTabNavigate = (tab: TabKey) => { + const handleTabNavigate = (tab: TabKey, subTab?: string) => { setActiveTab(tab); + setActiveSubTab(subTab || _DefaultSubTab); + // update url params if (tab === TabKey.CONSOLE) { // when switch to dashboard, clear all query params, only keep base path @@ -114,6 +146,12 @@ const ConsoleContent: React.FC = () => { // other tabs set corresponding tab params const params = new URLSearchParams(); params.set("tab", tab); + + // add subtab parameter if provided + if (subTab) { + params.set("subtab", subTab); + } + router.push(`/console?${params.toString()}`, { scroll: false }); } }; @@ -151,23 +189,15 @@ const ConsoleContent: React.FC = () => { ); - case "login-settings": - return ( - - - - ); case "system-settings": return ( - - - + item.key === activeTab) + ?.subItems?.find((item) => item.key === activeSubTab)} + onTabNavigate={handleTabNavigate} + /> ); default: return ( @@ -185,25 +215,12 @@ const ConsoleContent: React.FC = () => {
{/* Sidebar */} - } - className="w-full justify-start h-auto p-3" - onPress={() => { - window.open("https://discord.gg/cyZfcdCXkW", "_blank"); - }} - > -
- {t("Discord")} -
- - } /> {/* Main Content */} diff --git a/frontend/src/components/console/PaymentChannelsContent.tsx b/frontend/src/components/console/PaymentChannelsContent.tsx index c143da1..5a9174c 100644 --- a/frontend/src/components/console/PaymentChannelsContent.tsx +++ b/frontend/src/components/console/PaymentChannelsContent.tsx @@ -1,46 +1,56 @@ -'use client'; +"use client"; -import React from 'react'; -import { StripeConfigForm } from './StripeConfigForm'; -import { useTranslation } from "@/shared/lib/useTranslation"; +import React from "react"; +import { StripeConfigForm } from "../payment/StripeConfigForm"; +import { AlipayConfigForm } from "../payment/AlipayConfigForm"; +import { WechatConfigForm } from "../payment/WechatConfigForm"; import { usePaymentChannelManagement } from "@/hooks/usePaymentChannelManagement"; -import { StripeConfig } from "@/types/payment"; -import { toast } from "react-hot-toast"; export const PaymentChannelsContent: React.FC = () => { - const { t } = useTranslation(); - const { stripeConfig, - isSaving, + alipayConfig, + wechatConfig, + isWechatSaving, + isStripeSaving, + isAlipaySaving, saveStripeConfig, - testStripeConnection, + saveAlipayConfig, + saveWechatConfig, + enableChannel, + disableChannel, } = usePaymentChannelManagement(); - - // test stripe connection - const handleTestStripeConnection = async (config: StripeConfig) => { - const result = await testStripeConnection(config); - - if (result.success) { - toast.success(t("Stripe connection test successful")); - } else { - toast.error(result.message || t("Stripe connection test failed")); - } - }; - return (
{/* stripe configuration */} + {/* coming soon */} + {/* alipay configuration */} + {/* */} + {/* coming soon */} + {/* wechat configuration */} + {/* */}
); }; -export default PaymentChannelsContent; \ No newline at end of file +export default PaymentChannelsContent; diff --git a/frontend/src/components/console/Sidebar.tsx b/frontend/src/components/console/Sidebar.tsx new file mode 100644 index 0000000..29b022c --- /dev/null +++ b/frontend/src/components/console/Sidebar.tsx @@ -0,0 +1,161 @@ +"use client"; + +import React from "react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { Button, Divider, Link, Tooltip } from "@nextui-org/react"; +import { LogOut } from "lucide-react"; +import { DashboardSidebarProps } from "@/shared/types/dashboard"; +import { DynamicLogo } from "@/shared/components/DynamicLogo"; +import { FaDiscord } from "react-icons/fa"; + +const ConsoleSidebar: React.FC = ({ + activeTab, + activeSubTab, + onTabNavigate, + onLogout, + sidebarItems, +}) => { + const { t } = useTranslation(); + + const handleSubItemClick = (parentKey: string, subKey: string) => { + onTabNavigate?.(parentKey as any, subKey); + }; + + return ( +
+ {/* Main Sidebar */} +
+ {/* Header */} +
+ + + +
+ + {/* Navigation */} +
+ {sidebarItems.map((item) => ( + + + + + + ))} +
+ +
+ + +
+ + + + + {/* Logout */} + + + +
+
+
+ + {/* Sub Menu Panel */} + {(() => { + const activeItem = sidebarItems.find((item) => item.key === activeTab); + if (!activeItem?.subItems?.length) return null; + + return ( +
+
+

+ {t(activeItem.label)} +

+

+ {t(activeItem.description)} +

+
+ +
+ {activeItem.subItems?.map((subItem) => { + const isSubActive = activeSubTab === subItem.key; + + return ( + + + + ); + })} +
+
+ ); + })()} +
+ ); +}; + +export default ConsoleSidebar; diff --git a/frontend/src/components/console/StripeConfigForm.tsx b/frontend/src/components/console/StripeConfigForm.tsx deleted file mode 100644 index 3106138..0000000 --- a/frontend/src/components/console/StripeConfigForm.tsx +++ /dev/null @@ -1,121 +0,0 @@ -'use client'; - -import React, { useEffect, useState } from 'react'; -import { Input, Button, AccordionItem, Accordion } from '@nextui-org/react'; -import { Eye, EyeOff } from 'lucide-react'; -import { StripeConfig } from '@/types/payment'; -import { useTranslation } from "@/shared/lib/useTranslation"; - -interface StripeConfigFormProps { - config: StripeConfig; - onSave: (config: StripeConfig) => void; - onTest: (config: StripeConfig) => void; - isLoading?: boolean; - isTestLoading?: boolean; -} - -export const StripeConfigForm: React.FC = ({ - config, - onSave, - isLoading = false, -}) => { - const { t } = useTranslation(); - const [formData, setFormData] = useState(config); - const [showSecretKey, setShowSecretKey] = useState(false); - const [showWebhookSecret, setShowWebhookSecret] = useState(false); - useEffect(() => { - console.log("config", config); - setFormData(config); - }, [config]); - - const handleInputChange = (field: keyof StripeConfig, value: string) => { - setFormData(prev => ({ - ...prev, - [field]: value - })); - }; - - const handleSave = () => { - onSave(formData); - }; - - - const isFormValid = formData.secret.trim() !== '' && formData.webhook_secret.trim() !== ''; - - return ( - - -

{t('Stripe Configuration')}

-

{t('Configure Stripe payment interface')}

-
- } > -
- {/* Secret Key */} - handleInputChange('secret', e.target.value)} - type={showSecretKey ? "text" : "password"} - endContent={ - - } - isRequired - /> - - {/* Webhook Secret (Optional) */} - handleInputChange('webhook_secret', e.target.value)} - type={showWebhookSecret ? "text" : "password"} - isRequired - endContent={ - - } - /> -
- - {/* Action Buttons */} -
- -
- - - ); -}; \ No newline at end of file diff --git a/frontend/src/components/console/SystemSettingsContent.tsx b/frontend/src/components/console/SystemSettingsContent.tsx index ac814bb..18a59d8 100644 --- a/frontend/src/components/console/SystemSettingsContent.tsx +++ b/frontend/src/components/console/SystemSettingsContent.tsx @@ -1,18 +1,33 @@ "use client"; import React, { useState } from "react"; -import { PlatformConfigForm } from "@/components/system-setting/PlatformConfigForm"; -import { AdminConfigForm } from "@/components/system-setting/AdminConfigForm"; -import { EmailConfigForm } from "@/components/system-setting/EmailConfigForm"; +import { HomepageSettings } from "@/components/system-setting/HomepageSettings"; +import { AboutPageSettings } from "@/components/system-setting/AboutPageSettings"; +import { EmailAndAdminSettings } from "@/components/system-setting/EmailAndAdminSettings"; import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement"; import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; import { Theme } from "@/shared/types/system"; import i18n from "@/shared/lib/i18n"; +import { PlatformConfigForm } from "../system-setting/PlatformConfigForm"; +import DashboardDemoContent from "@/shared/components/DashboardDemoContent"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { SidebarSubItem, TabKey } from "@/shared/types/dashboard"; +import { LoginSettingsContent } from "./LoginSettingsContent"; -export const SystemSettingsContent: React.FC = () => { +interface SystemSettingsContentProps { + activeSubTab?: string; + subTab?: SidebarSubItem; + onTabNavigate: (tab: TabKey, subTab?: string) => void; +} + +export const SystemSettingsContent: React.FC = ({ + activeSubTab, + subTab, + onTabNavigate, +}) => { const { updateClientConfig } = usePlatformConfig(); const [isAboutLoading, setIsAboutLoading] = useState(false); - + const { t } = useTranslation(); const { // platform config platformConfig, @@ -31,6 +46,10 @@ export const SystemSettingsContent: React.FC = () => { // image upload uploadImage, + + // login config + loginConfig, + saveLoginConfig, } = useSystemConfigManagement(); // save admin config @@ -77,33 +96,60 @@ export const SystemSettingsContent: React.FC = () => { }); }; + // Render content based on active sub tab + const renderSubTabContent = () => { + switch (activeSubTab) { + case "homepage": + return ; + case "about-page": + return ( + + ); + case "email-admin": + return ( + + ); + case "login-settings": + return ( + + ); + case "general": + default: + return ( + + ); + } + }; + return ( -
- {/* platform config */} - - - {/* admin config */} - - - {/* email config */} - -
+ + {renderSubTabContent()} + ); }; diff --git a/frontend/src/components/dashboard/Main.tsx b/frontend/src/components/dashboard/Main.tsx index 116ccf3..fec8c78 100644 --- a/frontend/src/components/dashboard/Main.tsx +++ b/frontend/src/components/dashboard/Main.tsx @@ -29,7 +29,7 @@ const DashboardContent: React.FC = () => { state.user_token, state.user, ]); - const { loginConfig } = usePlatformConfig(); + const { loginConfig, paymentChannels } = usePlatformConfig(); const [logOut, useGetUser] = useGlobalStore((state) => [ state.logOut, @@ -163,14 +163,16 @@ const DashboardContent: React.FC = () => {
- + {paymentChannels.length > 0 && ( + + )}
diff --git a/frontend/src/components/marketplace/Faq.tsx b/frontend/src/components/marketplace/Faq.tsx new file mode 100644 index 0000000..a2580ed --- /dev/null +++ b/frontend/src/components/marketplace/Faq.tsx @@ -0,0 +1,58 @@ +"use client"; + +import React from "react"; +import { Accordion, AccordionItem } from "@nextui-org/react"; +import { Plus } from "lucide-react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext"; + +function FaqClient() { + const { faqItems } = usePlatformConfig(); + const { t } = useTranslation(); + // Custom indicator component with plus sign that fades out when expanded + const CustomIndicator = ({ isOpen }: { isOpen?: boolean }) => ( + + ); + if (faqItems.length === 0) return null; + + return ( +
+
+

+ {t("FAQs")} +

+ {/**content */} +
+ + {faqItems.map((faq, index) => ( + + {faq.question} + + } + className="pt-2 px-2" + indicator={({ isOpen }) => } + > +
+ {faq.answer} +
+
+ ))} +
+
+
+
+ ); +} + +export function Faq() { + return ; +} diff --git a/frontend/src/components/mcp-services/BasicInfoTab.tsx b/frontend/src/components/mcp-services/BasicInfoTab.tsx index c5d2bab..f5c5e59 100644 --- a/frontend/src/components/mcp-services/BasicInfoTab.tsx +++ b/frontend/src/components/mcp-services/BasicInfoTab.tsx @@ -66,9 +66,9 @@ export const BasicInfoTab: React.FC = ({ onInputChange('auth_token', ''); }} > - {t('None')} - {t('API Key')} - {t('Bearer Token')} + {t('None')} + {t('API Key')} + {t('Bearer Token')} {/* auth config input fields */} diff --git a/frontend/src/components/mcp-services/DescriptionTab.tsx b/frontend/src/components/mcp-services/DescriptionTab.tsx index 82a4129..b2b67ed 100644 --- a/frontend/src/components/mcp-services/DescriptionTab.tsx +++ b/frontend/src/components/mcp-services/DescriptionTab.tsx @@ -1,13 +1,13 @@ "use client"; -import React from 'react'; -import { useTranslation } from '@/shared/lib/useTranslation'; -import { MCPServiceFormData } from '@/types/mcp-service'; -import dynamic from 'next/dynamic'; +import React from "react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { MCPServiceFormData } from "@/types/mcp-service"; +import dynamic from "next/dynamic"; // dynamic import MDEditor to avoid SSR problem const MDEditor = dynamic( - () => import('@uiw/react-md-editor').then((mod) => mod.default), + () => import("@uiw/react-md-editor").then((mod) => mod.default), { ssr: false } ); @@ -18,29 +18,30 @@ interface DescriptionTabProps { export const DescriptionTab: React.FC = ({ formData, - onInputChange + onInputChange, }) => { const { t } = useTranslation(); const handleMarkdownChange = (value?: string) => { - onInputChange('long_description', value || ''); + onInputChange("long_description", value || ""); }; return (
= ({
); -}; \ No newline at end of file +}; diff --git a/frontend/src/components/mcp-services/PricingTab.tsx b/frontend/src/components/mcp-services/PricingTab.tsx index 9f5eaa9..d8a82cc 100644 --- a/frontend/src/components/mcp-services/PricingTab.tsx +++ b/frontend/src/components/mcp-services/PricingTab.tsx @@ -1,15 +1,11 @@ "use client"; -import React from 'react'; -import { - Input, - Select, - SelectItem, -} from '@nextui-org/react'; -import { useTranslation } from '@/shared/lib/useTranslation'; -import { MCPServiceFormData } from '@/types/mcp-service'; -import { getCurrencySymbol } from '@/shared/utils/currency'; -import { ChargeType } from '@/shared/types/marketplace'; +import React from "react"; +import { Input, Select, SelectItem } from "@nextui-org/react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { MCPServiceFormData } from "@/types/mcp-service"; +import { getCurrencySymbol } from "@/shared/utils/currency"; +import { ChargeType } from "@/shared/types/marketplace"; interface PricingTabProps { formData: MCPServiceFormData; @@ -18,52 +14,111 @@ interface PricingTabProps { export const PricingTab: React.FC = ({ formData, - onInputChange + onInputChange, }) => { const { t } = useTranslation(); - return (
{formData.charge_type !== ChargeType.Free && ( - onInputChange('price', e.target.value)} - description={t('Price per unit (call or token)')} - startContent={{getCurrencySymbol()}} - /> + <> + {formData.charge_type === ChargeType.PerToken ? ( +
+ + onInputChange("input_token_price", e.target.value) + } + placeholder={t("Price per million input tokens")} + startContent={ + + {getCurrencySymbol()} + + } + /> + + onInputChange("output_token_price", e.target.value) + } + placeholder={t("Price per million output tokens")} + startContent={ + + {getCurrencySymbol()} + + } + /> +
+ ) : ( + onInputChange("price", e.target.value)} + description={t("Price per API call")} + startContent={ + + {getCurrencySymbol()} + + } + /> + )} + )}
); -}; \ No newline at end of file +}; diff --git a/frontend/src/components/mcp-services/ServiceFiltersBar.tsx b/frontend/src/components/mcp-services/ServiceFiltersBar.tsx index 3e2674f..7e0f91a 100644 --- a/frontend/src/components/mcp-services/ServiceFiltersBar.tsx +++ b/frontend/src/components/mcp-services/ServiceFiltersBar.tsx @@ -1,10 +1,10 @@ "use client"; -import React from 'react'; -import { Input, Select, SelectItem, Button } from '@nextui-org/react'; -import { useTranslation } from '@/shared/lib/useTranslation'; -import { ServiceFilters } from '@/types/mcp-service'; -import { Search, Plus } from 'lucide-react'; +import React from "react"; +import { Input, Select, SelectItem, Button } from "@nextui-org/react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { ServiceFilters } from "@/types/mcp-service"; +import { Search, Plus } from "lucide-react"; interface ServiceFiltersBarProps { filters: ServiceFilters; @@ -16,7 +16,7 @@ interface ServiceFiltersBarProps { export const ServiceFiltersBar: React.FC = ({ filters, onFiltersChange, - onImportOpenAPI + onImportOpenAPI, }) => { const { t } = useTranslation(); @@ -24,20 +24,20 @@ export const ServiceFiltersBar: React.FC = ({ onFiltersChange({ ...filters, search: value }); }; - const handleStatusChange = (value: string) => { onFiltersChange({ ...filters, status: value }); }; return ( -
+
{/* = ({ ))} */} - - -
); -}; \ No newline at end of file +}; diff --git a/frontend/src/components/mcp-services/ServiceTable.tsx b/frontend/src/components/mcp-services/ServiceTable.tsx index a568d2f..6a914d5 100644 --- a/frontend/src/components/mcp-services/ServiceTable.tsx +++ b/frontend/src/components/mcp-services/ServiceTable.tsx @@ -1,6 +1,6 @@ "use client"; -import React from 'react'; +import React from "react"; import { Table, TableHeader, @@ -12,19 +12,19 @@ import { Button, Tooltip, Pagination, - Spinner -} from '@nextui-org/react'; -import { useTranslation } from '@/shared/lib/useTranslation'; -import { EnabledEnum, MCPService } from '@/types/mcp-service'; + Spinner, +} from "@nextui-org/react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { EnabledEnum, MCPService } from "@/types/mcp-service"; import { Trash2, Zap, PencilIcon, CircleCheckIcon, BanIcon, -} from 'lucide-react'; -import { ChargeType } from '@/shared/types/marketplace'; -import { Price } from '@/shared/components/marketplace/Price'; +} from "lucide-react"; +import { ChargeType } from "@/shared/types/marketplace"; +import { Price } from "@/shared/components/marketplace/Price"; interface ServiceTableProps { services: MCPService[]; @@ -58,22 +58,29 @@ export const ServiceTable: React.FC = ({ const items = services; const getStatusColor = (enabled: number) => { - return enabled === EnabledEnum.Online ? 'success' : 'danger'; + return enabled === EnabledEnum.Online ? "success" : "danger"; }; + const handleEdit = React.useCallback( + (service: MCPService) => { + onEdit(service); + }, + [onEdit] + ); - const handleEdit = React.useCallback((service: MCPService) => { - onEdit(service); - }, [onEdit]); - - const handleDelete = React.useCallback((service: MCPService) => { - onDelete(service); - }, [onDelete]); - - const handleToggleStatus = React.useCallback((service: MCPService) => { - onToggleStatus(service); - }, [onToggleStatus]); + const handleDelete = React.useCallback( + (service: MCPService) => { + onDelete(service); + }, + [onDelete] + ); + const handleToggleStatus = React.useCallback( + (service: MCPService) => { + onToggleStatus(service); + }, + [onToggleStatus] + ); if (loading && services.length === 0) { return ( @@ -96,7 +103,7 @@ export const ServiceTable: React.FC = ({
= ({ } > - {t('Service Name')} - {t('API Endpoint')} - {t('Status')} - {t('Pricing')} - {t('Actions')} + {t("Service Name")} + {t("API Endpoint")} + {t("Status")} + {t("Pricing")} + {t("Actions")} } - emptyContent={t('No services found')} + emptyContent={t("No services found")} > {(service) => ( @@ -134,17 +141,22 @@ export const ServiceTable: React.FC = ({ size="sm" variant="flat" > - {t(service.enabled === 1 ? 'Online' : 'Offline')} + {t(service.enabled === 1 ? "Online" : "Offline")}
- +
- + - + - +
); -}; \ No newline at end of file +}; diff --git a/frontend/src/components/mcp-services/ToolsTab.tsx b/frontend/src/components/mcp-services/ToolsTab.tsx index 1d8c814..f8ba8b0 100644 --- a/frontend/src/components/mcp-services/ToolsTab.tsx +++ b/frontend/src/components/mcp-services/ToolsTab.tsx @@ -38,7 +38,8 @@ export const ToolsTab: React.FC = ({ removeWrapper > - {t('Tool Name')} + {t('Tool Name')} + {t('Tool URL')} {t('Description')} @@ -49,7 +50,13 @@ export const ToolsTab: React.FC = ({ handleToolChange(index, 'name', e.target.value)} + size="sm" + isDisabled + /> + + + diff --git a/frontend/src/components/payment/AlipayConfigForm.tsx b/frontend/src/components/payment/AlipayConfigForm.tsx new file mode 100644 index 0000000..a2d03d0 --- /dev/null +++ b/frontend/src/components/payment/AlipayConfigForm.tsx @@ -0,0 +1,188 @@ +"use client"; + +import React, { useEffect, useState } from "react"; +import { + Input, + Button, + AccordionItem, + Accordion, + Switch, +} from "@nextui-org/react"; +import { Eye, EyeOff } from "lucide-react"; +import { AlipayConfig } from "@/types/payment"; +import { useTranslation } from "@/shared/lib/useTranslation"; + +interface AlipayConfigFormProps { + config: AlipayConfig; + onSave: (config: AlipayConfig) => void; + onEnable: (channelId: string) => Promise; + onDisable: (channelId: string) => Promise; + isLoading?: boolean; +} + +export const AlipayConfigForm: React.FC = ({ + config, + onSave, + onEnable, + onDisable, + isLoading = false, +}) => { + const { t } = useTranslation(); + const [formData, setFormData] = useState(config); + const [showAppPrivateKey, setShowAppPrivateKey] = useState(false); + const [showAlipayPublicKey, setShowAlipayPublicKey] = useState(false); + + useEffect(() => { + setFormData(config); + }, [config]); + + const handleInputChange = ( + field: keyof AlipayConfig, + value: string | boolean + ) => { + setFormData((prev) => ({ + ...prev, + [field]: value, + })); + }; + const handleEnableDisable = async (value: boolean) => { + let result: boolean | null = null; + if (value) { + result = await onEnable("alipay"); + } else { + result = await onDisable("alipay"); + } + if (result) { + setFormData((prev) => ({ + ...prev, + is_enabled: value, + })); + } + }; + + const handleSave = () => { + onSave(formData); + }; + + const isFormValid = + formData.app_id.trim() !== "" && + formData.app_private_key.trim() !== "" && + formData.alipay_public_key.trim() !== ""; + + return ( + + +
+
+

+ {t("Alipay Configuration")} +

+

+ {t("Configure Alipay payment interface")} +

+
+ +
+
+ } + > +
+ {/* App ID */} + handleInputChange("app_id", e.target.value)} + isRequired + autoComplete="off" + isDisabled={!formData.is_enabled} + /> + + {/* App Private Key */} + + handleInputChange("app_private_key", e.target.value) + } + type={showAppPrivateKey ? "text" : "password"} + endContent={ + + } + isRequired + autoComplete="off" + isDisabled={!formData.is_enabled} + /> + + {/* Alipay Public Key */} + + handleInputChange("alipay_public_key", e.target.value) + } + type={showAlipayPublicKey ? "text" : "password"} + isRequired + endContent={ + + } + autoComplete="off" + isDisabled={!formData.is_enabled} + /> +
+ + {/* Action Buttons */} + {formData.is_enabled && ( +
+ +
+ )} + + + ); +}; diff --git a/frontend/src/components/payment/StripeConfigForm.tsx b/frontend/src/components/payment/StripeConfigForm.tsx new file mode 100644 index 0000000..e3a9260 --- /dev/null +++ b/frontend/src/components/payment/StripeConfigForm.tsx @@ -0,0 +1,177 @@ +"use client"; + +import React, { useEffect, useState } from "react"; +import { + Input, + Button, + AccordionItem, + Accordion, + Switch, +} from "@nextui-org/react"; +import { Eye, EyeOff } from "lucide-react"; +import { StripeConfig } from "@/types/payment"; +import { useTranslation } from "@/shared/lib/useTranslation"; + +interface StripeConfigFormProps { + config: StripeConfig; + onSave: (config: StripeConfig) => void; + onEnable: (channelId: string) => Promise; + onDisable: (channelId: string) => Promise; + isLoading?: boolean; +} + +export const StripeConfigForm: React.FC = ({ + config, + onSave, + onEnable, + onDisable, + isLoading = false, +}) => { + const { t } = useTranslation(); + const [formData, setFormData] = useState(config); + const [showSecretKey, setShowSecretKey] = useState(false); + const [showWebhookSecret, setShowWebhookSecret] = useState(false); + useEffect(() => { + setFormData(config); + }, [config]); + + const handleInputChange = ( + field: keyof StripeConfig, + value: string | boolean + ) => { + setFormData((prev) => ({ + ...prev, + [field]: value, + })); + }; + + const handleEnableDisable = async (value: boolean) => { + let result: boolean | null = null; + if (value) { + result = await onEnable("stripe"); + } else { + result = await onDisable("stripe"); + } + if (result) { + setFormData((prev) => ({ + ...prev, + is_enabled: value, + })); + } + }; + + const handleSave = () => { + onSave(formData); + }; + + const isFormValid = + formData.secret.trim() !== "" && formData.webhook_secret.trim() !== ""; + + return ( + + +
+
+

+ {t("Stripe Configuration")} +

+

+ {t("Configure Stripe payment interface")} +

+
+ +
+
+ } + > +
+ {/* Secret Key */} + handleInputChange("secret", e.target.value)} + type={showSecretKey ? "text" : "password"} + endContent={ + + } + isRequired + autoComplete="off" + isDisabled={!formData.is_enabled} + /> + + {/* Webhook Secret (Optional) */} + + handleInputChange("webhook_secret", e.target.value) + } + type={showWebhookSecret ? "text" : "password"} + isRequired + endContent={ + + } + autoComplete="off" + isDisabled={!formData.is_enabled} + /> +
+ + {/* Action Buttons */} + {formData.is_enabled && ( +
+ +
+ )} + + + ); +}; diff --git a/frontend/src/components/payment/WechatConfigForm.tsx b/frontend/src/components/payment/WechatConfigForm.tsx new file mode 100644 index 0000000..e3fa8e1 --- /dev/null +++ b/frontend/src/components/payment/WechatConfigForm.tsx @@ -0,0 +1,140 @@ +"use client"; + +import React, { useEffect, useState } from "react"; +import { + Input, + Button, + AccordionItem, + Accordion, + Switch, +} from "@nextui-org/react"; +import { WechatConfig } from "@/types/payment"; +import { useTranslation } from "@/shared/lib/useTranslation"; + +interface WechatConfigFormProps { + config: WechatConfig; + onSave: (config: WechatConfig) => void; + onEnable: (channelId: string) => Promise; + onDisable: (channelId: string) => Promise; + isLoading?: boolean; +} + +export const WechatConfigForm: React.FC = ({ + config, + onSave, + onEnable, + onDisable, + isLoading = false, +}) => { + const { t } = useTranslation(); + const [formData, setFormData] = useState(config); + + useEffect(() => { + setFormData(config); + }, [config]); + + const handleInputChange = ( + field: keyof WechatConfig, + value: string | boolean + ) => { + setFormData((prev) => ({ + ...prev, + [field]: value, + })); + }; + const handleEnableDisable = async (value: boolean) => { + let result: boolean | null = null; + if (value) { + result = await onEnable("wechat"); + } else { + result = await onDisable("wechat"); + } + if (result) { + setFormData((prev) => ({ + ...prev, + is_enabled: value, + })); + } + }; + + const handleSave = () => { + onSave(formData); + }; + + const isFormValid = + formData.app_id.trim() !== "" && formData.mch_id.trim() !== ""; + + return ( + + +
+
+

+ {t("WeChat Configuration")} +

+

+ {t("Configure WeChat payment interface")} +

+
+ +
+
+ } + > +
+ {/* App ID */} + handleInputChange("app_id", e.target.value)} + isRequired + autoComplete="off" + isDisabled={!formData.is_enabled} + /> + + {/* Merchant ID */} + handleInputChange("mch_id", e.target.value)} + isRequired + autoComplete="off" + isDisabled={!formData.is_enabled} + /> +
+ + {/* Action Buttons */} + {formData.is_enabled && ( +
+ +
+ )} + + + ); +}; diff --git a/frontend/src/components/system-setting/AboutPageSettings.tsx b/frontend/src/components/system-setting/AboutPageSettings.tsx new file mode 100644 index 0000000..2060122 --- /dev/null +++ b/frontend/src/components/system-setting/AboutPageSettings.tsx @@ -0,0 +1,138 @@ +"use client"; + +import React, { useState, useEffect } from "react"; +import { Button, AccordionItem, Accordion } from "@nextui-org/react"; +import MDEditor, { commands } from "@uiw/react-md-editor"; +import { PlatformConfig } from "@/shared/types/system"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { calculateFileSha256 } from "@/shared/utils/crypto"; +import "@uiw/react-md-editor/markdown-editor.css"; +import "@uiw/react-markdown-preview/markdown.css"; + +interface AboutPageSettingsProps { + config: PlatformConfig; + onAboutSave: (aboutContent: string) => Promise; + onImageUpload?: (file: File, sha256?: string) => Promise; + isAboutLoading?: boolean; +} + +export const AboutPageSettings: React.FC = ({ + config, + onAboutSave, + onImageUpload, + isAboutLoading = false, +}) => { + const { t } = useTranslation(); + const [aboutContent, setAboutContent] = useState(config.about_page || ""); + + useEffect(() => { + setAboutContent(config.about_page || ""); + }, [config.about_page]); + + const handleAboutSave = async () => { + await onAboutSave(aboutContent); + }; + + const handleImageUpload = async (file: File): Promise => { + try { + // 计算文件的 SHA256 哈希值 + const sha256 = await calculateFileSha256(file); + return await onImageUpload!(file, sha256); + } catch (error) { + console.error("Image upload failed:", error); + throw error; + } + }; + + return ( +
+
+ setAboutContent(value || "")} + preview="live" + hideToolbar={false} + visibleDragbar={false} + data-color-mode="light" + textareaProps={{ + placeholder: t("Enter about page content (supports Markdown)"), + style: { + fontSize: 14, + lineHeight: 1.6, + fontFamily: + 'ui-monospace, SFMono-Regular, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace', + }, + }} + height="100%" + commands={[ + // 默认命令 + commands.bold, + commands.italic, + commands.strikethrough, + commands.hr, + commands.title, + commands.divider, + commands.link, + commands.quote, + commands.code, + commands.codeBlock, + commands.comment, + commands.divider, + commands.unorderedListCommand, + commands.orderedListCommand, + commands.checkedListCommand, + commands.divider, + // 自定义图片上传命令 + { + name: "image-upload", + keyCommand: "image-upload", + buttonProps: { + "aria-label": "Upload image", + title: "Upload image", + }, + icon: ( + + + + ), + execute: (state, api) => { + const input = document.createElement("input"); + input.type = "file"; + input.accept = "image/*"; + input.onchange = async (e) => { + const file = (e.target as HTMLInputElement).files?.[0]; + if (file) { + try { + const dataUrl = await handleImageUpload(file); + const imageMarkdown = `![${file.name}](${window.location.origin}${dataUrl})`; + api.replaceSelection(imageMarkdown); + } catch (error) { + console.error("Image upload failed:", error); + } + } + }; + input.click(); + }, + }, + ]} + /> +
+ + {/* About Save Button */} +
+ +
+
+ ); +}; diff --git a/frontend/src/components/system-setting/AdminConfigForm.tsx b/frontend/src/components/system-setting/AdminConfigForm.tsx index efdf2cf..bde0f19 100644 --- a/frontend/src/components/system-setting/AdminConfigForm.tsx +++ b/frontend/src/components/system-setting/AdminConfigForm.tsx @@ -1,9 +1,9 @@ -'use client'; +"use client"; -import React, { useEffect, useState } from 'react'; -import { Input, Button, AccordionItem, Accordion } from '@nextui-org/react'; -import { Eye, EyeOff } from 'lucide-react'; -import { AdminConfig } from '@/types/system'; +import React, { useEffect, useState } from "react"; +import { Input, Button, AccordionItem, Accordion } from "@nextui-org/react"; +import { Eye, EyeOff } from "lucide-react"; +import { AdminConfig } from "@/types/system"; import { useTranslation } from "@/shared/lib/useTranslation"; interface AdminConfigFormProps { @@ -20,20 +20,20 @@ export const AdminConfigForm: React.FC = ({ const { t } = useTranslation(); const [formData, setFormData] = useState(config); const [showPassword, setShowPassword] = useState(false); - const [confirmPassword, setConfirmPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(""); const [showConfirmPassword, setShowConfirmPassword] = useState(false); useEffect(() => { setFormData({ ...config, - password: '', + password: "", }); - setConfirmPassword(''); + setConfirmPassword(""); }, [config]); const handleInputChange = (field: keyof AdminConfig, value: string) => { - setFormData(prev => ({ + setFormData((prev) => ({ ...prev, - [field]: value + [field]: value, })); }; @@ -42,41 +42,53 @@ export const AdminConfigForm: React.FC = ({ }; const isFormValid = - formData.username.trim() !== '' && - formData.password.trim() !== '' && + formData.username.trim() !== "" && + formData.password?.trim() !== "" && formData.password === confirmPassword && - formData.password.length >= 8; + formData.password?.length >= 8; const passwordsMatch = formData.password === confirmPassword; return ( - - -

{t('Administrator Account')}

-

{t('Configure administrator login credentials')}

- - }> + + +

+ {t("Administrator Account")} +

+

+ {t("Configure administrator login credentials")} +

+ + } + >
{/* admin username */} handleInputChange('username', e.target.value)} + onChange={(e) => handleInputChange("username", e.target.value)} isRequired /> {/* admin password */} handleInputChange('password', e.target.value)} + onChange={(e) => handleInputChange("password", e.target.value)} type={showPassword ? "text" : "password"} endContent={ } isRequired - autoComplete='new-password' - color={formData.password.length > 0 && formData.password.length < 8 ? "danger" : "default"} - errorMessage={formData.password.length > 0 && formData.password.length < 8 ? t('Password must be at least 8 characters') : ""} + autoComplete="new-password" + color={ + formData.password?.length > 0 && formData.password?.length < 8 + ? "danger" + : "default" + } + errorMessage={ + formData.password?.length > 0 && formData.password?.length < 8 + ? t("Password must be at least 8 characters") + : "" + } /> {/* confirm password */} setConfirmPassword(e.target.value)} type={showConfirmPassword ? "text" : "password"} @@ -118,10 +138,18 @@ export const AdminConfigForm: React.FC = ({ )} } - autoComplete='new-password' + autoComplete="new-password" isRequired - color={confirmPassword.length > 0 && !passwordsMatch ? "danger" : "default"} - errorMessage={confirmPassword.length > 0 && !passwordsMatch ? t('Passwords do not match') : ""} + color={ + confirmPassword?.length > 0 && !passwordsMatch + ? "danger" + : "default" + } + errorMessage={ + confirmPassword?.length > 0 && !passwordsMatch + ? t("Passwords do not match") + : "" + } />
@@ -133,12 +161,12 @@ export const AdminConfigForm: React.FC = ({ onPress={handleSave} isLoading={isLoading} isDisabled={!isFormValid} - size='sm' + size="sm" > - {t('Save')} + {t("Save")}
); -}; \ No newline at end of file +}; diff --git a/frontend/src/components/system-setting/EmailAndAdminSettings.tsx b/frontend/src/components/system-setting/EmailAndAdminSettings.tsx new file mode 100644 index 0000000..0573f9c --- /dev/null +++ b/frontend/src/components/system-setting/EmailAndAdminSettings.tsx @@ -0,0 +1,39 @@ +"use client"; + +import React from "react"; +import { EmailConfigForm } from "./EmailConfigForm"; +import { AdminConfig, EmailConfig } from "@/types/system"; +import { AdminConfigForm } from "./AdminConfigForm"; + +interface EmailAndAdminSettingsProps { + emailConfig: EmailConfig; + adminConfig: AdminConfig; + onSaveEmailConfig: (config: EmailConfig) => void; + onSaveAdminConfig: (config: AdminConfig) => void; + isLoading?: boolean; + isAdminLoading?: boolean; +} + +export const EmailAndAdminSettings: React.FC = ({ + emailConfig, + adminConfig, + onSaveEmailConfig, + onSaveAdminConfig, + isLoading = false, + isAdminLoading = false, +}) => { + return ( +
+ + +
+ ); +}; diff --git a/frontend/src/components/system-setting/EmbeddedHtmlSettings.tsx b/frontend/src/components/system-setting/EmbeddedHtmlSettings.tsx new file mode 100644 index 0000000..edb8360 --- /dev/null +++ b/frontend/src/components/system-setting/EmbeddedHtmlSettings.tsx @@ -0,0 +1,165 @@ +"use client"; + +import React, { useEffect, useState } from "react"; +import { + AccordionItem, + Accordion, + Textarea, + Button, + Switch, + Alert, +} from "@nextui-org/react"; +import { useTranslation } from "@/shared/lib/useTranslation"; +import { EmbeddedHtmlConfig } from "@/shared/types/system"; + +interface EmbeddedHtmlSettingsProps { + onSave?: (config: EmbeddedHtmlConfig) => void; + config?: EmbeddedHtmlConfig; +} + +export const EmbeddedHtmlSettings: React.FC = ({ + onSave, + config = { html: "", is_enabled: false }, +}) => { + const { t } = useTranslation(); + const [htmlData, setHtmlData] = useState(config); + const [isSaving, setIsSaving] = useState(false); + useEffect(() => { + setHtmlData(config); + }, [config]); + + const handleSave = async () => { + setIsSaving(true); + try { + await onSave?.(htmlData); + } finally { + setIsSaving(false); + } + }; + + const handleHtmlChange = (value: string) => { + setHtmlData((prev) => ({ ...prev, html: value })); + }; + const handleToggleEnabled = async (enabled: boolean) => { + const updatedConfig = { + ...htmlData, + is_enabled: enabled, + }; + // when toggle the switch, save directly, same as GoogleAuthConfigForm + const result = await onSave?.(updatedConfig); + if (result) { + setHtmlData((prev) => ({ ...prev, is_enabled: enabled })); + } + }; + + return ( + + +

+ {t("Embedded HTML")} +

+

+ {t("Configure custom HTML content for global injection")} +

+ + } + > +
+ {/* Enable/Disable Toggle */} +
+
+ + {t("Enable Custom HTML")} + + + {t("Toggle to enable or disable custom HTML injection")} + +
+ +
+ + {/* HTML Editor */} +
+