Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
755d48a2f8 | ||
|
|
284880a170 | ||
|
|
950b516081 | ||
|
|
0088a7b447 | ||
|
|
19f646c318 | ||
|
|
115ac5caf7 | ||
|
|
798082934e | ||
|
|
a017b0fa93 | ||
|
|
877dbb6a4e | ||
|
|
523265e550 | ||
|
|
5d2db84d75 | ||
|
|
4826859152 | ||
|
|
92f8b68f0e | ||
|
|
87a4b6e2de | ||
|
|
58d30344f5 | ||
|
|
a6064035bd | ||
|
|
141fb4758f | ||
|
|
5450027bbc | ||
|
|
721a213bbf | ||
|
|
9ce81f5012 | ||
|
|
a28f3bb680 | ||
|
|
14e45235b4 | ||
|
|
6a69d678fd | ||
|
|
48ba7ffd96 | ||
|
|
faa1f552e6 | ||
|
|
b2bd2e30dd | ||
|
|
e25e119ba1 | ||
|
|
eb1811fa3a | ||
|
|
ee65da1665 | ||
|
|
bda95f756a | ||
|
|
ae7b6d20e4 | ||
|
|
0d1dff05d6 | ||
|
|
434518b2b3 | ||
|
|
3321efc3d4 | ||
|
|
0313ced503 | ||
|
|
d17e5e95dd | ||
|
|
41f9d74c5e | ||
|
|
7f17b22896 | ||
|
|
186ba8ca81 | ||
|
|
777649f82b | ||
|
|
f042cdf911 | ||
|
|
7c75c07216 | ||
|
|
33549167d9 | ||
|
|
0ae689f9fe | ||
|
|
21c72f17ba | ||
|
|
76e8dbc083 | ||
|
|
96abfc2752 | ||
|
|
a992866058 | ||
|
|
39db3d9a94 | ||
|
|
c71a416046 | ||
|
|
9a605cc9f0 | ||
|
|
e8aaeefe85 | ||
|
|
51d41bc3d4 | ||
|
|
c1b224af46 | ||
|
|
521c1b7a07 | ||
|
|
3c9b037ba7 | ||
|
|
f3a1107838 | ||
|
|
d53fe311a3 | ||
|
|
407081adfc | ||
|
|
09704af14a | ||
|
|
46d5040068 | ||
|
|
3faa35e970 | ||
|
|
a0e7662f76 | ||
|
|
d49144afe9 | ||
|
|
81637440d6 | ||
|
|
c949aac528 | ||
|
|
5e08cd2ff5 | ||
|
|
c790fbef51 | ||
|
|
bb9dd11869 | ||
|
|
a0b827b32e | ||
|
|
7e135f4949 | ||
|
|
ead0689b81 | ||
|
|
5f621308ea |
No files matched your search
@@ -6,7 +6,7 @@ MYSQL_PASSWORD=mysql_ZTdhRB
|
||||
MYSQL_DB=xpack
|
||||
|
||||
# 服务端口配置
|
||||
API_PORT=8000
|
||||
API_PORT=8002
|
||||
ADMIN_PORT=8001
|
||||
|
||||
# 调试配置
|
||||
@@ -24,4 +24,10 @@ RABBITMQ_HOST=xpack-rabbitmq
|
||||
RABBITMQ_PORT=5672
|
||||
RABBITMQ_USER=rabbitmq
|
||||
RABBITMQ_PASSWORD=rabbitmq_Gs123dA
|
||||
RABBITMQ_VHOST=/
|
||||
RABBITMQ_VHOST=/
|
||||
|
||||
# Payment config encryption key (Base64-encoded 32-byte random value for AES-GCM)
|
||||
# Quick generation: python -c "import os,base64; print(base64.b64encode(os.urandom(32)).decode())"
|
||||
PAYMENT_CONFIG_SECRET_KEY=uyyhfMJ+xpEE+IC5mPigpscekkR2ucz6Sj7sHYLhJQA=
|
||||
# Optional: key ID used to support key rotation identification
|
||||
PAYMENT_CONFIG_KEY_ID=default
|
||||
@@ -135,8 +135,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
@@ -183,8 +182,8 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
<br>
|
||||
|
||||
4. Im Browser über Port 3000 öffnen
|
||||
* **Admin‑Login**: http://{IP}:3000/admin-signin
|
||||
4. Im Browser über Port 8000 öffnen
|
||||
* **Admin‑Login**: http://{IP}:8000/admin-signin
|
||||
* **Benutzer**: admin
|
||||
* **Passwort**: 123456789
|
||||
</details>
|
||||
|
||||
@@ -136,8 +136,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
|
||||
@@ -135,8 +135,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
@@ -183,8 +182,8 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
<br>
|
||||
|
||||
4. Accédez à l’interface sur le port 3000
|
||||
* **Connexion admin** : http://{IP}:3000/admin-signin
|
||||
4. Accédez à l’interface sur le port 8000
|
||||
* **Connexion admin** : http://{IP}:8000/admin-signin
|
||||
* **Utilisateur** : admin
|
||||
* **Mot de passe** : 123456789
|
||||
</details>
|
||||
|
||||
@@ -135,8 +135,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
@@ -183,8 +182,8 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
<br>
|
||||
|
||||
4. ブラウザでポート 3000 にアクセス
|
||||
* **管理画面ログイン**: http://{IP}:3000/admin-signin
|
||||
4. ブラウザでポート 8000 にアクセス
|
||||
* **管理画面ログイン**: http://{IP}:8000/admin-signin
|
||||
* **管理ユーザー**: admin
|
||||
* **管理パスワード**: 123456789
|
||||
</details>
|
||||
|
||||
@@ -135,8 +135,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
@@ -183,8 +182,8 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
<br>
|
||||
|
||||
4. 브라우저에서 3000 포트로 접속
|
||||
* **관리자 로그인 주소**: http://{IP}:3000/admin-signin
|
||||
4. 브라우저에서 8000 포트로 접속
|
||||
* **관리자 로그인 주소**: http://{IP}:8000/admin-signin
|
||||
* **관리자 계정**: admin
|
||||
* **관리자 비밀번호**: 123456789
|
||||
</details>
|
||||
|
||||
@@ -100,7 +100,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
支持系统包括:
|
||||
- CentOS 7.9 / 8.5
|
||||
- Ubuntu 20.04 / 22.04
|
||||
- Ubuntu 20.04 / 22.04 / 24.04
|
||||
- Debian 12.4
|
||||
- 阿里云 Linux 2.1903 / 3.2104
|
||||
|
||||
@@ -125,7 +125,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
4. 打开浏览器访问 `http://localhost:3000` 使用平台
|
||||
4. 打开浏览器访问 `http://localhost:8000` 使用平台
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -136,8 +136,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
@@ -184,8 +183,8 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
<br>
|
||||
|
||||
4. 瀏覽器透過 3000 埠連線
|
||||
* **管理員登入**:http://{IP}:3000/admin-signin
|
||||
4. 瀏覽器透過 8000 埠連線
|
||||
* **管理員登入**:http://{IP}:8000/admin-signin
|
||||
* **帳號**:admin
|
||||
* **密碼**:123456789
|
||||
</details>
|
||||
|
||||
@@ -141,8 +141,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
- "8000:80" # Map port 8000 of the container to port 80 of the host, if you want to access XPack-MCP-Market in your browser at port 8000
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
@@ -190,9 +189,9 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
|
||||
<br>
|
||||
|
||||
4. Access `XPack-MCP-Market` in your browser at port 3000
|
||||
4. Access `XPack-MCP-Market` in your browser at port 8000
|
||||
|
||||
* **Admin User Login Address**: http://{IP}:3000/admin
|
||||
* **Admin User Login Address**: http://{IP}:8000/admin
|
||||
* **Admin User**: admin
|
||||
* **Admin Password**: 123456789
|
||||
</details>
|
||||
@@ -213,8 +212,16 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
> Requirements:
|
||||
> - Node >= 22.x
|
||||
> - Pnpm >= 10.x
|
||||
|
||||
1. Execute the frontend build script
|
||||
1. Configure environment variable NEXT_PUBLIC_API_URL:
|
||||
```
|
||||
vi frontend/.env
|
||||
```
|
||||
|
||||
File content:
|
||||
```
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8001
|
||||
```
|
||||
2. Execute the frontend build script
|
||||
```
|
||||
cd scripts && ./frontend_build.sh && cd ../
|
||||
```
|
||||
@@ -270,7 +277,7 @@ curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
```
|
||||
### Docker Build
|
||||
```
|
||||
docker build -t xpack-mcp-market --build-arg APP=xpack-mcp-market --build-arg VERSION=1.0.0 -f ./scripts/Dockerfile ./
|
||||
docker build -t xpack-mcp-market --build-arg APP=xpack-mcp-market --build-arg VERSION=1.1.0 -f ./scripts/Dockerfile ./
|
||||
```
|
||||
</details>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ XPack WebUI is the flagship frontend interface for the MCP Store ecosystem, desi
|
||||
|
||||
### ✨ Key Features
|
||||
|
||||
- **🛍️ Comprehensive Marketplace**: Browse, search, and discover MCP services across multiple categories
|
||||
- **🛍️ Comprehensive Marketplace**: Browse, search, and discover MCP servers across multiple categories
|
||||
- **👤 Multi-tier Authentication**: Secure user and admin authentication systems
|
||||
- **⚙️ Advanced Admin Console**: Complete service management, user administration, and revenue tracking
|
||||
- **🌐 Full Internationalization**: Native support for English and Chinese with extensible i18n framework
|
||||
@@ -110,7 +110,7 @@ src/
|
||||
│ ├── console/ # Admin console components
|
||||
│ ├── dashboard/ # User dashboard components
|
||||
│ ├── marketplace/ # Marketplace components
|
||||
│ ├── mcp-services/ # MCP service management
|
||||
│ ├── mcp-services/ # MCP server management
|
||||
│ ├── user-management/ # User administration
|
||||
│ ├── revenue-management/# Revenue tracking
|
||||
│ ├── system-setting/ # System configuration
|
||||
@@ -129,7 +129,7 @@ src/
|
||||
│ └── utils/ # Utility functions
|
||||
├── services/ # Backend API integration
|
||||
│ ├── marketplaceService.ts # Marketplace API
|
||||
│ ├── mcpService.ts # MCP service API
|
||||
│ ├── mcpService.ts # MCP server API
|
||||
│ ├── userService.ts # User management API
|
||||
│ ├── revenueService.ts # Revenue tracking API
|
||||
│ ├── paymentChannelService.ts # Payment API
|
||||
@@ -139,7 +139,7 @@ src/
|
||||
├── hooks/ # App-specific hooks
|
||||
│ ├── useAdminLogin.tsx # Admin authentication
|
||||
│ ├── useLogin.tsx # User authentication
|
||||
│ ├── useMCPServicesList.ts # MCP services data
|
||||
│ ├── useMCPServicesList.ts # MCP servers data
|
||||
│ ├── useMCPServiceDetail.ts # Service details
|
||||
│ ├── useUserManagement.ts # User management
|
||||
│ ├── useRevenueManagement.ts # Revenue data
|
||||
@@ -150,7 +150,7 @@ src/
|
||||
├── types/ # TypeScript type definitions
|
||||
│ ├── admin.ts # Admin types
|
||||
│ ├── dashboard.ts # Dashboard types
|
||||
│ ├── mcp-service.ts # MCP service types
|
||||
│ ├── mcp-service.ts # MCP server types
|
||||
│ ├── payment.ts # Payment types
|
||||
│ ├── revenue.ts # Revenue types
|
||||
│ ├── system.ts # System types
|
||||
@@ -166,7 +166,7 @@ src/
|
||||
|
||||
### Marketplace Experience
|
||||
|
||||
- **Service Discovery**: Advanced search and filtering capabilities for MCP services
|
||||
- **Service Discovery**: Advanced search and filtering capabilities for MCP servers
|
||||
- **Service Catalog**: Browse services by categories with detailed information
|
||||
- **Service Details**: Comprehensive service documentation and API specifications
|
||||
- **Installation Guides**: Step-by-step integration instructions for developers
|
||||
@@ -178,7 +178,7 @@ src/
|
||||
|
||||
### Admin Console
|
||||
|
||||
- **MCP Services Management**: Complete CRUD operations for MCP services
|
||||
- **MCP Servers Management**: Complete CRUD operations for MCP servers
|
||||
- Service creation and editing with OpenAPI generator
|
||||
- OpenAPI document parsing from files or URLs
|
||||
- Service status management (enabled/disabled)
|
||||
|
||||
@@ -47,7 +47,7 @@ const result = await rpcClient.call("marketplace.getServices", {
|
||||
Located in `src/services/marketplaceService.ts`:
|
||||
|
||||
```typescript
|
||||
// Fetch all MCP services
|
||||
// Fetch all MCP servers
|
||||
export async function fetchServices(): Promise<ServiceData[]>;
|
||||
|
||||
// Fetch service by ID
|
||||
@@ -352,7 +352,7 @@ function ServicesPage() {
|
||||
|
||||
### Public Endpoints
|
||||
|
||||
- `GET /api/web/mcp_services` - List all MCP services
|
||||
- `GET /api/web/mcp_services` - List all MCP servers
|
||||
- `POST /api/web/mcp_service_info` - Get service details by ID
|
||||
- `GET /api/web/categories` - List service categories
|
||||
- `POST /api/auth/login` - User login
|
||||
|
||||
@@ -58,7 +58,7 @@ src/
|
||||
│ ├── console/ # Console management
|
||||
│ ├── dashboard/ # Dashboard components
|
||||
│ ├── marketplace/ # Marketplace components
|
||||
│ ├── mcp-services/ # MCP service management
|
||||
│ ├── mcp-services/ # MCP server management
|
||||
│ ├── revenue-management/# Revenue tracking
|
||||
│ ├── system-setting/ # System configuration
|
||||
│ ├── user-management/ # User administration
|
||||
@@ -77,7 +77,7 @@ src/
|
||||
│ └── utils/ # Utility functions
|
||||
├── services/ # Backend API integration
|
||||
│ ├── marketplaceService.ts # Marketplace API
|
||||
│ ├── mcpService.ts # MCP service API
|
||||
│ ├── mcpService.ts # MCP server API
|
||||
│ ├── userService.ts # User management API
|
||||
│ ├── revenueService.ts # Revenue tracking API
|
||||
│ ├── paymentChannelService.ts # Payment API
|
||||
@@ -87,7 +87,7 @@ src/
|
||||
├── hooks/ # App-specific hooks
|
||||
│ ├── useAdminLogin.tsx # Admin authentication
|
||||
│ ├── useLogin.tsx # User authentication
|
||||
│ ├── useMCPServicesList.ts # MCP services data
|
||||
│ ├── useMCPServicesList.ts # MCP servers data
|
||||
│ ├── useMCPServiceDetail.ts # Service details
|
||||
│ ├── useUserManagement.ts # User management
|
||||
│ ├── useRevenueManagement.ts # Revenue data
|
||||
@@ -98,7 +98,7 @@ src/
|
||||
├── types/ # TypeScript type definitions
|
||||
│ ├── admin.ts # Admin types
|
||||
│ ├── dashboard.ts # Dashboard types
|
||||
│ ├── mcp-service.ts # MCP service types
|
||||
│ ├── mcp-service.ts # MCP server types
|
||||
│ ├── payment.ts # Payment types
|
||||
│ ├── revenue.ts # Revenue types
|
||||
│ ├── system.ts # System types
|
||||
|
||||
@@ -16,34 +16,34 @@ XPack WebUI supports multiple languages using react-i18next. This guide covers h
|
||||
The i18n system is configured in `src/shared/lib/i18n.ts`:
|
||||
|
||||
```typescript
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
import Backend from 'i18next-http-backend'
|
||||
import LanguageDetector from 'i18next-browser-languagedetector'
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import Backend from "i18next-http-backend";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
|
||||
i18n
|
||||
.use(Backend)
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
fallbackLng: 'en',
|
||||
debug: process.env.NODE_ENV === 'development',
|
||||
|
||||
fallbackLng: "en",
|
||||
debug: process.env.NODE_ENV === "development",
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
|
||||
backend: {
|
||||
loadPath: '/locales/{{lng}}/{{ns}}.json',
|
||||
},
|
||||
|
||||
detection: {
|
||||
order: ['localStorage', 'navigator', 'htmlTag'],
|
||||
caches: ['localStorage'],
|
||||
},
|
||||
})
|
||||
|
||||
export default i18n
|
||||
backend: {
|
||||
loadPath: "/locales/{{lng}}/{{ns}}.json",
|
||||
},
|
||||
|
||||
detection: {
|
||||
order: ["localStorage", "navigator", "htmlTag"],
|
||||
caches: ["localStorage"],
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
```
|
||||
|
||||
### Translation Files Structure
|
||||
@@ -73,7 +73,7 @@ import { useTranslation } from '@/shared/lib/useTranslation'
|
||||
|
||||
function MyComponent() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t('Welcome')}</h1>
|
||||
@@ -90,7 +90,7 @@ import { useTranslation } from '@/shared/lib/useTranslation'
|
||||
|
||||
function MarketplaceComponent() {
|
||||
const { t } = useTranslation('marketplace')
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t('title')}</h1>
|
||||
@@ -106,7 +106,7 @@ function MarketplaceComponent() {
|
||||
function AdminComponent() {
|
||||
const { t: tCommon } = useTranslation('common')
|
||||
const { t: tAdmin } = useTranslation('admin')
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button>{tCommon('save')}</button>
|
||||
@@ -139,7 +139,7 @@ function AdminComponent() {
|
||||
```typescript
|
||||
function Component() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t('welcome')}</h1>
|
||||
@@ -172,7 +172,7 @@ function Component() {
|
||||
```typescript
|
||||
function UserProfile() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t('user.profile.title')}</h1>
|
||||
@@ -198,7 +198,7 @@ function UserProfile() {
|
||||
function Component() {
|
||||
const { t } = useTranslation()
|
||||
const user = { name: 'John', lastLogin: new Date() }
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t('greeting', { name: user.name })}</h1>
|
||||
@@ -227,7 +227,7 @@ function Component() {
|
||||
function Component() {
|
||||
const { t } = useTranslation()
|
||||
const count = 5
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>{t('item', { count })}</p>
|
||||
@@ -255,7 +255,7 @@ function Component() {
|
||||
function Component() {
|
||||
const { t } = useTranslation()
|
||||
const userGender = 'male'
|
||||
|
||||
|
||||
return (
|
||||
<button>
|
||||
{t('button.save', { context: userGender })}
|
||||
@@ -278,11 +278,11 @@ const languages = [
|
||||
|
||||
function LanguageSelector() {
|
||||
const { i18n, t } = useTranslation()
|
||||
|
||||
|
||||
const changeLanguage = (languageCode: string) => {
|
||||
i18n.changeLanguage(languageCode)
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Select
|
||||
label={t('common.language')}
|
||||
@@ -305,24 +305,27 @@ function LanguageSelector() {
|
||||
### Programmatic Language Change
|
||||
|
||||
```typescript
|
||||
import { useTranslation } from '@/shared/lib/useTranslation'
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
function useLanguage() {
|
||||
const { i18n } = useTranslation()
|
||||
|
||||
const changeLanguage = useCallback((language: string) => {
|
||||
i18n.changeLanguage(language)
|
||||
// Optionally save to user preferences
|
||||
localStorage.setItem('preferred-language', language)
|
||||
}, [i18n])
|
||||
|
||||
const getCurrentLanguage = () => i18n.language
|
||||
|
||||
const { i18n } = useTranslation();
|
||||
|
||||
const changeLanguage = useCallback(
|
||||
(language: string) => {
|
||||
i18n.changeLanguage(language);
|
||||
// Optionally save to user preferences
|
||||
localStorage.setItem("preferred-language", language);
|
||||
},
|
||||
[i18n]
|
||||
);
|
||||
|
||||
const getCurrentLanguage = () => i18n.language;
|
||||
|
||||
return {
|
||||
currentLanguage: i18n.language,
|
||||
changeLanguage,
|
||||
getCurrentLanguage,
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -373,20 +376,20 @@ i18n.init({
|
||||
// ... other config
|
||||
interpolation: {
|
||||
format: (value, format, lng) => {
|
||||
if (format === 'uppercase') return value.toUpperCase()
|
||||
if (format === 'currency') {
|
||||
if (format === "uppercase") return value.toUpperCase();
|
||||
if (format === "currency") {
|
||||
return new Intl.NumberFormat(lng, {
|
||||
style: 'currency',
|
||||
currency: 'USD'
|
||||
}).format(value)
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
}).format(value);
|
||||
}
|
||||
if (format === 'date') {
|
||||
return new Intl.DateTimeFormat(lng).format(value)
|
||||
if (format === "date") {
|
||||
return new Intl.DateTimeFormat(lng).format(value);
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
})
|
||||
return value;
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
```json
|
||||
@@ -401,27 +404,30 @@ i18n.init({
|
||||
```typescript
|
||||
// Custom hook with additional features
|
||||
export function useAppTranslation(namespace?: string) {
|
||||
const { t, i18n } = useTranslation(namespace)
|
||||
|
||||
const tWithFallback = useCallback((key: string, options?: any) => {
|
||||
const translation = t(key, options)
|
||||
|
||||
// Log missing translations in development
|
||||
if (process.env.NODE_ENV === 'development' && translation === key) {
|
||||
console.warn(`Missing translation for key: ${key}`)
|
||||
}
|
||||
|
||||
return translation
|
||||
}, [t])
|
||||
|
||||
const isRTL = i18n.language === 'ar' || i18n.language === 'he'
|
||||
|
||||
const { t, i18n } = useTranslation(namespace);
|
||||
|
||||
const tWithFallback = useCallback(
|
||||
(key: string, options?: any) => {
|
||||
const translation = t(key, options);
|
||||
|
||||
// Log missing translations in development
|
||||
if (process.env.NODE_ENV === "development" && translation === key) {
|
||||
console.warn(`Missing translation for key: ${key}`);
|
||||
}
|
||||
|
||||
return translation;
|
||||
},
|
||||
[t]
|
||||
);
|
||||
|
||||
const isRTL = i18n.language === "ar" || i18n.language === "he";
|
||||
|
||||
return {
|
||||
t: tWithFallback,
|
||||
i18n,
|
||||
isRTL,
|
||||
currentLanguage: i18n.language,
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -458,7 +464,7 @@ export function useAppTranslation(namespace?: string) {
|
||||
// en/marketplace.json - Feature-specific translations
|
||||
{
|
||||
"title": "MCP Store",
|
||||
"subtitle": "Discover and install MCP services",
|
||||
"subtitle": "Discover and install MCP servers",
|
||||
"search": {
|
||||
"placeholder": "Search services...",
|
||||
"noResults": "No services found",
|
||||
@@ -482,42 +488,45 @@ export function useAppTranslation(namespace?: string) {
|
||||
|
||||
```typescript
|
||||
// Validation script to check for missing translations
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
function validateTranslations() {
|
||||
const localesDir = path.join(process.cwd(), 'public/locales')
|
||||
const languages = fs.readdirSync(localesDir)
|
||||
const baseLanguage = 'en'
|
||||
|
||||
const baseTranslations = loadTranslations(baseLanguage)
|
||||
|
||||
languages.forEach(lang => {
|
||||
if (lang === baseLanguage) return
|
||||
|
||||
const translations = loadTranslations(lang)
|
||||
const missingKeys = findMissingKeys(baseTranslations, translations)
|
||||
|
||||
const localesDir = path.join(process.cwd(), "public/locales");
|
||||
const languages = fs.readdirSync(localesDir);
|
||||
const baseLanguage = "en";
|
||||
|
||||
const baseTranslations = loadTranslations(baseLanguage);
|
||||
|
||||
languages.forEach((lang) => {
|
||||
if (lang === baseLanguage) return;
|
||||
|
||||
const translations = loadTranslations(lang);
|
||||
const missingKeys = findMissingKeys(baseTranslations, translations);
|
||||
|
||||
if (missingKeys.length > 0) {
|
||||
console.warn(`Missing translations in ${lang}:`, missingKeys)
|
||||
console.warn(`Missing translations in ${lang}:`, missingKeys);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function findMissingKeys(base: any, target: any, prefix = ''): string[] {
|
||||
const missing: string[] = []
|
||||
|
||||
Object.keys(base).forEach(key => {
|
||||
const fullKey = prefix ? `${prefix}.${key}` : key
|
||||
|
||||
function findMissingKeys(base: any, target: any, prefix = ""): string[] {
|
||||
const missing: string[] = [];
|
||||
|
||||
Object.keys(base).forEach((key) => {
|
||||
const fullKey = prefix ? `${prefix}.${key}` : key;
|
||||
|
||||
if (!(key in target)) {
|
||||
missing.push(fullKey)
|
||||
} else if (typeof base[key] === 'object' && typeof target[key] === 'object') {
|
||||
missing.push(...findMissingKeys(base[key], target[key], fullKey))
|
||||
missing.push(fullKey);
|
||||
} else if (
|
||||
typeof base[key] === "object" &&
|
||||
typeof target[key] === "object"
|
||||
) {
|
||||
missing.push(...findMissingKeys(base[key], target[key], fullKey));
|
||||
}
|
||||
})
|
||||
|
||||
return missing
|
||||
});
|
||||
|
||||
return missing;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -525,32 +534,32 @@ function findMissingKeys(base: any, target: any, prefix = ''): string[] {
|
||||
|
||||
```typescript
|
||||
// Extract translation keys from components
|
||||
import { parse } from '@babel/parser'
|
||||
import traverse from '@babel/traverse'
|
||||
import fs from 'fs'
|
||||
import { parse } from "@babel/parser";
|
||||
import traverse from "@babel/traverse";
|
||||
import fs from "fs";
|
||||
|
||||
function extractTranslationKeys(filePath: string): string[] {
|
||||
const code = fs.readFileSync(filePath, 'utf-8')
|
||||
const code = fs.readFileSync(filePath, "utf-8");
|
||||
const ast = parse(code, {
|
||||
sourceType: 'module',
|
||||
plugins: ['typescript', 'jsx']
|
||||
})
|
||||
|
||||
const keys: string[] = []
|
||||
|
||||
sourceType: "module",
|
||||
plugins: ["typescript", "jsx"],
|
||||
});
|
||||
|
||||
const keys: string[] = [];
|
||||
|
||||
traverse(ast, {
|
||||
CallExpression(path) {
|
||||
if (
|
||||
path.node.callee.type === 'Identifier' &&
|
||||
path.node.callee.name === 't' &&
|
||||
path.node.arguments[0]?.type === 'StringLiteral'
|
||||
path.node.callee.type === "Identifier" &&
|
||||
path.node.callee.name === "t" &&
|
||||
path.node.arguments[0]?.type === "StringLiteral"
|
||||
) {
|
||||
keys.push(path.node.arguments[0].value)
|
||||
keys.push(path.node.arguments[0].value);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return keys
|
||||
},
|
||||
});
|
||||
|
||||
return keys;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -560,25 +569,25 @@ function extractTranslationKeys(filePath: string): string[] {
|
||||
|
||||
```typescript
|
||||
// Good: Descriptive, hierarchical keys
|
||||
t('marketplace.service.install.button')
|
||||
t('user.profile.form.validation.email.required')
|
||||
t('admin.dashboard.stats.users.total')
|
||||
t("marketplace.service.install.button");
|
||||
t("user.profile.form.validation.email.required");
|
||||
t("admin.dashboard.stats.users.total");
|
||||
|
||||
// Bad: Generic, flat keys
|
||||
t('button1')
|
||||
t('error')
|
||||
t('text')
|
||||
t("button1");
|
||||
t("error");
|
||||
t("text");
|
||||
```
|
||||
|
||||
### 2. Consistent Namespace Usage
|
||||
|
||||
```typescript
|
||||
// Good: Feature-based namespaces
|
||||
const { t } = useTranslation('marketplace')
|
||||
const { t: tCommon } = useTranslation('common')
|
||||
const { t } = useTranslation("marketplace");
|
||||
const { t: tCommon } = useTranslation("common");
|
||||
|
||||
// Bad: Mixed namespace usage
|
||||
const { t } = useTranslation() // Default namespace for everything
|
||||
const { t } = useTranslation(); // Default namespace for everything
|
||||
```
|
||||
|
||||
### 3. Translation Context
|
||||
@@ -601,10 +610,8 @@ const { t } = useTranslation() // Default namespace for everything
|
||||
|
||||
```typescript
|
||||
// Good: Use interpolation
|
||||
t('welcome.message', { userName: user.name })
|
||||
|
||||
// Bad: String concatenation
|
||||
`Welcome, ${user.name}!`
|
||||
t("welcome.message", { userName: user.name })// Bad: String concatenation
|
||||
`Welcome, ${user.name}!`;
|
||||
```
|
||||
|
||||
### 5. Error Message Translations
|
||||
@@ -649,7 +656,7 @@ describe('MyComponent', () => {
|
||||
renderWithI18n(<MyComponent />)
|
||||
expect(screen.getByText('Welcome')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
|
||||
it('renders in Chinese', async () => {
|
||||
await i18n.changeLanguage('zh-CN')
|
||||
renderWithI18n(<MyComponent />)
|
||||
@@ -662,12 +669,12 @@ describe('MyComponent', () => {
|
||||
|
||||
```typescript
|
||||
// test-utils/i18n-for-tests.ts
|
||||
import i18n from 'i18next'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
i18n.use(initReactI18next).init({
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
lng: "en",
|
||||
fallbackLng: "en",
|
||||
debug: false,
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
@@ -675,20 +682,20 @@ i18n.use(initReactI18next).init({
|
||||
resources: {
|
||||
en: {
|
||||
translation: {
|
||||
'Welcome': 'Welcome',
|
||||
'Goodbye': 'Goodbye',
|
||||
}
|
||||
Welcome: "Welcome",
|
||||
Goodbye: "Goodbye",
|
||||
},
|
||||
},
|
||||
'zh-CN': {
|
||||
"zh-CN": {
|
||||
translation: {
|
||||
'Welcome': '欢迎',
|
||||
'Goodbye': '再见',
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Welcome: "欢迎",
|
||||
Goodbye: "再见",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n
|
||||
export default i18n;
|
||||
```
|
||||
|
||||
## Adding New Languages
|
||||
@@ -704,10 +711,10 @@ export default i18n
|
||||
```typescript
|
||||
// Add to language selector
|
||||
const languages = [
|
||||
{ code: 'en', name: 'English', flag: '🇺🇸' },
|
||||
{ code: 'zh-CN', name: '中文', flag: '🇨🇳' },
|
||||
{ code: 'es', name: 'Español', flag: '🇪🇸' }, // New language
|
||||
]
|
||||
{ code: "en", name: "English", flag: "🇺🇸" },
|
||||
{ code: "zh-CN", name: "中文", flag: "🇨🇳" },
|
||||
{ code: "es", name: "Español", flag: "🇪🇸" }, // New language
|
||||
];
|
||||
```
|
||||
|
||||
### 3. Update i18n Configuration
|
||||
@@ -716,12 +723,12 @@ const languages = [
|
||||
// Add fallback languages if needed
|
||||
i18n.init({
|
||||
fallbackLng: {
|
||||
'zh-CN': ['zh', 'en'],
|
||||
'es': ['en'],
|
||||
'default': ['en']
|
||||
"zh-CN": ["zh", "en"],
|
||||
es: ["en"],
|
||||
default: ["en"],
|
||||
},
|
||||
// ... other config
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
This comprehensive i18n guide ensures consistent and maintainable internationalization throughout the XPack WebUI application.
|
||||
This comprehensive i18n guide ensures consistent and maintainable internationalization throughout the XPack WebUI application.
|
||||
@@ -21,13 +21,15 @@ const nextConfig = {
|
||||
},
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
source: "/api/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8001"}/api/:path*`,
|
||||
},
|
||||
// {
|
||||
// source: "/api/:path*",
|
||||
// destination: `${process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8001"}/api/:path*`,
|
||||
// },
|
||||
{
|
||||
source: "/uploads/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8001"}/uploads/:path*`,
|
||||
destination: `${
|
||||
process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8001"
|
||||
}/uploads/:path*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
"@nextui-org/theme": "^2.4.5",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@uiw/react-markdown-preview": "^5.1.5",
|
||||
"@uiw/react-md-editor": "^4.0.7",
|
||||
"animejs": "^4.0.2",
|
||||
"async_hooks": "^1.0.0",
|
||||
"crypto-js": "^4.2.0",
|
||||
"framer-motion": "^11.5.6",
|
||||
"i18next": "^23.8.0",
|
||||
@@ -38,7 +40,6 @@
|
||||
"react-hover-video-player": "^10.0.2",
|
||||
"react-i18next": "^14.0.1",
|
||||
"react-icons": "^5.3.0",
|
||||
"react-markdown": "^10.1.0",
|
||||
"recharts": "^2.15.1",
|
||||
"simplex-noise": "^4.0.3",
|
||||
"swr": "^2.2.4",
|
||||
|
||||
@@ -26,12 +26,18 @@ importers:
|
||||
'@types/crypto-js':
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2
|
||||
'@uiw/react-markdown-preview':
|
||||
specifier: ^5.1.5
|
||||
version: 5.1.5(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
'@uiw/react-md-editor':
|
||||
specifier: ^4.0.7
|
||||
version: 4.0.7(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
animejs:
|
||||
specifier: ^4.0.2
|
||||
version: 4.0.2
|
||||
async_hooks:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
crypto-js:
|
||||
specifier: ^4.2.0
|
||||
version: 4.2.0
|
||||
@@ -80,9 +86,6 @@ importers:
|
||||
react-icons:
|
||||
specifier: ^5.3.0
|
||||
version: 5.5.0(react@18.3.1)
|
||||
react-markdown:
|
||||
specifier: ^10.1.0
|
||||
version: 10.1.0(@types/react@18.3.23)(react@18.3.1)
|
||||
recharts:
|
||||
specifier: ^2.15.1
|
||||
version: 2.15.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
@@ -1219,72 +1222,85 @@ packages:
|
||||
resolution: {integrity: sha512-IVfGJa7gjChDET1dK9SekxFFdflarnUB8PwW8aGwEoF3oAsSDuNUTYS+SKDOyOJxQyDC1aPFMuRYLoDInyV9Ew==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-arm@1.1.0':
|
||||
resolution: {integrity: sha512-s8BAd0lwUIvYCJyRdFqvsj+BJIpDBSxs6ivrOPm/R7piTs5UIwY5OjXrP2bqXC9/moGsyRa37eYWYCOGVXxVrA==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-ppc64@1.1.0':
|
||||
resolution: {integrity: sha512-tiXxFZFbhnkWE2LA8oQj7KYR+bWBkiV2nilRldT7bqoEZ4HiDOcePr9wVDAZPi/Id5fT1oY9iGnDq20cwUz8lQ==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-s390x@1.1.0':
|
||||
resolution: {integrity: sha512-xukSwvhguw7COyzvmjydRb3x/09+21HykyapcZchiCUkTThEQEOMtBj9UhkaBRLuBrgLFzQ2wbxdeCCJW/jgJA==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linux-x64@1.1.0':
|
||||
resolution: {integrity: sha512-yRj2+reB8iMg9W5sULM3S74jVS7zqSzHG3Ol/twnAAkAhnGQnpjj6e4ayUz7V+FpKypwgs82xbRdYtchTTUB+Q==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-libvips-linuxmusl-arm64@1.1.0':
|
||||
resolution: {integrity: sha512-jYZdG+whg0MDK+q2COKbYidaqW/WTz0cc1E+tMAusiDygrM4ypmSCjOJPmFTvHHJ8j/6cAGyeDWZOsK06tP33w==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-libvips-linuxmusl-x64@1.1.0':
|
||||
resolution: {integrity: sha512-wK7SBdwrAiycjXdkPnGCPLjYb9lD4l6Ze2gSdAGVZrEL05AOUJESWU2lhlC+Ffn5/G+VKuSm6zzbQSzFX/P65A==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-linux-arm64@0.34.2':
|
||||
resolution: {integrity: sha512-D8n8wgWmPDakc83LORcfJepdOSN6MvWNzzz2ux0MnIbOqdieRZwVYY32zxVx+IFUT8er5KPcyU3XXsn+GzG/0Q==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linux-arm@0.34.2':
|
||||
resolution: {integrity: sha512-0DZzkvuEOqQUP9mo2kjjKNok5AmnOr1jB2XYjkaoNRwpAYMDzRmAqUIa1nRi58S2WswqSfPOWLNOr0FDT3H5RQ==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linux-s390x@0.34.2':
|
||||
resolution: {integrity: sha512-EGZ1xwhBI7dNISwxjChqBGELCWMGDvmxZXKjQRuqMrakhO8QoMgqCrdjnAqJq/CScxfRn+Bb7suXBElKQpPDiw==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linux-x64@0.34.2':
|
||||
resolution: {integrity: sha512-sD7J+h5nFLMMmOXYH4DD9UtSNBD05tWSSdWAcEyzqW8Cn5UxXvsHAxmxSesYUsTOBmUnjtxghKDl15EvfqLFbQ==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@img/sharp-linuxmusl-arm64@0.34.2':
|
||||
resolution: {integrity: sha512-NEE2vQ6wcxYav1/A22OOxoSOGiKnNmDzCYFOZ949xFmrWZOVII1Bp3NqVVpvj+3UeHMFyN5eP/V5hzViQ5CZNA==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-linuxmusl-x64@0.34.2':
|
||||
resolution: {integrity: sha512-DOYMrDm5E6/8bm/yQLCWyuDJwUnlevR8xtF8bs+gjZ7cyUNYXiSf/E8Kp0Ss5xasIaXSHzb888V1BE4i1hFhAA==}
|
||||
engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@img/sharp-wasm32@0.34.2':
|
||||
resolution: {integrity: sha512-/VI4mdlJ9zkaq53MbIG6rZY+QRN3MLbR6usYlgITEzi4Rpx5S6LFKsycOQjkOGmqTNmkIdLjEvooFKwww6OpdQ==}
|
||||
@@ -1391,24 +1407,28 @@ packages:
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@next/swc-linux-arm64-musl@15.3.4':
|
||||
resolution: {integrity: sha512-wFyZ7X470YJQtpKot4xCY3gpdn8lE9nTlldG07/kJYexCUpX1piX+MBfZdvulo+t1yADFVEuzFfVHfklfEx8kw==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@next/swc-linux-x64-gnu@15.3.4':
|
||||
resolution: {integrity: sha512-gEbH9rv9o7I12qPyvZNVTyP/PWKqOp8clvnoYZQiX800KkqsaJZuOXkWgMa7ANCCh/oEN2ZQheh3yH8/kWPSEg==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@next/swc-linux-x64-musl@15.3.4':
|
||||
resolution: {integrity: sha512-Cf8sr0ufuC/nu/yQ76AnarbSAXcwG/wj+1xFPNbyNo8ltA6kw5d5YqO8kQuwVIxk13SBdtgXrNyom3ZosHAy4A==}
|
||||
engines: {node: '>= 10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@next/swc-win32-arm64-msvc@15.3.4':
|
||||
resolution: {integrity: sha512-ay5+qADDN3rwRbRpEhTOreOn1OyJIXS60tg9WMYTWCy3fB6rGoyjLVxc4dR9PYjEdR2iDYsaF5h03NA+XuYPQQ==}
|
||||
@@ -2712,24 +2732,28 @@ packages:
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@swc/core-linux-arm64-musl@1.10.18':
|
||||
resolution: {integrity: sha512-4rv+E4VLdgQw6zjbTAauCAEExxChvxMpBUMCiZweTNPKbJJ2dY6BX2WGJ1ea8+RcgqR/Xysj3AFbOz1LBz6dGA==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@swc/core-linux-x64-gnu@1.10.18':
|
||||
resolution: {integrity: sha512-vTNmyRBVP+sZca+vtwygYPGTNudTU6Gl6XhaZZ7cEUTBr8xvSTgEmYXoK/2uzyXpaTUI4Bmtp1x81cGN0mMoLQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@swc/core-linux-x64-musl@1.10.18':
|
||||
resolution: {integrity: sha512-1TZPReKhFCeX776XaT6wegknfg+g3zODve+r4oslFHI+g7cInfWlxoGNDS3niPKyuafgCdOjme2g3OF+zzxfsQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@swc/core-win32-arm64-msvc@1.10.18':
|
||||
resolution: {integrity: sha512-o/2CsaWSN3bkzVQ6DA+BiFKSVEYvhWGA1h+wnL2zWmIDs2Knag54sOEXZkCaf8YQyZesGeXJtPEy9hh/vjJgkA==}
|
||||
@@ -3083,8 +3107,8 @@ packages:
|
||||
'@uiw/copy-to-clipboard@1.0.17':
|
||||
resolution: {integrity: sha512-O2GUHV90Iw2VrSLVLK0OmNIMdZ5fgEg4NhvtwINsX+eZ/Wf6DWD0TdsK9xwV7dNRnK/UI2mQtl0a2/kRgm1m1A==}
|
||||
|
||||
'@uiw/react-markdown-preview@5.1.4':
|
||||
resolution: {integrity: sha512-6k13WVNHCEaamz3vh54OQ1tseIXneKlir1+E/VFQBPq8PRod+gwLfYtiitDBWu+ZFttoiKPLZ7flgHrVM+JNOg==}
|
||||
'@uiw/react-markdown-preview@5.1.5':
|
||||
resolution: {integrity: sha512-DNOqx1a6gJR7Btt57zpGEKTfHRlb7rWbtctMRO2f82wWcuoJsxPBrM+JWebDdOD0LfD8oe2CQvW2ICQJKHQhZg==}
|
||||
peerDependencies:
|
||||
react: '>=16.8.0'
|
||||
react-dom: '>=16.8.0'
|
||||
@@ -3137,41 +3161,49 @@ packages:
|
||||
resolution: {integrity: sha512-UYA0MA8ajkEDCFRQdng/FVx3F6szBvk3EPnkTTQuuO9lV1kPGuTB+V9TmbDxy5ikaEgyWKxa4CI3ySjklZ9lFA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@unrs/resolver-binding-linux-arm64-musl@1.9.2':
|
||||
resolution: {integrity: sha512-P/CO3ODU9YJIHFqAkHbquKtFst0COxdphc8TKGL5yCX75GOiVpGqd1d15ahpqu8xXVsqP4MGFP2C3LRZnnL5MA==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@unrs/resolver-binding-linux-ppc64-gnu@1.9.2':
|
||||
resolution: {integrity: sha512-uKStFlOELBxBum2s1hODPtgJhY4NxYJE9pAeyBgNEzHgTqTiVBPjfTlPFJkfxyTjQEuxZbbJlJnMCrRgD7ubzw==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@unrs/resolver-binding-linux-riscv64-gnu@1.9.2':
|
||||
resolution: {integrity: sha512-LkbNnZlhINfY9gK30AHs26IIVEZ9PEl9qOScYdmY2o81imJYI4IMnJiW0vJVtXaDHvBvxeAgEy5CflwJFIl3tQ==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@unrs/resolver-binding-linux-riscv64-musl@1.9.2':
|
||||
resolution: {integrity: sha512-vI+e6FzLyZHSLFNomPi+nT+qUWN4YSj8pFtQZSFTtmgFoxqB6NyjxSjAxEC1m93qn6hUXhIsh8WMp+fGgxCoRg==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@unrs/resolver-binding-linux-s390x-gnu@1.9.2':
|
||||
resolution: {integrity: sha512-sSO4AlAYhSM2RAzBsRpahcJB1msc6uYLAtP6pesPbZtptF8OU/CbCPhSRW6cnYOGuVmEmWVW5xVboAqCnWTeHQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@unrs/resolver-binding-linux-x64-gnu@1.9.2':
|
||||
resolution: {integrity: sha512-jkSkwch0uPFva20Mdu8orbQjv2A3G88NExTN2oPTI1AJ+7mZfYW3cDCTyoH6OnctBKbBVeJCEqh0U02lTkqD5w==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [glibc]
|
||||
|
||||
'@unrs/resolver-binding-linux-x64-musl@1.9.2':
|
||||
resolution: {integrity: sha512-Uk64NoiTpQbkpl+bXsbeyOPRpUoMdcUqa+hDC1KhMW7aN1lfW8PBlBH4mJ3n3Y47dYE8qi0XTxy1mBACruYBaw==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
libc: [musl]
|
||||
|
||||
'@unrs/resolver-binding-wasm32-wasi@1.9.2':
|
||||
resolution: {integrity: sha512-EpBGwkcjDicjR/ybC0g8wO5adPNdVuMrNalVgYcWi+gYtC1XYNuxe3rufcO7dA76OHGeVabcO6cSkPJKVcbCXQ==}
|
||||
@@ -3342,6 +3374,9 @@ packages:
|
||||
resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
async_hooks@1.0.0:
|
||||
resolution: {integrity: sha512-t4BSJgx48V3e7U6Ll3/WOUNmxIRPzmPdxVfgbyzcnRItEnn4iKp4F//b0sV3L9hzbdr5qxWdNWzOF7t+rjYSfA==}
|
||||
|
||||
attr-accept@2.2.5:
|
||||
resolution: {integrity: sha512-0bDNnY/u6pPwHDMoF0FieU354oBi0a8rD9FcsLwzcGWbc8KS8KPIi7y+s13OlVY+gMWc/9xEMUgNE6Qm8ZllYQ==}
|
||||
engines: {node: '>=4'}
|
||||
@@ -11173,7 +11208,7 @@ snapshots:
|
||||
|
||||
'@uiw/copy-to-clipboard@1.0.17': {}
|
||||
|
||||
'@uiw/react-markdown-preview@5.1.4(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||
'@uiw/react-markdown-preview@5.1.5(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||
dependencies:
|
||||
'@babel/runtime': 7.26.9
|
||||
'@uiw/copy-to-clipboard': 1.0.17
|
||||
@@ -11197,7 +11232,7 @@ snapshots:
|
||||
'@uiw/react-md-editor@4.0.7(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
|
||||
dependencies:
|
||||
'@babel/runtime': 7.26.9
|
||||
'@uiw/react-markdown-preview': 5.1.4(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
'@uiw/react-markdown-preview': 5.1.5(@types/react@18.3.23)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
react: 18.3.1
|
||||
react-dom: 18.3.1(react@18.3.1)
|
||||
rehype: 13.0.2
|
||||
@@ -11445,6 +11480,8 @@ snapshots:
|
||||
|
||||
async-function@1.0.0: {}
|
||||
|
||||
async_hooks@1.0.0: {}
|
||||
|
||||
attr-accept@2.2.5: {}
|
||||
|
||||
autoprefixer@10.4.20(postcss@8.5.3):
|
||||
|
||||
@@ -1,13 +1,243 @@
|
||||
{
|
||||
"**XPack** is a lightweight, open-source marketplace framework for MCP (Model Context Protocol) services.": "**XPack** is a lightweight, open-source marketplace framework for MCP (Model Context Protocol) services.",
|
||||
"It allows you to transform any OpenAPI into a monetizable MCP service and build your own API store in just minutes.": "It allows you to transform any OpenAPI into a monetizable MCP service and build your own API store in just minutes.",
|
||||
"✨ With XPack, you can:": "✨ With XPack, you can:",
|
||||
"- ✅ **One-click OpenAPI → MCP service config**": "- ✅ **One-click OpenAPI → MCP service config**",
|
||||
"- 🧾 **SEO-friendly homepage + mcp service page**": "- 🧾 **SEO-friendly homepage + mcp service page**",
|
||||
"- 💳 **Built-in billing (per-call)**": "- 💳 **Built-in billing (per-call)**",
|
||||
"- 👥 **User account management**": "- 👥 **User account management**",
|
||||
"- 🛠 **Support Stripe Payment**": "- 🛠 **Support Stripe Payment**",
|
||||
"- 🔐 **Support Email & Google OAuth Sign in**": "- 🔐 **Support Email & Google OAuth Sign in**",
|
||||
"Everything is open-source and licensed under **Apache 2.0** — ready for commercial use.": "Everything is open-source and licensed under **Apache 2.0** — ready for commercial use.",
|
||||
"About Us": "About Us"
|
||||
}
|
||||
"Server Configuration": "Server Configuration",
|
||||
"Subdomain": "Subdomain",
|
||||
"Enter subdomain (e.g., mysite)": "Enter subdomain (e.g., mysite)",
|
||||
"Subdomain is required": "Subdomain is required",
|
||||
"Subdomain must contain only lowercase letters, numbers, and hyphens": "Subdomain must contain only lowercase letters, numbers, and hyphens",
|
||||
"Subdomain must be between 3 and 63 characters": "Subdomain must be between 3 and 63 characters",
|
||||
"Log in to your admin account to continue": "Log in to your admin account to continue",
|
||||
"Your unique subdomain for the platform": "Your unique subdomain for the platform",
|
||||
"Let's get started!": "Let's get started!",
|
||||
"Welcome! It's time to set up Lethe Live.": "Welcome! It's time to set up Lethe Live.",
|
||||
"Start a new Ghost publication": "Start a new Ghost publication",
|
||||
"Customize your design": "Customize your design",
|
||||
"Craft a look that reflects your brand and style": "Craft a look that reflects your brand and style",
|
||||
"Explore the editor": "Explore the editor",
|
||||
"Build your audience": "Build your audience",
|
||||
"Share your publication": "Share your publication",
|
||||
"More questions? Check out our": "More questions? Check out our",
|
||||
"Help Center": "Help Center",
|
||||
"Skip onboarding": "Skip onboarding",
|
||||
"Great! All tasks completed!": "Great! All tasks completed!",
|
||||
"Continue to Dashboard": "Continue to Dashboard",
|
||||
"Page Not Found": "Page Not Found",
|
||||
"The page you're looking for doesn't exist or has been moved.": "The page you're looking for doesn't exist or has been moved.",
|
||||
"This page could not be found.": "This page could not be found.",
|
||||
"Back to Home": "Back to Home",
|
||||
"Subdomain Change Warning": "Subdomain Change Warning",
|
||||
"The subdomain has been changed. You will be automatically redirected to the new address in {{seconds}} seconds.": "The subdomain has been changed. You will be automatically redirected to the new address in {{seconds}} seconds.",
|
||||
"New Address": "New Address",
|
||||
"Redirect Now": "Redirect Now",
|
||||
"Daily Registered Users": "Daily Registered Users",
|
||||
"Daily Revenue": "Daily Revenue",
|
||||
"Daily API Calls": "Daily API Calls",
|
||||
"Top Servers by Calls": "Top Servers by Calls",
|
||||
"Date": "Date",
|
||||
"Users": "Users",
|
||||
"Revenue": "Revenue",
|
||||
"Calls": "Calls",
|
||||
"Server Name": "Server Name",
|
||||
"Call Volume": "Call Volume",
|
||||
"Last 30 Days Overview": "Last 30 Days Overview",
|
||||
"Sort by Call Volume": "Sort by Call Volume",
|
||||
"Sort by Name": "Sort by Name",
|
||||
"Total subscribers": "Total subscribers",
|
||||
"Avg. open rate": "Avg. open rate",
|
||||
"Avg. click rate": "Avg. click rate",
|
||||
"Total Users": "Total Users",
|
||||
"Total Revenue": "Total Revenue",
|
||||
"Total API Calls": "Total API Calls",
|
||||
"API server for machine learning tasks": "API server for machine learning tasks",
|
||||
"Web Scraping Statistics": "Web Scraping Statistics",
|
||||
"Total Scraped Pages": "Total Scraped Pages",
|
||||
"Total number of pages scraped from the website": "Total number of pages scraped from the website",
|
||||
"Scraping Growth Chart": "Scraping Growth Chart",
|
||||
"New Pages": "New Pages",
|
||||
"Daily growth of scraped pages over time": "Daily growth of scraped pages over time",
|
||||
"Real-time data processing service": "Real-time data processing service",
|
||||
"Natural language processing service": "Natural language processing service",
|
||||
"Computer vision analysis tool": "Computer vision analysis tool",
|
||||
"Translation and localization service": "Translation and localization service",
|
||||
"Web search and indexing engine": "Web search and indexing engine",
|
||||
"Cloud file storage and management": "Cloud file storage and management",
|
||||
"Email delivery and management service": "Email delivery and management service",
|
||||
"Weather data and forecasting API": "Weather data and forecasting API",
|
||||
"Calendar synchronization service": "Calendar synchronization service",
|
||||
"Settings": "Settings",
|
||||
"System Settings": "System Settings",
|
||||
"General": "General",
|
||||
"Platform basic configuration": "Platform basic configuration",
|
||||
"Homepage": "Homepage",
|
||||
"Homepage content and theme settings": "Homepage content and theme settings",
|
||||
"Payment Channels": "Payment Channels",
|
||||
"Configure payment channels": "Configure payment channels",
|
||||
"Admin Settings": "Admin Settings",
|
||||
"Configure admin login credentials": "Configure admin login credentials",
|
||||
"Search settings": "Search settings",
|
||||
"Clear": "Clear",
|
||||
"No results": "No results",
|
||||
"Welcome to Your Platform!": "Welcome to Your Platform!",
|
||||
"Let's set up {{platformName}} to get you started.": "Let's set up {{platformName}} to get you started.",
|
||||
"Configure Platform Settings": "Configure Platform Settings",
|
||||
"Set up your platform name, domain, and branding.": "Set up your platform name, domain, and branding.",
|
||||
"Add MCP Services": "Add MCP Services",
|
||||
"Configure and deploy your first MCP server tools.": "Configure and deploy your first MCP server tools.",
|
||||
"Manage Users": "Manage Users",
|
||||
"View and configure user accounts and permissions.": "View and configure user accounts and permissions.",
|
||||
"Configure Payment & Billing": "Configure Payment & Billing",
|
||||
"Set up payment channels and token pricing.": "Set up payment channels and token pricing.",
|
||||
"Generate API Keys": "Generate API Keys",
|
||||
"Create API keys for external integrations.": "Create API keys for external integrations.",
|
||||
"Share Your Platform": "Share Your Platform",
|
||||
"Invite users and promote your MCP platform.": "Invite users and promote your MCP platform.",
|
||||
"Need help getting started? Check out our": "Need help getting started? Check out our",
|
||||
"Discord Community": "Discord Community",
|
||||
"Skip setup guide": "Skip setup guide",
|
||||
"Excellent! Your platform is ready to go!": "Excellent! Your platform is ready to go!",
|
||||
"Go to Dashboard": "Go to Dashboard",
|
||||
"Platform": "Platform",
|
||||
"Billing & Payments": "Billing & Payments",
|
||||
"Administration": "Administration",
|
||||
"Meta Data": "Meta Data",
|
||||
"Extra content for search engines and social accounts": "Extra content for search engines and social accounts",
|
||||
"Search": "Search",
|
||||
"X Card": "X Card",
|
||||
"Facebook Card": "Facebook Card",
|
||||
"Meta Title": "Meta Title",
|
||||
"Enter meta title": "Enter meta title",
|
||||
"Recommended: 70 characters": "Recommended: 70 characters",
|
||||
"Meta Description": "Meta Description",
|
||||
"Enter meta description": "Enter meta description",
|
||||
"Recommended: 156 characters": "Recommended: 156 characters",
|
||||
"Preview": "Preview",
|
||||
"Lethe Live": "Lethe Live",
|
||||
"Thoughts, stories and ideas.": "Thoughts, stories and ideas.",
|
||||
"Upload X Image": "Upload X Image",
|
||||
"Upload Facebook Image": "Upload Facebook Image",
|
||||
"Uploading...": "Uploading...",
|
||||
"X Title": "X Title",
|
||||
"Enter X title": "Enter X title",
|
||||
"X Description": "X Description",
|
||||
"Enter X description": "Enter X description",
|
||||
"Facebook Title": "Facebook Title",
|
||||
"Enter Facebook title": "Enter Facebook title",
|
||||
"Facebook Description": "Facebook Description",
|
||||
"Enter Facebook description": "Enter Facebook description",
|
||||
"Meta data saved successfully": "Meta data saved successfully",
|
||||
"Please select a valid image file": "Please select a valid image file",
|
||||
"Image size should be less than 5MB": "Image size should be less than 5MB",
|
||||
"Failed to upload image": "Failed to upload image",
|
||||
"General settings": "General settings",
|
||||
"Title & description": "Title & description",
|
||||
"Configure your site title and description": "Configure your site title and description",
|
||||
"Meta data": "Meta data",
|
||||
"SEO metadata and site configuration": "SEO metadata and site configuration",
|
||||
"Connect your social media accounts": "Connect your social media accounts",
|
||||
"Custom domain": "Custom domain",
|
||||
"Configure your custom domain settings": "Configure your custom domain settings",
|
||||
"Site": "Site",
|
||||
"Branding": "Branding",
|
||||
"Logo, colors, and brand identity": "Logo, colors, and brand identity",
|
||||
"Theme": "Theme",
|
||||
"Visual theme and appearance settings": "Visual theme and appearance settings",
|
||||
"Navigation": "Navigation",
|
||||
"Configure site navigation and menus": "Configure site navigation and menus",
|
||||
"Business": "Business",
|
||||
"Payment": "Payment",
|
||||
"Payment processing and billing settings": "Payment processing and billing settings",
|
||||
"XPack Explore": "XPack Explore",
|
||||
"Explore XPack features and integrations": "Explore XPack features and integrations",
|
||||
"Advanced": "Advanced",
|
||||
"Code injection": "Code injection",
|
||||
"Custom code injection and scripts": "Custom code injection and scripts",
|
||||
"Enter the domain you want to use": "Enter the domain you want to use",
|
||||
"Enter your full domain name (e.g., www.example.com)": "Enter your full domain name (e.g., www.example.com)",
|
||||
"Create your DNS records": "Create your DNS records",
|
||||
"Add the following DNS records at your DNS provider": "Add the following DNS records at your DNS provider",
|
||||
"DNS Records Table": "DNS Records Table",
|
||||
"Type": "Type",
|
||||
"Host": "Host",
|
||||
"Value": "Value",
|
||||
"Activate custom domain": "Activate custom domain",
|
||||
"Your DNS looks good. You can activate now.": "Your DNS looks good. You can activate now.",
|
||||
"Make sure your DNS records have propagated before activation.": "Make sure your DNS records have propagated before activation.",
|
||||
"Activate": "Activate",
|
||||
"Domain": "Domain",
|
||||
"Please enter a valid URL with http:// or https://": "Please enter a valid URL with http:// or https://",
|
||||
"Create MCP Server": "Create MCP Server",
|
||||
"Choose how you want to create your MCP server": "Choose how you want to create your MCP server",
|
||||
"Website Content Scraper": "Website Content Scraper",
|
||||
"Create an MCP server that can scrape and extract content from websites": "Create an MCP server that can scrape and extract content from websites",
|
||||
"OpenAPI Generator": "OpenAPI Generator",
|
||||
"Generate MCP server from OpenAPI/Swagger documentation": "Generate MCP server from OpenAPI/Swagger documentation",
|
||||
"Update Website Scraper": "Update Website Scraper",
|
||||
"Sync from OpenAPI": "Sync from OpenAPI",
|
||||
"Update Server": "Update Server",
|
||||
"Add Server": "Add Server",
|
||||
"Website URL": "Website URL",
|
||||
"Enter the website URL (e.g., https://example.com)": "Enter the website URL (e.g., https://example.com)",
|
||||
"Update website URL for content scraping": "Update website URL for content scraping",
|
||||
"Enter the website URL you want to scrape content from": "Enter the website URL you want to scrape content from",
|
||||
"Creating webscraper server...": "Creating webscraper server...",
|
||||
"Sync server configuration from OpenAPI/Swagger documentation": "Sync server configuration from OpenAPI/Swagger documentation",
|
||||
"Generate MCP server configuration from OpenAPI/Swagger documentation": "Generate MCP server configuration from OpenAPI/Swagger documentation",
|
||||
"From URL": "From URL",
|
||||
"Upload File": "Upload File",
|
||||
"OpenAPI URL": "OpenAPI URL",
|
||||
"Enter the URL to your OpenAPI/Swagger specification": "Enter the URL to your OpenAPI/Swagger specification",
|
||||
"Upload OpenAPI File": "Upload OpenAPI File",
|
||||
"Choose File": "Choose File",
|
||||
"Supports JSON and YAML formats": "Supports JSON and YAML formats",
|
||||
"Parsing OpenAPI document...": "Parsing OpenAPI document...",
|
||||
"Back": "Back",
|
||||
"Create Server": "Create Server",
|
||||
"Generate Server": "Generate Server",
|
||||
"Sync Server": "Sync Server",
|
||||
"Select Type": "Select Type",
|
||||
"Configure": "Configure",
|
||||
"OR": "OR",
|
||||
"Use Website Scraper": "Use Website Scraper",
|
||||
"Use OpenAPI Generator": "Use OpenAPI Generator",
|
||||
"Data scraping in progress...": "Data scraping in progress...",
|
||||
"Scraped {{current}} of {{total}} pages": "Scraped {{current}} of {{total}} pages",
|
||||
"Scraped {{count}} pages": "Scraped {{count}} pages",
|
||||
"Modifying the URL will trigger re-scraping of the website data.": "Modifying the URL will trigger re-scraping of the website data.",
|
||||
"You have modified the Website URL. This will trigger re-scraping of the website data. Are you sure you want to continue?": "You have modified the Website URL. This will trigger re-scraping of the website data. Are you sure you want to continue?",
|
||||
"Scraping...": "Scraping...",
|
||||
"Server Type": "Server Type",
|
||||
"Edit Website URL": "Edit Website URL",
|
||||
"Modifying the website URL will trigger re-scraping of the website data. This process may take some time to complete.": "Modifying the website URL will trigger re-scraping of the website data. This process may take some time to complete.",
|
||||
"Please enter a valid URL": "Please enter a valid URL",
|
||||
"Use the refresh button to modify the website URL": "Use the refresh button to modify the website URL",
|
||||
"Cannot publish while scraping": "Cannot publish while scraping",
|
||||
"Publish": "Publish",
|
||||
"Unpublish": "Unpublish",
|
||||
"Published": "Published",
|
||||
"Unpublished": "Unpublished",
|
||||
"Your brand": "Your brand",
|
||||
"Support JPG, PNG, GIF, SVG. Max size 5MB": "Support JPG, PNG, GIF, SVG. Max size 5MB",
|
||||
"Site title": "Site title",
|
||||
"Enter site title": "Enter site title",
|
||||
"Main title displayed on the home page": "Main title displayed on the home page",
|
||||
"Site description": "Site description",
|
||||
"Enter site description": "Enter site description",
|
||||
"Secondary description displayed below the main title": "Secondary description displayed below the main title",
|
||||
"Title is required": "Title is required",
|
||||
"Custom Domain": "Custom Domain",
|
||||
"Activate your domain": "Activate your domain",
|
||||
"Set Custom Domain": "Set Custom Domain",
|
||||
"Configure platform language": "Configure platform language",
|
||||
"Enter title": "Enter title",
|
||||
"Enter link URL": "Enter link URL",
|
||||
"Configure FAQ": "Configure FAQ",
|
||||
"Enter question": "Enter question",
|
||||
"Enter answer": "Enter answer",
|
||||
"Enable Stripe Payment": "Enable Stripe Payment",
|
||||
"Toggle to enable or disable Stripe payment interface": "Toggle to enable or disable Stripe payment interface",
|
||||
"Enter Secret Key": "Enter Secret Key",
|
||||
"Enter Webhook Secret": "Enter Webhook Secret",
|
||||
"Email Login Settings": "Email Login Settings",
|
||||
"Open in new tab": "Open in new tab",
|
||||
"Analyze platform usage and revenue": "Analyze platform usage and revenue",
|
||||
"Change your password": "Change your password"
|
||||
}
|
||||
@@ -81,7 +81,7 @@
|
||||
"Free": "Free",
|
||||
"Sign up now to get 100 free calls every month.": "Sign up now to get 100 free calls every month.",
|
||||
"Generate and manage dynamic PowerPoints and Google Slides with your own custom branding and layouts.": "Generate and manage dynamic PowerPoints and Google Slides with your own custom branding and layouts.",
|
||||
"Try for free": "Try for free",
|
||||
"Sign up to get the auth key": "Sign up to get the auth key",
|
||||
"Lightning Fast Setup": "Lightning Fast Setup",
|
||||
"Enterprise Security": "Enterprise Security",
|
||||
"Global Scale": "Global Scale",
|
||||
@@ -103,7 +103,7 @@
|
||||
"Build AI Agents": "Build AI Agents",
|
||||
"With Incredible MCP": "With Incredible MCP",
|
||||
"Instant Integration": "Instant Integration",
|
||||
"Connect to global APIs and MCP services with just one config or SDK.": "Connect to global APIs and MCP services with just one config or SDK.",
|
||||
"Connect to global APIs and MCP servers with just one config or SDK.": "Connect to global APIs and MCP servers with just one config or SDK.",
|
||||
"Zero Overhead": "Zero Overhead",
|
||||
"Flexible pay-as-you-go pricing to fuel agent growth at every stage.": "Flexible pay-as-you-go pricing to fuel agent growth at every stage.",
|
||||
"Secure & Compliant": "Secure & Compliant",
|
||||
@@ -119,24 +119,24 @@
|
||||
"Get Started": "Get Started",
|
||||
"Demo": "Demo",
|
||||
"Start Deploying": "Start Deploying",
|
||||
"We help these products connect to global services.": "We help these products connect to global services.",
|
||||
"We help these products connect to global servers.": "We help these products connect to global servers.",
|
||||
"Become a partner": "Become a partner",
|
||||
"AI Design": "AI Design",
|
||||
"AI Agent": "AI Agent",
|
||||
"AI Browser": "AI Browser",
|
||||
"Home": "Home",
|
||||
"Services": "Services",
|
||||
"Servers": "Servers",
|
||||
"Interesting in \n becoming a partner?": "Interesting in \n becoming a partner?",
|
||||
"Other Partners": "Other Partners",
|
||||
"Services List": "Services List",
|
||||
"Submit services": "Submit services",
|
||||
"Interesting in \n becoming a services supplier?": "Interesting in \n becoming a services supplier?",
|
||||
"Apply to become a supplier and provide services to global users.": "Apply to become a supplier and provide services to global users.",
|
||||
"Servers List": "Servers List",
|
||||
"Submit servers": "Submit servers",
|
||||
"Interesting in \n becoming a servers supplier?": "Interesting in \n becoming a servers supplier?",
|
||||
"Apply to become a supplier and provide servers to global users.": "Apply to become a supplier and provide servers to global users.",
|
||||
"Become a supplier": "Become a supplier",
|
||||
"We only list some services": "We only list some services",
|
||||
"Other Services": "Other Services",
|
||||
"We only list some servers": "We only list some servers",
|
||||
"Other Servers": "Other Servers",
|
||||
"Submit a demo": "Submit a demo",
|
||||
"Number of service categories": "Number of service categories",
|
||||
"Number of server categories": "Number of server categories",
|
||||
"Number of MCP Tools": "Number of MCP Tools",
|
||||
"Time for integration": "Time for integration",
|
||||
"Daily MCP request count": "Daily MCP request count",
|
||||
@@ -148,31 +148,31 @@
|
||||
"It's hard to say goodbyes": "It's hard to say goodbyes",
|
||||
"We're sorry to see you go. Your subscription has been cancelled.": "We're sorry to see you go. Your subscription has been cancelled.",
|
||||
"Playground": "Playground",
|
||||
"MCP Services Management": "MCP Services Management",
|
||||
"Service List": "Service List",
|
||||
"Add Service": "Add Service",
|
||||
"MCP Servers Management": "MCP Servers Management",
|
||||
"Server List": "Server List",
|
||||
"Add Server": "Add Server",
|
||||
"OpenAPI Generator": "OpenAPI Generator",
|
||||
"Service Name": "Service Name",
|
||||
"Service Description": "Service Description",
|
||||
"Service Category": "Service Category",
|
||||
"Service Status": "Service Status",
|
||||
"Online": "Online",
|
||||
"Offline": "Offline",
|
||||
"Server Name": "Server Name",
|
||||
"Server Description": "Server Description",
|
||||
"Server Category": "Server Category",
|
||||
"Server Status": "Server Status",
|
||||
"Published": "Published",
|
||||
"Unpublished": "Unpublished",
|
||||
"Actions": "Actions",
|
||||
"Edit": "Edit",
|
||||
"Delete": "Delete",
|
||||
"Toggle Status": "Toggle Status",
|
||||
"Create New Service": "Create New Service",
|
||||
"Edit Service": "Edit Service",
|
||||
"Create New Server": "Create New Server",
|
||||
"Edit Server": "Edit Server",
|
||||
"Generate from OpenAPI": "Generate from OpenAPI",
|
||||
"Update from OpenAPI": "Update from OpenAPI",
|
||||
"Sync from OpenAPI": "Sync from OpenAPI",
|
||||
"Sync service configuration from OpenAPI/Swagger documentation": "Sync service configuration from OpenAPI/Swagger documentation",
|
||||
"Sync Service": "Sync Service",
|
||||
"Sync server configuration from OpenAPI/Swagger documentation": "Sync server configuration from OpenAPI/Swagger documentation",
|
||||
"Sync Server": "Sync Server",
|
||||
"OpenAPI URL": "OpenAPI URL",
|
||||
"Upload OpenAPI File": "Upload OpenAPI File",
|
||||
"Generate Service": "Generate Service",
|
||||
"Service Configuration": "Service Configuration",
|
||||
"Generate Server": "Generate Server",
|
||||
"Server Configuration": "Server Configuration",
|
||||
"API Endpoint": "API Endpoint",
|
||||
"Authentication": "Authentication",
|
||||
"API Key": "API Key",
|
||||
@@ -190,15 +190,14 @@
|
||||
"Edit Tool": "Edit Tool",
|
||||
"Delete Tool": "Delete Tool",
|
||||
"Save Changes": "Save Changes",
|
||||
"No tools configured for this service": "No tools configured for this service",
|
||||
"Add tools to extend service functionality": "Add tools to extend service functionality",
|
||||
"Configure and manage tools for this service": "Configure and manage tools for this service",
|
||||
"No tools configured for this server": "No tools configured for this server",
|
||||
"Add tools to extend server functionality": "Add tools to extend server functionality",
|
||||
"Configure and manage tools for this server": "Configure and manage tools for this server",
|
||||
"Add New Tool": "Add New Tool",
|
||||
"Enter tool name": "Enter tool name",
|
||||
"Enter tool description": "Enter tool description",
|
||||
"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",
|
||||
@@ -217,41 +216,36 @@
|
||||
"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",
|
||||
"Brief description of the service": "Brief description of the service",
|
||||
"Detailed description of the service": "Detailed description of the service",
|
||||
"Brief description of the server": "Brief description of the server",
|
||||
"Detailed description of the server": "Detailed description of the server",
|
||||
"Basic Information": "Basic Information",
|
||||
"API Configuration": "API Configuration",
|
||||
"Authentication Type": "Authentication Type",
|
||||
"Update Service": "Update Service",
|
||||
"Create Service": "Create Service",
|
||||
"Update Server": "Update Server",
|
||||
"Create Server": "Create Server",
|
||||
"Confirm Delete": "Confirm Delete",
|
||||
"Are you sure you want to delete this service?": "Are you sure you want to delete this service?",
|
||||
"Are you sure you want to delete this server?": "Are you sure you want to delete this server?",
|
||||
"This action cannot be undone.": "This action cannot be undone.",
|
||||
"Manage your MCP services, configure APIs, and monitor service status": "Manage your MCP services, configure APIs, and monitor service status",
|
||||
"Search services...": "Search services...",
|
||||
"Manage your MCP servers, configure APIs, and monitor server status": "Manage your MCP servers, configure APIs, and monitor server status",
|
||||
"Search MCP servers": "Search MCP servers",
|
||||
"Filter by category": "Filter by category",
|
||||
"Filter by status": "Filter by status",
|
||||
"All Categories": "All Categories",
|
||||
"All Status": "All Status",
|
||||
"Created": "Created",
|
||||
"Last Updated": "Last Updated",
|
||||
"Total Services": "Total Services",
|
||||
"Online Services": "Online Services",
|
||||
"Offline Services": "Offline Services",
|
||||
"Service created successfully": "Service created successfully",
|
||||
"Service updated successfully": "Service updated successfully",
|
||||
"Service deleted successfully": "Service deleted successfully",
|
||||
"Service status updated successfully": "Service status updated successfully",
|
||||
"Failed to create service": "Failed to create service",
|
||||
"Failed to update service": "Failed to update service",
|
||||
"Failed to delete service": "Failed to delete service",
|
||||
"Failed to update service status": "Failed to update service status",
|
||||
"Total Servers": "Total Servers",
|
||||
"Server created successfully": "Server created successfully",
|
||||
"Server updated successfully": "Server updated successfully",
|
||||
"Server deleted successfully": "Server deleted successfully",
|
||||
"Server status updated successfully": "Server status updated successfully",
|
||||
"Failed to create server": "Failed to create server",
|
||||
"Failed to update server": "Failed to update server",
|
||||
"Failed to delete server": "Failed to delete server",
|
||||
"Failed to update server status": "Failed to update server status",
|
||||
"Invalid OpenAPI URL": "Invalid OpenAPI URL",
|
||||
"Failed to parse OpenAPI document": "Failed to parse OpenAPI document",
|
||||
"OpenAPI document parsed successfully": "OpenAPI document parsed successfully",
|
||||
@@ -261,8 +255,8 @@
|
||||
"Please select a file": "Please select a file",
|
||||
"File uploaded successfully": "File uploaded successfully",
|
||||
"Failed to upload file": "Failed to upload file",
|
||||
"Service name is required": "Service name is required",
|
||||
"Service description is required": "Service description is required",
|
||||
"Server name is required": "Server name is required",
|
||||
"Server description is required": "Server description is required",
|
||||
"API endpoint is required": "API endpoint is required",
|
||||
"Documentation is required": "Documentation is required",
|
||||
"Connect Your AI Agent to the Real World": "Connect Your AI Agent to the Real World",
|
||||
@@ -297,13 +291,13 @@
|
||||
"Login Success": "Login Success",
|
||||
"Login Error": "Login Error",
|
||||
"Back Home": "Back Home",
|
||||
"MCP Services": "MCP Services",
|
||||
"MCP Servers": "MCP Servers",
|
||||
"User Management": "User Management",
|
||||
"Revenue Management": "Revenue Management",
|
||||
"Payment Channels": "Payment Channels",
|
||||
"System Settings": "System Settings",
|
||||
"Overview and analytics": "Overview and analytics",
|
||||
"Manage MCP services and API tools": "Manage MCP services and API tools",
|
||||
"Manage MCP servers and API tools": "Manage MCP servers and API tools",
|
||||
"Manage registered users": "Manage registered users",
|
||||
"View user recharge history": "View user recharge history",
|
||||
"Configure payment channels": "Configure payment channels",
|
||||
@@ -357,7 +351,7 @@
|
||||
"No": "No",
|
||||
"User Statistics": "User Statistics",
|
||||
"API Calls": "API Calls",
|
||||
"Services Used": "Services Used",
|
||||
"Servers Used": "Servers Used",
|
||||
"Total Spent": "Total Spent",
|
||||
"Wallet Balance": "Wallet Balance",
|
||||
"Confirm Ban User": "Confirm Ban User",
|
||||
@@ -392,7 +386,7 @@
|
||||
"Email already exists": "Email already exists",
|
||||
"Invalid email format": "Invalid email format",
|
||||
"Sign up with Google": "Sign up with Google",
|
||||
"Terms of Service": "Terms of Service",
|
||||
"Terms of Server": "Terms of Server",
|
||||
"Privacy Policy": "Privacy Policy",
|
||||
"By signing up, you agree to our": "By signing up, you agree to our",
|
||||
"and": "and",
|
||||
@@ -436,9 +430,9 @@
|
||||
"Enable Google Login": "Enable Google Login",
|
||||
"Administrator Account": "Administrator Account",
|
||||
"Platform Information": "Platform Information",
|
||||
"Delete Service": "Delete Service",
|
||||
"Delete Server": "Delete Server",
|
||||
"Parsing OpenAPI document...": "Parsing OpenAPI document...",
|
||||
"Generated Service Configuration": "Generated Service Configuration",
|
||||
"Generated Server Configuration": "Generated Server Configuration",
|
||||
"None": "None",
|
||||
"Tags": "Tags",
|
||||
"Paid": "Paid",
|
||||
@@ -476,7 +470,7 @@
|
||||
"Enter your verification code": "Enter your verification code",
|
||||
"Resend": "Resend",
|
||||
"Verify Email Error": "Verify Email Error",
|
||||
"Generate MCP service configuration from OpenAPI/Swagger documentation": "Generate MCP service configuration from OpenAPI/Swagger documentation",
|
||||
"Generate MCP server configuration from OpenAPI/Swagger documentation": "Generate MCP server configuration from OpenAPI/Swagger documentation",
|
||||
"From URL": "From URL",
|
||||
"Upload File": "Upload File",
|
||||
"Choose File": "Choose File",
|
||||
@@ -485,7 +479,12 @@
|
||||
"Invalid email address": "Invalid email address",
|
||||
"Back to Home": "Back to Home",
|
||||
"Enter the URL to your OpenAPI/Swagger specification": "Enter the URL to your OpenAPI/Swagger specification",
|
||||
"Enter service name": "Enter service name",
|
||||
"Enter server name": "Enter server name",
|
||||
"Server ID": "Server ID",
|
||||
"Enter server ID": "Enter server ID",
|
||||
"Modifying the ID will affect the MCP access URL. Please modify with caution.": "Modifying the ID will affect the MCP access URL. Please modify with caution.",
|
||||
"You have modified the Server ID. This will affect the MCP access URL and may break existing integrations. Are you sure you want to continue?": "You have modified the Server ID. This will affect the MCP access URL and may break existing integrations. Are you sure you want to continue?",
|
||||
|
||||
"The header name for the API key (e.g., X-API-Key, Authorization)": "The header name for the API key (e.g., X-API-Key, Authorization)",
|
||||
"Enter API key": "Enter API key",
|
||||
"Enter bearer token": "Enter bearer token",
|
||||
@@ -551,7 +550,7 @@
|
||||
"Select currency": "Select currency",
|
||||
"Default currency for the platform": "Default currency for the platform",
|
||||
"call": "call",
|
||||
"No services found": "No services found",
|
||||
"No servers found": "No servers found",
|
||||
"free/day": "free/day",
|
||||
"Account (Email)": "Account (Email)",
|
||||
"Recharge Amount": "Recharge Amount",
|
||||
@@ -569,7 +568,7 @@
|
||||
"No tools added yet. Add your first tool using the input above.": "No tools added yet. Add your first tool using the input above.",
|
||||
"Insert tool below": "Insert tool below",
|
||||
"Remove tool": "Remove tool",
|
||||
"Service Detail": "Service Detail",
|
||||
"Server Detail": "Server Detail",
|
||||
"Billing Mode": "Billing Mode",
|
||||
"Enable free quota": "Enable free quota",
|
||||
"Configure Stripe payment interface": "Configure Stripe payment interface",
|
||||
@@ -598,9 +597,9 @@
|
||||
"Platform total fund pool": "Platform total fund pool",
|
||||
"Today's API Calls": "Today's API Calls",
|
||||
"API call count": "API call count",
|
||||
"Total MCP Services": "Total MCP Services",
|
||||
"Deployed services": "Deployed services",
|
||||
"This is your AI service management center. You can quickly view platform core data on the left and manage and configure your MCP services, users, payment channels, etc.": "This is your AI service management center. You can quickly view platform core data on the left and manage and configure your MCP services, users, payment channels, etc.",
|
||||
"Total MCP Servers": "Total MCP Servers",
|
||||
"Deployed servers": "Deployed servers",
|
||||
"This is your AI server management center. You can quickly view platform core data on the left and manage and configure your MCP servers, users, payment channels, etc.": "This is your AI server management center. You can quickly view platform core data on the left and manage and configure your MCP servers, users, payment channels, etc.",
|
||||
"Log In": "Log In",
|
||||
"Register Date": "Register Date",
|
||||
"Dashboard": "Dashboard",
|
||||
@@ -646,17 +645,16 @@
|
||||
"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}}",
|
||||
"Log Out": "Log Out",
|
||||
"Enter your username": "Enter your username",
|
||||
"Login": "Login",
|
||||
"Admin Portal": "Admin Portal",
|
||||
"Log in to admin console": "Log in to admin console",
|
||||
"Welcome to XPack.AI Open Source": "Welcome to XPack.AI Open Source",
|
||||
"Are you sure you want to delete this \"{{name}}\" service?": "Are you sure you want to delete this \"{{name}}\" service?",
|
||||
"Service status toggled successfully": "Service status toggled successfully",
|
||||
"Failed to toggle service status": "Failed to toggle service status",
|
||||
"Log in to your admin account to continue": "Log in to your admin account to continue",
|
||||
"Welcome to XPack.AI": "Welcome to XPack.AI",
|
||||
"Are you sure you want to delete this \"{{name}}\" server?": "Are you sure you want to delete this \"{{name}}\" server?",
|
||||
"Server status toggled successfully": "Server status toggled successfully",
|
||||
"Failed to toggle server status": "Failed to toggle server status",
|
||||
"Stripe configuration saved successfully": "Stripe configuration saved successfully",
|
||||
"Failed to save Stripe configuration": "Failed to save Stripe configuration",
|
||||
"System config updated successfully": "System config updated successfully",
|
||||
@@ -691,8 +689,6 @@
|
||||
"{{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",
|
||||
"Email Configuration": "Email Configuration",
|
||||
"Configure SMTP settings for email notifications": "Configure SMTP settings for email notifications",
|
||||
@@ -766,10 +762,10 @@
|
||||
"Traditional email and password authentication": "Traditional email and password authentication",
|
||||
"Email/Verification Code": "Email/Verification Code",
|
||||
"Passwordless login with email verification code": "Passwordless login with email verification code",
|
||||
"Email service is not configured. Please configure email settings first.": "Email service is not configured. Please configure email settings first.",
|
||||
"SMTP is not configured. Please configure email settings first.": "SMTP is not configured. Please configure email settings first.",
|
||||
"Go to Settings": "Go to Settings",
|
||||
"AI Tools Marketplace": "AI Tools Marketplace",
|
||||
"A marketplace for AI tools and services. Discover and integrate powerful AI solutions for your projects.": "A marketplace for AI tools and services. Discover and integrate powerful AI solutions for your projects.",
|
||||
"A marketplace for AI tools and servers. Discover and integrate powerful AI solutions for your projects.": "A marketplace for AI tools and servers. Discover and integrate powerful AI solutions for your projects.",
|
||||
"Configuration": "Configuration",
|
||||
"Featured Products": "Featured Products",
|
||||
"Search": "Search",
|
||||
@@ -799,7 +795,6 @@
|
||||
"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<script>\n // Google Analytics\n gtag('config', 'GA_MEASUREMENT_ID');\n</script>\n\n<style>\n .custom-style {\n color: #333;\n }\n</style>": "Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n<script>\n // Google Analytics\n gtag('config', 'GA_MEASUREMENT_ID');\n</script>\n\n<style>\n .custom-style {\n color: #333;\n }\n</style>",
|
||||
"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.",
|
||||
@@ -838,8 +833,6 @@
|
||||
"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",
|
||||
@@ -872,5 +865,17 @@
|
||||
"Input": "Input",
|
||||
"Output": "Output",
|
||||
"1M tokens": "1M tokens",
|
||||
"Total Spending": "Total Spending"
|
||||
"Total Spending": "Total Spending",
|
||||
"Remote": "Remote",
|
||||
"Platform Logo": "Platform Logo",
|
||||
"Support JPG, PNG, GIF. Max size 5MB": "Support JPG, PNG, GIF. Max size 5MB",
|
||||
"(30 days)": "(30 days)",
|
||||
"Sign in": "Sign in",
|
||||
"or create your account": "or create your account",
|
||||
"No account? Just continue—we’ll set you up.": "No account? Just continue—we’ll set you up.",
|
||||
"Password must be at least 6 characters": "Password must be at least 6 characters",
|
||||
"Email is required": "Email is required",
|
||||
"No servers available": "No servers available",
|
||||
"(Deleted)": "(Deleted)",
|
||||
"Transport Type": "Transport Type"
|
||||
}
|
||||
@@ -1,13 +1,243 @@
|
||||
{
|
||||
"**XPack** is a lightweight, open-source marketplace framework for MCP (Model Context Protocol) services.": "**XPack** 是一个轻量级的开源 MCP(模型上下文协议)服务市场框架。",
|
||||
"It allows you to transform any OpenAPI into a monetizable MCP service and build your own API store in just minutes.": "它允许您将任何 OpenAPI 转换为可盈利的 MCP 服务,并在几分钟内构建您自己的 API 商店。",
|
||||
"✨ With XPack, you can:": "✨ 使用 XPack,您可以:",
|
||||
"- ✅ **One-click OpenAPI → MCP service config**": "- ✅ **一键 OpenAPI → MCP 服务配置**",
|
||||
"- 🧾 **SEO-friendly homepage + mcp service page**": "- 🧾 **SEO 友好的主页 + MCP 服务页面**",
|
||||
"- 💳 **Built-in billing (per-call)**": "- 💳 **内置计费(按调用计费)**",
|
||||
"- 👥 **User account management**": "- 👥 **用户账户管理**",
|
||||
"- 🛠 **Support Stripe Payment**": "- 🛠 **支持 Stripe 支付**",
|
||||
"- 🔐 **Support Email & Google OAuth Sign in**": "- 🔐 **支持邮箱和 Google OAuth 登录**",
|
||||
"Everything is open-source and licensed under **Apache 2.0** — ready for commercial use.": "一切都是开源的,采用 **Apache 2.0** 许可证 — 可用于商业用途。",
|
||||
"About Us": "关于我们"
|
||||
}
|
||||
"Server Configuration": "服务器配置",
|
||||
"Subdomain": "子域名",
|
||||
"Enter subdomain (e.g., mysite)": "输入子域名(例如:mysite)",
|
||||
"Subdomain is required": "子域名不能为空",
|
||||
"Subdomain must contain only lowercase letters, numbers, and hyphens": "子域名只能包含小写字母、数字和连字符",
|
||||
"Subdomain must be between 3 and 63 characters": "子域名长度需在 3 到 63 个字符之间",
|
||||
"Log in to your admin account to continue": "登录管理员账号以继续",
|
||||
"Your unique subdomain for the platform": "平台的唯一子域名",
|
||||
"Let's get started!": "开始设置!",
|
||||
"Welcome! It's time to set up Lethe Live.": "欢迎!是时候设置 Lethe Live 了。",
|
||||
"Start a new Ghost publication": "开始新的 Ghost 发布",
|
||||
"Customize your design": "自定义你的设计",
|
||||
"Craft a look that reflects your brand and style": "打造反映你品牌与风格的外观",
|
||||
"Explore the editor": "探索编辑器",
|
||||
"Build your audience": "构建你的受众",
|
||||
"Share your publication": "分享你的发布内容",
|
||||
"More questions? Check out our": "还有问题?请查看我们的",
|
||||
"Help Center": "帮助中心",
|
||||
"Skip onboarding": "跳过引导",
|
||||
"Great! All tasks completed!": "太棒了!所有任务都已完成!",
|
||||
"Continue to Dashboard": "进入仪表盘",
|
||||
"Page Not Found": "页面未找到",
|
||||
"The page you're looking for doesn't exist or has been moved.": "你要访问的页面不存在或已被移动。",
|
||||
"This page could not be found.": "无法找到此页面。",
|
||||
"Back to Home": "返回首页",
|
||||
"Subdomain Change Warning": "子域名更改提醒",
|
||||
"The subdomain has been changed. You will be automatically redirected to the new address in {{seconds}} seconds.": "子域名已更改。你将在 {{seconds}} 秒后自动跳转至新地址。",
|
||||
"New Address": "新地址",
|
||||
"Redirect Now": "立即跳转",
|
||||
"Daily Registered Users": "每日注册用户",
|
||||
"Daily Revenue": "每日营收",
|
||||
"Daily API Calls": "每日 API 调用",
|
||||
"Top Servers by Calls": "调用量最多的服务器",
|
||||
"Date": "日期",
|
||||
"Users": "用户",
|
||||
"Revenue": "收入",
|
||||
"Calls": "调用量",
|
||||
"Server Name": "服务器名称",
|
||||
"Call Volume": "调用量",
|
||||
"Last 30 Days Overview": "近 30 天概览",
|
||||
"Sort by Call Volume": "按调用量排序",
|
||||
"Sort by Name": "按名称排序",
|
||||
"Total subscribers": "订阅者总数",
|
||||
"Avg. open rate": "平均打开率",
|
||||
"Avg. click rate": "平均点击率",
|
||||
"Total Users": "用户总数",
|
||||
"Total Revenue": "总收入",
|
||||
"Total API Calls": "API 调用总数",
|
||||
"API server for machine learning tasks": "用于机器学习任务的 API 服务器",
|
||||
"Web Scraping Statistics": "网页爬取统计",
|
||||
"Total Scraped Pages": "已爬取页面总数",
|
||||
"Total number of pages scraped from the website": "从网站爬取的页面总数",
|
||||
"Scraping Growth Chart": "爬取增长图",
|
||||
"New Pages": "新增页面",
|
||||
"Daily growth of scraped pages over time": "每日新增爬取页面数量",
|
||||
"Real-time data processing service": "实时数据处理服务",
|
||||
"Natural language processing service": "自然语言处理服务",
|
||||
"Computer vision analysis tool": "计算机视觉分析工具",
|
||||
"Translation and localization service": "翻译与本地化服务",
|
||||
"Web search and indexing engine": "网页搜索与索引引擎",
|
||||
"Cloud file storage and management": "云端文件存储与管理",
|
||||
"Email delivery and management service": "邮件投递与管理服务",
|
||||
"Weather data and forecasting API": "天气数据与预测 API",
|
||||
"Calendar synchronization service": "日历同步服务",
|
||||
"Settings": "设置",
|
||||
"System Settings": "系统设置",
|
||||
"General": "通用设置",
|
||||
"Platform basic configuration": "平台基础配置",
|
||||
"Homepage": "首页",
|
||||
"Homepage content and theme settings": "首页内容与主题设置",
|
||||
"Payment Channels": "支付渠道",
|
||||
"Configure payment channels": "配置支付渠道",
|
||||
"Admin Settings": "管理员设置",
|
||||
"Configure admin login credentials": "配置管理员登录信息",
|
||||
"Search settings": "搜索设置",
|
||||
"Clear": "清除",
|
||||
"No results": "无结果",
|
||||
"Welcome to Your Platform!": "欢迎使用你的平台!",
|
||||
"Let's set up {{platformName}} to get you started.": "让我们来设置 {{platformName}},开始你的旅程。",
|
||||
"Configure Platform Settings": "配置平台设置",
|
||||
"Set up your platform name, domain, and branding.": "设置平台名称、域名和品牌标识。",
|
||||
"Add MCP Services": "添加 MCP 服务",
|
||||
"Configure and deploy your first MCP server tools.": "配置并部署你的第一个 MCP 服务器工具。",
|
||||
"Manage Users": "管理用户",
|
||||
"View and configure user accounts and permissions.": "查看并配置用户账号与权限。",
|
||||
"Configure Payment & Billing": "配置支付与结算",
|
||||
"Set up payment channels and token pricing.": "设置支付渠道与 Token 定价。",
|
||||
"Generate API Keys": "生成 API Key",
|
||||
"Create API keys for external integrations.": "为外部集成创建 API Key。",
|
||||
"Share Your Platform": "分享你的平台",
|
||||
"Invite users and promote your MCP platform.": "邀请用户并推广你的 MCP 平台。",
|
||||
"Need help getting started? Check out our": "需要帮助?请查看我们的",
|
||||
"Discord Community": "Discord 社区",
|
||||
"Skip setup guide": "跳过设置向导",
|
||||
"Excellent! Your platform is ready to go!": "太棒了!你的平台已准备就绪!",
|
||||
"Go to Dashboard": "进入仪表盘",
|
||||
"Platform": "平台",
|
||||
"Billing & Payments": "账单与支付",
|
||||
"Administration": "管理",
|
||||
"Meta Data": "元数据",
|
||||
"Extra content for search engines and social accounts": "用于搜索引擎与社交平台的额外信息",
|
||||
"Search": "搜索",
|
||||
"X Card": "X 卡片",
|
||||
"Facebook Card": "Facebook 卡片",
|
||||
"Meta Title": "Meta 标题",
|
||||
"Enter meta title": "输入 Meta 标题",
|
||||
"Recommended: 70 characters": "建议:70 个字符",
|
||||
"Meta Description": "Meta 描述",
|
||||
"Enter meta description": "输入 Meta 描述",
|
||||
"Recommended: 156 characters": "建议:156 个字符",
|
||||
"Preview": "预览",
|
||||
"Lethe Live": "Lethe Live",
|
||||
"Thoughts, stories and ideas.": "思想、故事与想法。",
|
||||
"Upload X Image": "上传 X 图片",
|
||||
"Upload Facebook Image": "上传 Facebook 图片",
|
||||
"Uploading...": "上传中...",
|
||||
"X Title": "X 标题",
|
||||
"Enter X title": "输入 X 标题",
|
||||
"X Description": "X 描述",
|
||||
"Enter X description": "输入 X 描述",
|
||||
"Facebook Title": "Facebook 标题",
|
||||
"Enter Facebook title": "输入 Facebook 标题",
|
||||
"Facebook Description": "Facebook 描述",
|
||||
"Enter Facebook description": "输入 Facebook 描述",
|
||||
"Meta data saved successfully": "元数据保存成功",
|
||||
"Please select a valid image file": "请选择有效的图片文件",
|
||||
"Image size should be less than 5MB": "图片大小应小于 5MB",
|
||||
"Failed to upload image": "图片上传失败",
|
||||
"General settings": "通用设置",
|
||||
"Title & description": "标题与描述",
|
||||
"Configure your site title and description": "配置站点标题与描述",
|
||||
"Meta data": "元数据",
|
||||
"SEO metadata and site configuration": "SEO 元数据与站点配置",
|
||||
"Connect your social media accounts": "连接你的社交媒体账号",
|
||||
"Custom domain": "自定义域名",
|
||||
"Configure your custom domain settings": "配置你的自定义域名设置",
|
||||
"Site": "站点",
|
||||
"Branding": "品牌",
|
||||
"Logo, colors, and brand identity": "Logo、颜色与品牌识别",
|
||||
"Theme": "主题",
|
||||
"Visual theme and appearance settings": "视觉主题与外观设置",
|
||||
"Navigation": "导航",
|
||||
"Configure site navigation and menus": "配置站点导航与菜单",
|
||||
"Business": "业务",
|
||||
"Payment": "支付",
|
||||
"Payment processing and billing settings": "支付处理与结算设置",
|
||||
"XPack Explore": "XPack 探索",
|
||||
"Explore XPack features and integrations": "探索 XPack 的功能与集成",
|
||||
"Advanced": "高级",
|
||||
"Code injection": "代码注入",
|
||||
"Custom code injection and scripts": "自定义代码注入与脚本",
|
||||
"Enter the domain you want to use": "输入你要使用的域名",
|
||||
"Enter your full domain name (e.g., www.example.com)": "输入完整域名(例如:www.example.com)",
|
||||
"Create your DNS records": "创建你的 DNS 记录",
|
||||
"Add the following DNS records at your DNS provider": "在你的 DNS 服务商处添加以下记录",
|
||||
"DNS Records Table": "DNS 记录表",
|
||||
"Type": "类型",
|
||||
"Host": "主机名",
|
||||
"Value": "值",
|
||||
"Activate custom domain": "激活自定义域名",
|
||||
"Your DNS looks good. You can activate now.": "DNS 看起来没问题。现在可以激活了。",
|
||||
"Make sure your DNS records have propagated before activation.": "激活前请确保 DNS 记录已生效。",
|
||||
"Activate": "激活",
|
||||
"Domain": "域名",
|
||||
"Please enter a valid URL with http:// or https://": "请输入包含 http:// 或 https:// 的有效 URL",
|
||||
"Create MCP Server": "创建 MCP 服务器",
|
||||
"Choose how you want to create your MCP server": "选择创建 MCP 服务器的方式",
|
||||
"Website Content Scraper": "网站内容爬虫",
|
||||
"Create an MCP server that can scrape and extract content from websites": "创建可以爬取并提取网站内容的 MCP 服务器",
|
||||
"OpenAPI Generator": "OpenAPI 生成器",
|
||||
"Generate MCP server from OpenAPI/Swagger documentation": "从 OpenAPI/Swagger 文档生成 MCP 服务器",
|
||||
"Update Website Scraper": "更新网站爬虫",
|
||||
"Sync from OpenAPI": "从 OpenAPI 同步",
|
||||
"Update Server": "更新服务器",
|
||||
"Add Server": "添加服务器",
|
||||
"Website URL": "网站 URL",
|
||||
"Enter the website URL (e.g., https://example.com)": "输入网站 URL(例如:https://example.com)",
|
||||
"Update website URL for content scraping": "更新用于内容爬取的网站 URL",
|
||||
"Enter the website URL you want to scrape content from": "输入你想爬取内容的网站 URL",
|
||||
"Creating webscraper server...": "正在创建爬虫服务器...",
|
||||
"Sync server configuration from OpenAPI/Swagger documentation": "从 OpenAPI/Swagger 文档同步服务器配置",
|
||||
"Generate MCP server configuration from OpenAPI/Swagger documentation": "从 OpenAPI/Swagger 文档生成 MCP 服务器配置",
|
||||
"From URL": "从 URL",
|
||||
"Upload File": "上传文件",
|
||||
"OpenAPI URL": "OpenAPI URL",
|
||||
"Enter the URL to your OpenAPI/Swagger specification": "输入 OpenAPI/Swagger 规范的 URL",
|
||||
"Upload OpenAPI File": "上传 OpenAPI 文件",
|
||||
"Choose File": "选择文件",
|
||||
"Supports JSON and YAML formats": "支持 JSON 与 YAML 格式",
|
||||
"Parsing OpenAPI document...": "正在解析 OpenAPI 文档...",
|
||||
"Back": "返回",
|
||||
"Create Server": "创建服务器",
|
||||
"Generate Server": "生成服务器",
|
||||
"Sync Server": "同步服务器",
|
||||
"Select Type": "选择类型",
|
||||
"Configure": "配置",
|
||||
"OR": "或",
|
||||
"Use Website Scraper": "使用网站爬虫",
|
||||
"Use OpenAPI Generator": "使用 OpenAPI 生成器",
|
||||
"Data scraping in progress...": "数据爬取进行中...",
|
||||
"Scraped {{current}} of {{total}} pages": "已爬取 {{current}} / {{total}} 个页面",
|
||||
"Scraped {{count}} pages": "已爬取 {{count}} 个页面",
|
||||
"Modifying the URL will trigger re-scraping of the website data.": "修改 URL 将会触发重新爬取网站数据。",
|
||||
"You have modified the Website URL. This will trigger re-scraping of the website data. Are you sure you want to continue?": "你已修改网站 URL。这将触发重新爬取网站数据。确定要继续吗?",
|
||||
"Scraping...": "正在爬取...",
|
||||
"Server Type": "服务器类型",
|
||||
"Edit Website URL": "编辑网站 URL",
|
||||
"Modifying the website URL will trigger re-scraping of the website data. This process may take some time to complete.": "修改网站 URL 将触发重新爬取数据。该过程可能需要一段时间完成。",
|
||||
"Please enter a valid URL": "请输入有效的 URL",
|
||||
"Use the refresh button to modify the website URL": "使用刷新按钮来修改网站 URL",
|
||||
"Cannot publish while scraping": "爬取未完成,无法发布",
|
||||
"Publish": "发布",
|
||||
"Unpublish": "取消发布",
|
||||
"Published": "已发布",
|
||||
"Unpublished": "未发布",
|
||||
"Your brand": "你的品牌",
|
||||
"Support JPG, PNG, GIF, SVG. Max size 5MB": "支持 JPG, PNG, GIF, SVG. 最大支持 5MB",
|
||||
"Site title": "站点标题",
|
||||
"Enter site title": "输入站点标题",
|
||||
"Main title displayed on the home page": "首页显示的主标题",
|
||||
"Site description": "站点描述",
|
||||
"Enter site description": "输入站点描述",
|
||||
"Secondary description displayed below the main title": "主标题下方显示的次标题",
|
||||
"Title is required": "标题不能为空",
|
||||
"Custom Domain": "自定义域名",
|
||||
"Activate your domain": "激活您的域名",
|
||||
"Set Custom Domain": "设置自定义域名",
|
||||
"Configure platform language": "配置平台语言",
|
||||
"Enter title": "输入标题",
|
||||
"Enter link URL": "输入链接 URL",
|
||||
"Configure FAQ": "配置常见问题",
|
||||
"Enter question": "输入问题",
|
||||
"Enter answer": "输入答案",
|
||||
"Enable Stripe Payment": "启用 Stripe 支付",
|
||||
"Toggle to enable or disable Stripe payment interface": "切换以启用或禁用 Stripe 支付接口",
|
||||
"Enter Secret Key": "输入 Stripe 密钥",
|
||||
"Enter Webhook Secret": "输入 Stripe Webhook 密钥",
|
||||
"Email Login Settings": "邮箱登录设置",
|
||||
"Open in new tab": "在新标签页打开",
|
||||
"Analyze platform usage and revenue": "分析平台使用情况和收入",
|
||||
"Change your password": "更改您的密码"
|
||||
}
|
||||
@@ -81,7 +81,7 @@
|
||||
"Free": "免费",
|
||||
"Sign up now to get 100 free calls every month.": "注册即可获得每月 100 次免费调用",
|
||||
"Generate and manage dynamic PowerPoints and Google Slides with your own custom branding and layouts.": "使用您自己的自定义品牌和布局生成和管理动态 PowerPoint 和 Google 幻灯片。",
|
||||
"Try for free": "免费试用",
|
||||
"Sign up to get the auth key": "注册以获取认证密钥",
|
||||
"Lightning Fast Setup": "闪电般快速设置",
|
||||
"Enterprise Security": "企业级安全",
|
||||
"Global Scale": "全球规模",
|
||||
@@ -103,7 +103,7 @@
|
||||
"Build AI Agents": "使用令人难以置信的 MCP",
|
||||
"With Incredible MCP": "构建 AI Agent",
|
||||
"Instant Integration": "即时集成",
|
||||
"Connect to global APIs and MCP services with just one config or SDK.": "通过一个配置或 SDK 连接到全球 API 和 MCP 服务。",
|
||||
"Connect to global APIs and MCP servers with just one config or SDK.": "通过一个配置或 SDK 连接到全球 API 和 MCP 服务。",
|
||||
"Zero Overhead": "零开销",
|
||||
"Flexible pay-as-you-go pricing to fuel agent growth at every stage.": "灵活的按使用付费定价,为每个阶段的 Agent 增长提供动力。",
|
||||
"Secure & Compliant": "安全 & 合规",
|
||||
@@ -119,24 +119,24 @@
|
||||
"Get Started": "立即开始",
|
||||
"Demo": "演示",
|
||||
"Start Deploying": "开始部署",
|
||||
"We help these products connect to global services.": "我们帮助这些产品连接到全球服务。",
|
||||
"We help these products connect to global servers.": "我们帮助这些产品连接到全球服务。",
|
||||
"Become a partner": "成为合作伙伴",
|
||||
"AI Design": "AI 设计",
|
||||
"AI Agent": "AI Agent",
|
||||
"AI Browser": "AI 浏览器",
|
||||
"Home": "首页",
|
||||
"Services": "服务",
|
||||
"Servers": "服务",
|
||||
"Interesting in \n becoming a partner?": "有兴趣\n 成为合作伙伴吗?",
|
||||
"Other Partners": "其他合作伙伴",
|
||||
"Services List": "服务列表",
|
||||
"Submit services": "提交服务",
|
||||
"Interesting in \n becoming a services supplier?": "有兴趣\n 成为服务供应商吗?",
|
||||
"Apply to become a supplier and provide services to global users.": "申请成为供应商,为全球用户提供服务。",
|
||||
"Servers List": "服务列表",
|
||||
"Submit servers": "提交服务",
|
||||
"Interesting in \n becoming a servers supplier?": "有兴趣\n 成为服务供应商吗?",
|
||||
"Apply to become a supplier and provide servers to global users.": "申请成为供应商,为全球用户提供服务。",
|
||||
"Become a supplier": "成为供应商",
|
||||
"We only list some services": "我们只列出部分服务",
|
||||
"Other Services": "其他服务",
|
||||
"We only list some servers": "我们只列出部分服务",
|
||||
"Other Servers": "其他服务",
|
||||
"Submit a demo": "提交演示",
|
||||
"Number of service categories": "服务分类数量",
|
||||
"Number of server categories": "服务分类数量",
|
||||
"Number of MCP Tools": "MCP 工具数量",
|
||||
"Time for integration": "集成时间",
|
||||
"Daily MCP request count": "每日 MCP 请求数量",
|
||||
@@ -148,31 +148,31 @@
|
||||
"It's hard to say goodbyes": "说再见总是很难",
|
||||
"We're sorry to see you go. Your subscription has been cancelled.": "我们很遗憾看到您离开。您的订阅已被取消。",
|
||||
"Playground": "演示环境",
|
||||
"MCP Services Management": "MCP 服务管理",
|
||||
"Service List": "服务列表",
|
||||
"Add Service": "添加服务",
|
||||
"MCP Servers Management": "MCP 服务管理",
|
||||
"Server List": "服务列表",
|
||||
"Add Server": "添加服务",
|
||||
"OpenAPI Generator": "OpenAPI 生成器",
|
||||
"Service Name": "服务名称",
|
||||
"Service Description": "服务描述",
|
||||
"Service Category": "服务分类",
|
||||
"Service Status": "服务状态",
|
||||
"Online": "上线",
|
||||
"Offline": "下线",
|
||||
"Server Name": "服务名称",
|
||||
"Server Description": "服务描述",
|
||||
"Server Category": "服务分类",
|
||||
"Server Status": "服务状态",
|
||||
"Published": "已发布",
|
||||
"Unpublished": "未发布",
|
||||
"Actions": "操作",
|
||||
"Edit": "编辑",
|
||||
"Delete": "删除",
|
||||
"Toggle Status": "切换状态",
|
||||
"Create New Service": "创建新服务",
|
||||
"Edit Service": "编辑服务",
|
||||
"Create New Server": "创建新服务",
|
||||
"Edit Server": "编辑服务",
|
||||
"Generate from OpenAPI": "从 OpenAPI 生成",
|
||||
"Update from OpenAPI": "从 OpenAPI 更新",
|
||||
"Sync from OpenAPI": "从 OpenAPI 同步",
|
||||
"Sync service configuration from OpenAPI/Swagger documentation": "从 OpenAPI/Swagger 文档同步服务配置",
|
||||
"Sync Service": "同步服务",
|
||||
"Sync server configuration from OpenAPI/Swagger documentation": "从 OpenAPI/Swagger 文档同步服务配置",
|
||||
"Sync Server": "同步服务",
|
||||
"OpenAPI URL": "OpenAPI 地址",
|
||||
"Upload OpenAPI File": "上传 OpenAPI 文件",
|
||||
"Generate Service": "生成服务",
|
||||
"Service Configuration": "服务配置",
|
||||
"Generate Server": "生成服务",
|
||||
"Server Configuration": "服务配置",
|
||||
"API Endpoint": "API 端点",
|
||||
"Authentication": "身份验证",
|
||||
"API Key": "API 密钥",
|
||||
@@ -182,7 +182,7 @@
|
||||
"Markdown Documentation": "Markdown 文档",
|
||||
"Save": "保存",
|
||||
"Cancel": "取消",
|
||||
"Service Documentation": "服务文档",
|
||||
"Server Documentation": "服务文档",
|
||||
"Manage Tools": "管理工具",
|
||||
"Tools Count": "工具数量",
|
||||
"Tool Name": "工具名称",
|
||||
@@ -191,15 +191,14 @@
|
||||
"Edit Tool": "编辑工具",
|
||||
"Delete Tool": "删除工具",
|
||||
"Save Changes": "保存更改",
|
||||
"No tools configured for this service": "此服务未配置任何工具",
|
||||
"Add tools to extend service functionality": "添加工具以扩展服务功能",
|
||||
"Configure and manage tools for this service": "配置和管理此服务的工具",
|
||||
"No tools configured for this server": "此服务未配置任何工具",
|
||||
"Add tools to extend server functionality": "添加工具以扩展服务功能",
|
||||
"Configure and manage tools for this server": "配置和管理此服务的工具",
|
||||
"Add New Tool": "添加新工具",
|
||||
"Enter tool name": "输入工具名称",
|
||||
"Enter tool description": "输入工具描述",
|
||||
"Tool name": "工具名称",
|
||||
"Tool description": "工具描述",
|
||||
"Take Offline": "下线",
|
||||
"Platform Domain": "平台域名",
|
||||
"Enter platform domain (e.g., example.com)": "输入平台域名(例如:example.com)",
|
||||
"The domain name of your platform": "您平台的域名",
|
||||
@@ -218,41 +217,36 @@
|
||||
"Question": "问题",
|
||||
"Answer": "答案",
|
||||
"No FAQ items available.": "暂无FAQ项目。",
|
||||
"Enter question": "输入问题",
|
||||
"Enter answer": "输入答案",
|
||||
"Insert below": "在下方插入",
|
||||
"Bring Online": "上线",
|
||||
"Short Description": "简短描述",
|
||||
"Long Description": "详细描述",
|
||||
"Brief description of the service": "服务的简短描述",
|
||||
"Detailed description of the service": "服务的详细描述",
|
||||
"Brief description of the server": "服务的简短描述",
|
||||
"Detailed description of the server": "服务的详细描述",
|
||||
"Basic Information": "基本信息",
|
||||
"API Configuration": "API配置",
|
||||
"Authentication Type": "认证类型",
|
||||
"Update Service": "更新服务",
|
||||
"Create Service": "创建服务",
|
||||
"Update Server": "更新服务",
|
||||
"Create Server": "创建服务",
|
||||
"Confirm Delete": "确认删除",
|
||||
"Are you sure you want to delete this service?": "您确定要删除此服务吗?",
|
||||
"Are you sure you want to delete this server?": "您确定要删除此服务吗?",
|
||||
"This action cannot be undone.": "此操作无法撤销。",
|
||||
"Manage your MCP services, configure APIs, and monitor service status": "管理您的MCP服务,配置API,并监控服务状态",
|
||||
"Search services...": "搜索服务...",
|
||||
"Manage your MCP servers, configure APIs, and monitor server status": "管理您的MCP服务,配置API,并监控服务状态",
|
||||
"Search MCP servers": "搜索服务...",
|
||||
"Filter by category": "按分类筛选",
|
||||
"Filter by status": "按状态筛选",
|
||||
"All Categories": "所有分类",
|
||||
"All Status": "所有状态",
|
||||
"Created": "创建时间",
|
||||
"Last Updated": "最后更新",
|
||||
"Total Services": "总服务数",
|
||||
"Online Services": "在线服务",
|
||||
"Offline Services": "离线服务",
|
||||
"Service created successfully": "服务创建成功",
|
||||
"Service updated successfully": "服务更新成功",
|
||||
"Service deleted successfully": "服务删除成功",
|
||||
"Service status updated successfully": "服务状态更新成功",
|
||||
"Failed to create service": "创建服务失败",
|
||||
"Failed to update service": "更新服务失败",
|
||||
"Failed to delete service": "删除服务失败",
|
||||
"Failed to update service status": "更新服务状态失败",
|
||||
"Total Servers": "总服务数",
|
||||
"Server created successfully": "服务创建成功",
|
||||
"Server updated successfully": "服务更新成功",
|
||||
"Server deleted successfully": "服务删除成功",
|
||||
"Server status updated successfully": "服务状态更新成功",
|
||||
"Failed to create server": "创建服务失败",
|
||||
"Failed to update server": "更新服务失败",
|
||||
"Failed to delete server": "删除服务失败",
|
||||
"Failed to update server status": "更新服务状态失败",
|
||||
"Invalid OpenAPI URL": "无效的 OpenAPI 地址",
|
||||
"Failed to parse OpenAPI document": "解析 OpenAPI 文档失败",
|
||||
"OpenAPI document parsed successfully": "OpenAPI 文档解析成功",
|
||||
@@ -262,8 +256,8 @@
|
||||
"Please select a file": "请选择文件",
|
||||
"File uploaded successfully": "文件上传成功",
|
||||
"Failed to upload file": "文件上传失败",
|
||||
"Service name is required": "服务名称为必填项",
|
||||
"Service description is required": "服务描述为必填项",
|
||||
"Server name is required": "服务名称为必填项",
|
||||
"Server description is required": "服务描述为必填项",
|
||||
"API endpoint is required": "API 端点为必填项",
|
||||
"Documentation is required": "文档为必填项",
|
||||
"Connect Your AI Agent to the Real World": "连接您的 AI Agent 到真实世界",
|
||||
@@ -298,13 +292,13 @@
|
||||
"Login Success": "登录成功",
|
||||
"Login Error": "登录错误",
|
||||
"Back Home": "返回首页",
|
||||
"MCP Services": "MCP 服务",
|
||||
"MCP Servers": "MCP 服务",
|
||||
"User Management": "用户管理",
|
||||
"Revenue Management": "收入管理",
|
||||
"Payment Channels": "支付渠道",
|
||||
"System Settings": "系统设置",
|
||||
"Overview and analytics": "概览和分析",
|
||||
"Manage MCP services and API tools": "管理MCP服务及API工具",
|
||||
"Manage MCP servers and API tools": "管理MCP服务及API工具",
|
||||
"Manage registered users": "管理注册用户",
|
||||
"View user recharge history": "查看用户充值历史",
|
||||
"Configure payment channels": "配置支付渠道",
|
||||
@@ -358,7 +352,7 @@
|
||||
"No": "否",
|
||||
"User Statistics": "用户统计",
|
||||
"API Calls": "API调用次数",
|
||||
"Services Used": "使用的服务",
|
||||
"Servers Used": "使用的服务",
|
||||
"Total Spent": "总消费",
|
||||
"Wallet Balance": "钱包余额",
|
||||
"Confirm Ban User": "确认封禁用户",
|
||||
@@ -393,7 +387,7 @@
|
||||
"Email already exists": "邮箱已存在",
|
||||
"Invalid email format": "邮箱格式无效",
|
||||
"Sign up with Google": "使用Google注册",
|
||||
"Terms of Service": "服务条款",
|
||||
"Terms of Server": "服务条款",
|
||||
"Privacy Policy": "隐私政策",
|
||||
"By signing up, you agree to our": "注册即表示您同意我们的",
|
||||
"and": "和",
|
||||
@@ -437,9 +431,9 @@
|
||||
"Enable Google Login": "启用Google登录",
|
||||
"Administrator Account": "管理员账户",
|
||||
"Platform Information": "平台信息",
|
||||
"Delete Service": "删除服务",
|
||||
"Delete Server": "删除服务",
|
||||
"Parsing OpenAPI document...": "正在解析OpenAPI文档...",
|
||||
"Generated Service Configuration": "生成的服务配置",
|
||||
"Generated Server Configuration": "生成的服务配置",
|
||||
"None": "无",
|
||||
"Tags": "标签",
|
||||
"Paid": "付费",
|
||||
@@ -477,7 +471,7 @@
|
||||
"Enter your verification code": "输入您的验证码",
|
||||
"Resend": "重新发送",
|
||||
"Verify Email Error": "邮箱验证错误",
|
||||
"Generate MCP service configuration from OpenAPI/Swagger documentation": "从OpenAPI/Swagger文档生成MCP服务配置",
|
||||
"Generate MCP server configuration from OpenAPI/Swagger documentation": "从OpenAPI/Swagger文档生成MCP服务配置",
|
||||
"From URL": "从URL",
|
||||
"Upload File": "上传文件",
|
||||
"Choose File": "选择文件",
|
||||
@@ -486,7 +480,12 @@
|
||||
"Invalid email address": "无效的邮箱地址",
|
||||
"Back to Home": "返回首页",
|
||||
"Enter the URL to your OpenAPI/Swagger specification": "输入您的OpenAPI/Swagger规范的URL",
|
||||
"Enter service name": "输入服务名称",
|
||||
"Enter server name": "输入服务名称",
|
||||
"Server ID": "服务器ID",
|
||||
"Enter server ID": "输入服务器ID",
|
||||
"Modifying the ID will affect the MCP access URL. Please modify with caution.": "修改ID会影响MCP的访问地址,需要谨慎修改。",
|
||||
"You have modified the Server ID. This will affect the MCP access URL and may break existing integrations. Are you sure you want to continue?": "您已修改了服务器ID。这将影响MCP访问地址,可能会破坏现有的集成。您确定要继续吗?",
|
||||
|
||||
"The header name for the API key (e.g., X-API-Key, Authorization)": "API密钥的头部名称(例如:X-API-Key, Authorization)",
|
||||
"Enter API key": "输入API密钥",
|
||||
"Enter bearer token": "输入Bearer令牌",
|
||||
@@ -553,7 +552,7 @@
|
||||
"Select currency": "选择货币",
|
||||
"Default currency for the platform": "平台默认货币",
|
||||
"call": "调用",
|
||||
"No services found": "未找到服务",
|
||||
"No servers found": "未找到服务",
|
||||
"free/day": "免费/天",
|
||||
"Account (Email)": "账户(邮箱)",
|
||||
"Recharge Amount": "充值金额",
|
||||
@@ -571,7 +570,7 @@
|
||||
"No tools added yet. Add your first tool using the input above.": "尚未添加工具。使用上面的输入添加您的第一个工具。",
|
||||
"Insert tool below": "在下方插入工具",
|
||||
"Remove tool": "移除工具",
|
||||
"Service Detail": "服务详情",
|
||||
"Server Detail": "服务详情",
|
||||
"Billing Mode": "计费模式",
|
||||
"Enable free quota": "启用免费配额",
|
||||
"Configure Stripe payment interface": "配置Stripe支付接口",
|
||||
@@ -600,9 +599,9 @@
|
||||
"Platform total fund pool": "平台总资金池",
|
||||
"Today's API Calls": "今日调用量",
|
||||
"API call count": "API 调用次数",
|
||||
"Total MCP Services": "MCP服务总数",
|
||||
"Deployed services": "已部署的服务",
|
||||
"This is your AI service management center. You can quickly view platform core data on the left and manage and configure your MCP services, users, payment channels, etc.": "这里是您的AI服务管理中心,您可以在左侧快速查看平台核心数据,在此管理和配置您的 MCP 服务、用户、支付渠道等。",
|
||||
"Total MCP Servers": "MCP服务总数",
|
||||
"Deployed servers": "已部署的服务",
|
||||
"This is your AI server management center. You can quickly view platform core data on the left and manage and configure your MCP servers, users, payment channels, etc.": "这里是您的AI服务管理中心,您可以在左侧快速查看平台核心数据,在此管理和配置您的 MCP 服务、用户、支付渠道等。",
|
||||
"Log In": "登录",
|
||||
"Register Date": "注册日期",
|
||||
"Dashboard": "仪表盘",
|
||||
@@ -648,17 +647,16 @@
|
||||
"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}}",
|
||||
"Log Out": "退出登录",
|
||||
"Enter your username": "输入您的用户名",
|
||||
"Login": "登录",
|
||||
"Admin Portal": "管理员门户",
|
||||
"Log in to admin console": "登录管理员控制台",
|
||||
"Welcome to XPack.AI Open Source": "欢迎来到XPack.AI开源项目",
|
||||
"Are you sure you want to delete this \"{{name}}\" service?": "您确定要删除这个\"{{name}}\"服务吗?",
|
||||
"Service status toggled successfully": "服务状态切换成功",
|
||||
"Failed to toggle service status": "切换服务状态失败",
|
||||
"Log in to your admin account to continue": "登录管理员控制台",
|
||||
"Welcome to XPack.AI": "欢迎来到XPack.AI",
|
||||
"Are you sure you want to delete this \"{{name}}\" server?": "您确定要删除这个\"{{name}}\"服务吗?",
|
||||
"Server status toggled successfully": "服务状态切换成功",
|
||||
"Failed to toggle server status": "切换服务状态失败",
|
||||
"Stripe configuration saved successfully": "Stripe 配置保存成功",
|
||||
"Failed to save Stripe configuration": "保存 Stripe 配置失败",
|
||||
"Failed to save {{channelName}} config": "保存{{channelName}}配置失败",
|
||||
@@ -693,8 +691,6 @@
|
||||
"Stripe config saved successfully": "Stripe 配置保存成功",
|
||||
"Alipay config saved successfully": "支付宝配置保存成功",
|
||||
"WeChat config saved successfully": "微信配置保存成功",
|
||||
"Login successful": "登录成功",
|
||||
"Logged out successfully": "退出登录成功",
|
||||
"Configure email settings": "配置邮箱设置",
|
||||
"Email Configuration": "邮箱配置",
|
||||
"Configure SMTP settings for email notifications": "配置SMTP设置用于邮件通知",
|
||||
@@ -768,10 +764,10 @@
|
||||
"Traditional email and password authentication": "传统邮箱和密码认证",
|
||||
"Email/Verification Code": "邮箱/验证码",
|
||||
"Passwordless login with email verification code": "邮箱验证码登录",
|
||||
"Email service is not configured. Please configure email settings first.": "邮箱服务未配置。请先配置邮箱设置。",
|
||||
"SMTP is not configured. Please configure email settings first.": "SMTP未配置。请先配置邮箱设置。",
|
||||
"Go to Settings": "前往设置",
|
||||
"AI Tools Marketplace": "AI工具市场",
|
||||
"A marketplace for AI tools and services. Discover and integrate powerful AI solutions for your projects.": "一个AI工具和服务的市场。发现并整合强大的AI解决方案,为您的项目提供支持。",
|
||||
"A marketplace for AI tools and servers. Discover and integrate powerful AI solutions for your projects.": "一个AI工具和服务的市场。发现并整合强大的AI解决方案,为您的项目提供支持。",
|
||||
"Configuration": "配置",
|
||||
"Featured Products": "推荐产品",
|
||||
"Search": "搜索",
|
||||
@@ -801,7 +797,6 @@
|
||||
"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<script>\n // Google Analytics\n gtag('config', 'GA_MEASUREMENT_ID');\n</script>\n\n<style>\n .custom-style {\n color: #333;\n }\n</style>": "在此输入您的自定义HTML、CSS或JavaScript代码...\n\n示例:\n<script>\n // Google Analytics\n gtag('config', 'GA_MEASUREMENT_ID');\n</script>\n\n<style>\n .custom-style {\n color: #333;\n }\n</style>",
|
||||
"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将在保存并启用后渲染。",
|
||||
@@ -840,8 +835,6 @@
|
||||
"Target": "目标",
|
||||
"Add Navigation Item": "添加导航项",
|
||||
"Remove Navigation Item": "删除导航项",
|
||||
"Enter title": "输入标题",
|
||||
"Enter link URL": "输入链接地址",
|
||||
"Same window": "当前窗口",
|
||||
"New window": "新窗口",
|
||||
"Custom HTML injection": "自定义HTML注入",
|
||||
@@ -874,5 +867,17 @@
|
||||
"Input": "输入",
|
||||
"Output": "输出",
|
||||
"1M tokens": "1M tokens",
|
||||
"Total Spending": "总支出"
|
||||
"Total Spending": "总支出",
|
||||
"Remote": "远程",
|
||||
"Platform Logo": "平台Logo",
|
||||
"Support JPG, PNG, GIF. Max size 5MB": "支持JPG、PNG、GIF格式,最大大小5MB",
|
||||
"(30 days)": "(30天)",
|
||||
"Sign in": "登录",
|
||||
"or create your account": "或创建您的账户",
|
||||
"No account? Just continue—we’ll set you up.": "没有账户?继续即可,我们会为您设置。",
|
||||
"Password must be at least 6 characters": "密码必须至少6个字符",
|
||||
"Email is required": "邮箱为必填项",
|
||||
"No servers available": "没有可用服务",
|
||||
"(Deleted)": "(已删除)",
|
||||
"Transport Type": "传输方式"
|
||||
}
|
||||
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 9.3 MiB |
@@ -0,0 +1,75 @@
|
||||
import { ApiResponse } from "@/shared/types";
|
||||
import { fetchAdminAPI } from "@/rpc/admin-api";
|
||||
|
||||
/**
|
||||
* Admin analytics API data structures based on OpenAPI spec
|
||||
* GET /api/admin/stats/analytics
|
||||
*/
|
||||
|
||||
export interface DayCountStringItem {
|
||||
stats_day: string; // yyyy-mm-dd
|
||||
count: string;
|
||||
}
|
||||
|
||||
export interface DayCountNumberItem {
|
||||
stats_day: string; // yyyy-mm-dd
|
||||
count: number;
|
||||
}
|
||||
|
||||
// 用户注册数据
|
||||
export interface UserRegisterData {
|
||||
total: number; // user register total count
|
||||
today?: number; // today user register count
|
||||
days: DayCountStringItem[]; // daily user register count
|
||||
}
|
||||
|
||||
// user pay data
|
||||
export interface UserPayData {
|
||||
total: number; // user pay total amount
|
||||
today?: number; // today user pay amount
|
||||
|
||||
days: DayCountNumberItem[]; // daily user pay amount
|
||||
}
|
||||
|
||||
// MCP 调用数据
|
||||
export interface MCPCallData {
|
||||
total: number; // mcp call total count
|
||||
today?: number; // today mcp call count
|
||||
days: DayCountNumberItem[]; // daily mcp call count
|
||||
}
|
||||
|
||||
// Top server items
|
||||
export interface TopServiceItem {
|
||||
id: string; // server id
|
||||
name: string; // server name
|
||||
short_description: string; // short description
|
||||
call_count: number; // call count
|
||||
is_deleted: boolean; //It means the server was deleted.
|
||||
}
|
||||
|
||||
// admin analytics data
|
||||
export interface AdminAnalyticsData {
|
||||
user_register: UserRegisterData;
|
||||
user_pay: UserPayData;
|
||||
mcp_call: MCPCallData;
|
||||
top_services: TopServiceItem[];
|
||||
}
|
||||
|
||||
// admin analytics response body
|
||||
export interface AdminAnalyticsResponse
|
||||
extends ApiResponse<AdminAnalyticsData> {
|
||||
success: boolean;
|
||||
code: string;
|
||||
error_message: string;
|
||||
data: AdminAnalyticsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get admin analytics data
|
||||
* Headers: { Authorization: string }
|
||||
*/
|
||||
export async function getAdminAnalytics(): Promise<AdminAnalyticsResponse> {
|
||||
return fetchAdminAPI<AdminAnalyticsData>("/api/admin/stats/analytics", {
|
||||
method: "GET",
|
||||
}) as unknown as AdminAnalyticsResponse;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { fetchAdminAPI } from "@/rpc/admin-api";
|
||||
import { ApiResponse } from "@/shared/types";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
export enum OnboardingTaskKey {
|
||||
PLATFORM_SETUP = "configure-platform-settings",
|
||||
MCP_SERVICES = "add-mcp-services",
|
||||
REVENUE_MANAGEMENT = "configure-platment-billings",
|
||||
SHARE_PLATFORM = "share-your-platform",
|
||||
}
|
||||
export enum TaskStatusEnum {
|
||||
COMPLETED = 1,
|
||||
NOT_STARTED = 0,
|
||||
}
|
||||
export type TaskItem = {
|
||||
task_id: OnboardingTaskKey;
|
||||
task_status: TaskStatusEnum;
|
||||
};
|
||||
export async function updateAdminOnboardingTasks(
|
||||
task: TaskItem
|
||||
): Promise<boolean> {
|
||||
const res = (await fetchAdminAPI<void>("/api/onboarding/task_update_status", {
|
||||
method: "PUT",
|
||||
body: task as unknown as BodyInit,
|
||||
})) as unknown as ApiResponse<void>;
|
||||
// if (!res.success) {
|
||||
// toast.error(res.error_message || "Failed to update onboarding task status");
|
||||
// }
|
||||
return res.success;
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import { AboutThemeSelector } from "@/components/theme/AboutThemeSelector";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const title = await getDynamicTitle("About");
|
||||
return createBaseMetadata(title);
|
||||
const platformConfig = await getDynamicTitle("About");
|
||||
return createBaseMetadata(platformConfig);
|
||||
}
|
||||
|
||||
export default async function AboutPage() {
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
'use server';
|
||||
"use server";
|
||||
|
||||
import { revalidatePath, revalidateTag } from 'next/cache';
|
||||
import { revalidatePath, revalidateTag } from "next/cache";
|
||||
import { headers } from "next/headers";
|
||||
|
||||
export async function revalidatePlatformConfig() {
|
||||
// 重新验证根路径和所有子路径
|
||||
revalidatePath('/', 'layout');
|
||||
|
||||
// 如果使用了标签缓存,也可以重新验证特定标签
|
||||
revalidateTag('platform-config');
|
||||
|
||||
console.log('Platform config cache revalidated');
|
||||
}
|
||||
// Get current host for host-specific cache invalidation
|
||||
const headersList = await headers();
|
||||
const host = headersList.get("host") || "default";
|
||||
|
||||
// Revalidate root path and all sub-paths
|
||||
revalidatePath("/", "layout");
|
||||
|
||||
// Revalidate host-specific cache tag
|
||||
revalidateTag(`platform-config-${host}`);
|
||||
|
||||
console.info(
|
||||
`Platform config cache revalidated for host: platform-config-${host}`
|
||||
);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { useAdminLogin } from "@/hooks/useAdminLogin";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
const adminLoginSchema = z.object({
|
||||
username: z.string().min(1, "Username is required"),
|
||||
@@ -62,4 +61,4 @@ export const AdminLoginForm = () => {
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
import React from "react";
|
||||
import type { Metadata } from "next";
|
||||
import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import ConsoleMain from "@/components/console/Main";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const platformConfig = await getDynamicTitle("Console");
|
||||
return createBaseMetadata(platformConfig);
|
||||
}
|
||||
|
||||
export default function AdminConsolePage() {
|
||||
return <ConsoleMain />;
|
||||
}
|
||||
@@ -15,8 +15,10 @@ const AdminLoginHeader = () => {
|
||||
return (
|
||||
<div className="flex flex-col items-center pb-6">
|
||||
<DynamicLogo alt="Platform Logo" className="h-[40px]" />
|
||||
<p className="text-xl font-medium mt-4">{t("Admin Portal")}</p>
|
||||
<p className="text-sm text-default-500">{t("Log in to admin console")}</p>
|
||||
<p className="text-xl font-medium mt-4">{t("Welcome")}</p>
|
||||
<p className="text-sm text-default-500">
|
||||
{t("Log in to your admin account to continue")}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -28,7 +30,7 @@ const AdminLoginPageContent = () => {
|
||||
const handleCheckLogin = async () => {
|
||||
const res = await getAdminUser();
|
||||
if (res.success) {
|
||||
router.push("/console");
|
||||
router.push("/admin/console");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import React from "react";
|
||||
import type { Metadata } from "next";
|
||||
import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import ConsoleMain from "@/components/console/Main";
|
||||
import DashboardMain from "@/components/dashboard/Main";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const title = await getDynamicTitle("Console");
|
||||
return createBaseMetadata(title);
|
||||
const platformConfig = await getDynamicTitle("Dashboard");
|
||||
return createBaseMetadata(platformConfig);
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<ConsoleMain />
|
||||
);
|
||||
export default function ConsolePage() {
|
||||
return <DashboardMain />;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import React from "react";
|
||||
import type { Metadata } from "next";
|
||||
import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import DashboardMain from "@/components/dashboard/Main";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const title = await getDynamicTitle("Dashboard");
|
||||
return createBaseMetadata(title);
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<DashboardMain />
|
||||
);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 11 KiB |
@@ -1,9 +1,13 @@
|
||||
input::placeholder,
|
||||
textarea::placeholder {
|
||||
--nextui-foreground-500: 240 5.03% 64.9%;
|
||||
}
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* Import theme styles */
|
||||
@import '../styles/themes.css';
|
||||
@import "../styles/themes.css";
|
||||
|
||||
html,
|
||||
body {
|
||||
@@ -84,3 +88,10 @@ body {
|
||||
background-size: 16px 16px; /* 每个格子的尺寸 */
|
||||
background-repeat: repeat;
|
||||
}
|
||||
.wmde-markdown ul,
|
||||
.wmde-markdown ol {
|
||||
list-style-type: revert;
|
||||
}
|
||||
.wmde-markdown {
|
||||
background-color: inherit !important;
|
||||
}
|
||||
@@ -2,7 +2,11 @@ import type { Metadata } from "next";
|
||||
import { Red_Hat_Display } from "next/font/google";
|
||||
import ClientRootProviders from "@/shared/components/ClientRootProviders";
|
||||
import "./globals.css";
|
||||
import { getCachedPlatformConfig, getDynamicTitle, createBaseMetadata } from "@/shared/utils/metadata";
|
||||
import {
|
||||
getCachedPlatformConfig,
|
||||
getDynamicTitle,
|
||||
createBaseMetadata,
|
||||
} from "@/shared/utils/metadata";
|
||||
|
||||
const redHatDisplay = Red_Hat_Display({
|
||||
subsets: ["latin"],
|
||||
@@ -11,8 +15,8 @@ const redHatDisplay = Red_Hat_Display({
|
||||
});
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const title = await getDynamicTitle();
|
||||
return createBaseMetadata(title);
|
||||
const platformConfig = await getDynamicTitle();
|
||||
return createBaseMetadata(platformConfig);
|
||||
}
|
||||
|
||||
export default async function RootLayout({
|
||||
@@ -23,7 +27,7 @@ export default async function RootLayout({
|
||||
const platformConfig = await getCachedPlatformConfig();
|
||||
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<html lang="en" suppressHydrationWarning data-color-mode="light">
|
||||
<head>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
@@ -32,15 +36,16 @@ export default async function RootLayout({
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
{platformConfig?.embeded_html?.is_enabled && platformConfig?.embeded_html?.html && (
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: platformConfig.embeded_html.html,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</head>
|
||||
<body className={redHatDisplay.className} suppressHydrationWarning>
|
||||
{platformConfig?.embeded_html?.is_enabled &&
|
||||
platformConfig?.embeded_html?.html && (
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: platformConfig.embeded_html.html,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<ClientRootProviders initConfig={platformConfig}>
|
||||
{children}
|
||||
</ClientRootProviders>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import React, { useEffect, Suspense } from "react";
|
||||
import { Spinner, Button } from "@nextui-org/react";
|
||||
import { useLogin } from "@/hooks/useLogin";
|
||||
import { useLogin } from "@/shared/hooks/useLogin";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { Icon } from "@iconify/react/dist/iconify.js";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
@@ -22,7 +22,7 @@ function LoginSuccessContent() {
|
||||
|
||||
const backHome = () => {
|
||||
const dynamicParams = new URLSearchParams(searchParams?.get("state") || "");
|
||||
router.push(`/login?${dynamicParams.toString()}`);
|
||||
router.push(`/?${dynamicParams.toString()}`);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -31,22 +31,14 @@ function LoginSuccessContent() {
|
||||
<Spinner size="lg" color="default" />
|
||||
) : status === "success" ? (
|
||||
<>
|
||||
<Icon
|
||||
fontSize={70}
|
||||
className="text-success"
|
||||
icon="mi:circle-check"
|
||||
/>
|
||||
<Icon fontSize={70} className="text-success" icon="mi:circle-check" />
|
||||
<div className="text-xl font-bold text-success">
|
||||
{t("Login Success")}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Icon
|
||||
fontSize={70}
|
||||
className="text-danger"
|
||||
icon="mi:circle-error"
|
||||
/>
|
||||
<Icon fontSize={70} className="text-danger" icon="mi:circle-error" />
|
||||
<div className="text-xl font-bold text-danger">
|
||||
{t("Login Error")}
|
||||
</div>
|
||||
@@ -59,8 +51,14 @@ function LoginSuccessContent() {
|
||||
|
||||
export default function LoginSuccessPage() {
|
||||
return (
|
||||
<Suspense fallback={<div className="flex justify-center mt-40"><Spinner size="lg" color="default" /></div>}>
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="flex justify-center mt-40">
|
||||
<Spinner size="lg" color="default" />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<LoginSuccessContent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import type { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ThemeSelector } from "@/components/theme/ThemeSelector";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const title = await getDynamicTitle();
|
||||
return createBaseMetadata(title);
|
||||
const platformConfig = await getDynamicTitle();
|
||||
return createBaseMetadata(platformConfig);
|
||||
}
|
||||
|
||||
export default async function HomePage({
|
||||
@@ -36,8 +36,8 @@ export default async function HomePage({
|
||||
services = response?.data?.services || [];
|
||||
total = response?.page?.total || 0;
|
||||
} catch (err) {
|
||||
console.error("Error fetching services:", err);
|
||||
error = "Failed to load services";
|
||||
console.error("Error fetching servers:", err);
|
||||
error = "Failed to load servers";
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -5,8 +5,6 @@ import type { Metadata } from "next";
|
||||
import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import { fetchServiceById } from "@/services/marketplaceService";
|
||||
import type { ServiceData } from "@/shared/types/marketplace";
|
||||
import { Footer } from "@/shared/components/Footer";
|
||||
import { Navigation } from "@/shared/components/Navigation";
|
||||
|
||||
interface ProductPageProps {
|
||||
params: Promise<{ id: string }>;
|
||||
@@ -32,20 +30,15 @@ export async function generateMetadata({
|
||||
|
||||
// use cached function to get data to generate metadata
|
||||
const product = await getProductById(id);
|
||||
const productName = product?.name || "Unknown";
|
||||
|
||||
if (product) {
|
||||
const title = await getDynamicTitle(product.name);
|
||||
return {
|
||||
...createBaseMetadata(title),
|
||||
description:
|
||||
product.short_description ||
|
||||
`Discover ${product.name} and its powerful tools`,
|
||||
};
|
||||
}
|
||||
|
||||
// default metadata if product not found
|
||||
const defaultTitle = await getDynamicTitle("Marketplace");
|
||||
return createBaseMetadata(defaultTitle);
|
||||
const platformConfig = await getDynamicTitle(productName);
|
||||
return {
|
||||
...createBaseMetadata(platformConfig),
|
||||
description:
|
||||
product?.short_description ||
|
||||
`Discover ${productName} and its powerful tools`,
|
||||
};
|
||||
}
|
||||
|
||||
export default async function ProductPage({ params }: ProductPageProps) {
|
||||
@@ -6,8 +6,21 @@ import { Icon } from "@iconify/react/dist/iconify.js";
|
||||
interface LoginButtonProps {
|
||||
title: string;
|
||||
icon?: string;
|
||||
color?: "default" | "primary" | "secondary" | "success" | "warning" | "danger";
|
||||
variant?: "solid" | "bordered" | "light" | "flat" | "faded" | "shadow" | "ghost";
|
||||
color?:
|
||||
| "default"
|
||||
| "primary"
|
||||
| "secondary"
|
||||
| "success"
|
||||
| "warning"
|
||||
| "danger";
|
||||
variant?:
|
||||
| "solid"
|
||||
| "bordered"
|
||||
| "light"
|
||||
| "flat"
|
||||
| "faded"
|
||||
| "shadow"
|
||||
| "ghost";
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
@@ -29,4 +42,4 @@ export const LoginButton = ({
|
||||
{title}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -6,12 +6,13 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { StepState } from "../page";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import i18n from "@/shared/lib/i18n";
|
||||
|
||||
const emailSchema = z.object({
|
||||
email: z
|
||||
.string()
|
||||
.email({ message: "Invalid email address" })
|
||||
.min(1, { message: "Email is required" }),
|
||||
.email({ message: i18n.t("Invalid email address") })
|
||||
.min(1, { message: i18n.t("Email is required") }),
|
||||
});
|
||||
|
||||
type EmailFormData = z.infer<typeof emailSchema>;
|
||||
@@ -30,7 +31,7 @@ export const LoginEmailFrom = ({ setEmail, setStep }: LoginEmailFromProps) => {
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<EmailFormData>({
|
||||
resolver: zodResolver(emailSchema),
|
||||
mode: "all",
|
||||
mode: "onBlur",
|
||||
});
|
||||
|
||||
const onSubmit = async (data: EmailFormData) => {
|
||||
@@ -61,7 +62,9 @@ export const LoginEmailFrom = ({ setEmail, setStep }: LoginEmailFromProps) => {
|
||||
type="submit"
|
||||
color="primary"
|
||||
isLoading={isSubmitting}
|
||||
className="w-full"
|
||||
size="lg"
|
||||
className="w-full font-semibold bg-default-900"
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Continue")}
|
||||
</Button>
|
||||
|
||||
@@ -7,15 +7,16 @@ import { z } from "zod";
|
||||
import { useState } from "react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { useLogin } from "@/hooks/useLogin";
|
||||
import { useLogin } from "@/shared/hooks/useLogin";
|
||||
import { md5Encrypt } from "@/shared/utils/crypto";
|
||||
import i18n from "@/shared/lib/i18n";
|
||||
|
||||
const emailPasswordSchema = z.object({
|
||||
email: z
|
||||
.string()
|
||||
.email({ message: "Invalid email address" })
|
||||
.min(1, { message: "Email is required" }),
|
||||
password: z.string().min(6, "Password must be at least 6 characters"),
|
||||
.email({ message: i18n.t("Invalid email address") })
|
||||
.min(1, { message: i18n.t("Email is required") }),
|
||||
password: z.string().min(6, i18n.t("Password must be at least 6 characters")),
|
||||
});
|
||||
|
||||
type EmailPasswordFormData = z.infer<typeof emailPasswordSchema>;
|
||||
@@ -37,7 +38,7 @@ export const LoginEmailPasswordForm = ({
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<EmailPasswordFormData>({
|
||||
resolver: zodResolver(emailPasswordSchema),
|
||||
mode: "all",
|
||||
mode: "onBlur",
|
||||
});
|
||||
|
||||
const onSubmit = async (data: EmailPasswordFormData) => {
|
||||
@@ -105,9 +106,11 @@ export const LoginEmailPasswordForm = ({
|
||||
type="submit"
|
||||
color="primary"
|
||||
isLoading={isSubmitting}
|
||||
className="w-full"
|
||||
size="lg"
|
||||
className="w-full font-semibold bg-default-900"
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Sign In")}
|
||||
{t("Continue")}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -1,86 +1,123 @@
|
||||
"use client";
|
||||
|
||||
import { Divider } from "@nextui-org/react";
|
||||
import { Suspense, useState } from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import { LoginButton } from "./LoginButton";
|
||||
import { useLogin } from "@/hooks/useLogin";
|
||||
import { useLogin } from "@/shared/hooks/useLogin";
|
||||
import { EmailVerificationForm } from "./VerifyEmail";
|
||||
import { LoginEmailFrom } from "./LoginEmailFrom";
|
||||
import { LoginEmailPasswordForm } from "./LoginEmailPasswordForm";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { EmailMode } from "@/shared/types/system";
|
||||
import BgCollagePattern from "@/shared/components/sign/BgCollagePattern";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
|
||||
export type StepState = "init" | "emailForm" | "verifyEmail";
|
||||
|
||||
const SignInComponent = () => {
|
||||
export default function SignInComponent() {
|
||||
const { t } = useTranslation();
|
||||
const [email, setEmail] = useState("");
|
||||
const [step, setStep] = useState<StepState>("init");
|
||||
const { googleLoginOrSignUp } = useLogin();
|
||||
const { loginConfig } = usePlatformConfig();
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
// 检查是否启用了 Google 登录
|
||||
const isGoogleLoginEnabled =
|
||||
loginConfig?.google?.is_enabled && loginConfig?.google?.client_id;
|
||||
|
||||
// 检查是否启用了邮箱登录
|
||||
const isEmailEnabled = loginConfig?.email?.is_enabled ?? true;
|
||||
|
||||
|
||||
// 获取邮箱登录模式
|
||||
const emailMode = loginConfig?.email?.mode ?? EmailMode.PASSWORD;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mt-2 flex w-full max-w-sm flex-col gap-8 rounded-large bg-content1 px-8 py-6 shadow-small backdrop-blur-sm">
|
||||
{step === "verifyEmail" && <EmailVerificationForm email={email} />}
|
||||
{step === "init" && isGoogleLoginEnabled && (
|
||||
<LoginButton
|
||||
title={t("Log in with Google")}
|
||||
color="primary"
|
||||
variant="solid"
|
||||
icon="flat-color-icons:google"
|
||||
onClick={googleLoginOrSignUp}
|
||||
/>
|
||||
)}
|
||||
{/* OR - 只有在启用 Google 登录且有其他登录方式时才显示分隔符 */}
|
||||
{isGoogleLoginEnabled && isEmailEnabled && (
|
||||
<div className="flex items-center gap-4">
|
||||
<Divider className="flex-1" />
|
||||
<p className="shrink-0 text-tiny text-default-500">{t("OR")}</p>
|
||||
<Divider className="flex-1" />
|
||||
</div>
|
||||
)}
|
||||
{/* Login With Email */}
|
||||
{step === "init" && isEmailEnabled && (
|
||||
<div className="space-y-4">
|
||||
{/* 邮箱/密码登录表单 */}
|
||||
{emailMode === EmailMode.PASSWORD && (
|
||||
<LoginEmailPasswordForm />
|
||||
)}
|
||||
<div
|
||||
className="relative w-full min-h-screen flex items-center justify-center"
|
||||
ref={containerRef}
|
||||
>
|
||||
{/* Background collage pattern */}
|
||||
<BgCollagePattern
|
||||
containerRef={containerRef}
|
||||
options={{
|
||||
radius: 30,
|
||||
background: "#f5f5f5",
|
||||
particleCount: 20000,
|
||||
color: "#006fee",
|
||||
colorPole: "#001aee",
|
||||
}}
|
||||
/>
|
||||
<div className="relative z-10 w-full max-w-md">
|
||||
<div className="bg-white rounded-2xl shadow-2xl p-8 backdrop-blur-lg bg-opacity-95">
|
||||
<div className="mb-10">
|
||||
<div className="flex gap-2 mb-4">
|
||||
<DynamicLogo className="h-[32px]" hideText />
|
||||
</div>
|
||||
<h1 className="text-3xl font-semibold text-default-900">
|
||||
{t("Sign in")} <br />
|
||||
<span>{t("or create your account")}</span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{/* 邮箱/验证码登录表单 */}
|
||||
{emailMode === EmailMode.CAPTCHA && (
|
||||
<LoginEmailFrom setEmail={setEmail} setStep={setStep} />
|
||||
)}
|
||||
<div className="space-y-6">
|
||||
{step === "verifyEmail" && (
|
||||
<EmailVerificationForm email={email} />
|
||||
)}
|
||||
{step === "init" && isGoogleLoginEnabled && (
|
||||
<LoginButton
|
||||
title={t("Log in with Google")}
|
||||
color="primary"
|
||||
variant="solid"
|
||||
icon="flat-color-icons:google"
|
||||
onClick={googleLoginOrSignUp}
|
||||
/>
|
||||
)}
|
||||
{/* OR - 只有在启用 Google 登录且有其他登录方式时才显示分隔符 */}
|
||||
{isGoogleLoginEnabled && isEmailEnabled && (
|
||||
<div className="flex items-center gap-4">
|
||||
<Divider className="flex-1" />
|
||||
<p className="shrink-0 text-tiny text-default-500">
|
||||
{t("OR")}
|
||||
</p>
|
||||
<Divider className="flex-1" />
|
||||
</div>
|
||||
)}
|
||||
{/* Login With Email */}
|
||||
{step === "init" && isEmailEnabled && (
|
||||
<div className="space-y-4">
|
||||
{/* 邮箱/密码登录表单 */}
|
||||
{emailMode === EmailMode.PASSWORD && (
|
||||
<LoginEmailPasswordForm />
|
||||
)}
|
||||
|
||||
{/* 邮箱/验证码登录表单 */}
|
||||
{emailMode === EmailMode.CAPTCHA && (
|
||||
<LoginEmailFrom setEmail={setEmail} setStep={setStep} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{step !== "init" && isGoogleLoginEnabled && (
|
||||
<LoginButton
|
||||
title={t("Log in with Google")}
|
||||
icon="flat-color-icons:google"
|
||||
onClick={googleLoginOrSignUp}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 底部提示文本 */}
|
||||
{step === "init" && (
|
||||
<div className="mt-6 text-center">
|
||||
<p className="text-sm text-gray-600">
|
||||
{t("No account? Just continue—we’ll set you up.")}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{step !== "init" && isGoogleLoginEnabled && (
|
||||
<LoginButton
|
||||
title={t("Log in with Google")}
|
||||
icon="flat-color-icons:google"
|
||||
onClick={googleLoginOrSignUp}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default function SignInWrapper() {
|
||||
return (
|
||||
<Suspense fallback={<></>}>
|
||||
<SignInComponent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useLogin } from "@/hooks/useLogin";
|
||||
import { useLogin } from "@/shared/hooks/useLogin";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import toast from "react-hot-toast";
|
||||
import { fetchAPI } from "@/shared/rpc/common-function";
|
||||
import { getEmail } from "@/utils/getEmail";
|
||||
import { getEmail } from "@/shared/utils/getEmail";
|
||||
|
||||
const schema = z.object({
|
||||
captcha: z
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
import React, { useEffect, Suspense } from "react";
|
||||
import { Spinner } from "@nextui-org/react";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import SignInComponent from "./components/SignIn";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useLogin } from "@/hooks/useLogin";
|
||||
import { useLogin } from "@/shared/hooks/useLogin";
|
||||
import { useSharedStore } from "@/shared/store/share";
|
||||
import { useGlobalStore } from "@/shared/store/global";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
|
||||
export interface LoginFormData {
|
||||
user_email: string;
|
||||
@@ -17,23 +14,6 @@ export interface LoginFormData {
|
||||
nick_name?: string;
|
||||
}
|
||||
|
||||
const LoginHeader = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center pb-6">
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="h-[40px]"
|
||||
/>
|
||||
<p className="text-xl font-medium mt-4">{t("Welcome")}</p>
|
||||
<p className="text-sm text-default-500">
|
||||
{t("Log in to your account to continue")}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export type StepState = "init" | "emailForm" | "verifyEmail";
|
||||
|
||||
const LoginPageContent = () => {
|
||||
@@ -58,10 +38,8 @@ const LoginPageContent = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col items-center justify-center w-full h-full mt-20">
|
||||
<LoginHeader />
|
||||
<div className="flex flex-col items-center justify-center w-full h-full">
|
||||
<SignInComponent />
|
||||
<Toaster />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
@@ -69,10 +47,16 @@ const LoginPageContent = () => {
|
||||
|
||||
const LoginPage = () => {
|
||||
return (
|
||||
<Suspense fallback={<div className="flex justify-center mt-40"><Spinner size="lg" color="default" /></div>}>
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="flex justify-center">
|
||||
<Spinner size="lg" color="default" />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<LoginPageContent />
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoginPage;
|
||||
export default LoginPage;
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import MarkdownPreview from "@uiw/react-markdown-preview";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Card, CardBody } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
@@ -14,26 +14,26 @@ export const AboutContent: React.FC = () => {
|
||||
<Card shadow="none" className="bg-transparent">
|
||||
<CardBody className="space-y-4">
|
||||
<h1 className="text-3xl font-bold mb-6">{t("About Us")}</h1>
|
||||
<div className="leading-relaxed prose prose-sm max-w-none">
|
||||
<div className="leading-relaxed max-w-none">
|
||||
{platformConfig.about_page ? (
|
||||
<ReactMarkdown>{platformConfig.about_page}</ReactMarkdown>
|
||||
<MarkdownPreview source={platformConfig.about_page} />
|
||||
) : (
|
||||
<ReactMarkdown>
|
||||
{`
|
||||
${t("**XPack** is a lightweight, open-source marketplace framework for MCP (Model Context Protocol) services.")}
|
||||
${t("It allows you to transform any OpenAPI into a monetizable MCP service and build your own API store in just minutes.")}
|
||||
<MarkdownPreview
|
||||
source={`
|
||||
${t("**XPack** is a lightweight, open-source marketplace framework for MCP (Model Context Protocol) servers.")}
|
||||
${t("It allows you to transform any OpenAPI into a monetizable MCP server and build your own API store in just minutes.")}
|
||||
|
||||
|
||||
${t("✨ With XPack, you can:")}
|
||||
${t("- ✅ **One-click OpenAPI → MCP service config**")}
|
||||
${t("- 🧾 **SEO-friendly homepage + mcp service page**")}
|
||||
${t("- ✅ **One-click OpenAPI → MCP server config**")}
|
||||
${t("- 🧾 **SEO-friendly homepage + mcp server page**")}
|
||||
${t("- 💳 **Built-in billing (per-call)**")}
|
||||
${t("- 👥 **User account management**")}
|
||||
${t("- 🛠 **Support Stripe Payment**")}
|
||||
${t("- 🔐 **Support Email & Google OAuth Sign in**")}
|
||||
|
||||
${t("Everything is open-source and licensed under **Apache 2.0** — ready for commercial use.")}`}
|
||||
</ReactMarkdown>
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardBody>
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useRef } from "react";
|
||||
import { Card, Spinner } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import toast from "react-hot-toast";
|
||||
import { UploadIcon } from "lucide-react";
|
||||
import { calculateFileSha256 } from "@/shared/utils/crypto";
|
||||
|
||||
interface UploadImageProps {
|
||||
onSave: (file: File, sha256?: string) => Promise<string>;
|
||||
imageUrl?: string;
|
||||
setImageUrl: (imageUrl: string) => void;
|
||||
className?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
const UploadImage: React.FC<UploadImageProps> = ({
|
||||
onSave,
|
||||
imageUrl,
|
||||
setImageUrl,
|
||||
className = "h-32 w-32",
|
||||
description,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleImageUpload = async (
|
||||
event: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
const file = event.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
// Validate file type
|
||||
if (!file.type.startsWith("image/")) {
|
||||
toast.error(t("Please select a valid image file"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate file size (max 5MB)
|
||||
if (file.size > 5 * 1024 * 1024) {
|
||||
toast.error(t("Image size should be less than 5MB"));
|
||||
return;
|
||||
}
|
||||
|
||||
setIsUploading(true);
|
||||
try {
|
||||
const sha256 = await calculateFileSha256(file);
|
||||
const imageUrl = await onSave(file, sha256);
|
||||
setImageUrl(imageUrl);
|
||||
} catch (error) {
|
||||
console.error("Upload failed:", error);
|
||||
toast.error(t("Failed to upload image"));
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImageClick = () => {
|
||||
if (!isUploading) {
|
||||
fileInputRef.current?.click();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Card
|
||||
className={`relative group ${isUploading ? "cursor-not-allowed" : "cursor-pointer"} ${className} `}
|
||||
style={{
|
||||
backgroundSize: "contain",
|
||||
backgroundPosition: "center",
|
||||
backgroundRepeat: "no-repeat",
|
||||
}}
|
||||
onPress={handleImageClick}
|
||||
isPressable={!isUploading}
|
||||
shadow="none"
|
||||
>
|
||||
{imageUrl && (
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt="Uploaded"
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
className={`absolute top-0 rounded-large right-0 bg-default-100 w-full h-full flex items-center justify-center transition-opacity duration-300 ${
|
||||
imageUrl && !isUploading ? "opacity-0" : "opacity-100"
|
||||
} group-hover:opacity-50 backdrop-blur-sm`}
|
||||
></div>
|
||||
<div
|
||||
className={`absolute w-full h-full flex flex-col gap-2 items-center justify-center ${
|
||||
imageUrl && !isUploading ? "opacity-0" : "opacity-100"
|
||||
} group-hover:opacity-100`}
|
||||
>
|
||||
<span>
|
||||
{isUploading ? <Spinner size="lg" /> : <UploadIcon size={48} />}
|
||||
</span>
|
||||
<span className="text-sm text-default-500">{description}</span>
|
||||
</div>
|
||||
</Card>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
onChange={handleImageUpload}
|
||||
className="hidden"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default UploadImage;
|
||||
@@ -0,0 +1,138 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { AdminConfig } from "@/types/system";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
const formSchema = z.object({
|
||||
password: z
|
||||
.string()
|
||||
.min(1, "Password is required")
|
||||
.max(100, "Password is too long")
|
||||
.min(8, "Password must be at least 8 characters"),
|
||||
confirmPassword: z
|
||||
.string()
|
||||
.min(1, "Confirm password is required")
|
||||
.max(100, "Confirm password is too long")
|
||||
.min(8, "Confirm password must be at least 8 characters"),
|
||||
});
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface AdminConfigFormProps {
|
||||
onSave: (config: AdminConfig) => Promise<boolean>;
|
||||
}
|
||||
|
||||
export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({ onSave }) => {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
watch,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
});
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave({
|
||||
password: data.password,
|
||||
} as AdminConfig);
|
||||
};
|
||||
const passwordsMatch = watch("password") === watch("confirmPassword");
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 pb-4"
|
||||
>
|
||||
<Controller
|
||||
name="password"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Administrator Password")}
|
||||
placeholder={t("Enter administrator password")}
|
||||
description={t("Password must be at least 8 characters long")}
|
||||
isInvalid={!!errors.password}
|
||||
errorMessage={errors.password?.message}
|
||||
type={showPassword ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete="new-password"
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="confirmPassword"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Confirm Password")}
|
||||
placeholder={t("Confirm administrator password")}
|
||||
description={t("Re-enter the password to confirm")}
|
||||
isInvalid={
|
||||
!!errors.confirmPassword ||
|
||||
(!passwordsMatch && (field.value?.length || 0) > 0)
|
||||
}
|
||||
errorMessage={
|
||||
errors.confirmPassword?.message || t("Passwords do not match")
|
||||
}
|
||||
type={showConfirmPassword ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showConfirmPassword ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
autoComplete="new-password"
|
||||
isRequired
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
className="w-fit"
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
.xpack-console-stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -1,105 +1,322 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { overviewService } from "@/services/overviewService";
|
||||
import { PlatformOverviewData } from "@/types/dashboard";
|
||||
import "./ConsoleStats.css"
|
||||
import { Alert, Card, CardBody, CardFooter } from "@nextui-org/react";
|
||||
import React, { useMemo, useState, useEffect } from "react";
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
CardHeader,
|
||||
Tabs,
|
||||
Tab,
|
||||
Listbox,
|
||||
ListboxItem,
|
||||
Skeleton,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { ChartBarIcon, DollarSignIcon, ServerIcon, UserIcon } from "lucide-react";
|
||||
import {
|
||||
LineChart,
|
||||
Line,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
Tooltip,
|
||||
ResponsiveContainer,
|
||||
} from "recharts";
|
||||
import {
|
||||
getAdminAnalytics,
|
||||
AdminAnalyticsData,
|
||||
TopServiceItem,
|
||||
} from "@/api/adminAnalytics.api";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
interface StatCardProps {
|
||||
title: string;
|
||||
value: string | number;
|
||||
icon: React.ReactNode;
|
||||
description?: string;
|
||||
// Chart data interface to match existing chart component
|
||||
interface ChartDataItem {
|
||||
date: string;
|
||||
users: number;
|
||||
revenue: number;
|
||||
calls: number;
|
||||
}
|
||||
|
||||
const StatCard: React.FC<StatCardProps> = ({ title, value, icon, description }) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card shadow="none" className="border-1">
|
||||
<CardBody>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-medium text-gray-600 mb-1">{t(title)}</p>
|
||||
<p className="text-2xl font-bold text-gray-900">{value}</p>
|
||||
</div>
|
||||
<div className="ml-4 text-blue-500">
|
||||
{icon}
|
||||
</div>
|
||||
</div>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
{description && (
|
||||
<p className="text-xs text-gray-500 mt-1">{t(description)}</p>
|
||||
)}
|
||||
</CardFooter>
|
||||
</Card>
|
||||
// Transform API data to chart format
|
||||
const transformToChartData = (
|
||||
analytics: AdminAnalyticsData
|
||||
): ChartDataItem[] => {
|
||||
// Get the maximum length of days arrays to handle potential mismatches
|
||||
const maxLength = Math.max(
|
||||
analytics.user_register.days.length,
|
||||
analytics.user_pay.days.length,
|
||||
analytics.mcp_call.days.length
|
||||
);
|
||||
|
||||
const chartData: ChartDataItem[] = [];
|
||||
|
||||
for (let i = 0; i < maxLength; i++) {
|
||||
// Format date for display (converting from YYYY-MM-DD to MMM DD)
|
||||
const userRegDay = analytics.user_register.days[i];
|
||||
const payDay = analytics.user_pay.days[i];
|
||||
const callDay = analytics.mcp_call.days[i];
|
||||
|
||||
// Use the first available date, format it nicely
|
||||
const rawDate =
|
||||
userRegDay?.stats_day || payDay?.stats_day || callDay?.stats_day;
|
||||
const formattedDate = rawDate
|
||||
? new Date(rawDate).toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
})
|
||||
: `Day ${i + 1}`;
|
||||
|
||||
chartData.push({
|
||||
date: formattedDate,
|
||||
users: userRegDay ? parseInt(userRegDay.count as string) || 0 : 0,
|
||||
revenue: payDay ? payDay.count : 0,
|
||||
calls: callDay ? callDay.count : 0,
|
||||
});
|
||||
}
|
||||
|
||||
return chartData;
|
||||
};
|
||||
|
||||
// Render label + total value in tab header
|
||||
const TabTitle: React.FC<{
|
||||
label: string;
|
||||
total: number | string;
|
||||
}> = ({ label, total }) => (
|
||||
<div className="flex flex-col items-start gap-2">
|
||||
<div className="text-sm text-default-500">{label}</div>
|
||||
<div className="text-2xl font-semibold text-default-900">
|
||||
{typeof total === "number" ? total.toLocaleString() : total}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const ConsoleStats: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const [overviewData, setOverviewData] = useState<PlatformOverviewData | null>(null);
|
||||
const fetchOverviewData = async () => {
|
||||
try {
|
||||
const data = await overviewService.getPlatformOverview();
|
||||
setOverviewData(data);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch overview data:', err);
|
||||
} finally {
|
||||
}
|
||||
};
|
||||
// get platform overview data
|
||||
const [activeTab, setActiveTab] = useState<string>("users");
|
||||
|
||||
// State for API data
|
||||
const [analyticsData, setAnalyticsData] = useState<AdminAnalyticsData | null>(
|
||||
null
|
||||
);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// Fetch analytics data on component mount
|
||||
useEffect(() => {
|
||||
fetchOverviewData();
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await getAdminAnalytics();
|
||||
|
||||
if (response.success) {
|
||||
setAnalyticsData(response.data);
|
||||
} else {
|
||||
toast.error(
|
||||
response.error_message || "Failed to load analytics data"
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
// Transform API data to chart format
|
||||
const chartData = useMemo<ChartDataItem[]>(() => {
|
||||
if (!analyticsData) return [];
|
||||
return transformToChartData(analyticsData);
|
||||
}, [analyticsData]);
|
||||
|
||||
// Format revenue as currency (USD by default)
|
||||
const formatCurrency = (value: number, currency: string = "USD") =>
|
||||
new Intl.NumberFormat("en-US", { style: "currency", currency }).format(
|
||||
value
|
||||
);
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="w-full flex flex-col gap-4 h-full">
|
||||
<Skeleton className="rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-24 rounded-lg bg-secondary" />
|
||||
</Skeleton>
|
||||
<div className="flex flex-col gap-3">
|
||||
<Skeleton className="w-3/5 rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-3 w-full rounded-lg bg-secondary" />
|
||||
</Skeleton>
|
||||
<Skeleton className="w-4/5 rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-3 w-full rounded-lg bg-secondary-300" />
|
||||
</Skeleton>
|
||||
<Skeleton className="w-2/5 rounded-lg" isLoaded={!loading}>
|
||||
<div className="h-3 w-full rounded-lg bg-secondary-200" />
|
||||
</Skeleton>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* stat card grid */}
|
||||
<div className="xpack-console-stats-grid gap-4">
|
||||
<StatCard
|
||||
title="Total Users"
|
||||
value={overviewData?.total_user.toLocaleString() || 0}
|
||||
icon={
|
||||
<UserIcon size={32} />
|
||||
}
|
||||
description="Platform registered users"
|
||||
/>
|
||||
<StatCard
|
||||
title="Total Revenue"
|
||||
value={overviewData?.total_balance.toLocaleString() || 0}
|
||||
icon={
|
||||
<DollarSignIcon size={32} />
|
||||
}
|
||||
description="Platform total fund pool"
|
||||
/>
|
||||
<StatCard
|
||||
title="Today's API Calls"
|
||||
value={overviewData?.invoke_count.today.toLocaleString() || 0}
|
||||
icon={
|
||||
<ChartBarIcon size={32} />
|
||||
}
|
||||
description="API call count"
|
||||
/>
|
||||
{/* Charts with Tabs */}
|
||||
<Card shadow="none" className="border-1">
|
||||
<CardHeader className="p-0 flex items-center justify-between">
|
||||
<Tabs
|
||||
selectedKey={activeTab}
|
||||
onSelectionChange={(key) => setActiveTab(key as string)}
|
||||
variant="underlined"
|
||||
color="primary"
|
||||
classNames={{
|
||||
base: "w-full",
|
||||
tab: "h-fit justify-start border-b-1 p-4",
|
||||
cursor: "w-[90%]",
|
||||
tabList: "w-full gap-0 p-0",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="users"
|
||||
title={
|
||||
<TabTitle
|
||||
label={t("Daily Registered Users")}
|
||||
total={analyticsData?.user_register.today || 0}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tab
|
||||
key="revenue"
|
||||
title={
|
||||
<TabTitle
|
||||
label={t("Daily Revenue")}
|
||||
total={formatCurrency(analyticsData?.user_pay.today || 0)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<Tab
|
||||
key="calls"
|
||||
title={
|
||||
<TabTitle
|
||||
label={t("Daily API Calls")}
|
||||
total={analyticsData?.mcp_call.today || 0}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</Tabs>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div className="w-full h-[300px]">
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData}>
|
||||
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
||||
<XAxis dataKey="date" />
|
||||
<YAxis />
|
||||
<Tooltip
|
||||
labelStyle={{ color: "#374151" }}
|
||||
contentStyle={{
|
||||
backgroundColor: "#f9fafb",
|
||||
border: "1px solid #e5e7eb",
|
||||
borderRadius: "8px",
|
||||
padding: "12px",
|
||||
}}
|
||||
/>
|
||||
{activeTab === "users" && (
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="users"
|
||||
stroke="#3b82f6"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
activeDot={{ fill: "#3b82f6", strokeWidth: 2, r: 4 }}
|
||||
/>
|
||||
)}
|
||||
{activeTab === "revenue" && (
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="revenue"
|
||||
stroke="#10b981"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
activeDot={{ fill: "#10b981", strokeWidth: 2, r: 4 }}
|
||||
/>
|
||||
)}
|
||||
{activeTab === "calls" && (
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="calls"
|
||||
stroke="#f59e0b"
|
||||
strokeWidth={2}
|
||||
dot={false}
|
||||
activeDot={{ fill: "#f59e0b", strokeWidth: 2, r: 4 }}
|
||||
/>
|
||||
)}
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
<StatCard
|
||||
title="Total MCP Services"
|
||||
value={overviewData?.total_service.toLocaleString() || 0}
|
||||
icon={
|
||||
<ServerIcon size={32} />
|
||||
}
|
||||
description="Deployed services"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* welcome guide */}
|
||||
<Alert color="primary" title={t("Welcome to XPack.AI Open Source")} description={t("This is your AI service management center. You can quickly view platform core data on the left and manage and configure your MCP services, users, payment channels, etc.")}></Alert>
|
||||
{/* Top Servers List */}
|
||||
<Card shadow="none" className="border-1">
|
||||
<CardHeader className="pb-0 flex items-center justify-between">
|
||||
<h4 className="text-lg font-semibold text-gray-900">
|
||||
{t("Top Servers by Calls")}
|
||||
</h4>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<div>
|
||||
{analyticsData?.top_services?.length ? (
|
||||
<Listbox
|
||||
aria-label="top servers"
|
||||
selectionMode="none"
|
||||
className="overflow-visible p-0"
|
||||
classNames={{ list: "overflow-visible space-y-3" }}
|
||||
>
|
||||
{(analyticsData.top_services || []).map(
|
||||
(service: TopServiceItem, index: number) => (
|
||||
<ListboxItem
|
||||
key={service.id}
|
||||
className="p-3 bg-gray-50 data-[hover=true]:bg-gray-100 cursor-default"
|
||||
classNames={{
|
||||
title: "w-full",
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between w-full gap-3">
|
||||
<div className="flex items-center justify-center min-w-8 w-8 h-8 bg-blue-100 text-blue-600 rounded-full text-sm font-semibold">
|
||||
{index + 1}
|
||||
</div>
|
||||
<div className="flex flex-col items-start flex-1 overflow-hidden">
|
||||
<div className="flex gap-1 w-full">
|
||||
<span className="text-danger-500">
|
||||
{service.is_deleted ? t("(Deleted)") : ""}
|
||||
</span>
|
||||
<span className="truncate w-full flex-1">
|
||||
{service.name}
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-xs text-gray-500 truncate w-full">
|
||||
{service.short_description}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="text-lg font-semibold text-gray-900">
|
||||
{service.call_count.toLocaleString()}
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
{t("Calls")}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxItem>
|
||||
)
|
||||
)}
|
||||
</Listbox>
|
||||
) : (
|
||||
<div className="text-center py-8 text-gray-500">
|
||||
{t("No servers available")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleStats;
|
||||
export default ConsoleStats;
|
||||
@@ -15,6 +15,7 @@ interface LoginSettingsContentProps {
|
||||
loginConfig: LoginConfig;
|
||||
saveLoginConfig: (config: LoginConfig) => Promise<boolean>;
|
||||
emailConfig: EmailConfig;
|
||||
type?: "email" | "google";
|
||||
}
|
||||
|
||||
export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
@@ -22,6 +23,7 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
emailConfig,
|
||||
type = "email",
|
||||
}) => {
|
||||
const [googleSubmitLoading, setGoogleSubmitLoading] = useState(false);
|
||||
const [emailSubmitLoading, setEmailSubmitLoading] = useState(false);
|
||||
@@ -83,20 +85,24 @@ export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
return (
|
||||
<div className="space-y-4 w-full">
|
||||
{/* email config */}
|
||||
<EmailConfigForm
|
||||
config={loginConfig}
|
||||
emailConfig={emailConfig}
|
||||
onSave={handleSaveLoginConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
onTabNavigate={onTabNavigate}
|
||||
/>
|
||||
{type === "email" && (
|
||||
<EmailConfigForm
|
||||
config={loginConfig}
|
||||
emailConfig={emailConfig}
|
||||
onSave={handleSaveLoginConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
onTabNavigate={onTabNavigate}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* google auth config */}
|
||||
<GoogleAuthConfigForm
|
||||
config={loginConfig.google}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={googleSubmitLoading}
|
||||
/>
|
||||
{type === "google" && (
|
||||
<GoogleAuthConfigForm
|
||||
config={loginConfig.google}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={googleSubmitLoading}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,156 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState, Suspense } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { useAdminStore } from "@/store/admin";
|
||||
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import ConsoleStats from "@/components/console/ConsoleStats";
|
||||
import PaymentChannelsContent from "@/components/console/PaymentChannelsContent";
|
||||
import SystemSettingsContent from "@/components/console/SystemSettingsContent";
|
||||
import { SidebarItem, TabKey } from "@/shared/types/dashboard";
|
||||
import { useAdminLogin } from "@/hooks/useAdminLogin";
|
||||
import { MCPServicesManagement } from "@/components/mcp-services/MCPServicesManagement";
|
||||
import UserManagement from "@/components/user-management/UserManagement";
|
||||
import RevenueManagement from "@/components/revenue-management/RevenueManagement";
|
||||
import {
|
||||
CreditCard,
|
||||
DollarSign,
|
||||
Home,
|
||||
Settings,
|
||||
Users,
|
||||
ServerIcon,
|
||||
} from "lucide-react";
|
||||
import ConsoleSidebar from "./Sidebar";
|
||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||
import { DollarSign, Home, ServerIcon, Users } from "lucide-react";
|
||||
import OnboardingWelcome, { REQUIRED_TASK_KEYS } from "./OnboardingWelcome";
|
||||
import ConsoleStats from "./ConsoleStats";
|
||||
import SystemSettingsModal from "./SystemSettingsModal";
|
||||
import SharePlatformModal from "./SharePlatformModal";
|
||||
import {
|
||||
OnboardingTaskKey,
|
||||
TaskItem,
|
||||
TaskStatusEnum,
|
||||
updateAdminOnboardingTasks,
|
||||
} from "@/api/onboard.api";
|
||||
|
||||
const ConsoleContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [admin_token] = useAdminStore((state) => [state.admin_token]);
|
||||
|
||||
const _DefaultSubTab = "general";
|
||||
const [admin_token, getAdminUser] = useAdminStore((state) => [
|
||||
state.admin_token,
|
||||
state.getAdminUser,
|
||||
]);
|
||||
|
||||
const getInitialTab = (): TabKey => {
|
||||
const tabFromUrl = searchParams.get("tab") as TabKey;
|
||||
if (
|
||||
tabFromUrl &&
|
||||
[
|
||||
"mcp-services",
|
||||
"user-management",
|
||||
"revenue-management",
|
||||
"payment-channels",
|
||||
"login-settings",
|
||||
"system-settings",
|
||||
].includes(tabFromUrl)
|
||||
["mcp-services", "user-management", "revenue-management"].includes(
|
||||
tabFromUrl
|
||||
)
|
||||
) {
|
||||
return tabFromUrl;
|
||||
}
|
||||
return TabKey.CONSOLE;
|
||||
};
|
||||
|
||||
const getInitialSubTab = (): string | undefined => {
|
||||
const subTabFromUrl = searchParams.get("subtab");
|
||||
return subTabFromUrl || _DefaultSubTab;
|
||||
};
|
||||
|
||||
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
|
||||
const [activeSubTab, setActiveSubTab] = useState<string | undefined>(
|
||||
getInitialSubTab
|
||||
);
|
||||
const isSkipOnboarding =
|
||||
typeof window !== "undefined" &&
|
||||
localStorage.getItem("admin_onboarding_skip") === "1";
|
||||
const [showOnboarding, setShowOnboarding] = useState<boolean>(false);
|
||||
const [completedTasks, setCompletedTasks] = useState<string[]>([]);
|
||||
const [isSettingsModalOpen, setIsSettingsModalOpen] =
|
||||
useState<boolean>(false);
|
||||
const [isShareModalOpen, setIsShareModalOpen] = useState<boolean>(false);
|
||||
const [settingModalKeyword, setSettingModalKeyword] = useState<string>("");
|
||||
const sidebarItems: SidebarItem[] = [
|
||||
{
|
||||
key: TabKey.CONSOLE,
|
||||
icon: <Home size={18} />,
|
||||
label: t("Dashboard"),
|
||||
description: t("Overview and analytics"),
|
||||
label: t("Analytics"),
|
||||
description: t("Analyze platform usage and revenue"),
|
||||
},
|
||||
{
|
||||
key: TabKey.MCP_SERVICES,
|
||||
icon: <ServerIcon size={18} />,
|
||||
label: t("MCP Services"),
|
||||
description: t("Manage MCP services and API tools"),
|
||||
label: t("MCP"),
|
||||
description: t("Manage MCP servers and API tools"),
|
||||
},
|
||||
{
|
||||
key: TabKey.USER_MANAGEMENT,
|
||||
icon: <Users size={18} />,
|
||||
label: t("User Management"),
|
||||
label: t("User"),
|
||||
description: t("Manage registered users"),
|
||||
},
|
||||
{
|
||||
key: TabKey.REVENUE_MANAGEMENT,
|
||||
icon: <DollarSign size={18} />,
|
||||
label: t("Revenue Management"),
|
||||
label: t("Revenue"),
|
||||
description: t("View user recharge history"),
|
||||
},
|
||||
{
|
||||
key: TabKey.PAYMENT_CHANNELS,
|
||||
icon: <CreditCard size={18} />,
|
||||
label: t("Payment Channels"),
|
||||
description: t("Configure payment channels"),
|
||||
},
|
||||
{
|
||||
key: TabKey.SYSTEM_SETTINGS,
|
||||
icon: <Settings size={18} />,
|
||||
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",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// If admin is not logged in, redirect to admin login page
|
||||
useEffect(() => {
|
||||
if (!admin_token) {
|
||||
router.push("/admin");
|
||||
window.location.href =
|
||||
process.env.NEXT_PUBLIC_ADMIN_LOGIN_URL || "/admin";
|
||||
}
|
||||
}, [admin_token, router]);
|
||||
}, [admin_token]);
|
||||
|
||||
const handleTabNavigate = (tab: TabKey, subTab?: string) => {
|
||||
setActiveTab(tab);
|
||||
setActiveSubTab(subTab || _DefaultSubTab);
|
||||
const handleTabNavigate = (tab: TabKey | string, _subTab?: string) => {
|
||||
setActiveTab(tab as TabKey);
|
||||
|
||||
// update url params
|
||||
if (tab === TabKey.CONSOLE) {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
router.push("/console", { scroll: false });
|
||||
window.history.pushState({}, "", "/admin/console");
|
||||
} else {
|
||||
// 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 });
|
||||
window.history.pushState({}, "", `/admin/console?${params.toString()}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -161,6 +113,94 @@ const ConsoleContent: React.FC = () => {
|
||||
adminLogout();
|
||||
};
|
||||
|
||||
const handleSettingsClick = () => {
|
||||
setIsSettingsModalOpen(true);
|
||||
};
|
||||
|
||||
const handleSettingsModalClose = () => {
|
||||
setIsSettingsModalOpen(false);
|
||||
setSettingModalKeyword("");
|
||||
};
|
||||
const initOnboarding = async () => {
|
||||
const res = await getAdminUser();
|
||||
if (!res.success) {
|
||||
adminLogout();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const completedTasks: string[] = (res.data.onboarding_tasks || [])
|
||||
.filter(
|
||||
(task: TaskItem) => task.task_status === TaskStatusEnum.COMPLETED
|
||||
)
|
||||
.map((task: TaskItem) => task.task_id);
|
||||
setCompletedTasks(completedTasks);
|
||||
setShowOnboarding(completedTasks.length !== REQUIRED_TASK_KEYS.length);
|
||||
} catch (e) {
|
||||
// Fallback to show onboarding if localStorage not available
|
||||
setShowOnboarding(false);
|
||||
}
|
||||
};
|
||||
//todo: onboarding
|
||||
// Initialize onboarding state from localStorage
|
||||
useEffect(() => {
|
||||
if (isSkipOnboarding) {
|
||||
setShowOnboarding(false);
|
||||
return;
|
||||
}
|
||||
initOnboarding();
|
||||
}, []);
|
||||
|
||||
const handleSkipOnboarding = () => {
|
||||
localStorage.setItem("admin_onboarding_skip", "1");
|
||||
setShowOnboarding(false);
|
||||
};
|
||||
|
||||
const markTaskAsCompleted = async (taskKey: OnboardingTaskKey) => {
|
||||
// Mark task as completed
|
||||
const next = Array.from(new Set([...completedTasks, taskKey]));
|
||||
setCompletedTasks(next);
|
||||
const result = await updateAdminOnboardingTasks({
|
||||
task_id: taskKey,
|
||||
task_status: TaskStatusEnum.COMPLETED,
|
||||
});
|
||||
if (!result) return;
|
||||
|
||||
if (next.length === REQUIRED_TASK_KEYS.length) {
|
||||
localStorage.setItem("admin_onboarding_skip", "1");
|
||||
setShowOnboarding(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTaskClick = async (taskKey: OnboardingTaskKey) => {
|
||||
switch (taskKey) {
|
||||
case OnboardingTaskKey.PLATFORM_SETUP:
|
||||
setIsSettingsModalOpen(true);
|
||||
await markTaskAsCompleted(taskKey);
|
||||
break;
|
||||
case OnboardingTaskKey.MCP_SERVICES:
|
||||
handleTabNavigate(TabKey.MCP_SERVICES);
|
||||
await markTaskAsCompleted(taskKey);
|
||||
break;
|
||||
case OnboardingTaskKey.REVENUE_MANAGEMENT:
|
||||
setSettingModalKeyword("Payment");
|
||||
setIsSettingsModalOpen(true);
|
||||
await markTaskAsCompleted(taskKey);
|
||||
break;
|
||||
case OnboardingTaskKey.SHARE_PLATFORM:
|
||||
setIsShareModalOpen(true);
|
||||
// 不在这里标记完成,等待实际分享后再标记
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const handleShareComplete = async () => {
|
||||
await markTaskAsCompleted(OnboardingTaskKey.SHARE_PLATFORM);
|
||||
};
|
||||
|
||||
const handleShareModalClose = () => {
|
||||
setIsShareModalOpen(false);
|
||||
};
|
||||
|
||||
// render different content based on activeTab
|
||||
const renderContent = () => {
|
||||
switch (activeTab) {
|
||||
@@ -178,30 +218,24 @@ const ConsoleContent: React.FC = () => {
|
||||
<RevenueManagement />
|
||||
</div>
|
||||
);
|
||||
case TabKey.PAYMENT_CHANNELS:
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t("Payment Channels")}
|
||||
description={t("Configure payment channels")}
|
||||
>
|
||||
<PaymentChannelsContent />
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
case "system-settings":
|
||||
return (
|
||||
<SystemSettingsContent
|
||||
activeSubTab={activeSubTab}
|
||||
subTab={sidebarItems
|
||||
.find((item) => item.key === activeTab)
|
||||
?.subItems?.find((item) => item.key === activeSubTab)}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
return showOnboarding ? (
|
||||
<OnboardingWelcome
|
||||
onSkipOnboarding={handleSkipOnboarding}
|
||||
onTaskClick={handleTaskClick}
|
||||
completedTasks={completedTasks}
|
||||
/>
|
||||
) : (
|
||||
<DashboardDemoContent
|
||||
title={t("Admin Dashboard")}
|
||||
description={t("Platform management and analytics")}
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<span>{t("Analytics")}</span>
|
||||
<span className="text-primary text-lg font-medium">
|
||||
{t("(30 days)")}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
description={t("Analyze platform usage and revenue")}
|
||||
>
|
||||
<ConsoleStats />
|
||||
</DashboardDemoContent>
|
||||
@@ -215,15 +249,33 @@ const ConsoleContent: React.FC = () => {
|
||||
{/* Sidebar */}
|
||||
<ConsoleSidebar
|
||||
activeTab={activeTab}
|
||||
activeSubTab={activeSubTab}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
onLogout={handleLogout}
|
||||
sidebarItems={sidebarItems}
|
||||
onSettingsClick={handleSettingsClick}
|
||||
/>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
|
||||
</div>
|
||||
|
||||
{/* Settings Modal */}
|
||||
{isSettingsModalOpen && (
|
||||
<SystemSettingsModal
|
||||
isOpen={true}
|
||||
onClose={handleSettingsModalClose}
|
||||
keyword={settingModalKeyword}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Share Platform Modal */}
|
||||
{isShareModalOpen && (
|
||||
<SharePlatformModal
|
||||
isOpen={true}
|
||||
onClose={handleShareModalClose}
|
||||
onShareComplete={handleShareComplete}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -244,4 +296,8 @@ const ConsoleMain: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleMain;
|
||||
// Export the base component for direct use
|
||||
export { ConsoleMain as ConsoleMainBase };
|
||||
|
||||
// Export with component injection support
|
||||
export default withComponentInjection("console/Main", ConsoleMain);
|
||||
@@ -0,0 +1,180 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
CheckCircle2,
|
||||
Share2,
|
||||
ArrowRight,
|
||||
Settings,
|
||||
ServerIcon,
|
||||
DollarSign,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardBody,
|
||||
Listbox,
|
||||
ListboxItem,
|
||||
Link,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { OnboardingTaskKey } from "@/api/onboard.api";
|
||||
|
||||
export const REQUIRED_TASK_KEYS = [
|
||||
OnboardingTaskKey.PLATFORM_SETUP,
|
||||
OnboardingTaskKey.MCP_SERVICES,
|
||||
OnboardingTaskKey.REVENUE_MANAGEMENT,
|
||||
OnboardingTaskKey.SHARE_PLATFORM,
|
||||
];
|
||||
interface OnboardingWelcomeProps {
|
||||
onSkipOnboarding: () => void;
|
||||
completedTasks: string[];
|
||||
onTaskClick: (taskKey: OnboardingTaskKey) => void;
|
||||
}
|
||||
const OnboardingWelcome: React.FC<OnboardingWelcomeProps> = ({
|
||||
onSkipOnboarding,
|
||||
completedTasks,
|
||||
onTaskClick,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const [activeTab, setActiveTab] = useState<OnboardingTaskKey | undefined>(
|
||||
REQUIRED_TASK_KEYS.find((task) => !completedTasks.includes(task))
|
||||
);
|
||||
useEffect(() => {
|
||||
setActiveTab(
|
||||
REQUIRED_TASK_KEYS.find((task) => !completedTasks.includes(task))
|
||||
);
|
||||
}, [completedTasks]);
|
||||
|
||||
const tasks = [
|
||||
{
|
||||
key: OnboardingTaskKey.PLATFORM_SETUP,
|
||||
title: t("Configure Platform Settings"),
|
||||
subtitle: t("Set up your platform name, domain, and branding."),
|
||||
icon: <Settings size={18} />,
|
||||
},
|
||||
{
|
||||
key: OnboardingTaskKey.MCP_SERVICES,
|
||||
title: t("Add MCP Services"),
|
||||
subtitle: t("Configure and deploy your first MCP server tools."),
|
||||
icon: <ServerIcon size={18} />,
|
||||
},
|
||||
{
|
||||
key: OnboardingTaskKey.REVENUE_MANAGEMENT,
|
||||
title: t("Configure Payment & Billing"),
|
||||
subtitle: t("Set up payment channels and token pricing."),
|
||||
icon: <DollarSign size={18} />,
|
||||
},
|
||||
{
|
||||
key: OnboardingTaskKey.SHARE_PLATFORM,
|
||||
title: t("Share Your Platform"),
|
||||
subtitle: t("Invite users and promote your MCP platform."),
|
||||
icon: <Share2 size={18} />,
|
||||
},
|
||||
];
|
||||
|
||||
const isTaskCompleted = (taskKey: string) => completedTasks.includes(taskKey);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col items-center justify-center p-6">
|
||||
{/* Header */}
|
||||
<div className="text-center mb-8">
|
||||
<h1 className="text-2xl font-bold text-gray-900 mb-2">
|
||||
{t("Welcome to {{name}}!", {
|
||||
name: platformConfig.name || "your platform",
|
||||
})}
|
||||
</h1>
|
||||
<p className="text-gray-600 text-sm">
|
||||
{t("Let's set up {{name}} to get you started.", {
|
||||
name: platformConfig.name || "your platform",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<Card className="w-full max-w-lg border-1 overflow-visible" shadow="none">
|
||||
<CardBody className="py-0 overflow-y-visible">
|
||||
<Listbox
|
||||
aria-label="Onboarding tasks"
|
||||
className="overflow-visible"
|
||||
classNames={{
|
||||
list: "overflow-visible",
|
||||
}}
|
||||
>
|
||||
{tasks.map((task, index) => (
|
||||
<ListboxItem
|
||||
key={task.key}
|
||||
startContent={
|
||||
<div
|
||||
className={`flex-shrink-0 ${
|
||||
!isTaskCompleted(task.key)
|
||||
? "text-primary"
|
||||
: "text-default-400"
|
||||
}`}
|
||||
>
|
||||
{task.icon}
|
||||
</div>
|
||||
}
|
||||
endContent={
|
||||
isTaskCompleted(task.key) ? (
|
||||
<CheckCircle2
|
||||
size={18}
|
||||
className="text-green-500 flex-shrink-0"
|
||||
/>
|
||||
) : (
|
||||
<ArrowRight
|
||||
size={18}
|
||||
className="text-primary flex-shrink-0 group-data-[hover=true]:translate-x-1 duration-300 ease-in-out"
|
||||
/>
|
||||
)
|
||||
}
|
||||
description={activeTab === task.key ? task.subtitle : undefined}
|
||||
onPress={() => {
|
||||
onTaskClick(task.key);
|
||||
}}
|
||||
className={`py-6 gap-3 ${
|
||||
!isTaskCompleted(task.key)
|
||||
? "data-[hover=true]:opacity-50"
|
||||
: "text-default-500 data-[hover=true]:text-default-500"
|
||||
} ${activeTab === task.key ? "scale-[1.15] border-2 border-primary bg-white px-6 data-[hover=true]:opacity-100 data-[hover=true]:bg-white" : "data-[hover=true]:bg-transparent"}`}
|
||||
classNames={{
|
||||
title: "font-bold text-md",
|
||||
}}
|
||||
showDivider={
|
||||
index !== tasks.length - 1 && activeTab !== task.key
|
||||
}
|
||||
>
|
||||
{task.title}
|
||||
</ListboxItem>
|
||||
))}
|
||||
</Listbox>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
{/* Help Section */}
|
||||
<div className="text-center my-6">
|
||||
<p className="text-xs text-gray-500">
|
||||
{t("Need help getting started? Check out our")}{" "}
|
||||
<Link
|
||||
href="https://discord.gg/cyZfcdCXkW"
|
||||
size="sm"
|
||||
className="font-medium"
|
||||
target="_blank"
|
||||
>
|
||||
{t("Discord Community")}
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Skip Button */}
|
||||
<div className="text-center">
|
||||
<Button onPress={onSkipOnboarding} size="sm" variant="bordered">
|
||||
{t("Skip setup guide")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OnboardingWelcome;
|
||||
@@ -6,7 +6,13 @@ import { AlipayConfigForm } from "../payment/AlipayConfigForm";
|
||||
import { WechatConfigForm } from "../payment/WechatConfigForm";
|
||||
import { usePaymentChannelManagement } from "@/hooks/usePaymentChannelManagement";
|
||||
|
||||
export const PaymentChannelsContent: React.FC = () => {
|
||||
interface PaymentChannelsContentProps {
|
||||
labelPlacement?: "outside" | "inside";
|
||||
}
|
||||
|
||||
export const PaymentChannelsContent: React.FC<PaymentChannelsContentProps> = ({
|
||||
labelPlacement = "inside",
|
||||
}) => {
|
||||
const {
|
||||
stripeConfig,
|
||||
alipayConfig,
|
||||
@@ -30,6 +36,7 @@ export const PaymentChannelsContent: React.FC = () => {
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isStripeSaving}
|
||||
labelPlacement={labelPlacement}
|
||||
/>
|
||||
{/* coming soon */}
|
||||
{/* alipay configuration */}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Link as LinkIcon } from "lucide-react";
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
Button,
|
||||
Image,
|
||||
} from "@nextui-org/react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { FaFacebook } from "react-icons/fa";
|
||||
import { FaLinkedin } from "react-icons/fa6";
|
||||
import { FaXTwitter } from "react-icons/fa6";
|
||||
import { copyToClipboard } from "@/shared/utils/clipboard";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
interface SharePlatformModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onShareComplete: () => void;
|
||||
}
|
||||
|
||||
const SharePlatformModal: React.FC<SharePlatformModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onShareComplete,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
|
||||
const handleCopyLink = async () => {
|
||||
try {
|
||||
const res = await copyToClipboard(window.location.origin);
|
||||
onShareComplete();
|
||||
if (res.success) {
|
||||
toast.success(t("Copied to clipboard"));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to copy link:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSocialShare = (platform: "x" | "facebook" | "linkedin") => {
|
||||
const text = t(
|
||||
`Just launched my first MCP Platform:{{name}} with xpack.ai 🚀
|
||||
Built in minutes, no coding, ready for AI Agents 🤖
|
||||
|
||||
👉Go and try my MCP: {{link}}
|
||||
#MCP #AI #APIs #XPack #AIagents #DevTools`,
|
||||
{
|
||||
name: platformConfig.name,
|
||||
link: window.location.origin,
|
||||
}
|
||||
);
|
||||
let url = "";
|
||||
const shareUrl = encodeURIComponent(window.location.origin);
|
||||
|
||||
switch (platform) {
|
||||
case "x":
|
||||
url = `https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${shareUrl}`;
|
||||
break;
|
||||
case "facebook":
|
||||
url = `https://www.facebook.com/sharer/sharer.php?u=${shareUrl}`;
|
||||
break;
|
||||
case "linkedin":
|
||||
url = `https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`;
|
||||
break;
|
||||
}
|
||||
if (url) {
|
||||
window.open(url, "_blank", "width=600,height=400");
|
||||
onShareComplete();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={onClose} size="xl">
|
||||
<ModalContent>
|
||||
<ModalBody>
|
||||
{/* Header */}
|
||||
<div className="my-6 flex flex-col gap-2 ">
|
||||
<h2 className="text-2xl font-extrabold text-primary md:text-4xl">
|
||||
{t("Your MCP Market is ready.")}
|
||||
</h2>
|
||||
<p className="text-2xl font-bold text-gray-900">
|
||||
{t("Share your MCP to the world")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Preview Card */}
|
||||
<div className="mb-6 rounded-xl border border-gray-200 bg-white p-6">
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-xl font-semibold text-gray-900">
|
||||
{platformConfig.website_title || platformConfig.name}
|
||||
</h3>
|
||||
<p className="text-gray-700">{platformConfig.meta_description}</p>
|
||||
</div>
|
||||
<div className="mt-4 flex items-center gap-2 text-sm text-gray-800">
|
||||
{platformConfig.logo && (
|
||||
<Image
|
||||
src={platformConfig.logo}
|
||||
alt={platformConfig.name}
|
||||
width={20}
|
||||
height={20}
|
||||
/>
|
||||
)}
|
||||
<span className="font-semibold">{platformConfig.name}</span>
|
||||
<span>•</span>
|
||||
<span className="text-gray-600">{window.location.hostname}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex flex-col items-stretch gap-4 sm:flex-row sm:items-center sm:justify-between mb-4">
|
||||
{/* Social buttons */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
onPress={() => handleSocialShare("x")}
|
||||
title={t("Share on X")}
|
||||
isIconOnly
|
||||
size="lg"
|
||||
variant="flat"
|
||||
>
|
||||
<FaXTwitter size={20} />
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => handleSocialShare("facebook")}
|
||||
title={t("Share on Facebook")}
|
||||
isIconOnly
|
||||
size="lg"
|
||||
variant="flat"
|
||||
>
|
||||
<FaFacebook size={20} className="text-primary" />
|
||||
</Button>
|
||||
<Button
|
||||
onPress={() => handleSocialShare("linkedin")}
|
||||
title={t("Share on LinkedIn")}
|
||||
isIconOnly
|
||||
size="lg"
|
||||
variant="flat"
|
||||
>
|
||||
<FaLinkedin size={20} className="text-blue-500" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Copy link button */}
|
||||
<Button
|
||||
onPress={handleCopyLink}
|
||||
size="lg"
|
||||
color="primary"
|
||||
className="gap-1 w-full bg-default-900"
|
||||
>
|
||||
<LinkIcon size={20} />
|
||||
<span className="text-base font-semibold">{t("Copy link")}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default SharePlatformModal;
|
||||
@@ -2,159 +2,112 @@
|
||||
|
||||
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 { Button, Divider, Tooltip } from "@nextui-org/react";
|
||||
import { ExternalLinkIcon, LogOut, Settings } from "lucide-react";
|
||||
import { DashboardSidebarProps } from "@/shared/types/dashboard";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { FaDiscord } from "react-icons/fa";
|
||||
import Link from "next/link";
|
||||
|
||||
const ConsoleSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
interface ConsoleSidebarProps extends DashboardSidebarProps {
|
||||
onSettingsClick?: () => void;
|
||||
}
|
||||
|
||||
const ConsoleSidebar: React.FC<ConsoleSidebarProps> = ({
|
||||
activeTab,
|
||||
activeSubTab,
|
||||
onTabNavigate,
|
||||
onLogout,
|
||||
sidebarItems,
|
||||
onSettingsClick,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSubItemClick = (parentKey: string, subKey: string) => {
|
||||
onTabNavigate?.(parentKey as any, subKey);
|
||||
};
|
||||
// Filter out system settings from sidebar items
|
||||
const filteredSidebarItems = sidebarItems.filter(
|
||||
(item) => item.key !== "system-settings"
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="flex h-screen">
|
||||
{/* Main Sidebar */}
|
||||
<div className="py-2 px-2 w-[70px] overflow-hidden border-r border-divider flex flex-col justify-between">
|
||||
{/* Header */}
|
||||
<div className="mb-6 mt-4 flex flex-col items-center gap-2">
|
||||
<Link href={process.env.NEXT_PUBLIC_DOMAIN || "/"}>
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="max-w-full h-auto max-h-[30px]"
|
||||
/>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
{sidebarItems.map((item) => (
|
||||
<React.Fragment key={item.key}>
|
||||
<Tooltip
|
||||
content={t(item.label)}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
<>
|
||||
<div className="flex h-screen">
|
||||
{/* Main Sidebar */}
|
||||
<div className="py-2 px-4 w-[300px] overflow-hidden border-r border-divider flex flex-col justify-between bg-default-50">
|
||||
{/* Header */}
|
||||
<div className="mb-6 mt-4 flex gap-2 justify-between items-center">
|
||||
<Link href="/" prefetch target="_blank">
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="max-w-full h-[32px] object-contain"
|
||||
/>
|
||||
</Link>
|
||||
<Tooltip content={t("Open in new tab")} closeDelay={0} disableAnimation>
|
||||
<Link
|
||||
href="/"
|
||||
prefetch
|
||||
target="_blank"
|
||||
className="hover:text-primary"
|
||||
>
|
||||
<Button
|
||||
key={item.key}
|
||||
variant={activeTab === item.key ? "flat" : "light"}
|
||||
color={activeTab === item.key ? "primary" : "default"}
|
||||
startContent={item.icon}
|
||||
className="w-full h-auto p-4"
|
||||
onPress={() => onTabNavigate?.(item.key)}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
<ExternalLinkIcon size={18} />
|
||||
</Link>
|
||||
</Tooltip>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Divider className="my-2" />
|
||||
{/* Navigation */}
|
||||
<div className="flex flex-col gap-2 flex-1">
|
||||
{filteredSidebarItems.map((item) => (
|
||||
<Button
|
||||
key={item.key}
|
||||
variant={activeTab === item.key ? "flat" : "light"}
|
||||
color={activeTab === item.key ? "primary" : "default"}
|
||||
startContent={item.icon}
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={() => onTabNavigate?.(item.key)}
|
||||
>
|
||||
{t(item.label)}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Tooltip
|
||||
content={t("Discord")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<div>
|
||||
<Divider className="my-2" />
|
||||
|
||||
<div className="space-y-2">
|
||||
<Button
|
||||
variant="light"
|
||||
startContent={<FaDiscord size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={() => {
|
||||
window.open("https://discord.gg/cyZfcdCXkW", "_blank");
|
||||
}}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
>
|
||||
{t("Discord")}
|
||||
</Button>
|
||||
|
||||
{/* Logout */}
|
||||
<Tooltip
|
||||
content={t("Log Out")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
{/* Settings */}
|
||||
<Button
|
||||
variant="light"
|
||||
startContent={<Settings size={18} />}
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={onSettingsClick}
|
||||
>
|
||||
{t("Settings")}
|
||||
</Button>
|
||||
|
||||
{/* Logout */}
|
||||
<Button
|
||||
variant="light"
|
||||
color="danger"
|
||||
startContent={<LogOut size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
className="w-full h-auto p-4 justify-start"
|
||||
onPress={onLogout}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
>
|
||||
{t("Log Out")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sub Menu Panel */}
|
||||
{(() => {
|
||||
const activeItem = sidebarItems.find((item) => item.key === activeTab);
|
||||
if (!activeItem?.subItems?.length) return null;
|
||||
|
||||
return (
|
||||
<div className="relative bg-content2/50 border-r overflow-hidden w-[240px] p-3">
|
||||
<div className="mb-3 pb-2 border-b">
|
||||
<h4 className="font-medium text-sm text-default-700">
|
||||
{t(activeItem.label)}
|
||||
</h4>
|
||||
<p className="text-xs text-default-500 mt-1">
|
||||
{t(activeItem.description)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1">
|
||||
{activeItem.subItems?.map((subItem) => {
|
||||
const isSubActive = activeSubTab === subItem.key;
|
||||
|
||||
return (
|
||||
<React.Fragment key={subItem.key}>
|
||||
<Button
|
||||
key={subItem.key}
|
||||
variant={isSubActive ? "flat" : "light"}
|
||||
color={isSubActive ? "primary" : "default"}
|
||||
size="sm"
|
||||
className={`w-full justify-start h-auto p-2 text-left ${
|
||||
isSubActive
|
||||
? "bg-primary/10 border border-primary/20"
|
||||
: "hover:bg-default-100"
|
||||
}`}
|
||||
onPress={() =>
|
||||
handleSubItemClick(activeItem.key, subItem.key)
|
||||
}
|
||||
>
|
||||
<div className="flex flex-col items-start w-full">
|
||||
<div className="font-medium text-xs">
|
||||
{t(subItem.label)}
|
||||
</div>
|
||||
{subItem.description && (
|
||||
<div className="text-xs opacity-60 mt-0.5 truncate w-full">
|
||||
{t(subItem.description)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Button>
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
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";
|
||||
|
||||
interface SystemSettingsContentProps {
|
||||
activeSubTab?: string;
|
||||
subTab?: SidebarSubItem;
|
||||
onTabNavigate: (tab: TabKey, subTab?: string) => void;
|
||||
}
|
||||
|
||||
export const SystemSettingsContent: React.FC<SystemSettingsContentProps> = ({
|
||||
activeSubTab,
|
||||
subTab,
|
||||
onTabNavigate,
|
||||
}) => {
|
||||
const { updateClientConfig } = usePlatformConfig();
|
||||
const [isAboutLoading, setIsAboutLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
// platform config
|
||||
platformConfig,
|
||||
platformLoading,
|
||||
savePlatformConfig,
|
||||
|
||||
// admin config
|
||||
adminConfig,
|
||||
adminLoading,
|
||||
saveAdminConfig,
|
||||
|
||||
// email config
|
||||
emailConfig,
|
||||
emailLoading,
|
||||
saveEmailConfig,
|
||||
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// login config
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
} = useSystemConfigManagement();
|
||||
|
||||
// save admin config
|
||||
const handleSaveAdminConfig = async (config: typeof adminConfig) => {
|
||||
await saveAdminConfig(config);
|
||||
};
|
||||
|
||||
// save email config
|
||||
const handleSaveEmailConfig = async (config: typeof emailConfig) => {
|
||||
await saveEmailConfig(config);
|
||||
};
|
||||
|
||||
// save platform config
|
||||
const handleSavePlatformConfig = async (config: typeof platformConfig) => {
|
||||
const result = await savePlatformConfig(config);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: config,
|
||||
});
|
||||
if (config.language !== i18n.language) {
|
||||
i18n.changeLanguage(config.language);
|
||||
}
|
||||
};
|
||||
|
||||
// handle theme change
|
||||
const handleThemeChange = async (theme: Theme) => {
|
||||
const updatedConfig = { ...platformConfig, theme };
|
||||
const result = await savePlatformConfig(updatedConfig, "theme");
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: updatedConfig,
|
||||
});
|
||||
};
|
||||
|
||||
// handle about save
|
||||
const handleAboutSave = async (aboutContent: string) => {
|
||||
setIsAboutLoading(true);
|
||||
const updatedConfig = { ...platformConfig, about_page: aboutContent };
|
||||
const result = await savePlatformConfig(updatedConfig, "about");
|
||||
setIsAboutLoading(false);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: updatedConfig,
|
||||
});
|
||||
};
|
||||
|
||||
// Render content based on active sub tab
|
||||
const renderSubTabContent = () => {
|
||||
switch (activeSubTab) {
|
||||
case "homepage":
|
||||
return <HomepageSettings />;
|
||||
case "about-page":
|
||||
return (
|
||||
<AboutPageSettings
|
||||
config={platformConfig}
|
||||
onAboutSave={handleAboutSave}
|
||||
onImageUpload={uploadImage}
|
||||
isAboutLoading={isAboutLoading}
|
||||
/>
|
||||
);
|
||||
case "email-admin":
|
||||
return (
|
||||
<EmailAndAdminSettings
|
||||
emailConfig={emailConfig}
|
||||
adminConfig={adminConfig}
|
||||
onSaveEmailConfig={handleSaveEmailConfig}
|
||||
onSaveAdminConfig={handleSaveAdminConfig}
|
||||
isLoading={emailLoading}
|
||||
isAdminLoading={adminLoading}
|
||||
/>
|
||||
);
|
||||
case "login-settings":
|
||||
return (
|
||||
<LoginSettingsContent
|
||||
onTabNavigate={onTabNavigate}
|
||||
loginConfig={loginConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
/>
|
||||
);
|
||||
case "general":
|
||||
default:
|
||||
return (
|
||||
<PlatformConfigForm
|
||||
config={platformConfig}
|
||||
onSave={handleSavePlatformConfig}
|
||||
onThemeChange={handleThemeChange}
|
||||
isLoading={platformLoading}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t(subTab?.label || "System Settings")}
|
||||
description={t(subTab?.description || "Platform basic configuration")}
|
||||
>
|
||||
{renderSubTabContent()}
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsContent;
|
||||
@@ -0,0 +1,465 @@
|
||||
"use client";
|
||||
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
ModalHeader,
|
||||
Button,
|
||||
} from "@nextui-org/react";
|
||||
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import SystemSettingsSidebar, {
|
||||
SettingsGroup,
|
||||
SettingsMenuItem,
|
||||
} from "./SystemSettingsSidebar";
|
||||
import {
|
||||
AppWindow,
|
||||
Captions,
|
||||
Code,
|
||||
CreditCard,
|
||||
GhostIcon,
|
||||
GlobeIcon,
|
||||
LockIcon,
|
||||
Mail,
|
||||
Package,
|
||||
Palette,
|
||||
SquareMenu,
|
||||
TableOfContents,
|
||||
Trello,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import SystemSettingsRightContent from "./SystemSettingsRightContent";
|
||||
import { SettingModalTab } from "./console.type";
|
||||
import { useHomepageConfigManagement } from "@/hooks/useHomepageConfigManagement";
|
||||
import { FcGoogle } from "react-icons/fc";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface SystemSettingsModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
keyword?: string;
|
||||
}
|
||||
|
||||
const SystemSettingsModal: React.FC<SystemSettingsModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
keyword,
|
||||
}) => {
|
||||
// Left menu active state
|
||||
const [activeSubTab, setActiveSubTab] = useState<SettingModalTab>(
|
||||
SettingModalTab.BRANDING
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Search state (pure frontend)
|
||||
const [searchQuery, setSearchQuery] = useState<string>(keyword || "");
|
||||
|
||||
// Scroll container and section refs
|
||||
const rightContentRef = useRef<HTMLDivElement | null>(null);
|
||||
const sectionRefs = useRef<Record<string, HTMLElement | null>>({});
|
||||
const titleRefs = useRef<Record<string, HTMLElement | null>>({});
|
||||
const scrollingByClickRef = useRef(false);
|
||||
const activeKeyRef = useRef<SettingModalTab>(SettingModalTab.BRANDING);
|
||||
|
||||
useEffect(() => {
|
||||
activeKeyRef.current = activeSubTab;
|
||||
}, [activeSubTab]);
|
||||
|
||||
// Load and manage config once here to avoid duplicate network calls
|
||||
const { updateClientConfig } = usePlatformConfig();
|
||||
const {
|
||||
// platform config
|
||||
platformConfig,
|
||||
savePlatformConfig,
|
||||
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// login config
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
|
||||
// email config
|
||||
emailConfig,
|
||||
saveEmailConfig,
|
||||
emailLoading,
|
||||
} = useSystemConfigManagement();
|
||||
const {
|
||||
homepageConfig,
|
||||
saveNavigationConfig,
|
||||
saveEmbeddedHtmlConfig,
|
||||
saveFaqConfig,
|
||||
} = useHomepageConfigManagement();
|
||||
|
||||
const handleSavePlatformConfig = async (config: { [key: string]: any }) => {
|
||||
const newConfig = { ...platformConfig, ...config };
|
||||
const result = await savePlatformConfig(newConfig);
|
||||
if (!result) return false;
|
||||
updateClientConfig({ platform: newConfig });
|
||||
return result;
|
||||
};
|
||||
|
||||
const handleThemeChange = async (theme: Theme) => {
|
||||
const updatedConfig = { ...platformConfig, theme };
|
||||
const result = await savePlatformConfig(updatedConfig, "theme");
|
||||
if (!result) return;
|
||||
updateClientConfig({ platform: updatedConfig });
|
||||
};
|
||||
|
||||
const settingsMenuItems: SettingsMenuItem[] = [
|
||||
// General settings
|
||||
|
||||
{
|
||||
key: SettingModalTab.BRANDING,
|
||||
label: "Branding",
|
||||
icon: <Trello size={16} />,
|
||||
description: "Logo, colors, and brand identity",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.TITLE_DESCRIPTION,
|
||||
label: "Title & description",
|
||||
icon: <Captions size={16} />,
|
||||
description: "Configure your site title and description",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.META_DATA,
|
||||
label: "Meta data",
|
||||
icon: <AppWindow size={16} />,
|
||||
description: "Extra content for search engines and social accounts",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.CUSTOM_DOMAIN,
|
||||
label: "Domain",
|
||||
icon: <GhostIcon size={16} />,
|
||||
description: "Configure your custom domain settings",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.PLATFORM_LANGUAGE,
|
||||
label: "Platform Language",
|
||||
icon: <GlobeIcon size={16} />,
|
||||
description: "Configure platform language",
|
||||
},
|
||||
// Site
|
||||
{
|
||||
key: SettingModalTab.THEME,
|
||||
label: "Theme",
|
||||
icon: <Palette size={16} />,
|
||||
description: "Visual theme and appearance settings",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.NAVIGATION,
|
||||
label: "Navigation",
|
||||
icon: <SquareMenu size={16} />,
|
||||
description: "Configure site navigation and menus",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.FAQ,
|
||||
label: "FAQ",
|
||||
icon: <TableOfContents size={16} />,
|
||||
description: "Configure FAQ",
|
||||
},
|
||||
// Business
|
||||
{
|
||||
key: SettingModalTab.PAYMENT,
|
||||
label: "Payment",
|
||||
icon: <CreditCard size={16} />,
|
||||
description: "Configure payment channels",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.XPACK_EXPLORE,
|
||||
label: "XPack Explore",
|
||||
icon: <Package size={16} />,
|
||||
description: "Explore XPack features and integrations",
|
||||
},
|
||||
// Advanced
|
||||
{
|
||||
key: SettingModalTab.SMTP_SETTINGS,
|
||||
label: "Email Configuration",
|
||||
icon: <Mail size={16} />,
|
||||
description: "Configure SMTP settings for email notifications",
|
||||
},
|
||||
|
||||
{
|
||||
key: SettingModalTab.EMAIL_LOGIN_SETTINGS,
|
||||
label: "Email Login Settings",
|
||||
icon: <LockIcon size={16} />,
|
||||
description: "Configure email-based authentication",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.GOOGLE_LOGIN_SETTINGS,
|
||||
label: "Google Login Settings",
|
||||
icon: <FcGoogle size={16} />,
|
||||
description: "Configure Google OAuth integration",
|
||||
},
|
||||
{
|
||||
key: SettingModalTab.CODE_INJECTION,
|
||||
label: "Code injection",
|
||||
icon: <Code size={16} />,
|
||||
description: "Custom code injection and scripts",
|
||||
},
|
||||
// Account
|
||||
{
|
||||
key: SettingModalTab.CHANGE_PASSWORD,
|
||||
label: "Password",
|
||||
icon: <LockIcon size={16} />,
|
||||
description: "Change your password",
|
||||
},
|
||||
];
|
||||
|
||||
// Hierarchical groups for the sidebar
|
||||
const settingsGroups: SettingsGroup[] = useMemo(() => {
|
||||
const mapByKey = Object.fromEntries(
|
||||
settingsMenuItems.map((it) => [it.key, it])
|
||||
);
|
||||
const groupItems = (keys: SettingModalTab[]) =>
|
||||
keys.map((k) => mapByKey[k]).filter(Boolean) as SettingsMenuItem[];
|
||||
return [
|
||||
{
|
||||
key: "general-settings",
|
||||
title: "General settings",
|
||||
items: groupItems([
|
||||
SettingModalTab.BRANDING,
|
||||
SettingModalTab.TITLE_DESCRIPTION,
|
||||
SettingModalTab.META_DATA,
|
||||
SettingModalTab.CUSTOM_DOMAIN,
|
||||
SettingModalTab.PLATFORM_LANGUAGE,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "site",
|
||||
title: "Site",
|
||||
items: groupItems([
|
||||
SettingModalTab.THEME,
|
||||
SettingModalTab.NAVIGATION,
|
||||
SettingModalTab.FAQ,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "business",
|
||||
title: "Business",
|
||||
items: groupItems([
|
||||
SettingModalTab.PAYMENT,
|
||||
SettingModalTab.XPACK_EXPLORE,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "advanced",
|
||||
title: "Advanced",
|
||||
items: groupItems([
|
||||
SettingModalTab.SMTP_SETTINGS,
|
||||
SettingModalTab.EMAIL_LOGIN_SETTINGS,
|
||||
SettingModalTab.GOOGLE_LOGIN_SETTINGS,
|
||||
SettingModalTab.CODE_INJECTION,
|
||||
]),
|
||||
},
|
||||
{
|
||||
key: "account",
|
||||
title: "Account",
|
||||
items: groupItems([SettingModalTab.CHANGE_PASSWORD]),
|
||||
},
|
||||
];
|
||||
}, []);
|
||||
|
||||
// Filter keys by search (pure frontend)
|
||||
const filteredKeys = useMemo(() => {
|
||||
const q = searchQuery.trim().toLowerCase();
|
||||
if (!q) return settingsMenuItems.map((it) => it.key);
|
||||
return settingsMenuItems
|
||||
.filter(
|
||||
(it) =>
|
||||
t(it.label).toLowerCase().includes(q) ||
|
||||
t(it.description || "")
|
||||
?.toLowerCase()
|
||||
.includes(q)
|
||||
)
|
||||
.map((it) => it.key);
|
||||
}, [searchQuery]);
|
||||
|
||||
// Optimized scroll to section function
|
||||
const scrollToSection = useCallback((key: SettingModalTab) => {
|
||||
const container = rightContentRef.current;
|
||||
const el = titleRefs.current[key];
|
||||
if (!container || !el) return;
|
||||
|
||||
// Prevent multiple rapid calls
|
||||
if (scrollingByClickRef.current) return;
|
||||
|
||||
const containerRect = container.getBoundingClientRect();
|
||||
const elRect = el.getBoundingClientRect();
|
||||
// scroll so that the title is aligned near the top of the container viewport
|
||||
const TOP_OFFSET = 16; // small padding
|
||||
const offset =
|
||||
elRect.top - containerRect.top + container.scrollTop - TOP_OFFSET;
|
||||
|
||||
scrollingByClickRef.current = true;
|
||||
setActiveSubTab(key);
|
||||
|
||||
// Use CSS-based scroll with better performance
|
||||
const prevBehavior = container.style.scrollBehavior;
|
||||
container.style.scrollBehavior = "smooth";
|
||||
container.scrollTo({ top: Math.max(0, offset) });
|
||||
|
||||
// Reset scroll behavior and stop suppressing after animation completes
|
||||
window.setTimeout(() => {
|
||||
if (container) {
|
||||
container.style.scrollBehavior = prevBehavior || "auto";
|
||||
}
|
||||
scrollingByClickRef.current = false;
|
||||
}, 400);
|
||||
}, []);
|
||||
|
||||
// Scroll-based scrollspy using rAF to avoid IO jitter
|
||||
useEffect(() => {
|
||||
const container = rightContentRef.current;
|
||||
if (!container || !isOpen) return;
|
||||
|
||||
let ticking = false;
|
||||
|
||||
const computeActive = () => {
|
||||
if (!container) return;
|
||||
const keys = filteredKeys;
|
||||
const rect = container.getBoundingClientRect();
|
||||
const containerTop = rect.top;
|
||||
const TOP_OFFSET = 16;
|
||||
|
||||
const scrollTop = container.scrollTop;
|
||||
const scrollHeight = container.scrollHeight;
|
||||
const containerHeight = container.clientHeight;
|
||||
|
||||
// Bottom stickiness
|
||||
if (scrollTop + containerHeight >= scrollHeight - 2) {
|
||||
const lastKey = keys[keys.length - 1];
|
||||
if (lastKey && activeKeyRef.current !== lastKey) {
|
||||
setActiveSubTab(lastKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine the last section whose title top is above the top + offset
|
||||
let currentKey: SettingModalTab | null = null;
|
||||
for (const k of keys) {
|
||||
const el = titleRefs.current[k];
|
||||
if (!el) continue;
|
||||
const r = el.getBoundingClientRect();
|
||||
if (r.top - containerTop <= TOP_OFFSET + 1) {
|
||||
currentKey = k;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentKey) {
|
||||
const firstKey = keys[0];
|
||||
if (firstKey && activeKeyRef.current !== firstKey) {
|
||||
setActiveSubTab(firstKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentKey && activeKeyRef.current !== currentKey) {
|
||||
setActiveSubTab(currentKey);
|
||||
}
|
||||
};
|
||||
|
||||
const onScroll = () => {
|
||||
if (scrollingByClickRef.current) return;
|
||||
if (!ticking) {
|
||||
ticking = true;
|
||||
requestAnimationFrame(() => {
|
||||
computeActive();
|
||||
ticking = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Initial compute and bind listeners
|
||||
computeActive();
|
||||
container.addEventListener("scroll", onScroll, { passive: true });
|
||||
|
||||
return () => {
|
||||
container.removeEventListener("scroll", onScroll);
|
||||
};
|
||||
}, [isOpen, filteredKeys]);
|
||||
|
||||
// When searching, auto-jump to first matched section
|
||||
useEffect(() => {
|
||||
if (!searchQuery.trim()) return;
|
||||
if (filteredKeys.length > 0) {
|
||||
const firstKey = filteredKeys[0];
|
||||
if (firstKey !== activeSubTab) {
|
||||
scrollToSection(firstKey);
|
||||
}
|
||||
}
|
||||
}, [searchQuery]); // Only depend on searchQuery, not filteredKeys
|
||||
|
||||
return (
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
size="full"
|
||||
classNames={{
|
||||
base: "h-screen !max-w-none !w-screen p-0",
|
||||
body: "flex-1 overflow-hidden",
|
||||
}}
|
||||
isDismissable={false}
|
||||
hideCloseButton={true}
|
||||
>
|
||||
<ModalContent>
|
||||
<ModalHeader className="flex justify-between border-b border-default">
|
||||
<h2 className="text-2xl font-bold">{t("System Settings")}</h2>
|
||||
<Button onPress={onClose} isIconOnly size="sm" variant="light">
|
||||
<XIcon size={24} className="text-gray-500" />
|
||||
</Button>
|
||||
</ModalHeader>
|
||||
<ModalBody className="p-0">
|
||||
<div className="flex h-full">
|
||||
{/* Left Navigation */}
|
||||
<SystemSettingsSidebar
|
||||
activeKey={activeSubTab}
|
||||
onSelect={scrollToSection}
|
||||
searchQuery={searchQuery}
|
||||
onSearchChange={setSearchQuery}
|
||||
groups={settingsGroups}
|
||||
filteredKeys={filteredKeys}
|
||||
/>
|
||||
|
||||
{/* Right Content: stacked sections with anchors */}
|
||||
<div className="flex-1">
|
||||
<SystemSettingsRightContent
|
||||
filteredKeys={filteredKeys}
|
||||
settingsMenuItems={settingsMenuItems}
|
||||
platformConfig={platformConfig}
|
||||
homepageConfig={homepageConfig}
|
||||
onSaveEmbeddedHtml={saveEmbeddedHtmlConfig}
|
||||
sectionRefs={sectionRefs}
|
||||
titleRefs={titleRefs}
|
||||
onSavePlatformConfig={handleSavePlatformConfig}
|
||||
handleThemeChange={handleThemeChange}
|
||||
uploadImage={uploadImage}
|
||||
scrollContainerRef={rightContentRef}
|
||||
saveNavigationConfig={saveNavigationConfig}
|
||||
saveFaqConfig={saveFaqConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
loginConfig={loginConfig}
|
||||
onSaveEmailConfig={saveEmailConfig}
|
||||
emailSubmitLoading={emailLoading}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsModal;
|
||||
@@ -0,0 +1,243 @@
|
||||
"use client";
|
||||
|
||||
import React, { useMemo } from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import {
|
||||
EmbeddedHtmlConfig,
|
||||
FaqItem,
|
||||
LoginConfig,
|
||||
PlatformConfig,
|
||||
Theme,
|
||||
TopNavigationItem,
|
||||
} from "@/shared/types/system";
|
||||
import { SettingsMenuItem } from "./SystemSettingsSidebar";
|
||||
import TitleAndDescPanel, {
|
||||
TitleAndDescPanelConfig,
|
||||
} from "./system-setting/TitleAndDescPanel";
|
||||
import MetaDataPanel from "./system-setting/MetaDataPanel";
|
||||
import BrandPanel, { BrandPanelConfig } from "./system-setting/BrandPanel";
|
||||
import { ThemeSelector } from "@/components/system-setting/ThemeSelector";
|
||||
import { TopNavigationSettings } from "@/components/system-setting/TopNavigationSettings";
|
||||
import { EmbeddedHtmlSettings } from "@/components/system-setting/EmbeddedHtmlSettings";
|
||||
import { ExplorePanel } from "./system-setting/ExplorePanel";
|
||||
import DomainPanel from "./system-setting/DomainPanel";
|
||||
import PaymentChannelsContent from "@/components/console/PaymentChannelsContent";
|
||||
import { HomepageConfig } from "@/services/homepageConfigService";
|
||||
import { FaqSettings } from "@/components/system-setting/FaqSettings";
|
||||
import { AdminConfigForm } from "./AdminConfigForm";
|
||||
import { systemConfigService } from "@/services/systemConfigService";
|
||||
import { md5Encrypt } from "@/shared/utils/crypto";
|
||||
import { AdminConfig, EmailConfig } from "@/types/system";
|
||||
import { LoginSettingsContent } from "./LoginSettingsContent";
|
||||
import { EmailConfigForm } from "@/components/system-setting/EmailConfigForm";
|
||||
import { LanguageSetting } from "@/components/system-setting/LanguageSetting";
|
||||
|
||||
interface SystemSettingsRightContentProps {
|
||||
filteredKeys: string[];
|
||||
settingsMenuItems: SettingsMenuItem[];
|
||||
platformConfig: PlatformConfig;
|
||||
homepageConfig: HomepageConfig;
|
||||
sectionRefs: React.MutableRefObject<Record<string, HTMLElement | null>>;
|
||||
titleRefs: React.MutableRefObject<Record<string, HTMLElement | null>>; // New: refs for section titles
|
||||
onSavePlatformConfig: (config: { [key: string]: any }) => Promise<boolean>;
|
||||
onSaveEmbeddedHtml: (config: EmbeddedHtmlConfig) => Promise<boolean>;
|
||||
handleThemeChange: (theme: Theme) => Promise<void>;
|
||||
uploadImage: any;
|
||||
scrollContainerRef?: React.RefObject<HTMLDivElement>;
|
||||
saveNavigationConfig: (config: TopNavigationItem[]) => Promise<boolean>;
|
||||
saveFaqConfig: (config: FaqItem[]) => Promise<boolean>;
|
||||
saveLoginConfig: (config: LoginConfig) => Promise<boolean>;
|
||||
emailConfig: EmailConfig;
|
||||
loginConfig: LoginConfig;
|
||||
onSaveEmailConfig: (config: EmailConfig) => Promise<boolean>;
|
||||
emailSubmitLoading: boolean;
|
||||
}
|
||||
|
||||
const SystemSettingsRightContent: React.FC<SystemSettingsRightContentProps> = ({
|
||||
filteredKeys,
|
||||
settingsMenuItems,
|
||||
platformConfig,
|
||||
homepageConfig,
|
||||
onSaveEmbeddedHtml,
|
||||
sectionRefs,
|
||||
titleRefs, // New prop
|
||||
onSavePlatformConfig,
|
||||
handleThemeChange,
|
||||
uploadImage,
|
||||
scrollContainerRef,
|
||||
saveNavigationConfig,
|
||||
saveFaqConfig,
|
||||
saveLoginConfig,
|
||||
emailConfig,
|
||||
loginConfig,
|
||||
onSaveEmailConfig,
|
||||
emailSubmitLoading,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const menuItems = useMemo(() => {
|
||||
return settingsMenuItems.filter((it) => filteredKeys.includes(it.key));
|
||||
}, [settingsMenuItems, filteredKeys]);
|
||||
const handleChangePassword = async (config: AdminConfig) => {
|
||||
const result = await systemConfigService.updateSystemConfig(
|
||||
{
|
||||
account: {
|
||||
...config,
|
||||
password: md5Encrypt(config.password),
|
||||
},
|
||||
},
|
||||
"password"
|
||||
);
|
||||
return result;
|
||||
};
|
||||
return (
|
||||
<div
|
||||
ref={scrollContainerRef}
|
||||
className="flex-1 overflow-y-auto h-full pb-40 space-y-6"
|
||||
style={{ scrollBehavior: "auto" }}
|
||||
>
|
||||
<div className="h-0" aria-hidden="true"></div>
|
||||
{menuItems.map((section) => (
|
||||
<>
|
||||
<section
|
||||
key={section.key}
|
||||
ref={(el) => {
|
||||
if (el) sectionRefs.current[section.key] = el;
|
||||
}}
|
||||
id={`section-${section.key}`}
|
||||
className="px-6 py-6 scroll-mt-16 border-1 rounded-lg shadow-md max-w-2xl mx-auto"
|
||||
>
|
||||
<div className="mb-4">
|
||||
<h2
|
||||
className="text-xl font-semibold"
|
||||
ref={(el) => {
|
||||
if (el) titleRefs.current[section.key] = el;
|
||||
}}
|
||||
id={`title-${section.key}`}
|
||||
>
|
||||
{t(section.label)}
|
||||
</h2>
|
||||
<p className="text-sm text-default-500">
|
||||
{t(section.description || "")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Content sections */}
|
||||
{section.key === "title-description" && (
|
||||
<TitleAndDescPanel
|
||||
config={platformConfig as TitleAndDescPanelConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "meta-data" && (
|
||||
<MetaDataPanel
|
||||
metaData={platformConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
uploadImage={uploadImage}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "custom-domain" && (
|
||||
<div className="space-y-4">
|
||||
<DomainPanel
|
||||
config={platformConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{section.key === "platform-language" && (
|
||||
<LanguageSetting
|
||||
config={platformConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "branding" && (
|
||||
<BrandPanel
|
||||
config={platformConfig as BrandPanelConfig}
|
||||
onSave={onSavePlatformConfig}
|
||||
onUploadImage={uploadImage}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "theme" && (
|
||||
<ThemeSelector
|
||||
value={platformConfig.theme || Theme.DEFAULT}
|
||||
onChange={handleThemeChange}
|
||||
/>
|
||||
)}
|
||||
{section.key === "smtp-settings" && (
|
||||
<EmailConfigForm
|
||||
config={emailConfig}
|
||||
onSave={onSaveEmailConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "email-login-settings" && (
|
||||
<LoginSettingsContent
|
||||
loginConfig={loginConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
type="email"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "google-login-settings" && (
|
||||
<LoginSettingsContent
|
||||
loginConfig={loginConfig}
|
||||
saveLoginConfig={saveLoginConfig}
|
||||
emailConfig={emailConfig}
|
||||
type="google"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "navigation" && (
|
||||
<TopNavigationSettings
|
||||
onSave={saveNavigationConfig}
|
||||
config={homepageConfig.top_navigation}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "faq" && (
|
||||
<FaqSettings
|
||||
onSave={saveFaqConfig}
|
||||
config={homepageConfig.faq}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "payment" && (
|
||||
<PaymentChannelsContent labelPlacement="outside" />
|
||||
)}
|
||||
|
||||
{section.key === "xpack-explore" && (
|
||||
<ExplorePanel
|
||||
isEnabled={!!platformConfig.is_showcased}
|
||||
onSave={onSavePlatformConfig}
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "code-injection" && (
|
||||
<EmbeddedHtmlSettings
|
||||
onSave={onSaveEmbeddedHtml}
|
||||
config={homepageConfig.embeded_html}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
|
||||
{section.key === "change-password" && (
|
||||
<AdminConfigForm onSave={handleChangePassword} />
|
||||
)}
|
||||
</section>
|
||||
</>
|
||||
))}
|
||||
{/* Bottom spacer to allow last sections to scroll higher into view for better selection */}
|
||||
<div className="h-40" aria-hidden="true" />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsRightContent;
|
||||
@@ -0,0 +1,157 @@
|
||||
"use client";
|
||||
|
||||
import React, { useMemo, useRef, useEffect } from "react";
|
||||
import { Input, Button, ScrollShadow } from "@nextui-org/react";
|
||||
import { Search } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { SettingModalTab } from "./console.type";
|
||||
|
||||
export interface SettingsMenuItem {
|
||||
key: SettingModalTab;
|
||||
label: string;
|
||||
description?: string;
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface SettingsGroup {
|
||||
key: string;
|
||||
title: string;
|
||||
items: SettingsMenuItem[];
|
||||
}
|
||||
|
||||
interface Props {
|
||||
activeKey: SettingModalTab;
|
||||
onSelect: (key: SettingModalTab) => void;
|
||||
searchQuery: string;
|
||||
onSearchChange: (val: string) => void;
|
||||
groups: SettingsGroup[];
|
||||
filteredKeys: SettingModalTab[]; // which item keys match the current search
|
||||
}
|
||||
|
||||
const SystemSettingsSidebar: React.FC<Props> = ({
|
||||
activeKey,
|
||||
onSelect,
|
||||
searchQuery,
|
||||
onSearchChange,
|
||||
groups,
|
||||
filteredKeys,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const sidebarScrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const activeItemRefs = useRef<Record<string, HTMLButtonElement | null>>({});
|
||||
|
||||
// filter groups based on filteredKeys
|
||||
const visibleGroups = useMemo(() => {
|
||||
const keySet = new Set(filteredKeys);
|
||||
return groups
|
||||
.map((g) => ({
|
||||
...g,
|
||||
items: g.items.filter((it) => keySet.has(it.key)),
|
||||
}))
|
||||
.filter((g) => g.items.length > 0);
|
||||
}, [groups, filteredKeys]);
|
||||
|
||||
const hasResults = visibleGroups.length > 0;
|
||||
|
||||
// Auto-scroll to active item when activeKey changes
|
||||
useEffect(() => {
|
||||
const activeElement = activeItemRefs.current[activeKey];
|
||||
const scrollContainer = sidebarScrollRef.current;
|
||||
|
||||
if (activeElement && scrollContainer) {
|
||||
// Get the scroll container element (ScrollShadow wraps content)
|
||||
const scrollElement =
|
||||
(scrollContainer.querySelector(
|
||||
'[data-scrollable="true"]'
|
||||
) as HTMLElement) || scrollContainer;
|
||||
|
||||
const containerRect = scrollElement.getBoundingClientRect();
|
||||
const elementRect = activeElement.getBoundingClientRect();
|
||||
|
||||
// Check if element is visible in container
|
||||
const isElementVisible =
|
||||
elementRect.top >= containerRect.top &&
|
||||
elementRect.bottom <= containerRect.bottom;
|
||||
|
||||
if (!isElementVisible) {
|
||||
// Calculate scroll position to center the active item
|
||||
const containerHeight = containerRect.height;
|
||||
const elementTop = activeElement.offsetTop;
|
||||
const elementHeight = activeElement.offsetHeight;
|
||||
const scrollTop = elementTop - containerHeight / 2 + elementHeight / 2;
|
||||
|
||||
scrollElement.scrollTo({
|
||||
top: Math.max(0, scrollTop),
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [activeKey]);
|
||||
|
||||
return (
|
||||
<ScrollShadow
|
||||
ref={sidebarScrollRef}
|
||||
className="w-[300px] border-r border-divider bg-content1/50 scrollbar-thin"
|
||||
>
|
||||
<div className="p-4 space-y-4">
|
||||
<Input
|
||||
size="sm"
|
||||
aria-label={t("Search settings")}
|
||||
placeholder={t("Search settings")}
|
||||
value={searchQuery}
|
||||
onValueChange={onSearchChange}
|
||||
startContent={<Search size={16} className="text-default-400" />}
|
||||
isClearable
|
||||
onClear={() => onSearchChange("")}
|
||||
/>
|
||||
|
||||
{!hasResults ? (
|
||||
<div className="text-xs text-default-400 px-1 py-2">
|
||||
{t("No results")}
|
||||
</div>
|
||||
) : (
|
||||
<nav className="space-y-6">
|
||||
{visibleGroups.map((group) => (
|
||||
<div key={group.key} className="space-y-1">
|
||||
<div className="px-2 text-[11px] tracking-wide text-default-400">
|
||||
{t(group.title)}
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
{group.items.map((item) => {
|
||||
const isActive = activeKey === item.key;
|
||||
return (
|
||||
<Button
|
||||
key={item.key}
|
||||
ref={(el) => {
|
||||
if (el) activeItemRefs.current[item.key] = el;
|
||||
}}
|
||||
variant={isActive ? "flat" : "light"}
|
||||
color={isActive ? "primary" : "default"}
|
||||
size="sm"
|
||||
className={`w-full border-1 justify-start h-auto py-3 px-3 text-left rounded-md ${
|
||||
isActive
|
||||
? "bg-primary/10 border-primary/20"
|
||||
: "hover:bg-default-100 border-transparent"
|
||||
}`}
|
||||
onPress={() => onSelect(item.key)}
|
||||
startContent={item.icon}
|
||||
>
|
||||
<div className="flex flex-col items-start w-full">
|
||||
<div className="font-medium text-sm">
|
||||
{t(item.label)}
|
||||
</div>
|
||||
</div>
|
||||
</Button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</nav>
|
||||
)}
|
||||
</div>
|
||||
</ScrollShadow>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsSidebar;
|
||||
@@ -0,0 +1,17 @@
|
||||
export enum SettingModalTab {
|
||||
TITLE_DESCRIPTION = "title-description",
|
||||
META_DATA = "meta-data",
|
||||
CUSTOM_DOMAIN = "custom-domain",
|
||||
BRANDING = "branding",
|
||||
THEME = "theme",
|
||||
PAYMENT = "payment",
|
||||
CODE_INJECTION = "code-injection",
|
||||
XPACK_EXPLORE = "xpack-explore",
|
||||
NAVIGATION = "navigation",
|
||||
FAQ = "faq",
|
||||
CHANGE_PASSWORD = "change-password",
|
||||
EMAIL_LOGIN_SETTINGS = "email-login-settings",
|
||||
GOOGLE_LOGIN_SETTINGS = "google-login-settings",
|
||||
SMTP_SETTINGS = "smtp-settings",
|
||||
PLATFORM_LANGUAGE = "platform-language",
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { Input, Card, CardBody } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface CustomDomainPanelProps {
|
||||
domain: string;
|
||||
setDomain: (domain: string) => void;
|
||||
}
|
||||
|
||||
const CustomDomainPanel: React.FC<CustomDomainPanelProps> = ({
|
||||
domain,
|
||||
setDomain,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [validationError, setValidationError] = useState<string | undefined>();
|
||||
|
||||
// Validate domain URL
|
||||
const validateDomain = (value: string): string | undefined => {
|
||||
if (!value.trim()) {
|
||||
return undefined; // Domain is optional
|
||||
}
|
||||
|
||||
// Basic domain format validation ,like www.example.com
|
||||
const domainRegex =
|
||||
/(?=.{1,255}$)(?:(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,}/;
|
||||
if (!domainRegex.test(value)) {
|
||||
return t("Please enter a valid domain");
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const handleBlur = () => {
|
||||
const error = validateDomain(domain);
|
||||
setValidationError(error);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card shadow="none">
|
||||
<CardBody className="flex flex-col p-0">
|
||||
<h3 className="font-semibold mb-2">
|
||||
{"1. "}
|
||||
{t("Enter the domain you want to use")}
|
||||
</h3>
|
||||
|
||||
<Input
|
||||
label={t("Domain")}
|
||||
placeholder={t("Enter your full domain name (e.g., www.example.com)")}
|
||||
value={domain}
|
||||
onChange={(e) => setDomain(e.target.value)}
|
||||
onBlur={handleBlur}
|
||||
isInvalid={!!validationError}
|
||||
errorMessage={validationError}
|
||||
/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomDomainPanel;
|
||||
@@ -0,0 +1,66 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
Table,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface DNSRecordsPanelProps {
|
||||
cnameTarget: string; // e.g., subdomain.domainhost.com
|
||||
apexATarget?: string; // optional A record IP for apex
|
||||
}
|
||||
|
||||
type DnsRow = { key: string; type: string; host: string; value: string };
|
||||
|
||||
const DNSRecordsPanel: React.FC<DNSRecordsPanelProps> = ({
|
||||
cnameTarget,
|
||||
apexATarget,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const rows: DnsRow[] = [
|
||||
...(cnameTarget
|
||||
? [{ key: "cname", type: "CNAME", host: "www", value: cnameTarget }]
|
||||
: []),
|
||||
...(apexATarget
|
||||
? [{ key: "a-record", type: "A", host: "@", value: apexATarget }]
|
||||
: []),
|
||||
];
|
||||
|
||||
return (
|
||||
<Card shadow="none">
|
||||
<CardBody className="p-0 flex flex-col gap-2">
|
||||
<h3 className="font-semibold mb-2">
|
||||
{"2. "}
|
||||
{t("Create your DNS records")}
|
||||
</h3>
|
||||
<Table aria-label={t("DNS Records Table")} shadow="none" removeWrapper>
|
||||
<TableHeader>
|
||||
<TableColumn>{t("Type")}</TableColumn>
|
||||
<TableColumn>{t("Host")}</TableColumn>
|
||||
<TableColumn>{t("Value")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody items={rows}>
|
||||
{(item) => (
|
||||
<TableRow key={item.key}>
|
||||
<TableCell>{item.type}</TableCell>
|
||||
<TableCell>{item.host}</TableCell>
|
||||
<TableCell>{item.value}</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default DNSRecordsPanel;
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalBody,
|
||||
ModalHeader,
|
||||
Card,
|
||||
CardBody,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import CustomDomainPanel from "./CustomDomainPanel";
|
||||
import DNSRecordsPanel from "./DNSRecordsPanel";
|
||||
|
||||
export type DomainActivationPanelConfig = {
|
||||
domain?: string;
|
||||
subdomain?: string;
|
||||
cname_a_ip?: string;
|
||||
};
|
||||
|
||||
interface DomainActivationPanelProps {
|
||||
config: DomainActivationPanelConfig;
|
||||
onSave: (config: DomainActivationPanelConfig) => void;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const DomainActivationPanel: React.FC<DomainActivationPanelProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
isOpen,
|
||||
onClose,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [domain, setDomain] = useState(config.domain || "");
|
||||
const handleActivate = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await onSave({
|
||||
domain,
|
||||
});
|
||||
onClose();
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal isOpen={isOpen} onClose={onClose} size="xl">
|
||||
<ModalContent>
|
||||
<ModalHeader>{t("Set Custom Domain")}</ModalHeader>
|
||||
<ModalBody className="flex flex-col gap-4">
|
||||
<CustomDomainPanel domain={domain} setDomain={setDomain} />
|
||||
<DNSRecordsPanel
|
||||
cnameTarget={`${config.subdomain || ""}${process.env.NEXT_PUBLIC_DOMAIN_HOST || ""}`}
|
||||
apexATarget={config.cname_a_ip}
|
||||
/>
|
||||
<Card shadow="none">
|
||||
<CardBody className="p-0 flex flex-col gap-2 pb-4">
|
||||
<h3 className="font-semibold mb-2">
|
||||
{"3. "}
|
||||
{t("Activate your domain")}
|
||||
</h3>
|
||||
<Button
|
||||
color="primary"
|
||||
isDisabled={!domain}
|
||||
isLoading={isLoading}
|
||||
onPress={handleActivate}
|
||||
size="sm"
|
||||
>
|
||||
{t("Activate")}
|
||||
</Button>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</ModalBody>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DomainActivationPanel;
|
||||
@@ -0,0 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import UploadImage from "@/components/common/UploadImage";
|
||||
|
||||
export type BrandPanelConfig = {
|
||||
logo: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
const brandPanelSchema = z.object({
|
||||
logo: z.string(),
|
||||
name: z.string().min(1, "Name is required"),
|
||||
});
|
||||
|
||||
interface BrandPanelProps {
|
||||
config: BrandPanelConfig;
|
||||
onSave: (config: BrandPanelConfig) => Promise<boolean>;
|
||||
onUploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
}
|
||||
|
||||
const BrandPanel: React.FC<BrandPanelProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onUploadImage,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<BrandPanelConfig>({
|
||||
resolver: zodResolver(brandPanelSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: config,
|
||||
});
|
||||
useEffect(() => {
|
||||
setValue("name", config.name);
|
||||
setValue("logo", config.logo);
|
||||
}, [config]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
<form onSubmit={handleSubmit(onSave)} className="flex flex-col gap-4">
|
||||
<Controller
|
||||
name="name"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<>
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Your brand")}
|
||||
placeholder={t("Enter your brand name")}
|
||||
isInvalid={!!errors.name}
|
||||
errorMessage={errors.name?.message}
|
||||
labelPlacement="outside"
|
||||
isRequired
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="logo"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-foreground">
|
||||
{t("Logo")}
|
||||
</label>
|
||||
<p className="text-xs text-gray-500">
|
||||
{t("Support JPG, PNG, GIF, SVG. Max size 5MB")}
|
||||
</p>
|
||||
</div>
|
||||
<UploadImage
|
||||
onSave={onUploadImage}
|
||||
setImageUrl={(imageUrl) => field.onChange(imageUrl)}
|
||||
imageUrl={field.value}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
type="submit"
|
||||
isLoading={isSubmitting}
|
||||
size="sm"
|
||||
isDisabled={!isValid}
|
||||
className="mt-2 w-fit"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default BrandPanel;
|
||||
@@ -0,0 +1,70 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EditIcon } from "lucide-react";
|
||||
import DomainActivationPanel from "../custom-domain/DomainActivationPanel";
|
||||
|
||||
export type DomainPanelConfig = {
|
||||
subdomain?: string;
|
||||
domain?: string;
|
||||
cname_a_ip?: string;
|
||||
};
|
||||
|
||||
interface DomainPanelProps {
|
||||
config: DomainPanelConfig;
|
||||
onSave: (config: DomainPanelConfig) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const DomainPanel: React.FC<DomainPanelProps> = ({ config, onSave }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [formData, setFormData] = useState<DomainPanelConfig>(config);
|
||||
const [showCustomDomainModal, setShowCustomDomainModal] = useState(false);
|
||||
// when context config updated, sync to form
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleCustomDomainSave = async (config: DomainPanelConfig) => {
|
||||
const result = await onSave(config);
|
||||
if (!result) return;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">{t("Custom Domain")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{formData.domain || t("Set your custom domain for the platform")}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
onPress={() => setShowCustomDomainModal(true)}
|
||||
isIconOnly
|
||||
startContent={<EditIcon size={16} />}
|
||||
variant="flat"
|
||||
></Button>
|
||||
</div>
|
||||
</div>
|
||||
{showCustomDomainModal && (
|
||||
<DomainActivationPanel
|
||||
config={{
|
||||
subdomain: formData.subdomain,
|
||||
domain: formData.domain,
|
||||
cname_a_ip: config.cname_a_ip,
|
||||
}}
|
||||
onSave={handleCustomDomainSave}
|
||||
isOpen={showCustomDomainModal}
|
||||
onClose={() => setShowCustomDomainModal(false)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DomainPanel;
|
||||
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Switch } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
export type ExplorePanelConfig = {
|
||||
is_showcased: boolean;
|
||||
};
|
||||
|
||||
interface ExplorePanelProps {
|
||||
isEnabled: boolean;
|
||||
onSave: (config: ExplorePanelConfig) => void;
|
||||
}
|
||||
|
||||
export const ExplorePanel: React.FC<ExplorePanelProps> = ({
|
||||
isEnabled,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* showcase in xpack */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Featured in the XPack showcase")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t(
|
||||
"Enable this option to feature your site in the XPack global showcase and reach users worldwide."
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={isEnabled}
|
||||
onValueChange={(value) => {
|
||||
onSave({
|
||||
is_showcased: value,
|
||||
});
|
||||
}}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Button, Card, CardBody, Input } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import UploadImage from "@/components/common/UploadImage";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { FaFacebook } from "react-icons/fa6";
|
||||
|
||||
export interface FacebookMetaData {
|
||||
facebook_title: string;
|
||||
facebook_description: string;
|
||||
facebook_image_url?: string;
|
||||
}
|
||||
|
||||
const formSchema = z.object({
|
||||
facebook_title: z
|
||||
.string()
|
||||
.max(200, "Title is too long")
|
||||
.optional()
|
||||
.default(""),
|
||||
facebook_description: z
|
||||
.string()
|
||||
.max(1000, "Description is too long")
|
||||
.optional()
|
||||
.default(""),
|
||||
facebook_image_url: z.string().optional().or(z.literal("")).default(""),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface MetaDataFacebookFormProps {
|
||||
metaData: FacebookMetaData;
|
||||
onSave: (metaData: FacebookMetaData) => Promise<boolean>;
|
||||
onUploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
platformConfig: PlatformConfig;
|
||||
}
|
||||
|
||||
const MetaDataFacebookForm: React.FC<MetaDataFacebookFormProps> = ({
|
||||
metaData,
|
||||
onSave,
|
||||
onUploadImage,
|
||||
platformConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: metaData,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!metaData) return;
|
||||
setValue("facebook_title", metaData.facebook_title || "");
|
||||
setValue("facebook_description", metaData.facebook_description || "");
|
||||
setValue("facebook_image_url", metaData.facebook_image_url || "");
|
||||
}, [metaData, setValue]);
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="max-w-2xl">
|
||||
<div className="mb-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<FaFacebook className="text-primary" size={40} />
|
||||
<div className="flex flex-col">
|
||||
<span className="font-semibold text-default-900">
|
||||
{platformConfig.name}
|
||||
</span>
|
||||
<span className="text-default-400 text-xs">2h</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-2 h-3 w-full rounded-large bg-default-100"></div>
|
||||
<div className="mb-4 h-3 w-3/5 rounded-large bg-default-100"></div>
|
||||
</div>
|
||||
<Card shadow="none" className="border-1 max-w-2xl">
|
||||
<CardBody className="px-0 py-4">
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 px-4"
|
||||
>
|
||||
<Controller
|
||||
name="facebook_image_url"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<UploadImage
|
||||
onSave={onUploadImage}
|
||||
imageUrl={field.value}
|
||||
setImageUrl={(imageUrl) => {
|
||||
field.onChange(imageUrl);
|
||||
}}
|
||||
className="h-[280px] w-full bg-default-100"
|
||||
description={t("Upload Facebook Image")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="facebook_title"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Facebook Title")}
|
||||
placeholder={platformConfig.headline || " "}
|
||||
isInvalid={!!errors.facebook_title}
|
||||
errorMessage={errors.facebook_title?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="facebook_description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Facebook Description")}
|
||||
placeholder={platformConfig.subheadline || " "}
|
||||
isInvalid={!!errors.facebook_description}
|
||||
errorMessage={errors.facebook_description?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-start mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataFacebookForm;
|
||||
@@ -0,0 +1,82 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Tabs, Tab } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import MetaDataFacebookForm from "./MetaDataFacebookForm";
|
||||
import MetaDataXForm from "./MetaDataXForm";
|
||||
import MetaDataSearchForm from "./MetaDataSearchForm";
|
||||
import { FacebookMetaData } from "./MetaDataFacebookForm";
|
||||
import { SearchMetaData } from "./MetaDataSearchForm";
|
||||
import { XMetaData } from "./MetaDataXForm";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
|
||||
interface MetaData {
|
||||
website_title?: string;
|
||||
meta_description?: string;
|
||||
x_title?: string;
|
||||
x_description?: string;
|
||||
x_image_url?: string;
|
||||
facebook_title?: string;
|
||||
facebook_description?: string;
|
||||
facebook_image_url?: string;
|
||||
}
|
||||
|
||||
interface MetaDataPanelProps {
|
||||
metaData: MetaData;
|
||||
onSave: (metaData: MetaData) => Promise<boolean>;
|
||||
uploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
platformConfig: PlatformConfig;
|
||||
}
|
||||
|
||||
const MetaDataPanel: React.FC<MetaDataPanelProps> = ({
|
||||
metaData,
|
||||
onSave,
|
||||
uploadImage,
|
||||
platformConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSave = async (data: MetaData) => {
|
||||
return await onSave({
|
||||
...metaData,
|
||||
...data,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<Tabs
|
||||
aria-label="Meta data options"
|
||||
variant="solid"
|
||||
className="w-full"
|
||||
destroyInactiveTabPanel={false}
|
||||
>
|
||||
<Tab key="search" title={t("Search")} className="pb-0">
|
||||
<MetaDataSearchForm
|
||||
metaData={metaData as SearchMetaData}
|
||||
onSave={handleSave}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
</Tab>
|
||||
|
||||
<Tab key="x" title={t("X Card")} className="pb-0">
|
||||
<MetaDataXForm
|
||||
metaData={metaData as XMetaData}
|
||||
onSave={handleSave}
|
||||
onUploadImage={uploadImage}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
</Tab>
|
||||
|
||||
<Tab key="facebook" title={t("Facebook Card")} className="pb-0">
|
||||
<MetaDataFacebookForm
|
||||
metaData={metaData as FacebookMetaData}
|
||||
onSave={handleSave}
|
||||
onUploadImage={uploadImage}
|
||||
platformConfig={platformConfig}
|
||||
/>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataPanel;
|
||||
@@ -0,0 +1,215 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Button, Card, CardBody, CardFooter, Input } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
|
||||
export interface SearchMetaData {
|
||||
website_title: string;
|
||||
meta_description: string;
|
||||
}
|
||||
|
||||
const formSchema = z.object({
|
||||
website_title: z.string().max(75, "Title is too long").optional().default(""),
|
||||
meta_description: z
|
||||
.string()
|
||||
.max(156, "Description is too long")
|
||||
.optional()
|
||||
.or(z.literal(""))
|
||||
.default(""),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface MetaDataSearchFormProps {
|
||||
metaData: SearchMetaData;
|
||||
platformConfig: PlatformConfig;
|
||||
onSave: (metaData: SearchMetaData) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const MetaDataSearchForm: React.FC<MetaDataSearchFormProps> = ({
|
||||
metaData,
|
||||
platformConfig,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
watch,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: metaData,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!metaData) return;
|
||||
setValue("meta_description", metaData.meta_description || "");
|
||||
setValue("website_title", metaData.website_title || "");
|
||||
}, [metaData, setValue]);
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave(data);
|
||||
};
|
||||
|
||||
const metaDescription = watch("meta_description");
|
||||
const websiteTitle = watch("website_title");
|
||||
|
||||
return (
|
||||
<Card shadow="none" className="border-1 max-w-2xl">
|
||||
<CardBody className="px-0 py-4">
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 px-4"
|
||||
>
|
||||
<Controller
|
||||
name="website_title"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Meta Title")}
|
||||
placeholder={platformConfig.headline || " "}
|
||||
isInvalid={!!errors.website_title}
|
||||
errorMessage={errors.website_title?.message}
|
||||
labelPlacement="outside"
|
||||
defaultValue={t("Recommended: 70 characters")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="meta_description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Meta Description")}
|
||||
placeholder={platformConfig.subheadline || " "}
|
||||
isInvalid={!!errors.meta_description}
|
||||
errorMessage={errors.meta_description?.message}
|
||||
labelPlacement="outside"
|
||||
defaultValue={t("Recommended: 156 characters")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-start mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</CardBody>
|
||||
<CardFooter className="p-0">
|
||||
<div className="w-full bg-default-100">
|
||||
<div className="mt-4 mb-2 text-grey-500 px-5 uppercase text-xs">
|
||||
{t("Preview")}
|
||||
</div>
|
||||
<div className="mx-5 -mb-5 overflow-hidden rounded-b-xl bg-grey-50 pt-2 ">
|
||||
<div className="rounded-t-lg bg-white px-5 py-3 shadow-lg mb-5">
|
||||
<div className="mt-3 flex items-center">
|
||||
<div>
|
||||
<svg fill="none" viewBox="0 0 92 31" className="mr-7 h-7">
|
||||
<title>google</title>
|
||||
<path
|
||||
d="M39.15 15.898c0 4.303-3.378 7.473-7.525 7.473s-7.526-3.17-7.526-7.473c0-4.334 3.38-7.474 7.526-7.474 4.147 0 7.526 3.14 7.526 7.474zm-3.294 0c0-2.69-1.958-4.529-4.231-4.529-2.273 0-4.231 1.84-4.231 4.529 0 2.662 1.958 4.528 4.231 4.528 2.273 0 4.231-1.87 4.231-4.528z"
|
||||
fill="#EA4335"
|
||||
></path>
|
||||
<path
|
||||
d="M55.386 15.898c0 4.303-3.379 7.473-7.526 7.473-4.146 0-7.526-3.17-7.526-7.473 0-4.33 3.38-7.474 7.526-7.474 4.147 0 7.526 3.14 7.526 7.474zm-3.294 0c0-2.69-1.959-4.529-4.232-4.529s-4.231 1.84-4.231 4.529c0 2.662 1.958 4.528 4.231 4.528 2.273 0 4.232-1.87 4.232-4.528z"
|
||||
fill="#FBBC05"
|
||||
></path>
|
||||
<path
|
||||
d="M70.945 8.875v13.418c0 5.52-3.267 7.774-7.13 7.774-3.636 0-5.825-2.423-6.65-4.404l2.868-1.19c.511 1.217 1.763 2.652 3.779 2.652 2.472 0 4.004-1.52 4.004-4.38V21.67h-.115c-.737.906-2.158 1.698-3.95 1.698-3.751 0-7.188-3.255-7.188-7.443 0-4.22 3.437-7.501 7.188-7.501 1.789 0 3.21.792 3.95 1.671h.115V8.88h3.129v-.004zm-2.895 7.05c0-2.632-1.763-4.556-4.005-4.556-2.273 0-4.177 1.924-4.177 4.556 0 2.604 1.904 4.501 4.177 4.501 2.242 0 4.005-1.897 4.005-4.501z"
|
||||
fill="#4285F4"
|
||||
></path>
|
||||
<path
|
||||
d="M76.103 1.01v21.903H72.89V1.011h3.213z"
|
||||
fill="#34A853"
|
||||
></path>
|
||||
<path
|
||||
d="M88.624 18.357l2.558 1.699c-.826 1.216-2.815 3.312-6.251 3.312-4.262 0-7.445-3.282-7.445-7.474 0-4.444 3.21-7.473 7.076-7.473 3.893 0 5.798 3.086 6.42 4.754l.341.85-10.028 4.137c.768 1.5 1.962 2.264 3.636 2.264 1.678 0 2.841-.822 3.693-2.069zm-7.87-2.688l6.703-2.774c-.368-.933-1.478-1.583-2.783-1.583-1.674 0-4.005 1.472-3.92 4.357z"
|
||||
fill="#EA4335"
|
||||
></path>
|
||||
<path
|
||||
d="M11.936 13.953v-3.17h10.726c.105.552.159 1.206.159 1.914 0 2.378-.653 5.32-2.757 7.416-2.046 2.123-4.66 3.255-8.124 3.255-6.42 0-11.818-5.21-11.818-11.605C.122 5.368 5.52.158 11.94.158c3.551 0 6.081 1.389 7.982 3.198l-2.246 2.237c-1.363-1.273-3.21-2.264-5.74-2.264-4.688 0-8.354 3.764-8.354 8.434s3.666 8.434 8.354 8.434c3.041 0 4.773-1.216 5.882-2.322.9-.896 1.492-2.176 1.725-3.925l-7.607.003z"
|
||||
fill="#4285F4"
|
||||
></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div className="grow">
|
||||
<div className="flex w-full items-center justify-end rounded-full bg-white p-3 px-4 shadow dark:bg-grey-900">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
stroke-width="1.5"
|
||||
className="pointer-events-none size-4 stroke-[2px] text-blue-600"
|
||||
>
|
||||
<path
|
||||
d="M0.750 9.812 A9.063 9.063 0 1 0 18.876 9.812 A9.063 9.063 0 1 0 0.750 9.812 Z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
transform="translate(-3.056 4.62) rotate(-23.025)"
|
||||
></path>
|
||||
<path
|
||||
d="M16.221 16.22L23.25 23.25"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
></path>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 flex items-center gap-2 border-t border-grey-200 pt-4 dark:border-grey-900">
|
||||
<div
|
||||
className="flex size-7 items-center justify-center rounded-full bg-grey-200 dark:bg-grey-700"
|
||||
style={{
|
||||
backgroundImage: `url("${platformConfig.logo}")`,
|
||||
backgroundSize: "contain",
|
||||
}}
|
||||
></div>
|
||||
<div className="flex flex-col text-sm">
|
||||
<span>{platformConfig.domain || window.location.host}</span>
|
||||
<span className="-mt-0.5 inline-block text-xs text-grey-600">
|
||||
https://
|
||||
{platformConfig.domain || window.location.host}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-1 flex flex-col">
|
||||
<span className="text-lg text-[#1a0dab] dark:text-blue">
|
||||
{websiteTitle || platformConfig.headline}
|
||||
</span>
|
||||
<span className="text-sm text-grey-900 dark:text-grey-700">
|
||||
{metaDescription || platformConfig.subheadline}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataSearchForm;
|
||||
@@ -0,0 +1,160 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Button, Card, CardBody, Input } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import UploadImage from "@/components/common/UploadImage";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { FaXTwitter } from "react-icons/fa6";
|
||||
|
||||
export interface XMetaData {
|
||||
x_title: string;
|
||||
x_description: string;
|
||||
x_image_url?: string;
|
||||
}
|
||||
|
||||
const formSchema = z.object({
|
||||
x_title: z.string().max(200, "Title is too long").optional().default(""),
|
||||
x_description: z
|
||||
.string()
|
||||
.max(1000, "Description is too long")
|
||||
.optional()
|
||||
.or(z.literal(""))
|
||||
.default(""),
|
||||
x_image_url: z.string().optional().or(z.literal("")).default(""),
|
||||
});
|
||||
|
||||
type FormData = z.infer<typeof formSchema>;
|
||||
|
||||
interface MetaDataXFormProps {
|
||||
metaData: XMetaData;
|
||||
onSave: (metaData: XMetaData) => Promise<boolean>;
|
||||
onUploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
platformConfig: PlatformConfig;
|
||||
}
|
||||
|
||||
const MetaDataXForm: React.FC<MetaDataXFormProps> = ({
|
||||
metaData,
|
||||
onSave,
|
||||
onUploadImage,
|
||||
platformConfig,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<FormData>({
|
||||
resolver: zodResolver(formSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: metaData,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!metaData) return;
|
||||
setValue("x_title", metaData.x_title || "");
|
||||
setValue("x_description", metaData.x_description || "");
|
||||
setValue("x_image_url", metaData.x_image_url || "");
|
||||
}, [metaData, setValue]);
|
||||
|
||||
const onSubmit = async (data: FormData) => {
|
||||
await onSave(data);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-start gap-2 w-full">
|
||||
<FaXTwitter size={40} />
|
||||
<div className="w-full">
|
||||
<div className="max-w-2xl">
|
||||
<div className="mb-2">
|
||||
<div className="flex">
|
||||
<span className="mr-1 font-semibold text-default-900">
|
||||
{platformConfig.name}
|
||||
</span>
|
||||
<span className="text-default-400">· 2h</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-2 h-3 w-full rounded-large bg-default-100"></div>
|
||||
<div className="mb-4 h-3 w-3/5 rounded-large bg-default-100"></div>
|
||||
</div>
|
||||
|
||||
<Card shadow="none" className="border-1 max-w-2xl">
|
||||
<CardBody className="px-0 py-4">
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
className="flex flex-col gap-4 px-4"
|
||||
>
|
||||
<Controller
|
||||
name="x_image_url"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<UploadImage
|
||||
onSave={onUploadImage}
|
||||
imageUrl={field.value}
|
||||
setImageUrl={(imageUrl) => {
|
||||
field.onChange(imageUrl);
|
||||
}}
|
||||
className="h-[280px] w-full bg-default-100"
|
||||
description={t("Upload X Image")}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="x_title"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("X Title")}
|
||||
placeholder={platformConfig.headline || " "}
|
||||
isInvalid={!!errors.x_title}
|
||||
errorMessage={errors.x_title?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="x_description"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
label={t("X Description")}
|
||||
placeholder={platformConfig.subheadline || " "}
|
||||
isInvalid={!!errors.x_description}
|
||||
errorMessage={errors.x_description?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-start mt-2">
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
size="sm"
|
||||
className="w-fit"
|
||||
isLoading={isSubmitting}
|
||||
isDisabled={!isValid}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default MetaDataXForm;
|
||||
@@ -0,0 +1,106 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { Input, Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { z } from "zod";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
|
||||
export type TitleAndDescPanelConfig = {
|
||||
headline: string;
|
||||
subheadline: string;
|
||||
};
|
||||
|
||||
const titleAndDescPanelSchema = z.object({
|
||||
headline: z.string().min(1, "Title is required"),
|
||||
subheadline: z.string(),
|
||||
});
|
||||
|
||||
interface TitleAndDescPanelProps {
|
||||
config: TitleAndDescPanelConfig;
|
||||
onSave: (config: TitleAndDescPanelConfig) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const TitleAndDescPanel: React.FC<TitleAndDescPanelProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
setValue,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<TitleAndDescPanelConfig>({
|
||||
resolver: zodResolver(titleAndDescPanelSchema),
|
||||
mode: "onBlur",
|
||||
defaultValues: config,
|
||||
});
|
||||
useEffect(() => {
|
||||
setValue("headline", config.headline);
|
||||
setValue("subheadline", config.subheadline);
|
||||
}, [config]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
<form onSubmit={handleSubmit(onSave)} className="flex flex-col gap-4">
|
||||
<Controller
|
||||
name="headline"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<>
|
||||
{/* homepage headline */}
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Site title")}
|
||||
placeholder={t("Enter site title")}
|
||||
description={t("Main title displayed on the home page")}
|
||||
isInvalid={!!errors.headline}
|
||||
errorMessage={errors.headline?.message}
|
||||
labelPlacement="outside"
|
||||
isRequired
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="subheadline"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<>
|
||||
{/* homepage subheadline */}
|
||||
<Input
|
||||
{...field}
|
||||
label={t("Site description")}
|
||||
placeholder={t("Enter site description")}
|
||||
description={t(
|
||||
"Secondary description displayed below the main title"
|
||||
)}
|
||||
isInvalid={!!errors.subheadline}
|
||||
errorMessage={errors.subheadline?.message}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
type="submit"
|
||||
isLoading={isSubmitting}
|
||||
size="sm"
|
||||
isDisabled={!isValid}
|
||||
className="mt-2 w-fit"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TitleAndDescPanel;
|
||||
@@ -93,17 +93,17 @@ const DashboardContent: React.FC = () => {
|
||||
},
|
||||
];
|
||||
|
||||
const handleTabNavigate = (tab: TabKey) => {
|
||||
setActiveTab(tab);
|
||||
const handleTabNavigate = (tab: TabKey | string) => {
|
||||
setActiveTab(tab as TabKey);
|
||||
// update url params
|
||||
if (tab === TabKey.OVERVIEW) {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
router.push("/dashboard", { scroll: false });
|
||||
router.push("/console", { scroll: false });
|
||||
} else {
|
||||
// other tabs set corresponding tab params
|
||||
const params = new URLSearchParams();
|
||||
params.set("tab", tab);
|
||||
router.push(`/dashboard?${params.toString()}`, { scroll: false });
|
||||
router.push(`/console?${params.toString()}`, { scroll: false });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Switch,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Select,
|
||||
SelectItem,
|
||||
Button,
|
||||
@@ -72,139 +70,115 @@ export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
|
||||
const isEmailEnabled = formData.email?.is_enabled || false;
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["email-login"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="email-login"
|
||||
title={
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex flex-col">
|
||||
<h3 className="text-lg font-semibold">{t("Email Login")}</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure email-based authentication")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* enable email login */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Enable Email Login")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Allow users to sign in with email")}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={isEmailEnabled}
|
||||
onValueChange={handleToggleEnabled}
|
||||
color="primary"
|
||||
size="sm"
|
||||
isDisabled={isLoading || (isCaptchaMode && !isEmailConfigured)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
{/* enable email login */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">{t("Enable Email Login")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Allow users to sign in with email")}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={isEmailEnabled}
|
||||
onValueChange={handleToggleEnabled}
|
||||
color="primary"
|
||||
size="sm"
|
||||
isDisabled={isLoading || (isCaptchaMode && !isEmailConfigured)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* authentication mode selection */}
|
||||
<div className="p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
{/* authentication mode selection */}
|
||||
<div className="p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Authentication Mode")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Choose how users authenticate with email")}
|
||||
</span>
|
||||
</div>
|
||||
<Select
|
||||
selectedKeys={[formData.email?.mode || EmailMode.PASSWORD]}
|
||||
onSelectionChange={(keys) => {
|
||||
const mode = Array.from(keys)[0] as EmailMode;
|
||||
handleModeChange(mode);
|
||||
}}
|
||||
size="sm"
|
||||
isDisabled={isLoading || !isEmailEnabled}
|
||||
renderValue={() => {
|
||||
const selectedKey = formData.email?.mode || EmailMode.PASSWORD;
|
||||
if (selectedKey === EmailMode.PASSWORD)
|
||||
return t("Email/Password");
|
||||
return t(
|
||||
selectedKey === EmailMode.CAPTCHA
|
||||
? "Email/Verification Code"
|
||||
: "Email/Password"
|
||||
);
|
||||
}}
|
||||
>
|
||||
<SelectItem key={EmailMode.PASSWORD} value={EmailMode.PASSWORD}>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Authentication Mode")}
|
||||
{t("Email/Password")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Choose how users authenticate with email")}
|
||||
{t("Traditional email and password authentication")}
|
||||
</span>
|
||||
</div>
|
||||
<Select
|
||||
selectedKeys={[formData.email?.mode || EmailMode.PASSWORD]}
|
||||
onSelectionChange={(keys) => {
|
||||
const mode = Array.from(keys)[0] as EmailMode;
|
||||
handleModeChange(mode);
|
||||
}}
|
||||
size="sm"
|
||||
isDisabled={isLoading || !isEmailEnabled}
|
||||
renderValue={() => {
|
||||
const selectedKey =
|
||||
formData.email?.mode || EmailMode.PASSWORD;
|
||||
if (selectedKey === EmailMode.PASSWORD)
|
||||
return t("Email/Password");
|
||||
return t(
|
||||
selectedKey === EmailMode.CAPTCHA
|
||||
? "Email/Verification Code"
|
||||
: "Email/Password"
|
||||
);
|
||||
}}
|
||||
>
|
||||
<SelectItem key={EmailMode.PASSWORD} value={EmailMode.PASSWORD}>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Email/Password")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Traditional email and password authentication")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
<SelectItem key={EmailMode.CAPTCHA} value={EmailMode.CAPTCHA}>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Email/Verification Code")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Passwordless login with email verification code")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* email configuration hint - only show in captcha mode */}
|
||||
{isEmailEnabled && isCaptchaMode && !isEmailConfigured && (
|
||||
<Alert color="warning" variant="flat" className="mb-4">
|
||||
<div className="flex gap-2">
|
||||
<span>
|
||||
{t(
|
||||
"Email service is not configured. Please configure email settings first."
|
||||
)}
|
||||
</SelectItem>
|
||||
<SelectItem key={EmailMode.CAPTCHA} value={EmailMode.CAPTCHA}>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Email/Verification Code")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Passwordless login with email verification code")}
|
||||
</span>
|
||||
<Link
|
||||
className="text-sm underline cursor-pointer"
|
||||
onPress={() => {
|
||||
onTabNavigate?.(TabKey.SYSTEM_SETTINGS, "email-admin");
|
||||
}}
|
||||
>
|
||||
{t("Go to Settings")}
|
||||
</Link>
|
||||
</div>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{/* save button - only show in enabled state */}
|
||||
{isEmailEnabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</SelectItem>
|
||||
</Select>
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
|
||||
{/* email configuration hint - only show in captcha mode */}
|
||||
{isEmailEnabled && isCaptchaMode && !isEmailConfigured && (
|
||||
<Alert color="warning" variant="flat" className="mb-4">
|
||||
<div className="flex gap-2">
|
||||
<span>
|
||||
{t(
|
||||
"SMTP is not configured. Please configure email settings first."
|
||||
)}
|
||||
</span>
|
||||
{onTabNavigate ? (
|
||||
<Link
|
||||
className="text-sm underline cursor-pointer"
|
||||
onPress={() => {
|
||||
onTabNavigate?.(TabKey.SYSTEM_SETTINGS, "email-admin");
|
||||
}}
|
||||
>
|
||||
{t("Go to Settings")}
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{/* save button - only show in enabled state */}
|
||||
{isEmailEnabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,16 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
Switch,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
} from "@nextui-org/react";
|
||||
import { Input, Button, Switch } from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { getGoogleRedirectUri } from "@/hooks/useLogin";
|
||||
import { getGoogleRedirectUri } from "@/shared/hooks/useLogin";
|
||||
import { GoogleAuthConfig } from "@/shared/types/system";
|
||||
|
||||
interface GoogleAuthConfigFormProps {
|
||||
@@ -47,115 +41,94 @@ export const GoogleAuthConfigForm: React.FC<GoogleAuthConfigFormProps> = ({
|
||||
const isFormValid = formData.client_id.trim() !== "";
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["google-auth-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="google-auth-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("Google Login Settings")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure Google OAuth integration")}
|
||||
</p>
|
||||
<>
|
||||
<div className="space-y-4">
|
||||
{/* enable google login */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Enable Google Login")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Allow users to sign in with Google")}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* enable google login */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Enable Google Login")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Allow users to sign in with Google")}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={formData.is_enabled}
|
||||
onValueChange={(value) => {
|
||||
onSave({
|
||||
...formData,
|
||||
is_enabled: value,
|
||||
});
|
||||
}}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Google Client ID */}
|
||||
<Input
|
||||
label={t("Google Client ID")}
|
||||
placeholder={t("OAuth 2.0 Client ID from Google Cloud Console")}
|
||||
value={formData.client_id}
|
||||
onChange={(e) => handleInputChange("client_id", e.target.value)}
|
||||
isRequired
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* Google Client Secret */}
|
||||
<Input
|
||||
label={t("Google Client Secret")}
|
||||
placeholder={t(
|
||||
"OAuth 2.0 Client Secret (optional, for server-side verification)"
|
||||
)}
|
||||
value={formData.client_secret || ""}
|
||||
onChange={(e) => handleInputChange("client_secret", e.target.value)}
|
||||
type={showClientSecret ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowClientSecret(!showClientSecret)}
|
||||
className="focus:outline-none"
|
||||
disabled={!formData.is_enabled}
|
||||
>
|
||||
{showClientSecret ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* Redirect URI */}
|
||||
<Input
|
||||
label={t("Redirect URI")}
|
||||
placeholder="https://yourdomain.com/auth/google/callback"
|
||||
description={t(
|
||||
"Authorized redirect URI configured in Google Cloud Console"
|
||||
)}
|
||||
value={getGoogleRedirectUri()}
|
||||
isDisabled={true}
|
||||
<Switch
|
||||
isSelected={formData.is_enabled}
|
||||
onValueChange={(value) => {
|
||||
onSave({
|
||||
...formData,
|
||||
is_enabled: value,
|
||||
});
|
||||
}}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
{formData.is_enabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size="sm"
|
||||
{/* Google Client ID */}
|
||||
<Input
|
||||
label={t("Google Client ID")}
|
||||
placeholder={t("OAuth 2.0 Client ID from Google Cloud Console")}
|
||||
value={formData.client_id}
|
||||
onChange={(e) => handleInputChange("client_id", e.target.value)}
|
||||
isRequired
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* Google Client Secret */}
|
||||
<Input
|
||||
label={t("Google Client Secret")}
|
||||
placeholder={t(
|
||||
"OAuth 2.0 Client Secret (optional, for server-side verification)"
|
||||
)}
|
||||
value={formData.client_secret || ""}
|
||||
onChange={(e) => handleInputChange("client_secret", e.target.value)}
|
||||
type={showClientSecret ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowClientSecret(!showClientSecret)}
|
||||
className="focus:outline-none"
|
||||
disabled={!formData.is_enabled}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
{showClientSecret ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* Redirect URI */}
|
||||
<Input
|
||||
label={t("Redirect URI")}
|
||||
placeholder="https://yourdomain.com/auth/google/callback"
|
||||
description={t(
|
||||
"Authorized redirect URI configured in Google Cloud Console"
|
||||
)}
|
||||
value={getGoogleRedirectUri()}
|
||||
isDisabled={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
{formData.is_enabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -47,7 +47,7 @@ export const MarketplaceMain: React.FC<MarketplaceMainProps> = ({
|
||||
setTotal(result.page.total);
|
||||
setCurrentPage(page);
|
||||
} catch (error) {
|
||||
console.error('Failed to load services:', error);
|
||||
console.error("Failed to load servers:", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export const MarketplaceMain: React.FC<MarketplaceMainProps> = ({
|
||||
|
||||
// when search query changes, scroll to the top of the page
|
||||
useEffect(() => {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}, [currentPage, searchQuery]);
|
||||
|
||||
// update URL parameters
|
||||
@@ -63,11 +63,11 @@ export const MarketplaceMain: React.FC<MarketplaceMainProps> = ({
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (page > 1) {
|
||||
params.set('page', page.toString());
|
||||
params.set("page", page.toString());
|
||||
}
|
||||
|
||||
if (search.trim()) {
|
||||
params.set('search', search.trim());
|
||||
params.set("search", search.trim());
|
||||
}
|
||||
|
||||
const queryString = params.toString();
|
||||
@@ -106,7 +106,7 @@ export const MarketplaceMain: React.FC<MarketplaceMainProps> = ({
|
||||
onSearch={handleSearch}
|
||||
/>
|
||||
|
||||
{/* Service List Section */}
|
||||
{/* Server List Section */}
|
||||
{loading ? (
|
||||
<div className="mx-auto h-[200px] flex items-center justify-center">
|
||||
<Spinner />
|
||||
@@ -122,4 +122,4 @@ export const MarketplaceMain: React.FC<MarketplaceMainProps> = ({
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,133 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Input,
|
||||
Select,
|
||||
SelectItem,
|
||||
Chip,
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { AuthMethod, MCPServiceFormData } from '@/types/mcp-service';
|
||||
|
||||
interface BasicInfoTabProps {
|
||||
formData: MCPServiceFormData;
|
||||
newTag: string;
|
||||
setNewTag: (value: string) => void;
|
||||
onInputChange: (field: keyof MCPServiceFormData, value: any) => void;
|
||||
onAddTag: () => void;
|
||||
onRemoveTag: (tag: string) => void;
|
||||
}
|
||||
|
||||
export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
||||
formData,
|
||||
newTag,
|
||||
setNewTag,
|
||||
onInputChange,
|
||||
onAddTag,
|
||||
onRemoveTag
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Input
|
||||
label={t('Service Name')}
|
||||
placeholder={t('Enter service name')}
|
||||
value={formData.name}
|
||||
onChange={(e) => onInputChange('name', e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
<Input
|
||||
label={t('Short Description')}
|
||||
placeholder={t('Brief description of the service')}
|
||||
value={formData.short_description || ''}
|
||||
onChange={(e) => onInputChange('short_description', e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
<Input
|
||||
label={t('API Endpoint')}
|
||||
placeholder="https://api.example.com/v1"
|
||||
value={formData.base_url || ''}
|
||||
onChange={(e) => onInputChange('base_url', e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
<Select
|
||||
label={t('Authentication Type')}
|
||||
selectedKeys={formData.auth_method ? [formData.auth_method] : []}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
onInputChange('auth_method', selectedKey);
|
||||
// clear auth config when switch auth type
|
||||
onInputChange('auth_header', '');
|
||||
onInputChange('auth_token', '');
|
||||
}}
|
||||
>
|
||||
<SelectItem key="none" value="none">{t('None')}</SelectItem>
|
||||
<SelectItem key="apikey" value="apikey">{t('API Key')}</SelectItem>
|
||||
<SelectItem key="token" value="token">{t('Bearer Token')}</SelectItem>
|
||||
</Select>
|
||||
|
||||
{/* auth config input fields */}
|
||||
{formData.auth_method === AuthMethod.APIKey && (
|
||||
<div className="space-y-4">
|
||||
<Input
|
||||
label={t('API Key Header Name')}
|
||||
placeholder="X-API-Key"
|
||||
value={formData.auth_header || ''}
|
||||
onChange={(e) => onInputChange('auth_header', e.target.value)}
|
||||
description={t('The header name for the API key (e.g., X-API-Key, Authorization)')}
|
||||
/>
|
||||
<Input
|
||||
label={t('API Key Value')}
|
||||
placeholder={t('Enter API key')}
|
||||
type="password"
|
||||
value={formData.auth_token || ''}
|
||||
onChange={(e) => onInputChange('auth_token', e.target.value)}
|
||||
autoComplete='new-password'
|
||||
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{formData.auth_method === AuthMethod.BearerToken && (
|
||||
<Input
|
||||
label={t('Bearer Token')}
|
||||
placeholder={t('Enter bearer token')}
|
||||
type="password"
|
||||
value={formData.auth_token || ''}
|
||||
onChange={(e) => onInputChange('auth_token', e.target.value)}
|
||||
description={t('The bearer token for authentication')}
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* tag management */}
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">{t('Tags')}</label>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
placeholder={t('Add tag')}
|
||||
value={newTag}
|
||||
onChange={(e) => setNewTag(e.target.value)}
|
||||
onKeyUp={(e) => e.key === 'Enter' && onAddTag()}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{(formData.tags || []).map((tag, index) => (
|
||||
<Chip
|
||||
key={index}
|
||||
onClose={() => onRemoveTag(tag)}
|
||||
variant="flat"
|
||||
>
|
||||
{tag}
|
||||
</Chip>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,41 +1,37 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useCallback, useEffect } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useMCPServicesList } from "@/hooks/useMCPServicesList";
|
||||
import { MCPService, MCPServiceFormData, EnabledEnum } from "@/types/mcp-service";
|
||||
import { MCPService, MCPServiceFormData } from "@/shared/types/mcp-service";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
import { ServiceFiltersBar } from "./ServiceFiltersBar";
|
||||
import { ServiceTable } from "./ServiceTable";
|
||||
import { ServiceEditPage } from "./ServiceEditPage";
|
||||
import { OpenAPIGeneratorModal } from "./OpenAPIGeneratorModal";
|
||||
import { ServiceFiltersBar } from "@/shared/components/mcp-services/ServiceFiltersBar";
|
||||
import { ServiceEditPage } from "@/components/mcp-services/ServiceEditPage";
|
||||
import { DeleteConfirmModal } from "@/shared/components/modal/DeleteConfirmModal";
|
||||
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import { ServiceTable } from "@/shared/components/mcp-services/ServiceTable";
|
||||
import { OpenAPIGeneratorModal } from "@/shared/components/mcp-services/OpenAPIGeneratorModal";
|
||||
|
||||
type ViewMode = "list" | "edit" | "create";
|
||||
|
||||
export const MCPServicesManagement: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const {
|
||||
services,
|
||||
loading,
|
||||
pagination,
|
||||
searchTerm,
|
||||
setSearchTerm,
|
||||
statusFilter,
|
||||
setStatusFilter,
|
||||
onPageChange,
|
||||
createService,
|
||||
updateService,
|
||||
deleteService,
|
||||
toggleServiceStatus,
|
||||
parseOpenAPIDocument,
|
||||
loadServices
|
||||
loadServices,
|
||||
} = useMCPServicesList();
|
||||
const [addServiceType, setAddServiceType] = useState<string | null>(null);
|
||||
|
||||
// Get initial state from URL
|
||||
const getInitialViewMode = (): ViewMode => {
|
||||
@@ -57,26 +53,29 @@ export const MCPServicesManagement: React.FC = () => {
|
||||
);
|
||||
|
||||
// Update URL when view mode or service ID changes
|
||||
const updateURL = useCallback((mode: ViewMode, serviceId?: string | null) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
const updateURL = useCallback(
|
||||
(mode: ViewMode, serviceId?: string | null) => {
|
||||
const params = new URLSearchParams(searchParams);
|
||||
|
||||
// Always keep the tab parameter
|
||||
params.set("tab", "mcp-services");
|
||||
// Always keep the tab parameter
|
||||
params.set("tab", "mcp-services");
|
||||
|
||||
if (mode === "list") {
|
||||
params.delete("mode");
|
||||
params.delete("serviceId");
|
||||
} else {
|
||||
params.set("mode", mode);
|
||||
if (serviceId) {
|
||||
params.set("serviceId", serviceId);
|
||||
} else {
|
||||
if (mode === "list") {
|
||||
params.delete("mode");
|
||||
params.delete("serviceId");
|
||||
} else {
|
||||
params.set("mode", mode);
|
||||
if (serviceId) {
|
||||
params.set("serviceId", serviceId);
|
||||
} else {
|
||||
params.delete("serviceId");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
router.push(`/console?${params.toString()}`, { scroll: false });
|
||||
}, [router, searchParams]);
|
||||
window.history.pushState({}, "", `/admin/console?${params.toString()}`);
|
||||
},
|
||||
[searchParams]
|
||||
);
|
||||
|
||||
// Sync state with URL on mount and URL changes
|
||||
useEffect(() => {
|
||||
@@ -94,29 +93,38 @@ export const MCPServicesManagement: React.FC = () => {
|
||||
null
|
||||
);
|
||||
|
||||
// Service CRUD operations
|
||||
const handleCreateService = useCallback(() => {
|
||||
setSelectedServiceId(null);
|
||||
setViewMode("create");
|
||||
updateURL("create");
|
||||
}, [updateURL]);
|
||||
// Server CRUD operations
|
||||
const handleCreateService = (type: string) => {
|
||||
setAddServiceType(type);
|
||||
setIsOpenAPIModalOpen(true);
|
||||
};
|
||||
|
||||
const handleEditService = useCallback((service: MCPService) => {
|
||||
setSelectedServiceId(service.id);
|
||||
setViewMode("edit");
|
||||
updateURL("edit", service.id);
|
||||
}, [updateURL]);
|
||||
const handleEditService = useCallback(
|
||||
(service: MCPService) => {
|
||||
setSelectedServiceId(service.id);
|
||||
setViewMode("edit");
|
||||
updateURL("edit", service.id);
|
||||
},
|
||||
[updateURL]
|
||||
);
|
||||
|
||||
const handleSaveService = useCallback(
|
||||
async (formData: MCPServiceFormData) => {
|
||||
async (formData: MCPServiceFormData, isDraft?: boolean) => {
|
||||
try {
|
||||
const result = selectedServiceId ? await updateService(selectedServiceId, formData) : await createService(formData);
|
||||
if (!result) return
|
||||
const result = selectedServiceId
|
||||
? await updateService(selectedServiceId, formData)
|
||||
: await createService(formData);
|
||||
if (!result) return false;
|
||||
if (isDraft) {
|
||||
return true;
|
||||
}
|
||||
setViewMode("list");
|
||||
setSelectedServiceId(null);
|
||||
updateURL("list");
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Failed to save service:", error);
|
||||
console.error("Failed to save server:", error);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[selectedServiceId, updateService, createService, updateURL]
|
||||
@@ -140,28 +148,22 @@ export const MCPServicesManagement: React.FC = () => {
|
||||
setIsDeleteModalOpen(false);
|
||||
setServiceToDelete(null);
|
||||
} catch (error) {
|
||||
console.error("Failed to delete service:", error);
|
||||
console.error("Failed to delete server:", error);
|
||||
}
|
||||
}
|
||||
}, [serviceToDelete, deleteService]);
|
||||
|
||||
const handleToggleStatus = useCallback(
|
||||
async (service: MCPService) => {
|
||||
async (serviceId: string) => {
|
||||
try {
|
||||
await toggleServiceStatus(service.id);
|
||||
await toggleServiceStatus(serviceId);
|
||||
} catch (error) {
|
||||
console.error("Failed to toggle service status:", error);
|
||||
console.error("Failed to toggle server status:", error);
|
||||
}
|
||||
},
|
||||
[toggleServiceStatus]
|
||||
);
|
||||
|
||||
// OpenAPI operations
|
||||
const handleOpenAPIGenerate = useCallback(() => {
|
||||
setIsOpenAPIModalOpen(true);
|
||||
}, []);
|
||||
|
||||
|
||||
const handleEditGeneratedService = useCallback(
|
||||
async (serviceId: string) => {
|
||||
try {
|
||||
@@ -172,7 +174,7 @@ export const MCPServicesManagement: React.FC = () => {
|
||||
setIsOpenAPIModalOpen(false);
|
||||
loadServices(1);
|
||||
} catch (error) {
|
||||
console.error("Failed to navigate to generated service:", error);
|
||||
console.error("Failed to navigate to generated server:", error);
|
||||
}
|
||||
},
|
||||
[updateURL]
|
||||
@@ -196,31 +198,26 @@ export const MCPServicesManagement: React.FC = () => {
|
||||
onSave={handleSaveService}
|
||||
onCancel={handleCancelEdit}
|
||||
loading={loading}
|
||||
onUnpublish={handleToggleStatus}
|
||||
onRefreshList={() => {
|
||||
loadServices(1);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title="MCP Services"
|
||||
description="Manage your MCP services, configure APIs, and monitor service status"
|
||||
title={t("MCP")}
|
||||
description={t(
|
||||
"Manage your MCP servers, configure APIs, and monitor server status"
|
||||
)}
|
||||
>
|
||||
<div className="space-y-6 w-full">
|
||||
{/* comming soon:Filters and Actions */}
|
||||
<ServiceFiltersBar
|
||||
filters={{
|
||||
search: searchTerm,
|
||||
status: statusFilter,
|
||||
}}
|
||||
onFiltersChange={(filters) => {
|
||||
setSearchTerm(filters.search);
|
||||
setStatusFilter(filters.status);
|
||||
}}
|
||||
onAddService={handleCreateService}
|
||||
onImportOpenAPI={handleOpenAPIGenerate}
|
||||
/>
|
||||
<ServiceFiltersBar onAddService={handleCreateService} />
|
||||
|
||||
{/* Services Table */}
|
||||
{/* Servers Table */}
|
||||
<ServiceTable
|
||||
services={services}
|
||||
loading={loading}
|
||||
@@ -232,25 +229,27 @@ export const MCPServicesManagement: React.FC = () => {
|
||||
/>
|
||||
|
||||
{/* Modals */}
|
||||
{
|
||||
isOpenAPIModalOpen && (
|
||||
<OpenAPIGeneratorModal
|
||||
isOpen={true}
|
||||
onClose={handleCloseOpenAPIModal}
|
||||
onGenerate={parseOpenAPIDocument}
|
||||
onEditGenerated={handleEditGeneratedService}
|
||||
/>
|
||||
)
|
||||
}
|
||||
{isOpenAPIModalOpen && (
|
||||
<OpenAPIGeneratorModal
|
||||
isOpen={true}
|
||||
onClose={handleCloseOpenAPIModal}
|
||||
onGenerate={parseOpenAPIDocument}
|
||||
onEditGenerated={handleEditGeneratedService}
|
||||
serverType={addServiceType || "openapi"}
|
||||
/>
|
||||
)}
|
||||
|
||||
<DeleteConfirmModal
|
||||
isOpen={isDeleteModalOpen}
|
||||
onClose={handleCloseDeleteModal}
|
||||
onConfirm={handleConfirmDelete}
|
||||
title={t('Confirm Delete')}
|
||||
description={t('Are you sure you want to delete this "{{name}}" service?', {
|
||||
name: serviceToDelete?.name || "",
|
||||
})}
|
||||
title={t("Confirm Delete")}
|
||||
description={t(
|
||||
'Are you sure you want to delete this "{{name}}" server?',
|
||||
{
|
||||
name: serviceToDelete?.name || "",
|
||||
}
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</DashboardDemoContent>
|
||||
|
||||
@@ -1,50 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button, Tabs, Tab, Spinner } from "@nextui-org/react";
|
||||
import { ChevronLeftIcon } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import {
|
||||
Button,
|
||||
Tabs,
|
||||
Tab,
|
||||
Spinner,
|
||||
} from '@nextui-org/react';
|
||||
import { ChevronLeftIcon } from 'lucide-react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { AuthMethod, MCPServiceFormData } from '@/types/mcp-service';
|
||||
AuthMethod,
|
||||
EnabledEnum,
|
||||
MCPServiceFormData,
|
||||
} from "@/shared/types/mcp-service";
|
||||
import { useMCPServiceDetail } from "@/hooks/useMCPServiceDetail";
|
||||
import { BasicInfoTab } from './BasicInfoTab';
|
||||
import { PricingTab } from './PricingTab';
|
||||
import { DescriptionTab } from './DescriptionTab';
|
||||
import { ToolsTab } from './ToolsTab';
|
||||
import { OpenAPIGeneratorModal } from './OpenAPIGeneratorModal';
|
||||
import { ChargeType } from '@/shared/types/marketplace';
|
||||
import { BasicInfoTab } from "@/shared/components/mcp-services/BasicInfoTab";
|
||||
import { PricingTab } from "@/shared/components/mcp-services/PricingTab";
|
||||
import { DescriptionTab } from "@/shared/components/mcp-services/DescriptionTab";
|
||||
import { ToolsTab } from "@/shared/components/mcp-services/ToolsTab";
|
||||
import { OpenAPIGeneratorModal } from "@/shared/components/mcp-services/OpenAPIGeneratorModal";
|
||||
import { ChargeType } from "@/shared/types/marketplace";
|
||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||
|
||||
const _DefaultFormData: MCPServiceFormData = {
|
||||
id: '',
|
||||
name: '',
|
||||
short_description: '',
|
||||
long_description: '',
|
||||
base_url: '',
|
||||
id: "",
|
||||
name: "",
|
||||
short_description: "",
|
||||
long_description: "",
|
||||
base_url: "",
|
||||
auth_method: AuthMethod.None,
|
||||
auth_header: '',
|
||||
auth_token: '',
|
||||
auth_header: "",
|
||||
auth_token: "",
|
||||
charge_type: ChargeType.Free,
|
||||
price: '',
|
||||
price: "",
|
||||
enabled: 0,
|
||||
tags: [],
|
||||
apis: []
|
||||
}
|
||||
apis: [],
|
||||
};
|
||||
|
||||
interface ServiceEditPageProps {
|
||||
serviceId?: string;
|
||||
onSave: (data: MCPServiceFormData) => void;
|
||||
onSave: (data: MCPServiceFormData, isDraft?: boolean) => void;
|
||||
onCancel: () => void;
|
||||
loading?: boolean;
|
||||
onUnpublish?: (serviceId: string) => void;
|
||||
onRefreshList?: () => void;
|
||||
}
|
||||
|
||||
export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
const BaseServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
serviceId,
|
||||
onSave,
|
||||
onCancel,
|
||||
loading = false
|
||||
loading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const isEditing = !!serviceId;
|
||||
@@ -54,19 +57,21 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
serviceDetail: service,
|
||||
detailLoading: dataLoading,
|
||||
getServiceDetail,
|
||||
clearServiceDetail
|
||||
clearServiceDetail,
|
||||
parseOpenAPIDocumentForUpdate,
|
||||
updateLoading,
|
||||
} = useMCPServiceDetail();
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isDraft, setIsDraft] = useState(false);
|
||||
|
||||
// use services list hook for OpenAPI update
|
||||
const { parseOpenAPIDocumentForUpdate, updateLoading } = useMCPServiceDetail();
|
||||
|
||||
const [formData, setFormData] = useState<MCPServiceFormData>(_DefaultFormData);
|
||||
const [newTag, setNewTag] = useState('');
|
||||
const [formData, setFormData] =
|
||||
useState<MCPServiceFormData>(_DefaultFormData);
|
||||
const [newTag, setNewTag] = useState("");
|
||||
|
||||
// OpenAPI modal state
|
||||
const [isOpenAPIModalOpen, setIsOpenAPIModalOpen] = useState(false);
|
||||
|
||||
// get service detail
|
||||
// get server detail
|
||||
useEffect(() => {
|
||||
if (serviceId) {
|
||||
getServiceDetail(serviceId);
|
||||
@@ -80,42 +85,70 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
|
||||
// when service data loaded, fill form
|
||||
useEffect(() => {
|
||||
if (!serviceId || !service) return
|
||||
if (!serviceId || !service) return;
|
||||
setFormData({
|
||||
...formData,
|
||||
...service
|
||||
...service,
|
||||
});
|
||||
|
||||
}, [service, serviceId]);
|
||||
|
||||
const handleInputChange = (field: keyof MCPServiceFormData, value: any) => {
|
||||
setFormData(prev => ({
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleAddTag = () => {
|
||||
if (newTag.trim() && !(formData.tags || []).includes(newTag.trim())) {
|
||||
setFormData(prev => ({
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
tags: [...(prev.tags || []), newTag.trim()]
|
||||
tags: [...(prev.tags || []), newTag.trim()],
|
||||
}));
|
||||
setNewTag('');
|
||||
setNewTag("");
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveTag = (tagToRemove: string) => {
|
||||
setFormData(prev => ({
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
tags: (prev.tags || []).filter(tag => tag !== tagToRemove)
|
||||
tags: (prev.tags || []).filter((tag) => tag !== tagToRemove),
|
||||
}));
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
onSave(formData);
|
||||
const handleSubmit = async (enabled?: EnabledEnum) => {
|
||||
// Check if slug_name has been modified
|
||||
const isSlugNameChanged =
|
||||
isEditing &&
|
||||
service?.slug_name &&
|
||||
formData.slug_name !== service.slug_name;
|
||||
|
||||
if (isSlugNameChanged) {
|
||||
const confirmed = window.confirm(
|
||||
t(
|
||||
"You have modified the Server ID. This will affect the MCP access URL and may break existing integrations. Are you sure you want to continue?"
|
||||
)
|
||||
);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Proceed with save
|
||||
setIsSaving(true);
|
||||
const isDraft =
|
||||
service?.enabled === EnabledEnum.Offline && enabled === undefined;
|
||||
setIsDraft(isDraft);
|
||||
await onSave(
|
||||
{
|
||||
...formData,
|
||||
headers: formData.headers?.filter((header) => header.name !== ""),
|
||||
...(enabled !== undefined ? { enabled } : {}),
|
||||
},
|
||||
isDraft
|
||||
);
|
||||
setIsSaving(false);
|
||||
setIsDraft(false);
|
||||
};
|
||||
|
||||
// OpenAPI update handlers
|
||||
@@ -127,19 +160,26 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
setIsOpenAPIModalOpen(false);
|
||||
};
|
||||
|
||||
const handleOpenAPIGenerate = async (url?: string, file?: File): Promise<{ service_id: string }> => {
|
||||
const handleOpenAPIGenerate = async (
|
||||
url?: string,
|
||||
file?: File
|
||||
): Promise<{ service_id: string }> => {
|
||||
if (!serviceId) {
|
||||
throw new Error('Service ID is required for update');
|
||||
throw new Error("Server ID is required for update");
|
||||
}
|
||||
|
||||
try {
|
||||
const updatedService = await parseOpenAPIDocumentForUpdate(serviceId, url, file);
|
||||
const updatedService = await parseOpenAPIDocumentForUpdate(
|
||||
serviceId,
|
||||
url,
|
||||
file
|
||||
);
|
||||
|
||||
// update form data
|
||||
setFormData({
|
||||
...formData,
|
||||
...updatedService,
|
||||
update_type: 'openapi'
|
||||
update_type: "openapi",
|
||||
});
|
||||
|
||||
// close modal
|
||||
@@ -148,14 +188,17 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
// return service_id format to compatible with OpenAPIGeneratorModal
|
||||
return { service_id: updatedService.id };
|
||||
} catch (error) {
|
||||
console.error('OpenAPI update failed:', error);
|
||||
console.error("OpenAPI update failed:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const isFormValid = () => {
|
||||
const hasBasicInfo = formData.name.trim() && formData.short_description?.trim();
|
||||
const hasBasicInfo =
|
||||
formData.name.trim() &&
|
||||
formData.short_description?.trim() &&
|
||||
formData.slug_name?.trim() &&
|
||||
formData.base_url?.trim();
|
||||
|
||||
// if free, no need to validate price
|
||||
if (formData.charge_type === ChargeType.Free) {
|
||||
@@ -163,9 +206,11 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
}
|
||||
|
||||
// if paid, need to validate price
|
||||
return hasBasicInfo &&
|
||||
return (
|
||||
hasBasicInfo &&
|
||||
formData.price !== undefined &&
|
||||
formData.price.trim() !== '';
|
||||
formData.price.trim() !== ""
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -173,16 +218,11 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
{/* page title */}
|
||||
<div className="flex items-center justify-between mb-6 px-8">
|
||||
<div className="flex items-center gap-3">
|
||||
<Button
|
||||
isIconOnly
|
||||
onPress={onCancel}
|
||||
variant='flat'
|
||||
size='sm'
|
||||
>
|
||||
<Button isIconOnly onPress={onCancel} variant="flat" size="sm">
|
||||
<ChevronLeftIcon className="w-5 h-5" />
|
||||
</Button>
|
||||
<h1 className="text-2xl font-bold">
|
||||
{isEditing ? t('Service Detail') : t('Create New Service')}
|
||||
{isEditing ? t("Server Detail") : t("Create New Server")}
|
||||
</h1>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -192,20 +232,39 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
onPress={handleOpenAPIUpdate}
|
||||
isDisabled={loading || dataLoading || updateLoading}
|
||||
isLoading={updateLoading}
|
||||
size='sm'
|
||||
size="sm"
|
||||
>
|
||||
{t('Update from OpenAPI')}
|
||||
{t("Update from OpenAPI")}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleSubmit}
|
||||
isDisabled={!isFormValid() || loading || dataLoading || updateLoading}
|
||||
isLoading={updateLoading}
|
||||
size='sm'
|
||||
onPress={() => handleSubmit()}
|
||||
isDisabled={
|
||||
!isFormValid() || loading || dataLoading || updateLoading
|
||||
}
|
||||
isLoading={
|
||||
isSaving && (isDraft || service?.enabled !== EnabledEnum.Offline)
|
||||
}
|
||||
size="sm"
|
||||
>
|
||||
{t('Save')}
|
||||
{service?.enabled === EnabledEnum.Offline
|
||||
? t("Save Draft")
|
||||
: t("Save")}
|
||||
</Button>
|
||||
{service?.enabled === EnabledEnum.Offline && (
|
||||
<Button
|
||||
color="success"
|
||||
onPress={() => handleSubmit(EnabledEnum.Online)}
|
||||
isDisabled={
|
||||
!isFormValid() || loading || dataLoading || updateLoading
|
||||
}
|
||||
isLoading={isSaving && !isDraft}
|
||||
size="sm"
|
||||
>
|
||||
{t("Publish")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -214,7 +273,7 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
<div className="flex-1 flex items-center justify-center">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<Spinner size="lg" />
|
||||
<p className="text-gray-600">{t('Loading service data...')}</p>
|
||||
<p className="text-gray-600">{t("Loading server data...")}</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@@ -222,17 +281,17 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
{/* form content */}
|
||||
{!dataLoading && (
|
||||
<Tabs
|
||||
aria-label="Service edit tabs"
|
||||
variant='bordered'
|
||||
color='primary'
|
||||
aria-label="Server edit tabs"
|
||||
variant="bordered"
|
||||
color="primary"
|
||||
classNames={{
|
||||
panel: "flex-1 overflow-y-auto px-8"
|
||||
panel: "flex-1 overflow-y-auto px-8",
|
||||
}}
|
||||
className=' px-8'
|
||||
className=" px-8"
|
||||
>
|
||||
<Tab key="basic" title={t('Basic Information')}>
|
||||
<Tab key="basic" title={t("Basic Information")}>
|
||||
<div className="pt-2 flex gap-4">
|
||||
<div className='flex-1'>
|
||||
<div className="flex-1">
|
||||
<BasicInfoTab
|
||||
formData={formData}
|
||||
newTag={newTag}
|
||||
@@ -242,7 +301,7 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
onRemoveTag={handleRemoveTag}
|
||||
/>
|
||||
</div>
|
||||
<div className='w-[400px] max-w-[1/2]'>
|
||||
<div className="w-[400px] max-w-[1/2]">
|
||||
<PricingTab
|
||||
formData={formData}
|
||||
onInputChange={handleInputChange}
|
||||
@@ -251,16 +310,13 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
</div>
|
||||
</Tab>
|
||||
|
||||
<Tab key="tools" title={t('Tools Management')}>
|
||||
<Tab key="tools" title={t("Tools Management")}>
|
||||
<div className="pt-2">
|
||||
<ToolsTab
|
||||
formData={formData}
|
||||
onInputChange={handleInputChange}
|
||||
/>
|
||||
<ToolsTab formData={formData} onInputChange={handleInputChange} />
|
||||
</div>
|
||||
</Tab>
|
||||
|
||||
<Tab key="description" title={t('Detailed Description')} >
|
||||
<Tab key="description" title={t("Detailed Description")}>
|
||||
<div className="pt-2 h-full">
|
||||
<DescriptionTab
|
||||
formData={formData}
|
||||
@@ -272,16 +328,18 @@ export const ServiceEditPage: React.FC<ServiceEditPageProps> = ({
|
||||
)}
|
||||
|
||||
{/* OpenAPI Generator Modal */}
|
||||
{
|
||||
isOpenAPIModalOpen && (
|
||||
<OpenAPIGeneratorModal
|
||||
isOpen={true}
|
||||
onClose={handleCloseOpenAPIModal}
|
||||
onGenerate={handleOpenAPIGenerate}
|
||||
mode="update"
|
||||
/>
|
||||
)
|
||||
}
|
||||
{isOpenAPIModalOpen && (
|
||||
<OpenAPIGeneratorModal
|
||||
isOpen={true}
|
||||
onClose={handleCloseOpenAPIModal}
|
||||
onGenerate={handleOpenAPIGenerate}
|
||||
mode="update"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
export const ServiceEditPage = withComponentInjection(
|
||||
"components/mcp-services/ServiceEditPage",
|
||||
BaseServiceEditPage
|
||||
);
|
||||
@@ -1,80 +0,0 @@
|
||||
"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";
|
||||
|
||||
interface ServiceFiltersBarProps {
|
||||
filters: ServiceFilters;
|
||||
onFiltersChange: (filters: ServiceFilters) => void;
|
||||
onAddService: () => void;
|
||||
onImportOpenAPI?: () => void;
|
||||
}
|
||||
|
||||
export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
filters,
|
||||
onFiltersChange,
|
||||
onImportOpenAPI,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSearchChange = (value: string) => {
|
||||
onFiltersChange({ ...filters, search: value });
|
||||
};
|
||||
|
||||
const handleStatusChange = (value: string) => {
|
||||
onFiltersChange({ ...filters, status: value });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:flex-row gap-4">
|
||||
<div className="flex-1">
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={onImportOpenAPI}
|
||||
startContent={<Plus size={16} />}
|
||||
size="sm"
|
||||
>
|
||||
{t("Add Service")}
|
||||
</Button>
|
||||
{/* <Input
|
||||
placeholder={t('Search services...')}
|
||||
value={filters.search}
|
||||
onValueChange={handleSearchChange}
|
||||
startContent={<Search className="w-4 h-4 text-gray-400" />}
|
||||
classNames={{
|
||||
input: "text-sm",
|
||||
inputWrapper: "h-10"
|
||||
}}
|
||||
/> */}
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
{/* <Select
|
||||
placeholder={t('Filter by status')}
|
||||
selectedKeys={filters.status ? [filters.status] : []}
|
||||
onSelectionChange={(keys) => {
|
||||
const value = Array.from(keys)[0] as string;
|
||||
handleStatusChange(value || '');
|
||||
}}
|
||||
className="w-40"
|
||||
classNames={{
|
||||
trigger: "h-10"
|
||||
}}
|
||||
>
|
||||
{[
|
||||
{ key: "all", label: t('All Status') },
|
||||
{ key: "enabled", label: t('Online') },
|
||||
{ key: "disabled", label: t('Offline') }
|
||||
].map((item) => (
|
||||
<SelectItem key={item.key} value={item.key}>
|
||||
{item.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select> */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,77 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import React, { useCallback } from 'react';
|
||||
import {
|
||||
Input,
|
||||
Table,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { MCPServiceAPIItem, MCPServiceFormData } from '@/types/mcp-service';
|
||||
|
||||
interface ToolsTabProps {
|
||||
formData: MCPServiceFormData;
|
||||
onInputChange: (field: keyof MCPServiceFormData, value: any) => void;
|
||||
}
|
||||
|
||||
export const ToolsTab: React.FC<ToolsTabProps> = ({
|
||||
formData,
|
||||
onInputChange
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleToolChange = useCallback((index: number, field: keyof MCPServiceAPIItem, value: string) => {
|
||||
onInputChange('apis', (formData.apis || []).map((api, i) =>
|
||||
i === index ? { ...api, [field]: value } : api
|
||||
));
|
||||
}, [formData.apis, onInputChange]);
|
||||
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Table
|
||||
aria-label="APIs table"
|
||||
removeWrapper
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className='w-1/4'>{t('Tool Name')}</TableColumn>
|
||||
<TableColumn className='w-1/4'>{t('Tool URL')}</TableColumn>
|
||||
<TableColumn>{t('Description')}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody emptyContent={t('No tools added yet. Add your first tool using the input above.')}>
|
||||
{(formData.apis || []).map((tool, index) => (
|
||||
<TableRow
|
||||
key={`tool-${index}`}
|
||||
>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.name}
|
||||
size="sm"
|
||||
isDisabled
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.url}
|
||||
size="sm"
|
||||
isDisabled
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.description || ''}
|
||||
onChange={(e) => handleToolChange(index, 'description', e.target.value)}
|
||||
size="sm"
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -18,6 +18,7 @@ interface StripeConfigFormProps {
|
||||
onEnable: (channelId: string) => Promise<boolean>;
|
||||
onDisable: (channelId: string) => Promise<boolean>;
|
||||
isLoading?: boolean;
|
||||
labelPlacement?: "outside" | "inside";
|
||||
}
|
||||
|
||||
export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
@@ -26,6 +27,7 @@ export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
onEnable,
|
||||
onDisable,
|
||||
isLoading = false,
|
||||
labelPlacement = "inside",
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<StripeConfig>(config);
|
||||
@@ -67,6 +69,115 @@ export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
const isFormValid =
|
||||
formData.secret.trim() !== "" && formData.webhook_secret.trim() !== "";
|
||||
|
||||
const panelContent = () => {
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={`flex flex-col gap-4 ${formData.is_enabled ? "" : "hidden"}`}
|
||||
>
|
||||
{/* Secret Key */}
|
||||
<Input
|
||||
label={t("Secret Key")}
|
||||
placeholder={t("Enter Secret Key")}
|
||||
description={t("Stripe secret key for server-side API calls")}
|
||||
value={formData.secret}
|
||||
onChange={(e) => handleInputChange("secret", e.target.value)}
|
||||
type={showSecretKey ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowSecretKey(!showSecretKey)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showSecretKey ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete="off"
|
||||
isDisabled={!formData.is_enabled}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* Webhook Secret (Optional) */}
|
||||
<Input
|
||||
label={t("Webhook Secret")}
|
||||
placeholder={t("Enter Webhook Secret")}
|
||||
description={t(
|
||||
"Webhook signing secret for verifying Stripe events"
|
||||
)}
|
||||
value={formData.webhook_secret || ""}
|
||||
onChange={(e) =>
|
||||
handleInputChange("webhook_secret", e.target.value)
|
||||
}
|
||||
type={showWebhookSecret ? "text" : "password"}
|
||||
isRequired
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowWebhookSecret(!showWebhookSecret)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showWebhookSecret ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
autoComplete="off"
|
||||
isDisabled={!formData.is_enabled}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
{formData.is_enabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
if (labelPlacement === "outside") {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Enable/Disable Toggle */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Enable Stripe Payment")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Toggle to enable or disable Stripe payment interface")}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={formData.is_enabled || false}
|
||||
onValueChange={handleEnableDisable}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
{panelContent()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
@@ -98,79 +209,7 @@ export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* Secret Key */}
|
||||
<Input
|
||||
label={t("Secret Key")}
|
||||
placeholder="sk_test_... or sk_live_..."
|
||||
description={t("Stripe secret key for server-side API calls")}
|
||||
value={formData.secret}
|
||||
onChange={(e) => handleInputChange("secret", e.target.value)}
|
||||
type={showSecretKey ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowSecretKey(!showSecretKey)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showSecretKey ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete="off"
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* Webhook Secret (Optional) */}
|
||||
<Input
|
||||
label={t("Webhook Secret")}
|
||||
placeholder="whsec_..."
|
||||
description={t(
|
||||
"Webhook signing secret for verifying Stripe events"
|
||||
)}
|
||||
value={formData.webhook_secret || ""}
|
||||
onChange={(e) =>
|
||||
handleInputChange("webhook_secret", e.target.value)
|
||||
}
|
||||
type={showWebhookSecret ? "text" : "password"}
|
||||
isRequired
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowWebhookSecret(!showWebhookSecret)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showWebhookSecret ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
autoComplete="off"
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
{formData.is_enabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{panelContent()}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
|
||||
@@ -6,19 +6,12 @@ import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import { useRevenueManagement } from "@/hooks/useRevenueManagement";
|
||||
|
||||
const RevenueManagement: React.FC = () => {
|
||||
|
||||
// use custom hook to manage revenue data
|
||||
const {
|
||||
records,
|
||||
loading,
|
||||
pagination,
|
||||
setPage,
|
||||
} = useRevenueManagement();
|
||||
|
||||
const { records, loading, pagination, setPage } = useRevenueManagement();
|
||||
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title="Revenue Management"
|
||||
title="Revenue"
|
||||
description="Monitor platform revenue and view user recharge history"
|
||||
>
|
||||
<div className="space-y-6 w-full">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button, AccordionItem, Accordion } from "@nextui-org/react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import MDEditor, { commands } from "@uiw/react-md-editor";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
@@ -53,7 +53,6 @@ export const AboutPageSettings: React.FC<AboutPageSettingsProps> = ({
|
||||
preview="live"
|
||||
hideToolbar={false}
|
||||
visibleDragbar={false}
|
||||
data-color-mode="light"
|
||||
textareaProps={{
|
||||
placeholder: t("Enter about page content (supports Markdown)"),
|
||||
style: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Input, Button, AccordionItem, Accordion, Select, SelectItem } from '@nextui-org/react';
|
||||
import { Eye, EyeOff } from 'lucide-react';
|
||||
import { EmailConfig } from '@/types/system';
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Input, Button, Select, SelectItem } from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { EmailConfig } from "@/types/system";
|
||||
|
||||
interface EmailConfigFormProps {
|
||||
config: EmailConfig;
|
||||
@@ -28,7 +28,7 @@ export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
|
||||
{ key: "465", label: "465 (SMTPS)" },
|
||||
{ key: "587", label: "587 (SMTP with STARTTLS)" },
|
||||
{ key: "2525", label: "2525 (Alternative SMTP)" },
|
||||
{ key: "custom", label: t('Custom') },
|
||||
{ key: "custom", label: t("Custom") },
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
@@ -39,9 +39,9 @@ export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (field: keyof EmailConfig, value: string) => {
|
||||
setFormData(prev => ({
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -50,11 +50,11 @@ export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
|
||||
};
|
||||
|
||||
const isFormValid =
|
||||
formData.smtp_host.trim() !== '' &&
|
||||
formData.smtp_port.trim() !== '' &&
|
||||
formData.smtp_user.trim() !== '' &&
|
||||
formData.smtp_password.trim() !== '' &&
|
||||
formData.smtp_sender.trim() !== '';
|
||||
formData.smtp_host.trim() !== "" &&
|
||||
formData.smtp_port.trim() !== "" &&
|
||||
formData.smtp_user.trim() !== "" &&
|
||||
formData.smtp_password.trim() !== "" &&
|
||||
formData.smtp_sender.trim() !== "";
|
||||
|
||||
// validate email format
|
||||
const isValidEmail = (email: string) => {
|
||||
@@ -68,141 +68,155 @@ export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<Accordion variant='splitted' itemClasses={{
|
||||
base: 'shadow-none border-1',
|
||||
}} defaultExpandedKeys={['email-config']} className='px-0'>
|
||||
<AccordionItem key="email-config" title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold flex items-center gap-2">
|
||||
{t('Email Configuration')}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">{t('Configure SMTP settings for email notifications')}</p>
|
||||
</div>
|
||||
}>
|
||||
<div className="space-y-4">
|
||||
{/* SMTP server address */}
|
||||
<Input
|
||||
label={t('SMTP Host')}
|
||||
placeholder={t('Enter SMTP server address')}
|
||||
description={t('SMTP server hostname or IP address')}
|
||||
value={formData.smtp_host}
|
||||
onChange={(e) => handleInputChange('smtp_host', e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
<>
|
||||
<div className="space-y-4">
|
||||
{/* SMTP server address */}
|
||||
<Input
|
||||
label={t("SMTP Host")}
|
||||
placeholder={t("Enter SMTP server address")}
|
||||
description={t("SMTP server hostname or IP address")}
|
||||
value={formData.smtp_host}
|
||||
onChange={(e) => handleInputChange("smtp_host", e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
{/* SMTP port */}
|
||||
<div className={`flex gap-3 ${isCustomPort ? 'flex-col' : ''}`}>
|
||||
<div className="flex-1">
|
||||
<Select
|
||||
label={t('SMTP Port')}
|
||||
placeholder={t('Select or enter port')}
|
||||
description={t('SMTP server port number')}
|
||||
selectedKeys={isCustomPort ? ["custom"] : (formData.smtp_port ? [formData.smtp_port] : [])}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedPort = Array.from(keys)[0] as string;
|
||||
if (selectedPort === "custom") {
|
||||
setIsCustomPort(true);
|
||||
// 如果当前端口不是预定义端口,保持当前值,否则清空
|
||||
const predefinedPorts = ["25", "465", "587", "2525"];
|
||||
if (predefinedPorts.includes(formData.smtp_port)) {
|
||||
handleInputChange('smtp_port', '');
|
||||
}
|
||||
} else if (selectedPort) {
|
||||
setIsCustomPort(false);
|
||||
handleInputChange('smtp_port', selectedPort);
|
||||
{/* SMTP port */}
|
||||
<div className={`flex gap-3 ${isCustomPort ? "flex-col" : ""}`}>
|
||||
<div className="flex-1">
|
||||
<Select
|
||||
label={t("SMTP Port")}
|
||||
placeholder={t("Select or enter port")}
|
||||
description={t("SMTP server port number")}
|
||||
selectedKeys={
|
||||
isCustomPort
|
||||
? ["custom"]
|
||||
: formData.smtp_port
|
||||
? [formData.smtp_port]
|
||||
: []
|
||||
}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedPort = Array.from(keys)[0] as string;
|
||||
if (selectedPort === "custom") {
|
||||
setIsCustomPort(true);
|
||||
// 如果当前端口不是预定义端口,保持当前值,否则清空
|
||||
const predefinedPorts = ["25", "465", "587", "2525"];
|
||||
if (predefinedPorts.includes(formData.smtp_port)) {
|
||||
handleInputChange("smtp_port", "");
|
||||
}
|
||||
}}
|
||||
isRequired
|
||||
>
|
||||
{commonPorts.map((port) => (
|
||||
<SelectItem key={port.key} value={port.key} textValue={port.label}>
|
||||
{port.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
{isCustomPort && (
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label={t('Custom Port')}
|
||||
placeholder={t('Enter custom port')}
|
||||
value={formData.smtp_port}
|
||||
onChange={(e) => handleInputChange('smtp_port', e.target.value)}
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
color={formData.smtp_port && !isValidPort(formData.smtp_port) ? "danger" : "default"}
|
||||
errorMessage={formData.smtp_port && !isValidPort(formData.smtp_port) ? t('Invalid port number') : ""}
|
||||
isRequired
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
} else if (selectedPort) {
|
||||
setIsCustomPort(false);
|
||||
handleInputChange("smtp_port", selectedPort);
|
||||
}
|
||||
}}
|
||||
isRequired
|
||||
>
|
||||
{commonPorts.map((port) => (
|
||||
<SelectItem
|
||||
key={port.key}
|
||||
value={port.key}
|
||||
textValue={port.label}
|
||||
>
|
||||
{port.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* SMTP username */}
|
||||
<Input
|
||||
label={t('SMTP Username')}
|
||||
placeholder={t('Enter SMTP username')}
|
||||
description={t('Username for SMTP authentication')}
|
||||
value={formData.smtp_user}
|
||||
onChange={(e) => handleInputChange('smtp_user', e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
{/* SMTP password */}
|
||||
<Input
|
||||
label={t('SMTP Password')}
|
||||
placeholder={t('Enter SMTP password')}
|
||||
description={t('Password for SMTP authentication')}
|
||||
value={formData.smtp_password}
|
||||
onChange={(e) => handleInputChange('smtp_password', e.target.value)}
|
||||
type={showPassword ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete='new-password'
|
||||
/>
|
||||
|
||||
{/* sender email */}
|
||||
<Input
|
||||
label={t('Sender Email')}
|
||||
placeholder={t('Enter sender email address')}
|
||||
description={t('Email address used as sender')}
|
||||
value={formData.smtp_sender}
|
||||
onChange={(e) => handleInputChange('smtp_sender', e.target.value)}
|
||||
type="email"
|
||||
isRequired
|
||||
color={formData.smtp_sender && !isValidEmail(formData.smtp_sender) ? "danger" : "default"}
|
||||
errorMessage={formData.smtp_sender && !isValidEmail(formData.smtp_sender) ? t('Invalid email format') : ""}
|
||||
/>
|
||||
{isCustomPort && (
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label={t("Custom Port")}
|
||||
placeholder={t("Enter custom port")}
|
||||
value={formData.smtp_port}
|
||||
onChange={(e) => handleInputChange("smtp_port", e.target.value)}
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
color={
|
||||
formData.smtp_port && !isValidPort(formData.smtp_port)
|
||||
? "danger"
|
||||
: "default"
|
||||
}
|
||||
errorMessage={
|
||||
formData.smtp_port && !isValidPort(formData.smtp_port)
|
||||
? t("Invalid port number")
|
||||
: ""
|
||||
}
|
||||
isRequired
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size='sm'
|
||||
>
|
||||
{t('Save')}
|
||||
</Button>
|
||||
{/* SMTP username */}
|
||||
<Input
|
||||
label={t("SMTP Username")}
|
||||
placeholder={t("Enter SMTP username")}
|
||||
description={t("Username for SMTP authentication")}
|
||||
value={formData.smtp_user}
|
||||
onChange={(e) => handleInputChange("smtp_user", e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
{/* SMTP password */}
|
||||
<Input
|
||||
label={t("SMTP Password")}
|
||||
placeholder={t("Enter SMTP password")}
|
||||
description={t("Password for SMTP authentication")}
|
||||
value={formData.smtp_password}
|
||||
onChange={(e) => handleInputChange("smtp_password", e.target.value)}
|
||||
type={showPassword ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showPassword ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete="new-password"
|
||||
/>
|
||||
|
||||
{/* sender email */}
|
||||
<Input
|
||||
label={t("Sender Email")}
|
||||
placeholder={t("Enter sender email address")}
|
||||
description={t("Email address used as sender")}
|
||||
value={formData.smtp_sender}
|
||||
onChange={(e) => handleInputChange("smtp_sender", e.target.value)}
|
||||
type="email"
|
||||
isRequired
|
||||
color={
|
||||
formData.smtp_sender && !isValidEmail(formData.smtp_sender)
|
||||
? "danger"
|
||||
: "default"
|
||||
}
|
||||
errorMessage={
|
||||
formData.smtp_sender && !isValidEmail(formData.smtp_sender)
|
||||
? t("Invalid email format")
|
||||
: ""
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -13,20 +13,25 @@ import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EmbeddedHtmlConfig } from "@/shared/types/system";
|
||||
|
||||
interface EmbeddedHtmlSettingsProps {
|
||||
onSave?: (config: EmbeddedHtmlConfig) => void;
|
||||
config?: EmbeddedHtmlConfig;
|
||||
onSave?: (config: EmbeddedHtmlConfig) => Promise<boolean>;
|
||||
config?: EmbeddedHtmlConfig | null;
|
||||
labelPlacement?: "outside" | "inside";
|
||||
}
|
||||
|
||||
export const EmbeddedHtmlSettings: React.FC<EmbeddedHtmlSettingsProps> = ({
|
||||
onSave,
|
||||
config = { html: "", is_enabled: false },
|
||||
labelPlacement = "inside",
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [htmlData, setHtmlData] = useState<EmbeddedHtmlConfig>(config);
|
||||
const [htmlData, setHtmlData] = useState<EmbeddedHtmlConfig>(
|
||||
config || { html: "", is_enabled: false }
|
||||
);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!config) return;
|
||||
setHtmlData(config);
|
||||
}, [config]);
|
||||
}, [config?.html, config?.is_enabled]);
|
||||
|
||||
const handleSave = async () => {
|
||||
setIsSaving(true);
|
||||
@@ -51,84 +56,61 @@ export const EmbeddedHtmlSettings: React.FC<EmbeddedHtmlSettingsProps> = ({
|
||||
setHtmlData((prev) => ({ ...prev, is_enabled: enabled }));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
className="px-0"
|
||||
defaultExpandedKeys={["embedded-html"]}
|
||||
>
|
||||
<AccordionItem
|
||||
key="embedded-html"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold flex items-center gap-2">
|
||||
{t("Embedded HTML")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure custom HTML content for global injection")}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* Enable/Disable Toggle */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Enable Custom HTML")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Toggle to enable or disable custom HTML injection")}
|
||||
</span>
|
||||
const panelContent = () => {
|
||||
return (
|
||||
<>
|
||||
<div className="mb-4">
|
||||
<div className="space-y-4">
|
||||
{/* Enable/Disable Toggle */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
{t("Enable Custom HTML")}
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Toggle to enable or disable custom HTML injection")}
|
||||
</span>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={htmlData.is_enabled}
|
||||
onValueChange={handleToggleEnabled}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={htmlData.is_enabled}
|
||||
onValueChange={handleToggleEnabled}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* HTML Editor */}
|
||||
<div className="space-y-2">
|
||||
<Textarea
|
||||
placeholder={t(
|
||||
"Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n<script>\n // Google Analytics\n gtag('config', 'GA_MEASUREMENT_ID');\n</script>\n\n<style>\n .custom-style {\n color: #333;\n }\n</style>"
|
||||
)}
|
||||
value={htmlData.html}
|
||||
onValueChange={handleHtmlChange}
|
||||
minRows={10}
|
||||
maxRows={20}
|
||||
description={t(
|
||||
"This HTML will be injected globally into the application. You can include script tags, CSS styles, or any valid HTML."
|
||||
)}
|
||||
radius="sm"
|
||||
className="text-xs"
|
||||
isDisabled={!htmlData.is_enabled}
|
||||
/>
|
||||
{/* HTML Editor */}
|
||||
<div className={`space-y-2 ${htmlData.is_enabled ? "" : "hidden"}`}>
|
||||
<Textarea
|
||||
value={htmlData.html}
|
||||
onValueChange={handleHtmlChange}
|
||||
minRows={10}
|
||||
maxRows={20}
|
||||
description={t(
|
||||
"This HTML will be injected globally into the application. You can include script tags, CSS styles, or any valid HTML."
|
||||
)}
|
||||
radius="sm"
|
||||
className="text-xs"
|
||||
isDisabled={!htmlData.is_enabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/* Action Buttons */}
|
||||
{htmlData.is_enabled && (
|
||||
<div className="flex gap-3 mt-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isSaving}
|
||||
isDisabled={!htmlData.html.trim()}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
{htmlData.is_enabled && (
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isSaving}
|
||||
isDisabled={!htmlData.html.trim()}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Usage Instructions */}
|
||||
<Alert
|
||||
color="primary"
|
||||
@@ -159,6 +141,37 @@ export const EmbeddedHtmlSettings: React.FC<EmbeddedHtmlSettingsProps> = ({
|
||||
</ul>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
if (labelPlacement === "outside") {
|
||||
return panelContent();
|
||||
}
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
className="px-0"
|
||||
defaultExpandedKeys={["embedded-html"]}
|
||||
>
|
||||
<AccordionItem
|
||||
key="embedded-html"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold flex items-center gap-2">
|
||||
{t("Embedded HTML")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure custom HTML content for global injection")}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{panelContent()}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
|
||||
@@ -22,11 +22,13 @@ import { FaqItem } from "@/shared/types/system";
|
||||
interface FaqSettingsProps {
|
||||
onSave?: (config: FaqItem[]) => void;
|
||||
config?: FaqItem[];
|
||||
labelPlacement?: "inside" | "outside";
|
||||
}
|
||||
const defaultFaqs = [{ question: "", answer: "" }];
|
||||
export const FaqSettings: React.FC<FaqSettingsProps> = ({
|
||||
onSave,
|
||||
config = [],
|
||||
labelPlacement = "inside",
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [faqs, setFaqs] = useState<FaqItem[]>(
|
||||
@@ -110,6 +112,125 @@ export const FaqSettings: React.FC<FaqSettingsProps> = ({
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
const panelContent = () => {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* FAQ Table */}
|
||||
<Table
|
||||
aria-label="FAQ management table"
|
||||
className="border-1 rounded-lg overflow-hidden"
|
||||
removeWrapper
|
||||
classNames={{
|
||||
thead: "[&>tr]:first:rounded-none",
|
||||
th: "first:rounded-none last:rounded-none",
|
||||
}}
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className="w-16">{t("Order")}</TableColumn>
|
||||
<TableColumn className="w-1/3">{t("Question")}</TableColumn>
|
||||
<TableColumn>{t("Answer")}</TableColumn>
|
||||
<TableColumn className="w-32">{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody emptyContent={t("No FAQ items available.")}>
|
||||
{faqs.map((faq, index) => (
|
||||
<TableRow
|
||||
key={index}
|
||||
draggable
|
||||
onDragStart={() => handleDragStart(index)}
|
||||
onDragEnter={() => handleDragEnter(index)}
|
||||
onDragEnd={handleDragEnd}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
className="cursor-move"
|
||||
>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<GripVertical className="w-4 h-4 text-gray-400" />
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={faq.question}
|
||||
onValueChange={(value) =>
|
||||
handleQuestionChange(index, value)
|
||||
}
|
||||
size="sm"
|
||||
placeholder={t("Enter question")}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="relative">
|
||||
<Input
|
||||
value={faq.answer}
|
||||
onValueChange={(value) =>
|
||||
handleAnswerChange(index, value)
|
||||
}
|
||||
onFocus={() => setFocusedAnswer(index)}
|
||||
size="sm"
|
||||
placeholder={t("Enter answer")}
|
||||
/>
|
||||
{focusedAnswer === index && (
|
||||
<div className="absolute top-0 left-0 right-0 z-50">
|
||||
<Textarea
|
||||
value={faq.answer}
|
||||
onValueChange={(value) =>
|
||||
handleAnswerChange(index, value)
|
||||
}
|
||||
size="sm"
|
||||
minRows={3}
|
||||
onBlur={() => setFocusedAnswer(null)}
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex gap-1">
|
||||
<Tooltip content={t("Insert below")}>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
onPress={() => handleInsertBelow(index)}
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("Delete")} color="danger">
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color="danger"
|
||||
onPress={() => handleDelete(index)}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<div className="flex ">
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleSaveAll}
|
||||
isLoading={isSaving}
|
||||
isDisabled={faqs.length === 0}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
if (labelPlacement === "outside") {
|
||||
return panelContent();
|
||||
}
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
@@ -133,115 +254,7 @@ export const FaqSettings: React.FC<FaqSettingsProps> = ({
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* FAQ Table */}
|
||||
<Table
|
||||
aria-label="FAQ management table"
|
||||
className="border-1 rounded-lg p-2"
|
||||
removeWrapper
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className="w-16">{t("Order")}</TableColumn>
|
||||
<TableColumn className="w-1/3">{t("Question")}</TableColumn>
|
||||
<TableColumn>{t("Answer")}</TableColumn>
|
||||
<TableColumn className="w-32">{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody emptyContent={t("No FAQ items available.")}>
|
||||
{faqs.map((faq, index) => (
|
||||
<TableRow
|
||||
key={index}
|
||||
draggable
|
||||
onDragStart={() => handleDragStart(index)}
|
||||
onDragEnter={() => handleDragEnter(index)}
|
||||
onDragEnd={handleDragEnd}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
className="cursor-move"
|
||||
>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<GripVertical className="w-4 h-4 text-gray-400" />
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={faq.question}
|
||||
onValueChange={(value) =>
|
||||
handleQuestionChange(index, value)
|
||||
}
|
||||
placeholder={t("Enter question")}
|
||||
size="sm"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="relative">
|
||||
<Input
|
||||
value={faq.answer}
|
||||
onValueChange={(value) =>
|
||||
handleAnswerChange(index, value)
|
||||
}
|
||||
onFocus={() => setFocusedAnswer(index)}
|
||||
placeholder={t("Enter answer")}
|
||||
size="sm"
|
||||
/>
|
||||
{focusedAnswer === index && (
|
||||
<div className="absolute top-0 left-0 right-0 z-50">
|
||||
<Textarea
|
||||
value={faq.answer}
|
||||
onValueChange={(value) =>
|
||||
handleAnswerChange(index, value)
|
||||
}
|
||||
placeholder={t("Enter answer")}
|
||||
size="sm"
|
||||
minRows={3}
|
||||
onBlur={() => setFocusedAnswer(null)}
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex gap-1">
|
||||
<Tooltip content={t("Insert below")}>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
onPress={() => handleInsertBelow(index)}
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("Delete")} color="danger">
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color="danger"
|
||||
onPress={() => handleDelete(index)}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<div className="flex ">
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleSaveAll}
|
||||
isLoading={isSaving}
|
||||
isDisabled={faqs.length === 0}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{panelContent()}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button, Select, SelectItem } from "@nextui-org/react";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import i18n, { SUPPORTED_LANGUAGES } from "@/shared/lib/i18n";
|
||||
|
||||
interface LanguageSettingProps {
|
||||
config: PlatformConfig;
|
||||
onSave: (config: PlatformConfig) => void;
|
||||
}
|
||||
|
||||
export const LanguageSetting: React.FC<LanguageSettingProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [formData, setFormData] = useState<PlatformConfig>(config);
|
||||
|
||||
// when context config updated, sync to form
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (
|
||||
field: keyof PlatformConfig,
|
||||
value: string | boolean
|
||||
) => {
|
||||
setFormData((prev) => {
|
||||
const newData = {
|
||||
...prev,
|
||||
[field]: value,
|
||||
};
|
||||
|
||||
return newData;
|
||||
});
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
setIsLoading(true);
|
||||
await onSave(formData);
|
||||
i18n.changeLanguage(formData.language);
|
||||
setIsLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* platform language */}
|
||||
<Select
|
||||
placeholder={t("Select platform language")}
|
||||
selectedKeys={formData.language ? [formData.language] : ["en"]}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
if (selectedKey) {
|
||||
handleInputChange("language", selectedKey);
|
||||
}
|
||||
}}
|
||||
labelPlacement="outside"
|
||||
>
|
||||
{SUPPORTED_LANGUAGES.map((language) => (
|
||||
<SelectItem key={language.name} value={language.name}>
|
||||
{language.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex gap-3 py-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useMemo, useRef } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
Select,
|
||||
SelectItem,
|
||||
Switch,
|
||||
Card,
|
||||
Spinner,
|
||||
} from "@nextui-org/react";
|
||||
import { PlatformConfig, Theme } from "@/shared/types/system";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
@@ -17,26 +19,37 @@ import { ThemeSelector } from "./ThemeSelector";
|
||||
import "@uiw/react-md-editor/markdown-editor.css";
|
||||
import "@uiw/react-markdown-preview/markdown.css";
|
||||
import toast from "react-hot-toast";
|
||||
import { UploadIcon } from "lucide-react";
|
||||
import { calculateFileSha256 } from "@/shared/utils/crypto";
|
||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||
|
||||
interface PlatformConfigFormProps {
|
||||
config: PlatformConfig;
|
||||
onSave: (config: PlatformConfig) => void;
|
||||
onThemeChange?: (theme: Theme) => Promise<void>;
|
||||
isLoading?: boolean;
|
||||
uploadImage: (file: File, sha256?: string) => Promise<string>;
|
||||
}
|
||||
|
||||
export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
const PlatformConfigFormBase: React.FC<PlatformConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onThemeChange,
|
||||
isLoading = false,
|
||||
uploadImage,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [formData, setFormData] = useState<PlatformConfig>(config);
|
||||
const [validationErrors, setValidationErrors] = useState<{
|
||||
domain?: string;
|
||||
mcp_server_prefix?: string;
|
||||
}>({});
|
||||
const [isUploading, setIsUploading] = useState(false);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const isValidate = useMemo(() => {
|
||||
return formData.name.trim().length > 0 && !isUploading;
|
||||
}, [formData, isUploading]);
|
||||
|
||||
// when context config updated, sync to form
|
||||
useEffect(() => {
|
||||
@@ -122,6 +135,42 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
handleInputChange("theme", theme);
|
||||
onThemeChange?.(theme);
|
||||
};
|
||||
const handleImageUpload = async (
|
||||
event: React.ChangeEvent<HTMLInputElement>
|
||||
) => {
|
||||
const file = event.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
// Validate file type
|
||||
if (!file.type.startsWith("image/")) {
|
||||
toast.error(t("Please select a valid image file"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate file size (max 5MB)
|
||||
if (file.size > 5 * 1024 * 1024) {
|
||||
toast.error(t("Image size should be less than 5MB"));
|
||||
return;
|
||||
}
|
||||
|
||||
setIsUploading(true);
|
||||
try {
|
||||
const sha256 = await calculateFileSha256(file);
|
||||
const imageUrl = await uploadImage(file, sha256);
|
||||
handleInputChange("logo", imageUrl);
|
||||
} catch (error) {
|
||||
console.error("Upload failed:", error);
|
||||
toast.error(t("Failed to upload image"));
|
||||
} finally {
|
||||
setIsUploading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleImageClick = () => {
|
||||
if (!isUploading) {
|
||||
fileInputRef.current?.click();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -147,7 +196,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* platform name */}
|
||||
<Input
|
||||
label={t("Platform Name")}
|
||||
@@ -155,16 +204,53 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
description={t("The name displayed across the platform")}
|
||||
value={formData.name}
|
||||
onChange={(e) => handleInputChange("name", e.target.value)}
|
||||
isRequired
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* platform logo */}
|
||||
<Input
|
||||
label={t("Platform Logo URL")}
|
||||
placeholder="https://example.com/logo.png"
|
||||
description={t("URL of the platform logo image (optional)")}
|
||||
value={formData.logo || ""}
|
||||
onChange={(e) => handleInputChange("logo", e.target.value)}
|
||||
/>
|
||||
<div className="space-y-2">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-foreground">
|
||||
{t("Platform Logo")}
|
||||
</label>
|
||||
<p className="text-xs text-gray-500">
|
||||
{t("Support JPG, PNG, GIF. Max size 5MB")}
|
||||
</p>
|
||||
</div>
|
||||
<Card
|
||||
className={`w-32 h-32 relative group border-1 ${isUploading ? "cursor-not-allowed" : "cursor-pointer"}`}
|
||||
style={{
|
||||
backgroundImage: formData.logo
|
||||
? `url(${formData.logo})`
|
||||
: "none",
|
||||
backgroundSize: "contain",
|
||||
backgroundPosition: "center",
|
||||
backgroundRepeat: "no-repeat",
|
||||
}}
|
||||
onPress={handleImageClick}
|
||||
isPressable={!isUploading}
|
||||
shadow="none"
|
||||
>
|
||||
<div
|
||||
className={`absolute top-0 right-0 bg-default-500/50 w-full h-full flex items-center justify-center transition-opacity duration-300 ${formData.logo && !isUploading ? "opacity-0" : "opacity-100"
|
||||
} group-hover:opacity-100`}
|
||||
>
|
||||
{isUploading ? (
|
||||
<Spinner size="lg" color="white" />
|
||||
) : (
|
||||
<UploadIcon size={48} className="text-white" />
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
onChange={handleImageUpload}
|
||||
className="hidden"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* website title */}
|
||||
<Input
|
||||
@@ -177,6 +263,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
onChange={(e) =>
|
||||
handleInputChange("website_title", e.target.value)
|
||||
}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* homepage headline */}
|
||||
@@ -186,6 +273,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
description={t("Main headline displayed on the homepage")}
|
||||
value={formData.headline || ""}
|
||||
onChange={(e) => handleInputChange("headline", e.target.value)}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* homepage subheadline */}
|
||||
@@ -197,6 +285,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
)}
|
||||
value={formData.subheadline || ""}
|
||||
onChange={(e) => handleInputChange("subheadline", e.target.value)}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* platform language */}
|
||||
@@ -210,6 +299,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
handleInputChange("language", selectedKey);
|
||||
}
|
||||
}}
|
||||
labelPlacement="outside"
|
||||
>
|
||||
{SUPPORTED_LANGUAGES.map((language) => (
|
||||
<SelectItem key={language.name} value={language.name}>
|
||||
@@ -229,6 +319,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
onChange={(e) => handleInputChange("domain", e.target.value)}
|
||||
isInvalid={!!validationErrors.domain}
|
||||
errorMessage={validationErrors.domain}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* mcp server prefix */}
|
||||
@@ -244,6 +335,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
}
|
||||
isInvalid={!!validationErrors.mcp_server_prefix}
|
||||
errorMessage={validationErrors.mcp_server_prefix}
|
||||
labelPlacement="outside"
|
||||
/>
|
||||
|
||||
{/* showcase in xpack */}
|
||||
@@ -277,6 +369,7 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
size="sm"
|
||||
isDisabled={!isValidate}
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
@@ -315,3 +408,12 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// Export the base component for direct use (avoiding circular dependency)
|
||||
export { PlatformConfigFormBase };
|
||||
|
||||
// Export with component injection support
|
||||
export const PlatformConfigForm = withComponentInjection(
|
||||
"forms/PlatformConfigForm",
|
||||
PlatformConfigFormBase
|
||||
);
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
interface TopNavigationSettingsProps {
|
||||
onSave?: (config: TopNavigationItem[]) => void;
|
||||
config?: TopNavigationItem[];
|
||||
labelPlacement?: "outside" | "inside";
|
||||
}
|
||||
const defaultNavigationItems = [
|
||||
{ title: "", link: "", target: TopNavigationTargetEnum.BLANK },
|
||||
@@ -33,6 +34,7 @@ const defaultNavigationItems = [
|
||||
export const TopNavigationSettings: React.FC<TopNavigationSettingsProps> = ({
|
||||
onSave,
|
||||
config = [],
|
||||
labelPlacement = "inside",
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [navigationItems, setNavigationItems] = useState<TopNavigationItem[]>(
|
||||
@@ -129,6 +131,133 @@ export const TopNavigationSettings: React.FC<TopNavigationSettingsProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
const panelContent = () => {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Navigation Table */}
|
||||
<Table
|
||||
aria-label="Navigation items management table"
|
||||
className="border-1 rounded-lg overflow-hidden"
|
||||
removeWrapper
|
||||
classNames={{
|
||||
thead: "[&>tr]:first:rounded-none",
|
||||
th: "first:rounded-none last:rounded-none",
|
||||
}}
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className="w-8">{t("Order")}</TableColumn>
|
||||
<TableColumn className="w-1/4">{t("Title")}</TableColumn>
|
||||
<TableColumn>{t("Link")}</TableColumn>
|
||||
<TableColumn className="w-32">{t("Target")}</TableColumn>
|
||||
<TableColumn className="w-8">{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody emptyContent={t("No navigation items available.")}>
|
||||
{navigationItems.map((item, index) => (
|
||||
<TableRow
|
||||
key={index}
|
||||
draggable
|
||||
onDragStart={() => handleDragStart(index)}
|
||||
onDragEnter={() => handleDragEnter(index)}
|
||||
onDragEnd={handleDragEnd}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
className="cursor-move"
|
||||
>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<GripVertical className="w-4 h-4 text-gray-400" />
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={item.title}
|
||||
onValueChange={(value) => handleTitleChange(index, value)}
|
||||
placeholder={t("Enter title")}
|
||||
size="sm"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={item.link}
|
||||
onValueChange={(value) => handleHrefChange(index, value)}
|
||||
placeholder={t("Enter link URL")}
|
||||
size="sm"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Select
|
||||
selectedKeys={[item.target]}
|
||||
onSelectionChange={(keys) => {
|
||||
const target = Array.from(keys)[0] as
|
||||
| TopNavigationTargetEnum.SELF
|
||||
| TopNavigationTargetEnum.BLANK;
|
||||
handleTargetChange(index, target);
|
||||
}}
|
||||
size="sm"
|
||||
className="min-w-24"
|
||||
>
|
||||
<SelectItem
|
||||
key={TopNavigationTargetEnum.SELF}
|
||||
value={TopNavigationTargetEnum.SELF}
|
||||
>
|
||||
{t("Same Tab")}
|
||||
</SelectItem>
|
||||
<SelectItem
|
||||
key={TopNavigationTargetEnum.BLANK}
|
||||
value={TopNavigationTargetEnum.BLANK}
|
||||
>
|
||||
{t("New Tab")}
|
||||
</SelectItem>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex gap-1">
|
||||
<Tooltip content={t("Insert below")}>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
onPress={() => handleInsertBelow(index)}
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("Delete")} color="danger">
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color="danger"
|
||||
onPress={() => handleDelete(index)}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<div className="flex">
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleSaveAll}
|
||||
isLoading={isSaving}
|
||||
isDisabled={navigationItems.length === 0}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
if (labelPlacement === "outside") {
|
||||
return panelContent();
|
||||
}
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
@@ -151,120 +280,7 @@ export const TopNavigationSettings: React.FC<TopNavigationSettingsProps> = ({
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* Navigation Table */}
|
||||
<Table
|
||||
aria-label="Navigation items management table"
|
||||
className="border-1 rounded-lg p-2"
|
||||
removeWrapper
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className="w-16">{t("Order")}</TableColumn>
|
||||
<TableColumn className="w-1/4">{t("Title")}</TableColumn>
|
||||
<TableColumn className="w-1/3">{t("Link")}</TableColumn>
|
||||
<TableColumn className="w-32">{t("Target")}</TableColumn>
|
||||
<TableColumn className="w-32">{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody emptyContent={t("No navigation items available.")}>
|
||||
{navigationItems.map((item, index) => (
|
||||
<TableRow
|
||||
key={index}
|
||||
draggable
|
||||
onDragStart={() => handleDragStart(index)}
|
||||
onDragEnter={() => handleDragEnter(index)}
|
||||
onDragEnd={handleDragEnd}
|
||||
onDragOver={(e) => e.preventDefault()}
|
||||
className="cursor-move"
|
||||
>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<GripVertical className="w-4 h-4 text-gray-400" />
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={item.title}
|
||||
onValueChange={(value) => handleTitleChange(index, value)}
|
||||
placeholder={t("Enter title")}
|
||||
size="sm"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={item.link}
|
||||
onValueChange={(value) => handleHrefChange(index, value)}
|
||||
placeholder={t("Enter link URL")}
|
||||
size="sm"
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Select
|
||||
selectedKeys={[item.target]}
|
||||
onSelectionChange={(keys) => {
|
||||
const target = Array.from(keys)[0] as
|
||||
| TopNavigationTargetEnum.SELF
|
||||
| TopNavigationTargetEnum.BLANK;
|
||||
handleTargetChange(index, target);
|
||||
}}
|
||||
size="sm"
|
||||
className="min-w-24"
|
||||
>
|
||||
<SelectItem
|
||||
key={TopNavigationTargetEnum.SELF}
|
||||
value={TopNavigationTargetEnum.SELF}
|
||||
>
|
||||
{t("Same Tab")}
|
||||
</SelectItem>
|
||||
<SelectItem
|
||||
key={TopNavigationTargetEnum.BLANK}
|
||||
value={TopNavigationTargetEnum.BLANK}
|
||||
>
|
||||
{t("New Tab")}
|
||||
</SelectItem>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex gap-1">
|
||||
<Tooltip content={t("Insert below")}>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
onPress={() => handleInsertBelow(index)}
|
||||
>
|
||||
<Plus className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Tooltip content={t("Delete")} color="danger">
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color="danger"
|
||||
onPress={() => handleDelete(index)}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<div className="flex">
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleSaveAll}
|
||||
isLoading={isSaving}
|
||||
isDisabled={navigationItems.length === 0}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{panelContent()}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
|
||||
@@ -11,20 +11,14 @@ import { Navigation } from "@/shared/components/Navigation";
|
||||
import { Footer } from "@/shared/components/Footer";
|
||||
import { NavigationItems } from "@/components/theme/Theme.const";
|
||||
import { AboutContent } from "@/components/about/AboutContent";
|
||||
import { useNavigationItems } from "@/shared/providers/ConfigProvider";
|
||||
|
||||
export const AboutThemeSelector: React.FC = () => {
|
||||
const { platformConfig, topNavigation } = usePlatformConfig();
|
||||
const currentTheme = platformConfig.theme || Theme.DEFAULT;
|
||||
const configNavigation = useNavigationItems() || NavigationItems;
|
||||
const navigationItems = [
|
||||
...NavigationItems,
|
||||
...(platformConfig.about_page
|
||||
? [
|
||||
{
|
||||
label: "About",
|
||||
href: "/about",
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...configNavigation,
|
||||
...topNavigation.map((item) => ({
|
||||
label: item.title,
|
||||
href: item.link,
|
||||
|
||||
@@ -15,6 +15,9 @@ import { NavigationItems } from "./Theme.const";
|
||||
import { copyToClipboard } from "@/shared/utils/clipboard";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { sanitizeMCPServerName } from "@/shared/utils/mcp";
|
||||
import { useNavigationItems } from "@/shared/providers/ConfigProvider";
|
||||
import { withComponentInjection } from "@/shared/hooks/useComponentInjection";
|
||||
|
||||
interface ProductDetailThemeSelectorProps {
|
||||
product: ServiceData;
|
||||
@@ -24,7 +27,7 @@ interface ProductDetailThemeSelectorProps {
|
||||
}[];
|
||||
}
|
||||
|
||||
export const ProductDetailThemeSelector: React.FC<
|
||||
const BasicProductDetailThemeSelector: React.FC<
|
||||
ProductDetailThemeSelectorProps
|
||||
> = ({ product, breadcrumbs }) => {
|
||||
const { platformConfig, topNavigation } = usePlatformConfig();
|
||||
@@ -34,16 +37,10 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
const [url, setUrl] = useState<string>("");
|
||||
const [mcpName, setMcpName] = useState<string>("");
|
||||
const { t } = useTranslation();
|
||||
const configNavigation = useNavigationItems() || NavigationItems;
|
||||
|
||||
const navigationItems = [
|
||||
...NavigationItems,
|
||||
...(platformConfig.about_page
|
||||
? [
|
||||
{
|
||||
label: "About",
|
||||
href: "/about",
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...configNavigation,
|
||||
...topNavigation.map((item) => ({
|
||||
label: item.title,
|
||||
href: item.link,
|
||||
@@ -53,29 +50,9 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
useEffect(() => {
|
||||
if (url || !product.slug_name) return;
|
||||
setUrl(
|
||||
`${
|
||||
mcpServerPrefix ||
|
||||
`${window.location.protocol}//${window.location.hostname}:8002`
|
||||
}/mcp/${product.slug_name}`
|
||||
`${mcpServerPrefix || window.location.origin}/mcp/${product.slug_name}`
|
||||
);
|
||||
}, [product.slug_name]);
|
||||
function sanitizeMCPServerName(rawName: string | undefined): string {
|
||||
if (!rawName) return "xpack-mcp-service";
|
||||
|
||||
// Lower-case & replace invalid chars with hyphen
|
||||
let name = rawName
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9-_]+/g, "-");
|
||||
|
||||
// Collapse multiple hyphens
|
||||
name = name.replace(/-+/g, "-");
|
||||
|
||||
// Trim leading/trailing hyphens
|
||||
name = name.replace(/^-+/, "").replace(/-+$/, "");
|
||||
|
||||
return name || "mcp-service";
|
||||
}
|
||||
useEffect(() => {
|
||||
setMcpName(sanitizeMCPServerName(product.name));
|
||||
}, [product.name]);
|
||||
@@ -85,7 +62,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey={Your-${platformConfig?.name}-API-Key}"
|
||||
"url": "${url}?authkey={Your-${platformConfig?.name}-Auth-Key}"
|
||||
}
|
||||
}
|
||||
}`;
|
||||
@@ -165,3 +142,7 @@ export const ProductDetailThemeSelector: React.FC<
|
||||
);
|
||||
}
|
||||
};
|
||||
export const ProductDetailThemeSelector = withComponentInjection(
|
||||
"components/theme/ProductDetailThemeSelector",
|
||||
BasicProductDetailThemeSelector
|
||||
);
|
||||
@@ -1,8 +1,3 @@
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
export const NavigationItems: NavigationItem[] = [
|
||||
{
|
||||
label: "Home",
|
||||
href: "/",
|
||||
},
|
||||
];
|
||||
export const NavigationItems: NavigationItem[] = [];
|
||||
@@ -15,6 +15,7 @@ import { MarketplaceMain } from "../marketplace/Main";
|
||||
import { Footer } from "@/shared/components/Footer";
|
||||
import { NavigationItems } from "./Theme.const";
|
||||
import { Faq } from "../marketplace/Faq";
|
||||
import { useNavigationItems } from "@/shared/providers/ConfigProvider";
|
||||
|
||||
interface ThemeSelectorProps {
|
||||
initialServices: ServiceData[];
|
||||
@@ -36,16 +37,9 @@ export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
|
||||
const router = useRouter();
|
||||
const { platformConfig, topNavigation } = usePlatformConfig();
|
||||
const currentTheme = platformConfig.theme || Theme.DEFAULT;
|
||||
const configNavigation = useNavigationItems() || NavigationItems;
|
||||
const navigationItems = [
|
||||
...NavigationItems,
|
||||
...(platformConfig.about_page
|
||||
? [
|
||||
{
|
||||
label: "About",
|
||||
href: "/about",
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...configNavigation,
|
||||
...topNavigation.map((item) => ({
|
||||
label: item.title,
|
||||
href: item.link,
|
||||
@@ -61,7 +55,7 @@ export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
// search suggestion
|
||||
const searchSuggestions = ["Search services..."];
|
||||
const searchSuggestions = ["Search MCP servers"];
|
||||
|
||||
// loading service data
|
||||
const loadServices = async (page: number, search: string) => {
|
||||
@@ -77,7 +71,7 @@ export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
|
||||
setTotal(result.page.total);
|
||||
setCurrentPage(page);
|
||||
} catch (error) {
|
||||
console.error("Failed to load services:", error);
|
||||
console.error("Failed to load servers:", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const ClassicDemo: React.FC = () => {
|
||||
<div className="bg-gray-100 border-b border-gray-300 px-4 py-1">
|
||||
<div className="flex space-x-4">
|
||||
<div className="text-xs text-gray-700 font-medium">Home</div>
|
||||
<div className="text-xs text-gray-500">Services</div>
|
||||
<div className="text-xs text-gray-500">Servers</div>
|
||||
<div className="text-xs text-gray-500">About</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,13 +47,13 @@ const ClassicDemo: React.FC = () => {
|
||||
{/* Content Section */}
|
||||
<div className="px-4 py-4 bg-gray-50">
|
||||
<div className="grid grid-cols-1 gap-3">
|
||||
{/* Service Item */}
|
||||
{/* Server Item */}
|
||||
<div className="bg-white border border-gray-200 rounded-sm p-3 shadow-sm">
|
||||
<div className="flex items-start space-x-3">
|
||||
<div className="w-4 h-4 bg-slate-600 rounded-sm mt-0.5"></div>
|
||||
<div className="flex-1">
|
||||
<div className="text-xs font-semibold text-slate-800 mb-1">
|
||||
Business Service
|
||||
Business Server
|
||||
</div>
|
||||
<div className="text-xs text-gray-600">
|
||||
Professional solutions for enterprise
|
||||
@@ -62,7 +62,7 @@ const ClassicDemo: React.FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service Item */}
|
||||
{/* Server Item */}
|
||||
<div className="bg-white border border-gray-200 rounded-sm p-3 shadow-sm">
|
||||
<div className="flex items-start space-x-3">
|
||||
<div className="w-4 h-4 bg-red-600 rounded-sm mt-0.5"></div>
|
||||
|
||||
@@ -13,6 +13,7 @@ import Link from "next/link";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||
|
||||
interface DetailProps {
|
||||
product: ServiceData;
|
||||
@@ -25,6 +26,7 @@ interface DetailProps {
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
onCopy: () => void;
|
||||
innerHeaderNode?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
@@ -33,6 +35,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
mcpName,
|
||||
navItems = [],
|
||||
onCopy,
|
||||
innerHeaderNode,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
@@ -47,8 +50,8 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<Navigation items={navItems} />
|
||||
<div>
|
||||
{/* Classic Product Header */}
|
||||
<div className="bg-white border-b border-gray-200 shadow-sm pt-28 pb-6">
|
||||
<div className="mx-auto p-6 max-w-7xl">
|
||||
<div className="bg-white border-b border-gray-200 shadow-sm pt-20 pb-6">
|
||||
<div className="mx-auto p-6 max-w-7xl relative">
|
||||
<div className="bg-gray-50 rounded-sm p-6 border border-gray-200">
|
||||
<Card shadow="none" className="bg-gray-50">
|
||||
<CardBody>
|
||||
@@ -107,6 +110,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
{innerHeaderNode}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -185,7 +189,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<Card>
|
||||
<CardBody>
|
||||
<p className="text-center">
|
||||
{t("No tools available in this service.")}
|
||||
{t("No tools available in this server.")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
@@ -211,40 +215,11 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
</h3>
|
||||
</div>
|
||||
{/* Code Snippet */}
|
||||
<Card className="w-full max-w-2xl bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
|
||||
<div className="text-left font-mono">
|
||||
<div className="flex items-center gap-2 mb-2 justify-between">
|
||||
<Chip className="text-white" size="sm" variant="flat">
|
||||
{platformConfig?.name} MCP
|
||||
</Chip>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="flat"
|
||||
className="min-w-6 w-6 h-6 p-0 text-white"
|
||||
onPress={onCopy}
|
||||
aria-label={t("Copy code")}
|
||||
>
|
||||
<Copy size={14} />
|
||||
</Button>
|
||||
</div>
|
||||
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"${mcpName}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
|
||||
{`"
|
||||
}
|
||||
}
|
||||
}`}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
</Card>
|
||||
<ServerConfig
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
className="w-full max-w-2xl"
|
||||
/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +54,6 @@ export const Home: React.FC<HomeProps> = ({
|
||||
total,
|
||||
pageSize,
|
||||
loading,
|
||||
error,
|
||||
onSearchChange,
|
||||
onSearch,
|
||||
onPageChange,
|
||||
@@ -65,19 +64,6 @@ export const Home: React.FC<HomeProps> = ({
|
||||
const { t } = useTranslation();
|
||||
const totalPages = Math.ceil(total / pageSize);
|
||||
|
||||
// 如果有错误,显示错误信息
|
||||
if (error) {
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
<div className="mx-auto h-[100px] flex items-center justify-center">
|
||||
<div className="text-red-600 bg-white px-6 py-4 rounded-lg shadow-md border border-red-200">
|
||||
Error: {error}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 top-0 left-0 right-0 bottom-0 flex flex-col justify-between">
|
||||
<Navigation items={navItems} />
|
||||
@@ -97,6 +83,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
<h1 className="text-4xl lg:text-5xl font-bold mb-6 text-slate-800">
|
||||
{t(
|
||||
platformConfig.headline ||
|
||||
platformConfig.name ||
|
||||
_DefaultPlatformConfig.headline ||
|
||||
""
|
||||
)}
|
||||
@@ -122,7 +109,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
placeholder={
|
||||
searchSuggestions.length > 0
|
||||
? t(searchSuggestions[0])
|
||||
: t("Search services...")
|
||||
: t("Search MCP servers")
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
@@ -153,7 +140,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service List Section */}
|
||||
{/* Server List Section */}
|
||||
{loading ? (
|
||||
<div className="mx-auto h-[200px] flex items-center justify-center">
|
||||
<div className="bg-white p-8 rounded-lg shadow-md">
|
||||
@@ -163,24 +150,24 @@ export const Home: React.FC<HomeProps> = ({
|
||||
) : (
|
||||
<div className="bg-gray-50 py-16">
|
||||
<div className="mx-auto px-6 max-w-7xl">
|
||||
{/* Services Grid */}
|
||||
{/* Server Grid */}
|
||||
<div className="flex flex-wrap justify-center gap-4 mb-12">
|
||||
{services.map((service) => (
|
||||
<Link
|
||||
key={service.service_id}
|
||||
href={`/marketplace/${service.service_id}`}
|
||||
className="w-full md:w-[calc(50%-16px)] lg:w-[calc(33%-16px)] xl:w-[calc(25%-16px)]"
|
||||
href={`/server/${service.service_id}`}
|
||||
className="block group w-full md:w-[calc(50%-16px)] lg:w-[calc(33%-16px)] xl:w-[calc(25%-16px)]"
|
||||
>
|
||||
<Card className="group h-[200px] w-full hover:shadow-lg transition-shadow duration-200 cursor-pointer border border-gray-200 bg-white rounded-sm shadow-sm">
|
||||
<CardBody className="p-4">
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between mb-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-2 w-full overflow-hidden">
|
||||
<div className="w-8 h-8 bg-slate-600 rounded-sm flex items-center justify-center">
|
||||
<Star className="w-4 h-4 text-white" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3 className="font-semibold text-gray-900 text-base mb-1 truncate group-hover:text-slate-700 transition-colors">
|
||||
<h3 className="font-semibold text-gray-900 text-base mb-1 truncate group-hover:text-slate-700 transition-colors truncate">
|
||||
{service.name}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@@ -6,8 +6,8 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { useAuth } from "@/shared/lib/useAuth";
|
||||
import Link from "next/link";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import Link from "next/link";
|
||||
|
||||
interface NavigationProps {
|
||||
items?: NavigationItem[];
|
||||
@@ -23,9 +23,17 @@ export const Navigation: React.FC<NavigationProps> = ({ items }) => {
|
||||
<div className="bg-slate-800 text-white px-4 py-2 ">
|
||||
<div className="flex items-center justify-between max-w-7xl mx-auto">
|
||||
<div className="flex items-center space-x-2">
|
||||
<DynamicLogo alt="Platform Logo" className="h-[20px] text-white" />
|
||||
<DynamicLogo alt="Platform Logo" className="h-[32px] text-white" />
|
||||
</div>
|
||||
<div className="flex space-x-2">
|
||||
<Button
|
||||
onPress={handleLogin}
|
||||
variant="light"
|
||||
className="hidden sm:block text-white text-sm px-4 py-1 rounded-sm font-medium"
|
||||
size="sm"
|
||||
>
|
||||
<b className="text-md"> {t("Sign In")}</b>
|
||||
</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
className="bg-red-600 hover:bg-red-700 text-white text-sm px-4 py-1 rounded-sm font-medium"
|
||||
@@ -42,7 +50,14 @@ export const Navigation: React.FC<NavigationProps> = ({ items }) => {
|
||||
<div className="bg-gray-100 border-b border-gray-300 px-4 py-2">
|
||||
<div className="flex items-center justify-between max-w-7xl mx-auto">
|
||||
<div className="flex space-x-6">
|
||||
{items?.map((item) => (
|
||||
{(
|
||||
items || [
|
||||
{
|
||||
label: "Home",
|
||||
href: "/",
|
||||
},
|
||||
]
|
||||
)?.map((item) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import { ServerConfig } from "@/shared/components/marketplace/ServerConfig";
|
||||
|
||||
interface DetailProps {
|
||||
product: ServiceData;
|
||||
@@ -24,6 +25,7 @@ interface DetailProps {
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
onCopy: () => void;
|
||||
innerHeaderNode?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
@@ -33,6 +35,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
mcpName,
|
||||
navItems = [],
|
||||
onCopy,
|
||||
innerHeaderNode,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
@@ -63,8 +66,9 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
{/* Creative Product Header */}
|
||||
<div className="pt-24">
|
||||
<div className="mx-auto p-6 max-w-7xl">
|
||||
<div className="bg-white/90 backdrop-blur-sm rounded-2xl p-6 shadow-lg border border-pink-200/50">
|
||||
<div className="bg-white/90 backdrop-blur-sm rounded-2xl p-6 shadow-lg border border-pink-200/50 relative">
|
||||
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
|
||||
{innerHeaderNode}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,7 +125,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
<div className="p-6 pt-4 space-y-4">
|
||||
{product.tools.length > 0 ? (
|
||||
product.tools.map((tool, index) => (
|
||||
<Card
|
||||
@@ -145,7 +149,7 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
<Card>
|
||||
<CardBody>
|
||||
<p className="text-center">
|
||||
{t("No tools available in this service.")}
|
||||
{t("No tools available in this server.")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
@@ -171,40 +175,11 @@ export const Detail: React.FC<DetailProps> = ({
|
||||
</h3>
|
||||
</div>
|
||||
{/* Code Snippet */}
|
||||
<Card className="w-full max-w-2xl bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
|
||||
<div className="text-left font-mono">
|
||||
<div className="flex items-center gap-2 mb-2 justify-between">
|
||||
<Chip className="text-white" size="sm" variant="flat">
|
||||
{platformConfig?.name} MCP
|
||||
</Chip>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="flat"
|
||||
className="min-w-6 w-6 h-6 p-0 text-white"
|
||||
onPress={onCopy}
|
||||
aria-label={t("Copy code")}
|
||||
>
|
||||
<Copy size={14} />
|
||||
</Button>
|
||||
</div>
|
||||
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
|
||||
<code className="text-gray-300 whitespace-pre-wrap">
|
||||
{`{
|
||||
"mcpServers": {
|
||||
"${mcpName}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey=`}
|
||||
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
|
||||
{`"
|
||||
}
|
||||
}
|
||||
}`}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
</Card>
|
||||
<ServerConfig
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
className="w-full max-w-2xl"
|
||||
/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -102,6 +102,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
<span className="bg-clip-text text-transparent bg-gradient-to-r from-pink-600 via-red-500 to-orange-600">
|
||||
{t(
|
||||
platformConfig.headline ||
|
||||
platformConfig.name ||
|
||||
_DefaultPlatformConfig.headline ||
|
||||
""
|
||||
)}
|
||||
@@ -130,7 +131,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
placeholder={
|
||||
searchSuggestions.length > 0
|
||||
? t(searchSuggestions[0])
|
||||
: t("✨ Discover amazing services...")
|
||||
: t("✨ Discover amazing servers...")
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
@@ -165,7 +166,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Creative Service List Section */}
|
||||
{/* Creative Server List Section */}
|
||||
{loading ? (
|
||||
<div className="relative z-10 mx-auto h-[200px] flex items-center justify-center">
|
||||
<div className="bg-white/90 backdrop-blur-xl p-8 rounded-2xl shadow-lg border border-pink-200/50">
|
||||
@@ -177,7 +178,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
) : (
|
||||
<div className="relative z-10">
|
||||
<div className="relative mx-auto px-6 py-16 max-w-8xl">
|
||||
{/* Creative Services Grid */}
|
||||
{/* Creative Server Grid */}
|
||||
<div className="flex flex-wrap justify-center gap-4 mb-12">
|
||||
{services.map((service, index) => {
|
||||
const gradientBorders = [
|
||||
@@ -208,7 +209,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
return (
|
||||
<Link
|
||||
key={service.service_id}
|
||||
href={`/marketplace/${service.service_id}`}
|
||||
href={`/server/${service.service_id}`}
|
||||
className="block group w-full md:w-[calc(50%-16px)] lg:w-[calc(33%-16px)] xl:w-[calc(25%-16px)]"
|
||||
>
|
||||
<Card
|
||||
@@ -237,7 +238,7 @@ export const Home: React.FC<HomeProps> = ({
|
||||
</div>
|
||||
|
||||
{/* service description */}
|
||||
<div className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
|
||||
<div className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-2">
|
||||
{service.short_description ||
|
||||
t("No description available")}
|
||||
</div>
|
||||
|
||||