Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19267e14c2 | ||
|
|
660c83e0c7 | ||
|
|
ea3174e0fe | ||
|
|
e01a0cb249 | ||
|
|
890d1d8bf3 | ||
|
|
b7197fb35d | ||
|
|
8751aa9ef6 | ||
|
|
35cb02a035 | ||
|
|
beba80a14c | ||
|
|
2c1b17a947 | ||
|
|
71322c2d9d | ||
|
|
d93a3f9af3 | ||
|
|
55457532cc | ||
|
|
9b953048b3 | ||
|
|
913006ba02 | ||
|
|
3a38426b13 | ||
|
|
e42e5ad752 | ||
|
|
c69ed103dc | ||
|
|
6cd52f0d92 | ||
|
|
be7033e9a2 | ||
|
|
8946be619d | ||
|
|
2262a7f49a | ||
|
|
11264d302d | ||
|
|
6a18812572 | ||
|
|
401b35cd10 | ||
|
|
f44102bdb7 | ||
|
|
29a779648d | ||
|
|
20eabea48f | ||
|
|
919285e716 | ||
|
|
01d1411d49 | ||
|
|
6cb7ca9902 | ||
|
|
3012d27aae | ||
|
|
dd3a784cb5 | ||
|
|
518d5f55c5 | ||
|
|
923496735e | ||
|
|
20903eeab5 | ||
|
|
4016bb9d52 | ||
|
|
bf9071122b | ||
|
|
3ff0b743a6 | ||
|
|
360e2cd20d | ||
|
|
e12f6c0db5 | ||
|
|
ec96465a96 | ||
|
|
920eb9154e | ||
|
|
a224445038 | ||
|
|
1c3e40d337 | ||
|
|
44d0768296 | ||
|
|
e9ae97762b | ||
|
|
26b8147f94 | ||
|
|
e4f97e1014 | ||
|
|
d3efa08da2 | ||
|
|
ede3d5c2a3 | ||
|
|
42665d13a7 | ||
|
|
c4bbf09a19 | ||
|
|
ba3a4fe2a2 | ||
|
|
496b9fa380 | ||
|
|
80b3118f3a | ||
|
|
c4f56df03b | ||
|
|
4d26a793a3 | ||
|
|
ac849ce4dd | ||
|
|
a9a83fa187 | ||
|
|
c2738813eb | ||
|
|
883ada7aac | ||
|
|
ad574f0162 | ||
|
|
5cc9e9910e | ||
|
|
d91c1c5369 | ||
|
|
f108551780 | ||
|
|
be19df6273 | ||
|
|
2eb02bb70f | ||
|
|
b548f2494d | ||
|
|
e1fdbdd026 | ||
|
|
7985c6ae2b | ||
|
|
fdfe2c63bc | ||
|
|
224a209fea | ||
|
|
99c33234bf | ||
|
|
deb0161a3a | ||
|
|
babb007082 | ||
|
|
ca2b732952 | ||
|
|
58292b0e6e | ||
|
|
63c44b6929 | ||
|
|
3a6508d214 | ||
|
|
b90c8c4d30 | ||
|
|
a20f0ca920 | ||
|
|
8ba3592035 | ||
|
|
f0696ace22 | ||
|
|
f984855871 | ||
|
|
bf18fffc5a | ||
|
|
a1b78da6a0 | ||
|
|
4d4f63a911 | ||
|
|
3e9f0fcf43 | ||
|
|
fcb073f53c | ||
|
|
c773797a82 | ||
|
|
6368727409 | ||
|
|
c531aadb6b | ||
|
|
f3850856eb | ||
|
|
bd41154b2d | ||
|
|
018256530c | ||
|
|
cb719d8c69 | ||
|
|
4e4f3eeffb | ||
|
|
d76e674e69 | ||
|
|
4468d2c2b1 | ||
|
|
3f3a2358a7 | ||
|
|
b46ea0db17 | ||
|
|
ef4839de39 |
No files matched your search
+1
-1
@@ -11,7 +11,7 @@ ADMIN_PORT=8001
|
||||
|
||||
# 调试配置
|
||||
DEBUG=false
|
||||
LOG_LEVEL=INFO
|
||||
LOG_LEVEL=DEBUG
|
||||
|
||||
# Redis 配置
|
||||
REDIS_HOST=xpack-redis
|
||||
|
||||
@@ -1,36 +1,37 @@
|
||||
# XPack 开源版本 - Copilot 编程指导
|
||||
# XPack Open Source Edition - Copilot Programming Guidelines
|
||||
|
||||
## 项目架构
|
||||
## Project Architecture
|
||||
|
||||
### 服务依赖
|
||||
- `admin_service` 和 `api_service` 相互独立,都依赖 `common`
|
||||
- 遵循分层架构:Controller → Service → Repository
|
||||
### Service Dependencies
|
||||
- `admin_service` and `api_service` are independent of each other, both depend on `common`
|
||||
- Follow layered architecture: Controller → Service → Repository
|
||||
|
||||
### 目录结构
|
||||
### Directory Structure
|
||||
```
|
||||
services/
|
||||
├── admin_service/ # 管理端服务
|
||||
├── api_service/ # API服务
|
||||
└── common/ # 公共模块
|
||||
├── admin_service/ # Admin service
|
||||
├── api_service/ # API service
|
||||
└── common/ # Common modules
|
||||
```
|
||||
|
||||
## 编码规范
|
||||
## Coding Standards
|
||||
|
||||
### 代码风格
|
||||
- 遵循 PEP 8,使用类型注解和 docstring
|
||||
- 命名:函数/变量用 `snake_case`,类用 `PascalCase`
|
||||
- 导入:优先使用 `services/common`,避免跨服务导入
|
||||
### Code Style
|
||||
- Follow PEP 8, use type annotations and docstrings
|
||||
- Naming: use `snake_case` for functions/variables, `PascalCase` for classes
|
||||
- Imports: prioritize `services/common`, avoid cross-service imports
|
||||
|
||||
### 日志要求
|
||||
- **必须使用英文**,使用 `services/common/logging_config.py`
|
||||
- 格式:`logger.info("Action completed: {context}")`
|
||||
- 避免敏感信息,包含必要上下文
|
||||
### Logging Requirements
|
||||
- **Must use English**, use `services/common/logging_config.py`
|
||||
- Format: `logger.info("Action completed: {context}")`
|
||||
- Avoid sensitive information, include necessary context
|
||||
|
||||
### 错误处理
|
||||
- 使用 `services/common/error_msg.py` 定义的错误消息
|
||||
- 统一异常处理和日志记录
|
||||
### Error Handling
|
||||
- Use error messages defined in `services/common/error_msg.py`
|
||||
- Unified exception handling and logging
|
||||
|
||||
## 开发建议
|
||||
- 有适当的日志记录(英文格式,统一格式)
|
||||
- 添加方法级别英文注释,需要简洁
|
||||
- 添加的注释一律使用英文
|
||||
## Development Guidelines
|
||||
- Think and analyze requirements first, wait for user confirmation before writing code
|
||||
- Include appropriate logging (English format, consistent style)
|
||||
- Add method-level English comments, keep them concise
|
||||
- All comments must be written in English
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
- name: Setup qshell
|
||||
uses: foxundermoon/setup-qshell@v5
|
||||
with:
|
||||
version: '2.9.0'
|
||||
version: '2.13.0'
|
||||
- name: build
|
||||
run: |
|
||||
cd scripts && ./docker_build.sh ${{ secrets.DOCKER_USERNAME }}
|
||||
|
||||
@@ -40,3 +40,5 @@ htmlcov/
|
||||
# Ignore local config
|
||||
local_settings.py
|
||||
/.secrets
|
||||
/uploads/
|
||||
/.vercel/
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
# XPack(全球首个开源 MCP 交易计费平台)
|
||||
|
||||

|
||||
|
||||
<p align="center">
|
||||
<a href="/README.md">English</a>
|
||||
|
|
||||
<a href="/README-zh-cn.md">简体中文</a>
|
||||
</p>
|
||||
|
||||
**XPack** 是全球首个开源 MCP 交易平台,帮助你在10分钟内快速搭建自己的 MCP 商店并立刻开始销售 MCP 服务。
|
||||
|
||||
<br>
|
||||
|
||||
✨ 使用 XPack,你可以:
|
||||
- ✅ 一键将 OpenAPI 转换为 MCP 服务并且为 MCP 定价
|
||||
- 🧾 自动生成 SEO 友好的主页和服务页
|
||||
- 💳 内置计费功能(支持按次、按Token收费)
|
||||
- 👥 管理注册用户、充值、交易记录等
|
||||
- 🛠 集成 Stripe 支付
|
||||
- 🔐 邮箱 & Google 登录认证
|
||||
- 📊 用户调用统计
|
||||
|
||||
本项目基于 **Apache 2.0 协议开源**,可放心用于商业用途。
|
||||
|
||||
<br>
|
||||
|
||||
# ✨ 快速开始
|
||||
|
||||
😍 只需一行命令,即可在 10 分钟内部署你的 MCP 交易平台:
|
||||
|
||||
```bash
|
||||
curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
```
|
||||
|
||||
该脚本会自动安装 MySQL、Redis、RabbitMQ,并启动 XPack 服务。
|
||||
|
||||
<br>
|
||||
|
||||
# 📸 功能截图
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
<br>
|
||||
|
||||
## 🖥️ 系统要求
|
||||
|
||||
### ✅ 推荐配置
|
||||
- **CPU**: 8 核
|
||||
- **内存**: 16 GB
|
||||
- **硬盘**: 200 GB
|
||||
- **操作系统**: Linux
|
||||
- **架构**: AMD64
|
||||
|
||||
### ✅ 最低配置
|
||||
- **CPU**: 2 核
|
||||
- **内存**: 4 GB
|
||||
- **硬盘**: 200 GB
|
||||
- **操作系统**: Linux / macOS
|
||||
- **架构**: AMD64 / ARM64
|
||||
|
||||
<br>
|
||||
|
||||
## 📦 运行依赖
|
||||
|
||||
XPack-MCP-Market 依赖以下服务(可容器化或自行安装):
|
||||
|
||||
| 组件 | 最低版本 |
|
||||
|-------------|------------|
|
||||
| **MySQL** | ≥ 5.7.x |
|
||||
| **Redis** | ≥ 6.2.x |
|
||||
| **RabbitMQ**| ≥ 4.0 |
|
||||
|
||||
请确保这些服务已正常运行并配置好连接参数。
|
||||
|
||||
<br>
|
||||
|
||||
## 💿 部署方式
|
||||
|
||||
### 🟢 快速部署命令
|
||||
|
||||
```bash
|
||||
curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
```
|
||||
|
||||
支持系统包括:
|
||||
- CentOS 7.9 / 8.5
|
||||
- Ubuntu 20.04 / 22.04
|
||||
- Debian 12.4
|
||||
- 阿里云 Linux 2.1903 / 3.2104
|
||||
|
||||
如需支持其他系统,请在 [Issues](https://github.com/xpack-ai/XPack-MCP-Market/issues) 提交反馈。
|
||||
|
||||
---
|
||||
|
||||
<details>
|
||||
<summary><h4>🔖Docker-Compose 部署</h4></summary>
|
||||
|
||||
安装 Docker 和 Docker Compose 后:
|
||||
|
||||
1. 编辑 `docker-compose.yml`
|
||||
```bash
|
||||
vi docker-compose.yml
|
||||
```
|
||||
|
||||
2. 修改配置,可参考 [示例配置](https://github.com/xpack-ai/XPack-MCP-Market/blob/main/scripts/docker-compose.yml)
|
||||
|
||||
3. 启动服务:
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
4. 打开浏览器访问 `http://localhost:3000` 使用平台
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><h4>🔖源码构建</h4></summary>
|
||||
|
||||
### 克隆仓库
|
||||
|
||||
```bash
|
||||
git clone https://github.com/xpack-ai/XPack-MCP-Market.git
|
||||
cd XPack-MCP-Market
|
||||
```
|
||||
|
||||
### ✅ 前端构建(需 Node ≥22,pnpm ≥10)
|
||||
|
||||
```bash
|
||||
cd scripts && ./frontend_build.sh && cd ../
|
||||
cd frontend/out && node server.js
|
||||
```
|
||||
|
||||
### ✅ 后端构建(需 Python ≥ 3.11)
|
||||
|
||||
推荐使用 [`uv`](https://github.com/astral-sh/uv)
|
||||
|
||||
```bash
|
||||
uv venv
|
||||
source .venv/bin/activate
|
||||
uv pip install -r requirements.txt
|
||||
cp .env.example .env
|
||||
vi .env
|
||||
```
|
||||
|
||||
启动服务:
|
||||
|
||||
- 管理后台(端口 8001)
|
||||
```bash
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload
|
||||
```
|
||||
|
||||
- MCP 服务接口(端口 8002)
|
||||
```bash
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>
|
||||
|
||||
# 🧾 开源协议
|
||||
|
||||
XPack-MCP-Market 遵循 [Apache 2.0 License](./LICENSE),支持商业用途与二次开发。
|
||||
|
||||
<br>
|
||||
|
||||
# 💌 联系我们
|
||||
|
||||
- 官网: [https://xpack.ai](https://xpack.ai)
|
||||
- 邮箱: [contact@xpack.com](mailto:contact@xpack.com)
|
||||
- Discord:[Link](https://discord.gg/cyZfcdCXkW)
|
||||
@@ -1,191 +1,285 @@
|
||||
# XPack-MCP-Market
|
||||

|
||||
# XPack
|
||||

|
||||
|
||||
## Hardware Requirements
|
||||
**Recommended Configuration**
|
||||
- CPU: 8 cores
|
||||
- Memory: 16GB
|
||||
- Storage: 200GB
|
||||
- Operating System: Linux
|
||||
- System Architecture: AMD64
|
||||
<p align="center">
|
||||
<a href="/README.md">English</a>
|
||||
|
|
||||
<a href="/README-zh-cn.md">简体中文</a>
|
||||
</p>
|
||||
|
||||
**Minimum Requirements**
|
||||
- CPU: 2 cores
|
||||
- Memory: 4GB
|
||||
- Storage: 200GB
|
||||
- Operating System: Linux / Mac
|
||||
- System Architecture: AMD64 / ARM64
|
||||
**XPack** is the world’s first open-source MCP marketplace, to quickly create and sell your own MCP services in just minutes.
|
||||
|
||||
**Dependencies**
|
||||
**XPack-MCP-Market** requires `MySQL, Redis, RabbitMQ` with the following versions:
|
||||
- **MySQL:** >= 5.7.x
|
||||
- **Redis:** >= 6.2.x
|
||||
- **RabbitMQ:** >=4.0
|
||||
<br>
|
||||
|
||||
## Deployment
|
||||
### Quick Start Script
|
||||
> Supported Systems:
|
||||
> - CentOS 7.9 (representing 7.x)
|
||||
> - CentOS 8.5 (representing 8.x)
|
||||
> - Ubuntu 20.04
|
||||
> - Ubuntu 22.04
|
||||
> - Debian 12.4
|
||||
> - Alibaba Cloud Linux 3.2104
|
||||
> - Alibaba Cloud Linux 2.1903
|
||||
Currently, installation has only been tested on the above systems. If you need one-click deployment for other systems, please submit an [Issue](https://github.com/xpack-ai/XPack-MCP-Market/issues).
|
||||
```
|
||||
curl -sSO https://download.xpack.com/install/quick-start.sh; bash quick-start.sh
|
||||
✨ With XPack, you can:
|
||||
- ✅ **One-click OpenAPI → MCP service config**
|
||||
- 🧾 **SEO-friendly homepage + mcp service page**
|
||||
- 💳 **Built-in billing (per-call or token usage)**
|
||||
- 👥 **User account management**
|
||||
- 🛠 **Support Stripe Payment**
|
||||
- 🔐 **Support Email & Google OAuth Sign in**
|
||||
|
||||
Everything is open-source and licensed under **Apache 2.0** — ready for commercial use.
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
# ✨ Quick Start
|
||||
😍 Deploying XPack is incredibly simple. With just one command line, you can deploy your MCP Market in 10 minutes.
|
||||
|
||||
```bash
|
||||
curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
```
|
||||
|
||||
### Docker-Compose Deployment
|
||||
To install XPack-MCP-Market using this method, you need to have [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/standalone/) installed.
|
||||
1. Edit the `docker-compose.yml` file
|
||||
```
|
||||
vi docker-compose.yml
|
||||
```
|
||||
2. Modify the configuration, you can reference the original file at [docker-compose.yml](https://github.com/xpack-ai/XPack-MCP-Market/blob/main/scripts/docker-compose.yml)
|
||||
```
|
||||
version: '3'
|
||||
services:
|
||||
xpack-mysql:
|
||||
image: mysql:8.0.37
|
||||
privileged: true
|
||||
restart: always
|
||||
container_name: xpack-mysql
|
||||
hostname: xpack-mysql
|
||||
command:
|
||||
- "--character-set-server=utf8mb4"
|
||||
- "--collation-server=utf8mb4_unicode_ci"
|
||||
ports:
|
||||
- "33306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=mysql_ZTdhRB
|
||||
- MYSQL_DATABASE=xpack
|
||||
volumes:
|
||||
- /var/lib/xpack/mysql:/var/lib/mysql
|
||||
networks:
|
||||
- xpack
|
||||
xpack-mcp-market:
|
||||
image: xpackai/xpack-mcp-market
|
||||
container_name: xpack-mcp-market
|
||||
privileged: true
|
||||
restart: always
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
- xpack-rabbitmq
|
||||
xpack-redis:
|
||||
container_name: xpack-redis
|
||||
image: redis:7.2.4
|
||||
hostname: xpack-redis
|
||||
privileged: true
|
||||
restart: always
|
||||
ports:
|
||||
- 6379:6379
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- "redis-server --protected-mode yes --logfile redis.log --appendonly no --port 6379 --requirepass redis_6sJZDm"
|
||||
networks:
|
||||
- xpack
|
||||
xpack-rabbitmq:
|
||||
image: rabbitmq:4.1.2-alpine
|
||||
container_name: xpack-rabbitmq
|
||||
privileged: true
|
||||
restart: always
|
||||
environment:
|
||||
- RABBITMQ_DEFAULT_USER=rabbitmq
|
||||
- RABBITMQ_DEFAULT_PASS=rabbitmq_Gs123dA
|
||||
networks:
|
||||
- xpack
|
||||
networks:
|
||||
xpack:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.101.0.0/24
|
||||
```
|
||||
3. Start XPack-MCP-Market
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
4. Access `XPack-MCP-Market` in your browser at port 3000
|
||||
[](https://www.youtube.com/watch?v=Ut4mbFXWbFs)
|
||||
|
||||
## Build Guide
|
||||
### Prerequisites
|
||||
1. Clone the XPack repository.
|
||||
```
|
||||
git clone https://github.com/xpack-ai/XPack-MCP-Market.git
|
||||
```
|
||||
2. Enter the project directory.
|
||||
```
|
||||
cd XPack-MCP-Market
|
||||
```
|
||||
### Frontend Build
|
||||
> Requirements:
|
||||
> - Node >= 22.x
|
||||
> - Pnpm >= 10.x
|
||||
|
||||
1. Execute the frontend build script
|
||||
```
|
||||
cd scripts && ./frontend_build.sh && cd ../
|
||||
```
|
||||
After compilation, the frontend code will be built into the `frontend/out` directory.
|
||||
<br>
|
||||
|
||||
2. Start the UI interface
|
||||
```
|
||||
cd frontend/out && node server.js
|
||||
```
|
||||
### Backend Build
|
||||
> Requirements:
|
||||
> - Python >= 3.11
|
||||
|
||||
#### Using`uv` (Recommended)
|
||||
1. Create virtual environment
|
||||
```
|
||||
uv venv
|
||||
```
|
||||
2. Activate virtual environment
|
||||
```
|
||||
source .venv/bin/activate
|
||||
```
|
||||
3. Install dependencies
|
||||
```
|
||||
uv pip install -r requirements.txt
|
||||
```
|
||||
4. Copy environment variable file
|
||||
```
|
||||
cp .env.example .env
|
||||
```
|
||||
5. Edit environment variables
|
||||
```
|
||||
vi .env
|
||||
```
|
||||
6. Start admin backend service
|
||||
**Foreground**
|
||||
```
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload
|
||||
```
|
||||
**Background**
|
||||
```
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload &
|
||||
# 📸 Features
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## 🖥️ System Requirements
|
||||
|
||||
### ✅ Recommended Hardware
|
||||
- **CPU**: 8 cores
|
||||
- **Memory**: 16 GB
|
||||
- **Storage**: 200 GB
|
||||
- **Operating System**: Linux
|
||||
- **Architecture**: AMD64
|
||||
|
||||
### ✅ Minimum Requirements
|
||||
- **CPU**: 2 cores
|
||||
- **Memory**: 4 GB
|
||||
- **Storage**: 200 GB
|
||||
- **Operating System**: Linux / macOS
|
||||
- **Architecture**: AMD64 / ARM64
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
## 📦 Runtime Dependencies
|
||||
|
||||
**XPack-MCP-Market** requires the following services (self-hosted or containerized):
|
||||
|
||||
| Component | Minimum Version |
|
||||
|-------------|-----------------|
|
||||
| **MySQL** | ≥ 5.7.x |
|
||||
| **Redis** | ≥ 6.2.x |
|
||||
| **RabbitMQ**| ≥ 4.0 |
|
||||
|
||||
Ensure these services are available and properly configured before running the backend.
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
## 💿 Deployment
|
||||
|
||||
😍 Deploying XPack is incredibly simple. With just one command line, you can deploy your MCP Market in 10 minutes.
|
||||
|
||||
```bash
|
||||
curl -sSO https://xpack.ai/install/quick-start.sh; bash quick-start.sh
|
||||
```
|
||||
|
||||
7. Start API to MCP service
|
||||
**Foreground**
|
||||
```
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload
|
||||
```
|
||||
**Background**
|
||||
```
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload &
|
||||
```
|
||||
### Docker Build
|
||||
```
|
||||
docker build -t xpack-mcp-market --build-arg APP=xpack-mcp-market --build-arg VERSION=1.0.0 -f ./scripts/Dockerfile ./
|
||||
```
|
||||
<details>
|
||||
<summary><h4>🔖Docker-Compose Deployment</h4></summary>
|
||||
|
||||
To install XPack-MCP-Market using this method, you need to have [Docker](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/standalone/) installed.
|
||||
|
||||
1. Edit the `docker-compose.yml` file
|
||||
```
|
||||
vi docker-compose.yml
|
||||
```
|
||||
<br>
|
||||
|
||||
2. Modify the configuration, you can reference the original file at [docker-compose.yml](https://github.com/xpack-ai/XPack-MCP-Market/blob/main/scripts/docker-compose.yml)
|
||||
```
|
||||
version: '3'
|
||||
services:
|
||||
xpack-mysql:
|
||||
image: mysql:8.0.37
|
||||
privileged: true
|
||||
restart: always
|
||||
container_name: xpack-mysql
|
||||
hostname: xpack-mysql
|
||||
command:
|
||||
- "--character-set-server=utf8mb4"
|
||||
- "--collation-server=utf8mb4_unicode_ci"
|
||||
ports:
|
||||
- "33306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=mysql_ZTdhRB
|
||||
- MYSQL_DATABASE=xpack
|
||||
volumes:
|
||||
- /var/lib/xpack/mysql:/var/lib/mysql
|
||||
networks:
|
||||
- xpack
|
||||
xpack-mcp-market:
|
||||
image: xpackai/xpack-mcp-market
|
||||
container_name: xpack-mcp-market
|
||||
privileged: true
|
||||
restart: always
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "8002:8002"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
- xpack-rabbitmq
|
||||
xpack-redis:
|
||||
container_name: xpack-redis
|
||||
image: redis:7.2.4
|
||||
hostname: xpack-redis
|
||||
privileged: true
|
||||
restart: always
|
||||
ports:
|
||||
- 6379:6379
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- "redis-server --protected-mode yes --logfile redis.log --appendonly no --port 6379 --requirepass redis_6sJZDm"
|
||||
networks:
|
||||
- xpack
|
||||
xpack-rabbitmq:
|
||||
image: rabbitmq:4.1.2-alpine
|
||||
container_name: xpack-rabbitmq
|
||||
privileged: true
|
||||
restart: always
|
||||
environment:
|
||||
- RABBITMQ_DEFAULT_USER=rabbitmq
|
||||
- RABBITMQ_DEFAULT_PASS=rabbitmq_Gs123dA
|
||||
networks:
|
||||
- xpack
|
||||
networks:
|
||||
xpack:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.101.0.0/24
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
3. Start XPack-MCP-Market
|
||||
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
4. Access `XPack-MCP-Market` in your browser at port 3000
|
||||
|
||||
* **Admin User Login Address**: http://{IP}:3000/admin-signin
|
||||
* **Admin User**: admin
|
||||
* **Admin Password**: 123456789
|
||||
</details>
|
||||
|
||||
|
||||
<details>
|
||||
<summary><h4>🔖Build</h4></summary>
|
||||
|
||||
1. Clone the XPack repository.
|
||||
```
|
||||
git clone https://github.com/xpack-ai/XPack-MCP-Market.git
|
||||
```
|
||||
2. Enter the project directory.
|
||||
```
|
||||
cd XPack-MCP-Market
|
||||
```
|
||||
### Frontend Build
|
||||
> Requirements:
|
||||
> - Node >= 22.x
|
||||
> - Pnpm >= 10.x
|
||||
|
||||
1. Execute the frontend build script
|
||||
```
|
||||
cd scripts && ./frontend_build.sh && cd ../
|
||||
```
|
||||
After compilation, the frontend code will be built into the `frontend/out` directory.
|
||||
|
||||
2. Start the UI interface
|
||||
```
|
||||
cd frontend/out && node server.js
|
||||
```
|
||||
### Backend Build
|
||||
> Requirements:
|
||||
> - Python >= 3.11
|
||||
|
||||
#### Using`uv` (Recommended)
|
||||
1. Create virtual environment
|
||||
```
|
||||
uv venv
|
||||
```
|
||||
2. Activate virtual environment
|
||||
```
|
||||
source .venv/bin/activate
|
||||
```
|
||||
3. Install dependencies
|
||||
```
|
||||
uv pip install -r requirements.txt
|
||||
```
|
||||
4. Copy environment variable file
|
||||
```
|
||||
cp .env.example .env
|
||||
```
|
||||
5. Edit environment variables
|
||||
```
|
||||
vi .env
|
||||
```
|
||||
6. Start admin backend service
|
||||
**Foreground**
|
||||
```
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload
|
||||
```
|
||||
**Background**
|
||||
```
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload &
|
||||
```
|
||||
|
||||
7. Start API to MCP service
|
||||
**Foreground**
|
||||
```
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload
|
||||
```
|
||||
**Background**
|
||||
```
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload &
|
||||
```
|
||||
### Docker Build
|
||||
```
|
||||
docker build -t xpack-mcp-market --build-arg APP=xpack-mcp-market --build-arg VERSION=1.0.0 -f ./scripts/Dockerfile ./
|
||||
```
|
||||
</details>
|
||||
|
||||
# 📸 Screenshots
|
||||
<img width="1415" height="797" alt="image" src="https://github.com/user-attachments/assets/5f71bfcf-c128-42ab-8077-3f2ede549f80" />
|
||||
|
||||
<img width="1415" height="797" alt="image" src="https://github.com/user-attachments/assets/d7c0b40d-182e-47a6-bcdf-bd36970f5ee6" />
|
||||
|
||||
<img width="1415" height="797" alt="image" src="https://github.com/user-attachments/assets/ae40f659-87ad-42d4-8379-b47a48eb6a29" />
|
||||
|
||||
<img width="1415" height="797" alt="image" src="https://github.com/user-attachments/assets/1049f4e5-ec3f-4520-8480-6d6432d6f5d2" />
|
||||
|
||||
<br>
|
||||
|
||||
# 🧾 License
|
||||
XPack-MCP-Market is licensed under the Apache 2.0 License.
|
||||
For details, please see the [LICENSE](./LICENSE) file.
|
||||
|
||||
<br>
|
||||
|
||||
# 📬 Contact
|
||||
- 🌐 Website: [https://xpack.ai](https://xpack.ai)
|
||||
- 📧 Email: [contact@xpack.com](mailto:contact@xpack.com)
|
||||
- 💬 Discord:[Link](https://discord.gg/cyZfcdCXkW)
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
# XPack-MCP-Market
|
||||

|
||||
|
||||
## 硬件要求
|
||||
**推荐配置**
|
||||
- CPU:8核
|
||||
- 内存:16G
|
||||
- 硬盘存储:200G
|
||||
- 操作系统:Linux
|
||||
- 系统架构:AMD64
|
||||
|
||||
**最低配置**
|
||||
- CPU:2核
|
||||
- 内存:4G
|
||||
- 硬盘存储:200G
|
||||
- 操作系统:Linux / Mac
|
||||
- 系统架构:AMD64 / ARM64
|
||||
|
||||
**程序依赖**
|
||||
**XPack** 依赖 `MySQL、Redis、RabbitMQ`,所需版本如下:
|
||||
- **MySQL:** >= 5.7.x
|
||||
- **Redis:** >= 6.2.x
|
||||
- **RabbitMQ:** >= 4.0
|
||||
|
||||
## 部署
|
||||
### 脚本一键部署
|
||||
> 支持的系统列表:
|
||||
> - CentOS 7.9(7.x为代表)
|
||||
> - CentOS 8.5(8.x为代表)
|
||||
> - Ubuntu 20.04
|
||||
> - Ubuntu 22.04
|
||||
> - Debian 12.4
|
||||
> - Alibaba Cloud Linux 3.2104
|
||||
> - Alibaba Cloud Linux 2.1903
|
||||
|
||||
当前仅测试了上述部署的安装,若需要其他系统的一键部署,可给我们提交[Issue](https://github.com/xpack-ai/XPack-MCP-Market/issues)。
|
||||
```bash
|
||||
curl -sSO https://download.xpack.com/install/quick-start.sh; bash quick-start.sh
|
||||
```
|
||||
|
||||
### Docker-Compose部署
|
||||
使用此方法安装 **XPack-MCP-Market**,你需要安装 [Docker](https://docs.docker.com/engine/install/) 和 [Docker Compose](https://docs.docker.com/compose/install/standalone/)。
|
||||
|
||||
1. 编辑 `docker-compose.yml` 文件
|
||||
```bash
|
||||
vi docker-compose.yml
|
||||
```
|
||||
|
||||
2. 修改文件配置,原文件可参考 [docker-compose.yml](https://github.com/xpack-ai/XPack-MCP-Market/blob/main/scripts/docker-compose.yml)
|
||||
```yaml
|
||||
version: '3'
|
||||
services:
|
||||
xpack-mysql:
|
||||
image: mysql:8.0.37
|
||||
privileged: true
|
||||
restart: always
|
||||
container_name: xpack-mysql
|
||||
hostname: xpack-mysql
|
||||
command:
|
||||
- "--character-set-server=utf8mb4"
|
||||
- "--collation-server=utf8mb4_unicode_ci"
|
||||
ports:
|
||||
- "33306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=mysql_ZTdhRB
|
||||
- MYSQL_DATABASE=xpack
|
||||
volumes:
|
||||
- /var/lib/xpack/mysql:/var/lib/mysql
|
||||
networks:
|
||||
- xpack
|
||||
xpack-mcp-market:
|
||||
image: xpackai/xpack-mcp-market
|
||||
container_name: xpack-mcp-market
|
||||
privileged: true
|
||||
restart: always
|
||||
networks:
|
||||
- xpack
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- xpack-mysql
|
||||
- xpack-redis
|
||||
- xpack-rabbitmq
|
||||
xpack-redis:
|
||||
container_name: xpack-redis
|
||||
image: redis:7.2.4
|
||||
hostname: xpack-redis
|
||||
privileged: true
|
||||
restart: always
|
||||
ports:
|
||||
- 6379:6379
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
- "redis-server --protected-mode yes --logfile redis.log --appendonly no --port 6379 --requirepass redis_6sJZDm"
|
||||
networks:
|
||||
- xpack
|
||||
xpack-rabbitmq:
|
||||
image: rabbitmq:4.1.2-alpine
|
||||
container_name: xpack-rabbitmq
|
||||
privileged: true
|
||||
restart: always
|
||||
environment:
|
||||
- RABBITMQ_DEFAULT_USER=rabbitmq
|
||||
- RABBITMQ_DEFAULT_PASS=rabbitmq_Gs123dA
|
||||
networks:
|
||||
- xpack
|
||||
networks:
|
||||
xpack:
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 172.101.0.0/24
|
||||
```
|
||||
|
||||
3. 启动XPack-MCP-Market
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
4. 浏览器访问XPack-MCP-Market,端口号默认为:3000
|
||||
[图片]
|
||||
|
||||
## 编译指南
|
||||
### 前期准备
|
||||
1. 拉取XPack-MCP-Market仓库
|
||||
```bash
|
||||
git clone https://github.com/xpack-ai/XPack-MCP-Market.git
|
||||
```
|
||||
|
||||
2. 进入项目目录
|
||||
```bash
|
||||
cd XPack-MCP-Market
|
||||
```
|
||||
|
||||
### 编译前端
|
||||
> 环境要求:
|
||||
> - Node >= 22.x
|
||||
> - Pnpm >= 10.x
|
||||
|
||||
1. 执行前端编译脚本
|
||||
```bash
|
||||
cd scripts && ./frontend_build.sh && cd ../
|
||||
```
|
||||
编译完成后,前端代码将编译进 `frontend/out` 目录。
|
||||
|
||||
2. 启动UI界面
|
||||
```bash
|
||||
cd frontend/out && node server.js
|
||||
```
|
||||
|
||||
### 编译后端
|
||||
> 环境要求:
|
||||
> - Python >= 3.11
|
||||
|
||||
#### 使用 `uv`(推荐)
|
||||
1. 创建虚拟环境
|
||||
```bash
|
||||
uv venv
|
||||
```
|
||||
|
||||
2. 激活虚拟环境
|
||||
```bash
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
3. 安装依赖
|
||||
```bash
|
||||
uv pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. 复制环境变量文件
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
5. 编辑环境变量
|
||||
```bash
|
||||
vi .env
|
||||
```
|
||||
|
||||
6. 启动管理后台服务
|
||||
**前台运行**
|
||||
```bash
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload
|
||||
```
|
||||
**后台运行**
|
||||
```bash
|
||||
uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload &
|
||||
```
|
||||
|
||||
7. 启动API转MCP服务
|
||||
**前台运行**
|
||||
```bash
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload
|
||||
```
|
||||
**后台运行**
|
||||
```bash
|
||||
uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload &
|
||||
```
|
||||
|
||||
### Docker编译
|
||||
```bash
|
||||
docker build -t xpack --build-arg APP=xpack --build-arg VERSION=1.0.0 -f ./scripts/Dockerfile ./
|
||||
```
|
||||
+1
-1
@@ -57,7 +57,7 @@ Create `.env.local` file in the project root and configure your backend service
|
||||
|
||||
```bash
|
||||
# Backend Service API URL Prefix
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8100
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8001
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ pnpm dev
|
||||
|
||||
```bash
|
||||
# 后端服务 API URL 前缀
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8100
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8001
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
```env
|
||||
# Backend Service API URL Prefix
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8100
|
||||
NEXT_PUBLIC_API_URL=http://127.0.0.1:8001
|
||||
```
|
||||
|
||||
3. **Start Development Server**
|
||||
|
||||
@@ -23,7 +23,11 @@ const nextConfig = {
|
||||
return [
|
||||
{
|
||||
source: "/api/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8100"}/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*`,
|
||||
},
|
||||
];
|
||||
},
|
||||
@@ -38,10 +42,6 @@ const nextConfig = {
|
||||
key: "X-Content-Type-Options",
|
||||
value: "nosniff",
|
||||
},
|
||||
{
|
||||
key: "X-Frame-Options",
|
||||
value: "DENY",
|
||||
},
|
||||
{
|
||||
key: "X-XSS-Protection",
|
||||
value: "1; mode=block",
|
||||
|
||||
@@ -1 +1,13 @@
|
||||
{}
|
||||
{
|
||||
"**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"
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
"Featured Packages": "Featured Packages",
|
||||
"Individual Tools": "Individual Tools",
|
||||
"Details": "Details",
|
||||
"Copy code": "Copy code",
|
||||
"excel": "Excel",
|
||||
"data": "Data",
|
||||
"analysis": "Analysis",
|
||||
@@ -139,10 +140,6 @@
|
||||
"Number of MCP Tools": "Number of MCP Tools",
|
||||
"Time for integration": "Time for integration",
|
||||
"Daily MCP request count": "Daily MCP request count",
|
||||
"10 Second": "10 Second",
|
||||
"15 Categories": "15 Categories",
|
||||
"1000+ Tools": "1000+ Tools",
|
||||
"1 Million+": "1 Million+",
|
||||
"API Name": "API Name",
|
||||
"Description": "Description",
|
||||
"Integrate once,\nnot a thousand times.": "Integrate once,\nnot a thousand times.",
|
||||
@@ -202,6 +199,27 @@
|
||||
"Tool name": "Tool name",
|
||||
"Tool description": "Tool description",
|
||||
"Take Offline": "Take Offline",
|
||||
"Platform Domain": "Platform Domain",
|
||||
"Enter platform domain (e.g., example.com)": "Enter platform domain (e.g., example.com)",
|
||||
"The domain name of your platform": "The domain name of your platform",
|
||||
"MCP Server Domain": "MCP Server Domain",
|
||||
"Enter MCP server domain (e.g., api.example.com)": "Enter MCP server domain (e.g., api.example.com)",
|
||||
"The domain for MCP server API calls": "The domain for MCP server API calls",
|
||||
"Featured in the XPack showcase": "Featured in the XPack showcase",
|
||||
"Enable this option to feature your site in the XPack global showcase and reach users worldwide.": "Enable this option to feature your site in the XPack global showcase and reach users worldwide.",
|
||||
"Please enter a platform domain before enabling showcase": "Please enter a platform domain before enabling showcase",
|
||||
"FAQ Management": "FAQ Management",
|
||||
"Configure frequently asked questions for your users": "Configure frequently asked questions for your users",
|
||||
"FAQ List": "FAQ List",
|
||||
"Edit questions and answers directly in the table below": "Edit questions and answers directly in the table below",
|
||||
"Save All": "Save All",
|
||||
"Order": "Order",
|
||||
"Question": "Question",
|
||||
"Answer": "Answer",
|
||||
"No FAQ items available.": "No FAQ items available.",
|
||||
"Enter question": "Enter question",
|
||||
"Enter answer": "Enter answer",
|
||||
"Insert below": "Insert below",
|
||||
"Bring Online": "Bring Online",
|
||||
"Short Description": "Short Description",
|
||||
"Long Description": "Long Description",
|
||||
@@ -238,6 +256,8 @@
|
||||
"Failed to parse OpenAPI document": "Failed to parse OpenAPI document",
|
||||
"OpenAPI document parsed successfully": "OpenAPI document parsed successfully",
|
||||
"Please enter a valid URL": "Please enter a valid URL",
|
||||
"Please enter a valid URL with http:// or https://": "Please enter a valid URL with http:// or https://",
|
||||
"Please fix validation errors before saving": "Please fix validation errors before saving",
|
||||
"Please select a file": "Please select a file",
|
||||
"File uploaded successfully": "File uploaded successfully",
|
||||
"Failed to upload file": "Failed to upload file",
|
||||
@@ -310,6 +330,14 @@
|
||||
"All Roles": "All Roles",
|
||||
"Ban User": "Ban User",
|
||||
"Unban User": "Unban User",
|
||||
"Recharge User": "Recharge User",
|
||||
"Current Balance": "Current Balance",
|
||||
"User recharged successfully": "User recharged successfully",
|
||||
"Please enter a valid amount": "Please enter a valid amount",
|
||||
"Minimum recharge amount is $1": "Minimum recharge amount is $1",
|
||||
"User not selected": "User not selected",
|
||||
"Recharge failed": "Recharge failed",
|
||||
"Network error, please try again": "Network error, please try again",
|
||||
"Delete User": "Delete User",
|
||||
"View Profile": "View Profile",
|
||||
"Edit User": "Edit User",
|
||||
@@ -390,12 +418,20 @@
|
||||
"Failed to test Google auth": "Failed to test Google auth",
|
||||
"Failed to fetch Stripe config": "Failed to fetch Stripe config",
|
||||
"Failed to save Stripe config": "Failed to save Stripe config",
|
||||
"Failed to save Alipay config": "Failed to save Alipay config",
|
||||
"Failed to save WeChat config": "Failed to save WeChat config",
|
||||
"Stripe connection test failed": "Stripe connection test failed",
|
||||
"Stripe connection test successful": "Stripe connection test successful",
|
||||
"Alipay connection test successful": "Alipay connection test successful",
|
||||
"Alipay connection test failed": "Alipay connection test failed",
|
||||
"WeChat connection test successful": "WeChat connection test successful",
|
||||
"WeChat connection test failed": "WeChat connection test failed",
|
||||
"Connection test failed": "Connection test failed",
|
||||
"Unknown error": "Unknown error",
|
||||
"Secret Key cannot be empty": "Secret Key cannot be empty",
|
||||
"Stripe Configuration": "Stripe Configuration",
|
||||
"Alipay Configuration": "Alipay Configuration",
|
||||
"WeChat Configuration": "WeChat Configuration",
|
||||
"Google Login Settings": "Google Login Settings",
|
||||
"Enable Google Login": "Enable Google Login",
|
||||
"Administrator Account": "Administrator Account",
|
||||
@@ -537,8 +573,19 @@
|
||||
"Billing Mode": "Billing Mode",
|
||||
"Enable free quota": "Enable free quota",
|
||||
"Configure Stripe payment interface": "Configure Stripe payment interface",
|
||||
"Configure Alipay payment interface": "Configure Alipay payment interface",
|
||||
"Configure WeChat payment interface": "Configure WeChat payment interface",
|
||||
"Secret Key": "Secret Key",
|
||||
"Stripe secret key for server-side API calls": "Stripe secret key for server-side API calls",
|
||||
"App ID": "App ID",
|
||||
"Alipay App ID": "Alipay App ID",
|
||||
"App Private Key": "App Private Key",
|
||||
"Alipay App Private Key": "Alipay App Private Key",
|
||||
"Alipay Public Key": "Alipay Public Key",
|
||||
"Alipay public key for verification": "Alipay public key for verification",
|
||||
"WeChat App ID": "WeChat App ID",
|
||||
"Merchant ID": "Merchant ID",
|
||||
"WeChat Merchant ID": "WeChat Merchant ID",
|
||||
"Webhook Secret": "Webhook Secret",
|
||||
"Test Connection": "Test Connection",
|
||||
"Monitor platform revenue and view user recharge history": "Monitor platform revenue and view user recharge history",
|
||||
@@ -597,6 +644,7 @@
|
||||
"Confirm": "Confirm",
|
||||
"Recharge Account": "Recharge Account",
|
||||
"Funds will be added to your account balance": "Funds will be added to your account balance",
|
||||
"Please select a payment method": "Please select a payment method",
|
||||
"Manage your balance and recharge history": "Manage your balance and recharge history",
|
||||
"Build incredible AI agents together": "Build incredible AI agents together",
|
||||
"Balance: {{amount}}": "Balance: {{amount}}",
|
||||
@@ -637,6 +685,12 @@
|
||||
"Total Revenue": "Total Revenue",
|
||||
"Failed to save stripe config": "Failed to save stripe config",
|
||||
"Stripe config saved successfully": "Stripe config saved successfully",
|
||||
"Alipay config saved successfully": "Alipay config saved successfully",
|
||||
"WeChat config saved successfully": "WeChat config saved successfully",
|
||||
"Failed to save {{channelName}} config": "Failed to save {{channelName}} config",
|
||||
"{{channelName}} config saved successfully": "{{channelName}} config saved successfully",
|
||||
"{{channelName}} connection test failed": "{{channelName}} connection test failed",
|
||||
"{{channelName}} connection test successful": "{{channelName}} connection test successful",
|
||||
"Login successful": "Login successful",
|
||||
"Logged out successfully": "Logged out successfully",
|
||||
"Configure email settings": "Configure email settings",
|
||||
@@ -680,5 +734,142 @@
|
||||
"Secondary headline displayed below the main headline": "Secondary headline displayed below the main headline",
|
||||
"Platform Language": "Platform Language",
|
||||
"Select platform language": "Select platform language",
|
||||
"Configure platform logo, name, titles, language": "Configure platform logo, name, titles, language"
|
||||
"Platform Theme": "Platform Theme",
|
||||
"Select platform theme": "Select platform theme",
|
||||
"Choose the visual theme for homepage and marketplace templates": "Choose the visual theme for homepage and marketplace templates",
|
||||
"Modern": "Modern",
|
||||
"Classic": "Classic",
|
||||
"Creative": "Creative",
|
||||
"Clean and minimalist design with modern UI elements": "Clean and minimalist design with modern UI elements",
|
||||
"Traditional layout with professional appearance": "Traditional layout with professional appearance",
|
||||
"Bold and artistic design with vibrant colors": "Bold and artistic design with vibrant colors",
|
||||
"Configure platform logo, name, titles, language": "Configure platform logo, name, titles, language",
|
||||
"At least one login method must be enabled": "At least one login method must be enabled",
|
||||
"About Page Content": "About Page Content",
|
||||
"Configure about page content": "Configure about page content",
|
||||
"Enter about page content (supports Markdown)": "Enter about page content (supports Markdown)",
|
||||
"Theme": "Theme",
|
||||
"Choose your preferred theme style": "Choose your preferred theme style",
|
||||
"Default": "Default",
|
||||
"Standard layout with clean and simple design": "Standard layout with clean and simple design",
|
||||
"Temu": "Temu",
|
||||
"E-commerce style with vibrant orange gradient background": "E-commerce style with vibrant orange gradient background",
|
||||
"Login Settings": "Login Settings",
|
||||
"Configure authentication methods": "Configure authentication methods",
|
||||
"Email Login": "Email Login",
|
||||
"Configure email-based authentication": "Configure email-based authentication",
|
||||
"Enable Email Login": "Enable Email Login",
|
||||
"Allow users to sign in with email": "Allow users to sign in with email",
|
||||
"Authentication Mode": "Authentication Mode",
|
||||
"Choose how users authenticate with email": "Choose how users authenticate with email",
|
||||
"Email/Password": "Email/Password",
|
||||
"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.",
|
||||
"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.",
|
||||
"Configuration": "Configuration",
|
||||
"Featured Products": "Featured Products",
|
||||
"Search": "Search",
|
||||
"Change Password": "Change Password",
|
||||
"Enter new password": "Enter new password",
|
||||
"Re-enter new password": "Re-enter new password",
|
||||
"Confirm new password": "Confirm new password",
|
||||
"New password and confirm password do not match": "New password and confirm password do not match",
|
||||
"New password must be at least 8 characters long": "New password must be at least 8 characters long",
|
||||
"New password and confirm password must be the same": "New password and confirm password must be the same",
|
||||
"New Password": "New Password",
|
||||
"Confirm New Password": "Confirm New Password",
|
||||
"Theme changed successfully": "Theme changed successfully",
|
||||
"Failed to change theme": "Failed to change theme",
|
||||
"About page saved successfully": "About page saved successfully",
|
||||
"Failed to save about page": "Failed to save about page",
|
||||
"General": "General",
|
||||
"Homepage": "Homepage",
|
||||
"Homepage content and theme settings": "Homepage content and theme settings",
|
||||
"About Page": "About Page",
|
||||
"About page content configuration": "About page content configuration",
|
||||
"Email & Admin": "Email & Admin",
|
||||
"Email and administrator settings": "Email and administrator settings",
|
||||
"Embedded HTML": "Embedded HTML",
|
||||
"Configure custom HTML content for global injection": "Configure custom HTML content for global injection",
|
||||
"Enable Custom HTML": "Enable Custom HTML",
|
||||
"Toggle to enable or disable custom HTML injection": "Toggle to enable or disable custom HTML injection",
|
||||
"Show Preview": "Show Preview",
|
||||
"Hide Preview": "Hide Preview",
|
||||
"Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n<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.",
|
||||
"Usage Instructions": "Usage Instructions",
|
||||
"You can include Google Analytics, custom CSS, or any tracking scripts": "You can include Google Analytics, custom CSS, or any tracking scripts",
|
||||
"The HTML will be injected into the document head section": "The HTML will be injected into the document head section",
|
||||
"Make sure your code is valid to avoid breaking the application": "Make sure your code is valid to avoid breaking the application",
|
||||
"Changes take effect immediately after saving and enabling": "Changes take effect immediately after saving and enabling",
|
||||
"Welcome to Your Platform": "Welcome to Your Platform",
|
||||
"Let's set up your platform with some basic information": "Let's set up your platform with some basic information",
|
||||
"Information needed": "Information needed",
|
||||
"Fields marked with * are required": "Fields marked with * are required",
|
||||
"Website title is required": "Website title is required",
|
||||
"Headline is required": "Headline is required",
|
||||
"Subheadline is required": "Subheadline is required",
|
||||
"Please fill in all required fields": "Please fill in all required fields",
|
||||
"Setup failed. Please try again.": "Setup failed. Please try again.",
|
||||
"Complete Setup": "Complete Setup",
|
||||
"Platform setup completed successfully!": "Platform setup completed successfully!",
|
||||
"Welcome to the famous five-minute platform setup process! Just fill in the information below and you'll be on your way to using the most extendable and powerful platform.": "Welcome to the famous five-minute platform setup process! Just fill in the information below and you'll be on your way to using the most extendable and powerful platform.",
|
||||
"Please provide the following information. Do not worry, you can always change these settings later in the admin panel.": "Please provide the following information. Do not worry, you can always change these settings later in the admin panel.",
|
||||
"Failed to update homepage config": "Failed to update homepage config",
|
||||
"Homepage config updated successfully": "Homepage config updated successfully",
|
||||
"Failed to load homepage config": "Failed to load homepage config",
|
||||
"FAQ updated successfully": "FAQ updated successfully",
|
||||
"Navigation updated successfully": "Navigation updated successfully",
|
||||
"Embedded HTML updated successfully": "Embedded HTML updated successfully",
|
||||
"Payment channels updated successfully": "Payment channels updated successfully",
|
||||
"Manage frequently asked questions": "Manage frequently asked questions",
|
||||
"Add FAQ Item": "Add FAQ Item",
|
||||
"Remove FAQ Item": "Remove FAQ Item",
|
||||
"Top Navigation": "Top Navigation",
|
||||
"Manage top navigation links": "Manage top navigation links",
|
||||
"Title": "Title",
|
||||
"Link": "Link",
|
||||
"Target": "Target",
|
||||
"Add Navigation Item": "Add Navigation Item",
|
||||
"Remove Navigation Item": "Remove Navigation Item",
|
||||
"Enter title": "Enter title",
|
||||
"Enter link URL": "Enter link URL",
|
||||
"Same window": "Same window",
|
||||
"New window": "New window",
|
||||
"Custom HTML injection": "Custom HTML injection",
|
||||
"Enable embedded HTML": "Enable embedded HTML",
|
||||
"HTML Content": "HTML Content",
|
||||
"Enter custom HTML code": "Enter custom HTML code",
|
||||
"Manage payment methods": "Manage payment methods",
|
||||
"Channel ID": "Channel ID",
|
||||
"Display Name": "Display Name",
|
||||
"Add Payment Channel": "Add Payment Channel",
|
||||
"Remove Payment Channel": "Remove Payment Channel",
|
||||
"Enter channel ID": "Enter channel ID",
|
||||
"Enter display name": "Enter display name",
|
||||
"Installation Status": "Installation Status",
|
||||
"First time installation": "First time installation",
|
||||
"System installed": "System installed",
|
||||
"Configure top navigation menu items and links": "Configure top navigation menu items and links",
|
||||
"Per Million Tokens": "Per Million Tokens",
|
||||
"Price per million tokens consumed": "Price per million tokens consumed",
|
||||
"Price per million tokens": "Price per million tokens",
|
||||
"Price per API call": "Price per API call",
|
||||
"Payment channel disabled successfully": "Payment channel disabled successfully",
|
||||
"Failed to disable payment channel": "Failed to disable payment channel",
|
||||
"Payment channel enabled successfully": "Payment channel enabled successfully",
|
||||
"Failed to enable payment channel": "Failed to enable payment channel",
|
||||
"Input Token Price": "Input Token Price",
|
||||
"Output Token Price": "Output Token Price",
|
||||
"Price per million input tokens": "Price per million input tokens",
|
||||
"Price per million output tokens": "Price per million output tokens",
|
||||
"Input": "Input",
|
||||
"Output": "Output",
|
||||
"1M tokens": "1M tokens"
|
||||
}
|
||||
@@ -1 +1,13 @@
|
||||
{}
|
||||
{
|
||||
"**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": "关于我们"
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
"Featured Packages": "精选工具包",
|
||||
"Individual Tools": "单个工具",
|
||||
"Details": "详情",
|
||||
"Copy code": "复制代码",
|
||||
"excel": "Excel",
|
||||
"data": "数据",
|
||||
"analysis": "分析",
|
||||
@@ -139,10 +140,6 @@
|
||||
"Number of MCP Tools": "MCP 工具数量",
|
||||
"Time for integration": "集成时间",
|
||||
"Daily MCP request count": "每日 MCP 请求数量",
|
||||
"10 Second": "10 秒",
|
||||
"15 Categories": "15 个分类",
|
||||
"1000+ Tools": "1000+ 工具",
|
||||
"1 Million+": "100 万+",
|
||||
"API Name": "API 名称",
|
||||
"Description": "描述",
|
||||
"Integrate once,\nnot a thousand times.": "集成一次,\n而不是千次。",
|
||||
@@ -203,6 +200,27 @@
|
||||
"Tool name": "工具名称",
|
||||
"Tool description": "工具描述",
|
||||
"Take Offline": "下线",
|
||||
"Platform Domain": "平台域名",
|
||||
"Enter platform domain (e.g., example.com)": "输入平台域名(例如:example.com)",
|
||||
"The domain name of your platform": "您平台的域名",
|
||||
"MCP Server Domain": "MCP 服务器域名",
|
||||
"Enter MCP server domain (e.g., api.example.com)": "输入 MCP 服务器域名(例如:api.example.com)",
|
||||
"The domain for MCP server API calls": "用于 MCP 服务器 API 调用的域名",
|
||||
"Featured in the XPack showcase": "展示在 XPack 的全球案例榜单",
|
||||
"Enable this option to feature your site in the XPack global showcase and reach users worldwide.": "当开启选项,你的网站会展示在 XPack 的全球案例榜单来获得全球用户的关注。",
|
||||
"Please enter a platform domain before enabling showcase": "启用展示功能前请先输入平台域名",
|
||||
"FAQ Management": "FAQ管理",
|
||||
"Configure frequently asked questions for your users": "为您的用户配置常见问题",
|
||||
"FAQ List": "FAQ列表",
|
||||
"Edit questions and answers directly in the table below": "在下方表格中直接编辑问题和答案",
|
||||
"Save All": "保存全部",
|
||||
"Order": "排序",
|
||||
"Question": "问题",
|
||||
"Answer": "答案",
|
||||
"No FAQ items available.": "暂无FAQ项目。",
|
||||
"Enter question": "输入问题",
|
||||
"Enter answer": "输入答案",
|
||||
"Insert below": "在下方插入",
|
||||
"Bring Online": "上线",
|
||||
"Short Description": "简短描述",
|
||||
"Long Description": "详细描述",
|
||||
@@ -239,6 +257,8 @@
|
||||
"Failed to parse OpenAPI document": "解析 OpenAPI 文档失败",
|
||||
"OpenAPI document parsed successfully": "OpenAPI 文档解析成功",
|
||||
"Please enter a valid URL": "请输入有效的 URL",
|
||||
"Please enter a valid URL with http:// or https://": "请输入有效的 URL,需要包含 http:// 或 https://",
|
||||
"Please fix validation errors before saving": "请修复验证错误后再保存",
|
||||
"Please select a file": "请选择文件",
|
||||
"File uploaded successfully": "文件上传成功",
|
||||
"Failed to upload file": "文件上传失败",
|
||||
@@ -311,6 +331,14 @@
|
||||
"All Roles": "所有角色",
|
||||
"Ban User": "封禁用户",
|
||||
"Unban User": "解封用户",
|
||||
"Recharge User": "为用户充值",
|
||||
"Current Balance": "当前余额",
|
||||
"User recharged successfully": "用户充值成功",
|
||||
"Please enter a valid amount": "请输入有效金额",
|
||||
"Minimum recharge amount is $1": "最低充值金额为 $1",
|
||||
"User not selected": "未选择用户",
|
||||
"Recharge failed": "充值失败",
|
||||
"Network error, please try again": "网络错误,请重试",
|
||||
"Delete User": "删除用户",
|
||||
"View Profile": "查看资料",
|
||||
"Edit User": "编辑用户",
|
||||
@@ -391,12 +419,20 @@
|
||||
"Failed to test Google auth": "测试Google认证失败",
|
||||
"Failed to fetch Stripe config": "获取Stripe配置失败",
|
||||
"Failed to save Stripe config": "保存Stripe配置失败",
|
||||
"Failed to save Alipay config": "保存支付宝配置失败",
|
||||
"Failed to save WeChat config": "保存微信配置失败",
|
||||
"Stripe connection test failed": "Stripe连接测试失败",
|
||||
"Stripe connection test successful": "Stripe连接测试成功",
|
||||
"Alipay connection test successful": "支付宝连接测试成功",
|
||||
"Alipay connection test failed": "支付宝连接测试失败",
|
||||
"WeChat connection test successful": "微信连接测试成功",
|
||||
"WeChat connection test failed": "微信连接测试失败",
|
||||
"Connection test failed": "连接测试失败",
|
||||
"Unknown error": "未知错误",
|
||||
"Secret Key cannot be empty": "密钥不能为空",
|
||||
"Stripe Configuration": "Stripe配置",
|
||||
"Alipay Configuration": "支付宝配置",
|
||||
"WeChat Configuration": "微信配置",
|
||||
"Google Login Settings": "Google登录设置",
|
||||
"Enable Google Login": "启用Google登录",
|
||||
"Administrator Account": "管理员账户",
|
||||
@@ -539,6 +575,17 @@
|
||||
"Billing Mode": "计费模式",
|
||||
"Enable free quota": "启用免费配额",
|
||||
"Configure Stripe payment interface": "配置Stripe支付接口",
|
||||
"Configure Alipay payment interface": "配置支付宝支付接口",
|
||||
"Configure WeChat payment interface": "配置微信支付接口",
|
||||
"App ID": "应用ID",
|
||||
"Alipay App ID": "支付宝应用ID",
|
||||
"App Private Key": "应用私钥",
|
||||
"Alipay App Private Key": "支付宝应用私钥",
|
||||
"Alipay Public Key": "支付宝公钥",
|
||||
"Alipay public key for verification": "支付宝公钥用于验证",
|
||||
"WeChat App ID": "微信应用ID",
|
||||
"Merchant ID": "商户号",
|
||||
"WeChat Merchant ID": "微信商户号",
|
||||
"Secret Key": "密钥",
|
||||
"Stripe secret key for server-side API calls": "用于服务端API调用的Stripe密钥",
|
||||
"Webhook Secret": "Webhook密钥",
|
||||
@@ -598,7 +645,8 @@
|
||||
"WeChat Pay": "微信支付",
|
||||
"Confirm": "确认",
|
||||
"Recharge Account": "充值账户",
|
||||
"Funds will be added to your account balance": "资金将添加到您的账户余额",
|
||||
"Funds will be added to your account balance": "资金将添加到您的账户余额中",
|
||||
"Please select a payment method": "请选择支付方式",
|
||||
"Manage your balance and recharge history": "管理您的余额和充值历史",
|
||||
"Build incredible AI agents together": "一起构建强大的 AI 代理",
|
||||
"Balance: {{amount}}": "余额: {{amount}}",
|
||||
@@ -613,6 +661,10 @@
|
||||
"Failed to toggle service status": "切换服务状态失败",
|
||||
"Stripe configuration saved successfully": "Stripe 配置保存成功",
|
||||
"Failed to save Stripe configuration": "保存 Stripe 配置失败",
|
||||
"Failed to save {{channelName}} config": "保存{{channelName}}配置失败",
|
||||
"{{channelName}} config saved successfully": "{{channelName}}配置保存成功",
|
||||
"{{channelName}} connection test failed": "{{channelName}}连接测试失败",
|
||||
"{{channelName}} connection test successful": "{{channelName}}连接测试成功",
|
||||
"System config updated successfully": "系统配置更新成功",
|
||||
"Failed to update system config": "更新系统配置失败",
|
||||
"Confirm Purchase": "确认购买",
|
||||
@@ -639,6 +691,8 @@
|
||||
"Total Revenue": "总收入",
|
||||
"Failed to save stripe config": "保存 Stripe 配置失败",
|
||||
"Stripe config saved successfully": "Stripe 配置保存成功",
|
||||
"Alipay config saved successfully": "支付宝配置保存成功",
|
||||
"WeChat config saved successfully": "微信配置保存成功",
|
||||
"Login successful": "登录成功",
|
||||
"Logged out successfully": "退出登录成功",
|
||||
"Configure email settings": "配置邮箱设置",
|
||||
@@ -682,5 +736,142 @@
|
||||
"Secondary headline displayed below the main headline": "副标题显示在主标题下方",
|
||||
"Platform Language": "平台语言",
|
||||
"Select platform language": "选择平台语言",
|
||||
"Configure platform logo, name, titles, language": "配置平台logo、名称、标题、语言"
|
||||
"Platform Theme": "平台主题",
|
||||
"Select platform theme": "选择平台主题",
|
||||
"Choose the visual theme for homepage and marketplace templates": "选择首页和市场模板的视觉主题",
|
||||
"Modern": "现代风格",
|
||||
"Classic": "经典风格",
|
||||
"Creative": "创意风格",
|
||||
"Clean and minimalist design with modern UI elements": "简洁的极简设计,配有现代UI元素",
|
||||
"Traditional layout with professional appearance": "传统布局,专业外观",
|
||||
"Bold and artistic design with vibrant colors": "大胆的艺术设计,色彩鲜艳",
|
||||
"Configure platform logo, name, titles, language": "配置平台logo、名称、标题、语言",
|
||||
"At least one login method must be enabled": "至少需要启用一种登录方式",
|
||||
"About Page Content": "关于页面内容",
|
||||
"Configure about page content": "配置关于页面内容",
|
||||
"Enter about page content (supports Markdown)": "输入关于页面内容(支持Markdown)",
|
||||
"Theme": "主题",
|
||||
"Choose your preferred theme style": "选择您喜欢的主题风格",
|
||||
"Default": "默认",
|
||||
"Standard layout with clean and simple design": "标准布局,简洁明了",
|
||||
"Temu": "Temu",
|
||||
"E-commerce style with vibrant orange gradient background": "电商风格,橙色渐变背景",
|
||||
"Login Settings": "登录设置",
|
||||
"Configure authentication methods": "配置认证方法",
|
||||
"Email Login": "邮箱登录",
|
||||
"Configure email-based authentication": "配置邮箱登录",
|
||||
"Enable Email Login": "启用邮箱登录",
|
||||
"Allow users to sign in with email": "允许用户使用邮箱登录",
|
||||
"Authentication Mode": "认证模式",
|
||||
"Choose how users authenticate with email": "选择用户认证方式",
|
||||
"Email/Password": "邮箱/密码",
|
||||
"Traditional email and password authentication": "传统邮箱和密码认证",
|
||||
"Email/Verification Code": "邮箱/验证码",
|
||||
"Passwordless login with email verification code": "邮箱验证码登录",
|
||||
"Email service is not configured. Please configure email settings first.": "邮箱服务未配置。请先配置邮箱设置。",
|
||||
"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解决方案,为您的项目提供支持。",
|
||||
"Configuration": "配置",
|
||||
"Featured Products": "推荐产品",
|
||||
"Search": "搜索",
|
||||
"Change Password": "修改密码",
|
||||
"Enter new password": "输入新密码",
|
||||
"Re-enter new password": "重新输入新密码",
|
||||
"Confirm new password": "确认新密码",
|
||||
"New password and confirm password do not match": "新密码和确认密码不匹配",
|
||||
"New password must be at least 8 characters long": "新密码至少需要8个字符",
|
||||
"New password and confirm password must be the same": "新密码和确认密码必须相同",
|
||||
"New Password": "新密码",
|
||||
"Confirm New Password": "确认新密码",
|
||||
"Theme changed successfully": "主题切换成功",
|
||||
"Failed to change theme": "主题切换失败",
|
||||
"About page saved successfully": "关于页面保存成功",
|
||||
"Failed to save about page": "关于页面保存失败",
|
||||
"General": "常规设置",
|
||||
"Homepage": "首页设置",
|
||||
"Homepage content and theme settings": "首页内容和主题设置",
|
||||
"About Page": "关于页面",
|
||||
"About page content configuration": "关于页面内容配置",
|
||||
"Email & Admin": "邮箱与管理员",
|
||||
"Email and administrator settings": "邮箱和管理员设置",
|
||||
"Embedded HTML": "嵌入式HTML",
|
||||
"Configure custom HTML content for global injection": "配置自定义HTML内容进行全局注入",
|
||||
"Enable Custom HTML": "启用自定义HTML",
|
||||
"Toggle to enable or disable custom HTML injection": "切换启用或禁用自定义HTML注入",
|
||||
"Show Preview": "显示预览",
|
||||
"Hide Preview": "隐藏预览",
|
||||
"Enter your custom HTML, CSS, or JavaScript code here...\n\nExample:\n<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将在保存并启用后渲染。",
|
||||
"Usage Instructions": "使用说明",
|
||||
"You can include Google Analytics, custom CSS, or any tracking scripts": "您可以包含Google Analytics、自定义CSS或任何跟踪脚本",
|
||||
"The HTML will be injected into the document head section": "HTML将注入到文档头部分",
|
||||
"Make sure your code is valid to avoid breaking the application": "确保您的代码有效,以避免破坏应用程序",
|
||||
"Changes take effect immediately after saving and enabling": "更改在保存并启用后立即生效",
|
||||
"Welcome to Your Platform": "欢迎使用您的平台",
|
||||
"Let's set up your platform with some basic information": "让我们用一些基本信息来设置您的平台",
|
||||
"Fields marked with * are required": "标有 * 的字段为必填项",
|
||||
"Website title is required": "网站标题为必填项",
|
||||
"Headline is required": "标题为必填项",
|
||||
"Subheadline is required": "副标题为必填项",
|
||||
"Please fill in all required fields": "请填写所有必填字段",
|
||||
"Setup failed. Please try again.": "设置失败,请重试。",
|
||||
"Complete Setup": "完成设置",
|
||||
"Platform setup completed successfully!": "平台设置成功完成!",
|
||||
"Welcome to the famous five-minute platform setup process! Just fill in the information below and you'll be on your way to using the most extendable and powerful platform.": "欢迎使用著名的五分钟平台设置流程!只需填写下面的信息,您就可以开始使用最具扩展性和功能强大的平台了。",
|
||||
"Information needed": "所需信息",
|
||||
"Please provide the following information. Do not worry, you can always change these settings later in the admin panel.": "请提供以下信息。不用担心,您随时可以在管理面板中更改这些设置。",
|
||||
"Failed to update homepage config": "更新主页配置失败",
|
||||
"Homepage config updated successfully": "主页配置更新成功",
|
||||
"Failed to load homepage config": "加载主页配置失败",
|
||||
"FAQ updated successfully": "常见问题更新成功",
|
||||
"Navigation updated successfully": "导航更新成功",
|
||||
"Embedded HTML updated successfully": "嵌入HTML更新成功",
|
||||
"Payment channels updated successfully": "支付渠道更新成功",
|
||||
"Manage frequently asked questions": "管理常见问题",
|
||||
"Add FAQ Item": "添加常见问题",
|
||||
"Remove FAQ Item": "删除常见问题",
|
||||
"Top Navigation": "顶部导航",
|
||||
"Manage top navigation links": "管理顶部导航链接",
|
||||
"Title": "标题",
|
||||
"Link": "链接",
|
||||
"Target": "目标",
|
||||
"Add Navigation Item": "添加导航项",
|
||||
"Remove Navigation Item": "删除导航项",
|
||||
"Enter title": "输入标题",
|
||||
"Enter link URL": "输入链接地址",
|
||||
"Same window": "当前窗口",
|
||||
"New window": "新窗口",
|
||||
"Custom HTML injection": "自定义HTML注入",
|
||||
"Enable embedded HTML": "启用嵌入HTML",
|
||||
"HTML Content": "HTML内容",
|
||||
"Enter custom HTML code": "输入自定义HTML代码",
|
||||
"Manage payment methods": "管理支付方式",
|
||||
"Channel ID": "渠道ID",
|
||||
"Display Name": "显示名称",
|
||||
"Add Payment Channel": "添加支付渠道",
|
||||
"Remove Payment Channel": "删除支付渠道",
|
||||
"Enter channel ID": "输入渠道ID",
|
||||
"Enter display name": "输入显示名称",
|
||||
"Installation Status": "安装状态",
|
||||
"First time installation": "首次安装",
|
||||
"System installed": "系统已安装",
|
||||
"Configure top navigation menu items and links": "配置顶部导航菜单项和链接",
|
||||
"Per Million Tokens": "每百万Token",
|
||||
"Price per million tokens consumed": "每百万Token消耗的价格",
|
||||
"Price per million tokens": "每百万Token价格",
|
||||
"Price per API call": "每次API调用价格",
|
||||
"Payment channel disabled successfully": "支付渠道禁用成功",
|
||||
"Failed to disable payment channel": "禁用支付渠道失败",
|
||||
"Payment channel enabled successfully": "支付渠道启用成功",
|
||||
"Failed to enable payment channel": "启用支付渠道失败",
|
||||
"Input Token Price": "输入Token价格",
|
||||
"Output Token Price": "输出Token价格",
|
||||
"Price per million input tokens": "每百万输入Token价格",
|
||||
"Price per million output tokens": "每百万输出Token价格",
|
||||
"Input": "输入",
|
||||
"Output": "输出",
|
||||
"1M tokens": "1M tokens"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import React from "react";
|
||||
import type { Metadata } from "next";
|
||||
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);
|
||||
}
|
||||
|
||||
export default async function AboutPage() {
|
||||
return <AboutThemeSelector />;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,30 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import React, { Suspense } from "react";
|
||||
import React, { Suspense, useEffect } from "react";
|
||||
import { Spinner } from "@nextui-org/react";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import AdminSignInComponent from "./components/AdminSignIn";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useAdminStore } from "@/store/admin";
|
||||
|
||||
const AdminLoginHeader = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center pb-6">
|
||||
<DynamicLogo
|
||||
alt="Platform Logo"
|
||||
className="h-[40px]"
|
||||
/>
|
||||
<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-sm text-default-500">{t("Log in to admin console")}</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const AdminLoginPageContent = () => {
|
||||
const [getAdminUser] = useAdminStore((state) => [state.getAdminUser]);
|
||||
const router = useRouter();
|
||||
|
||||
const handleCheckLogin = async () => {
|
||||
const res = await getAdminUser();
|
||||
if (res.success) {
|
||||
router.push("/console");
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
handleCheckLogin();
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col items-center justify-center w-full h-full mt-20">
|
||||
@@ -38,10 +48,16 @@ const AdminLoginPageContent = () => {
|
||||
|
||||
const AdminLoginPage = () => {
|
||||
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>
|
||||
}
|
||||
>
|
||||
<AdminLoginPageContent />
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminLoginPage;
|
||||
export default AdminLoginPage;
|
||||
@@ -2,6 +2,9 @@
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* Import theme styles */
|
||||
@import '../styles/themes.css';
|
||||
|
||||
html,
|
||||
body {
|
||||
padding: 0;
|
||||
|
||||
@@ -32,6 +32,13 @@ 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>
|
||||
<ClientRootProviders initConfig={platformConfig}>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { cache } from "react";
|
||||
import { notFound } from "next/navigation";
|
||||
import { ProductDetailClient } from "@/shared/components/marketplace/ProductDetail";
|
||||
import { ProductDetailThemeSelector } from "@/components/theme/ProductDetailThemeSelector";
|
||||
import type { Metadata } from "next";
|
||||
import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import { fetchServiceById } from "@/services/marketplaceService";
|
||||
@@ -8,20 +8,21 @@ 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 }>;
|
||||
}
|
||||
|
||||
const getProductById = cache(async (id: string): Promise<ServiceData | null> => {
|
||||
try {
|
||||
const product = await fetchServiceById(id);
|
||||
return product;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching product ${id}:`, error);
|
||||
return null;
|
||||
const getProductById = cache(
|
||||
async (id: string): Promise<ServiceData | null> => {
|
||||
try {
|
||||
const product = await fetchServiceById(id);
|
||||
return product;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching product ${id}:`, error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
// Generate metadata for SEO
|
||||
export async function generateMetadata({
|
||||
@@ -36,7 +37,9 @@ export async function generateMetadata({
|
||||
const title = await getDynamicTitle(product.name);
|
||||
return {
|
||||
...createBaseMetadata(title),
|
||||
description: product.short_description || `Discover ${product.name} and its powerful tools`,
|
||||
description:
|
||||
product.short_description ||
|
||||
`Discover ${product.name} and its powerful tools`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,13 +58,5 @@ export default async function ProductPage({ params }: ProductPageProps) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex flex-col justify-between">
|
||||
<Navigation />
|
||||
<main className="flex-1">
|
||||
<ProductDetailClient product={serviceData} />
|
||||
</main>
|
||||
<div> <Footer /></div>
|
||||
</div>
|
||||
)
|
||||
return <ProductDetailThemeSelector product={serviceData} />;
|
||||
}
|
||||
+11
-23
@@ -1,14 +1,12 @@
|
||||
import React, { Suspense } from "react";
|
||||
import { MarketplaceMain } from "@/components/marketplace/Main";
|
||||
import React from "react";
|
||||
import type { Metadata } from "next";
|
||||
import { createBaseMetadata, getDynamicTitle } from "@/shared/utils/metadata";
|
||||
import { Navigation } from "@/shared/components/Navigation";
|
||||
import { Footer } from "@/shared/components/Footer";
|
||||
import { fetchServices } from "@/services/marketplaceService";
|
||||
import type { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ThemeSelector } from "@/components/theme/ThemeSelector";
|
||||
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const title = await getDynamicTitle("Marketplace");
|
||||
const title = await getDynamicTitle();
|
||||
return createBaseMetadata(title);
|
||||
}
|
||||
|
||||
@@ -43,23 +41,13 @@ export default async function HomePage({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex flex-col justify-between">
|
||||
<Navigation />
|
||||
<main className="flex-1">
|
||||
<Suspense>
|
||||
<MarketplaceMain
|
||||
initialServices={services}
|
||||
initialTotal={total}
|
||||
initialPage={page}
|
||||
initialSearch={search}
|
||||
pageSize={pageSize}
|
||||
error={error}
|
||||
/>
|
||||
</Suspense>
|
||||
</main>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
<ThemeSelector
|
||||
initialServices={services}
|
||||
initialTotal={total}
|
||||
initialPage={page}
|
||||
initialSearch={search}
|
||||
pageSize={pageSize}
|
||||
error={error}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { Button, Input } from "@nextui-org/react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { StepState } from "../page";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
const emailSchema = z.object({
|
||||
email: z.string().email("Invalid email address"),
|
||||
email: z
|
||||
.string()
|
||||
.email({ message: "Invalid email address" })
|
||||
.min(1, { message: "Email is required" }),
|
||||
});
|
||||
|
||||
type EmailFormData = z.infer<typeof emailSchema>;
|
||||
@@ -20,13 +23,14 @@ interface LoginEmailFromProps {
|
||||
|
||||
export const LoginEmailFrom = ({ setEmail, setStep }: LoginEmailFromProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
const {
|
||||
register,
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors, isSubmitting },
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<EmailFormData>({
|
||||
resolver: zodResolver(emailSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
const onSubmit = async (data: EmailFormData) => {
|
||||
@@ -36,14 +40,22 @@ export const LoginEmailFrom = ({ setEmail, setStep }: LoginEmailFromProps) => {
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-col gap-4">
|
||||
<Input
|
||||
{...register("email")}
|
||||
type="email"
|
||||
label={t("Email")}
|
||||
placeholder={t("Enter your email")}
|
||||
isInvalid={!!errors.email}
|
||||
errorMessage={errors.email?.message}
|
||||
variant="bordered"
|
||||
<Controller
|
||||
name="email"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
type="email"
|
||||
label={t("Email")}
|
||||
placeholder={t("Enter your email")}
|
||||
isInvalid={!!errors.email}
|
||||
errorMessage={t(errors.email?.message || "")}
|
||||
variant="bordered"
|
||||
color={errors.email ? "danger" : "default"}
|
||||
className={errors.email ? "border-danger" : ""}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
@@ -55,4 +67,4 @@ export const LoginEmailFrom = ({ setEmail, setStep }: LoginEmailFromProps) => {
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,114 @@
|
||||
"use client";
|
||||
|
||||
import { Button, Input } from "@nextui-org/react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
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 { md5Encrypt } from "@/shared/utils/crypto";
|
||||
|
||||
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"),
|
||||
});
|
||||
|
||||
type EmailPasswordFormData = z.infer<typeof emailPasswordSchema>;
|
||||
|
||||
interface LoginEmailPasswordFormProps {
|
||||
onSuccess?: () => void;
|
||||
}
|
||||
|
||||
export const LoginEmailPasswordForm = ({
|
||||
onSuccess,
|
||||
}: LoginEmailPasswordFormProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const { emailPasswordLogin } = useLogin();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors, isSubmitting, isValid },
|
||||
} = useForm<EmailPasswordFormData>({
|
||||
resolver: zodResolver(emailPasswordSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
const onSubmit = async (data: EmailPasswordFormData) => {
|
||||
try {
|
||||
await emailPasswordLogin({
|
||||
user_email: data.email,
|
||||
password: md5Encrypt(data.password),
|
||||
});
|
||||
onSuccess?.();
|
||||
} catch (error) {
|
||||
console.error("Login failed:", error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-col gap-4">
|
||||
<Controller
|
||||
name="email"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
type="email"
|
||||
label={t("Email")}
|
||||
placeholder={t("Enter your email")}
|
||||
isInvalid={!!errors.email}
|
||||
errorMessage={t(errors.email?.message || "")}
|
||||
variant="bordered"
|
||||
color={errors.email ? "danger" : "default"}
|
||||
className={errors.email ? "border-danger" : ""}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="password"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
{...field}
|
||||
type={showPassword ? "text" : "password"}
|
||||
label={t("Password")}
|
||||
placeholder={t("Enter your password")}
|
||||
isInvalid={!!errors.password}
|
||||
errorMessage={errors.password?.message}
|
||||
variant="bordered"
|
||||
color={errors.password ? "danger" : "default"}
|
||||
className={errors.password ? "border-danger" : ""}
|
||||
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>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
color="primary"
|
||||
isLoading={isSubmitting}
|
||||
className="w-full"
|
||||
>
|
||||
{t("Sign In")}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
@@ -6,8 +6,10 @@ import { LoginButton } from "./LoginButton";
|
||||
import { useLogin } from "@/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";
|
||||
|
||||
export type StepState = "init" | "emailForm" | "verifyEmail";
|
||||
|
||||
@@ -16,10 +18,17 @@ const SignInComponent = () => {
|
||||
const [email, setEmail] = useState("");
|
||||
const [step, setStep] = useState<StepState>("init");
|
||||
const { googleLoginOrSignUp } = useLogin();
|
||||
const { googleAuthConfig } = usePlatformConfig();
|
||||
const { loginConfig } = usePlatformConfig();
|
||||
|
||||
// 检查是否启用了 Google 登录
|
||||
const isGoogleLoginEnabled = googleAuthConfig?.is_enabled && googleAuthConfig?.client_id;
|
||||
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 (
|
||||
<>
|
||||
@@ -34,8 +43,8 @@ const SignInComponent = () => {
|
||||
onClick={googleLoginOrSignUp}
|
||||
/>
|
||||
)}
|
||||
{/* OR - 只有在启用 Google 登录时才显示分隔符 */}
|
||||
{isGoogleLoginEnabled && (
|
||||
{/* 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>
|
||||
@@ -43,8 +52,18 @@ const SignInComponent = () => {
|
||||
</div>
|
||||
)}
|
||||
{/* Login With Email */}
|
||||
{step === "init" && (
|
||||
<LoginEmailFrom setEmail={setEmail} setStep={setStep} />
|
||||
{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
|
||||
@@ -64,4 +83,4 @@ export default function SignInWrapper() {
|
||||
<SignInComponent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Card, CardBody } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
export const AboutContent: React.FC = () => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<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">
|
||||
{platformConfig.about_page ? (
|
||||
<ReactMarkdown>{platformConfig.about_page}</ReactMarkdown>
|
||||
) : (
|
||||
<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.")}
|
||||
|
||||
|
||||
${t("✨ With XPack, you can:")}
|
||||
${t("- ✅ **One-click OpenAPI → MCP service config**")}
|
||||
${t("- 🧾 **SEO-friendly homepage + mcp service 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>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
Button,
|
||||
Input,
|
||||
} from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import toast from "react-hot-toast";
|
||||
import { useGlobalStore } from "@/shared/store/global";
|
||||
import { useSharedStore } from "@/shared/store/share";
|
||||
|
||||
interface ChangePasswordModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const ChangePasswordModal: React.FC<ChangePasswordModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [newPassword, setNewPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [showNewPassword, setShowNewPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
const { changePassword } = useGlobalStore();
|
||||
const { setUserToken } = useSharedStore();
|
||||
|
||||
const handleClose = () => {
|
||||
setNewPassword("");
|
||||
setConfirmPassword("");
|
||||
setShowNewPassword(false);
|
||||
setShowConfirmPassword(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
// 验证表单
|
||||
if (!newPassword.trim()) {
|
||||
toast.error(t("Please enter new password"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPassword.length < 8) {
|
||||
toast.error(t("Password must be at least 8 characters long"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newPassword !== confirmPassword) {
|
||||
toast.error(t("New passwords do not match"));
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await changePassword(newPassword);
|
||||
|
||||
if (result.success) {
|
||||
toast.success(t("Password changed successfully"));
|
||||
setUserToken(result.data.user_token || "");
|
||||
handleClose();
|
||||
return;
|
||||
}
|
||||
toast.error(result.error_message || t("Failed to change password"));
|
||||
};
|
||||
|
||||
const isFormValid =
|
||||
newPassword.trim() !== "" &&
|
||||
confirmPassword.trim() !== "" &&
|
||||
newPassword === confirmPassword &&
|
||||
newPassword.length >= 8;
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={handleClose} size="md">
|
||||
<ModalContent>
|
||||
<ModalHeader className="flex flex-col gap-1">
|
||||
{t("Change Password")}
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<div className="space-y-4">
|
||||
{/* New Password */}
|
||||
<Input
|
||||
label={t("New Password")}
|
||||
placeholder={t("Enter new password")}
|
||||
type={showNewPassword ? "text" : "password"}
|
||||
value={newPassword}
|
||||
onChange={(e) => setNewPassword(e.target.value)}
|
||||
description={t("Password must be at least 8 characters long")}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowNewPassword(!showNewPassword)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showNewPassword ? (
|
||||
<EyeOff className="w-4 h-4 text-gray-400" />
|
||||
) : (
|
||||
<Eye className="w-4 h-4 text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
{/* Confirm New Password */}
|
||||
<Input
|
||||
label={t("Confirm New Password")}
|
||||
placeholder={t("Confirm new password")}
|
||||
type={showConfirmPassword ? "text" : "password"}
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
color={
|
||||
confirmPassword && newPassword !== confirmPassword
|
||||
? "danger"
|
||||
: "default"
|
||||
}
|
||||
errorMessage={
|
||||
confirmPassword && newPassword !== confirmPassword
|
||||
? t("Passwords do not match")
|
||||
: undefined
|
||||
}
|
||||
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>
|
||||
}
|
||||
isRequired
|
||||
/>
|
||||
</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="default" variant="light" onPress={handleClose}>
|
||||
{t("Cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleSubmit}
|
||||
isDisabled={!isFormValid}
|
||||
>
|
||||
{t("Confirm")}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,103 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { EmailConfigForm } from "@/components/login-setting/EmailConfigForm";
|
||||
import { GoogleAuthConfigForm } from "@/components/login-setting/GoogleAuthConfigForm";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { LoginConfig, GoogleAuthConfig } from "@/shared/types/system";
|
||||
import { TabKey } from "@/shared/types/dashboard";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { EmailConfig } from "@/types/system";
|
||||
|
||||
interface LoginSettingsContentProps {
|
||||
onTabNavigate?: (tab: TabKey) => void;
|
||||
loginConfig: LoginConfig;
|
||||
saveLoginConfig: (config: LoginConfig) => Promise<boolean>;
|
||||
emailConfig: EmailConfig;
|
||||
}
|
||||
|
||||
export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
|
||||
onTabNavigate,
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
emailConfig,
|
||||
}) => {
|
||||
const [googleSubmitLoading, setGoogleSubmitLoading] = useState(false);
|
||||
const [emailSubmitLoading, setEmailSubmitLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const { updateClientConfig } = usePlatformConfig();
|
||||
|
||||
// 验证至少有一种登录方式启用
|
||||
const validateLoginMethods = (config: LoginConfig): boolean => {
|
||||
const isGoogleEnabled =
|
||||
config.google?.is_enabled && config.google?.client_id;
|
||||
const isEmailEnabled = config.email?.is_enabled;
|
||||
|
||||
const enabledCount = [isGoogleEnabled, isEmailEnabled].filter(
|
||||
Boolean
|
||||
).length;
|
||||
|
||||
if (enabledCount === 0) {
|
||||
toast.error(t("At least one login method must be enabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// save login config
|
||||
const handleSaveLoginConfig = async (config: LoginConfig) => {
|
||||
if (!validateLoginMethods(config)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setEmailSubmitLoading(true);
|
||||
const result = await saveLoginConfig(config);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
login: config,
|
||||
});
|
||||
setEmailSubmitLoading(false);
|
||||
};
|
||||
|
||||
// save google auth config
|
||||
const handleSaveGoogleAuthConfig = async (config: GoogleAuthConfig) => {
|
||||
const updatedLoginConfig = {
|
||||
...loginConfig,
|
||||
google: config,
|
||||
};
|
||||
|
||||
if (!validateLoginMethods(updatedLoginConfig)) {
|
||||
return;
|
||||
}
|
||||
|
||||
setGoogleSubmitLoading(true);
|
||||
const result = await saveLoginConfig(updatedLoginConfig);
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
login: updatedLoginConfig,
|
||||
});
|
||||
setGoogleSubmitLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4 w-full">
|
||||
{/* email config */}
|
||||
<EmailConfigForm
|
||||
config={loginConfig}
|
||||
emailConfig={emailConfig}
|
||||
onSave={handleSaveLoginConfig}
|
||||
isLoading={emailSubmitLoading}
|
||||
onTabNavigate={onTabNavigate}
|
||||
/>
|
||||
|
||||
{/* google auth config */}
|
||||
<GoogleAuthConfigForm
|
||||
config={loginConfig.google}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={googleSubmitLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -4,7 +4,6 @@ import React, { useEffect, useState, Suspense } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAdminStore } from "@/store/admin";
|
||||
import DashboardSidebar from "@/shared/components/DashboardSidebar";
|
||||
import DashboardDemoContent from "@/shared/components/DashboardDemoContent";
|
||||
import ConsoleStats from "@/components/console/ConsoleStats";
|
||||
import PaymentChannelsContent from "@/components/console/PaymentChannelsContent";
|
||||
@@ -14,179 +13,237 @@ 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 { Cog, CreditCard, DollarSign, Home, Settings, Users } from "lucide-react";
|
||||
import {
|
||||
CreditCard,
|
||||
DollarSign,
|
||||
Home,
|
||||
Settings,
|
||||
Users,
|
||||
LogIn,
|
||||
ServerIcon,
|
||||
} from "lucide-react";
|
||||
import { LoginSettingsContent } from "@/components/console/LoginSettingsContent";
|
||||
import ConsoleSidebar from "./Sidebar";
|
||||
|
||||
const ConsoleContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [admin_token] = useAdminStore((state) => [state.admin_token]);
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [admin_token] = useAdminStore((state) => [state.admin_token]);
|
||||
|
||||
const getInitialTab = (): TabKey => {
|
||||
const tabFromUrl = searchParams.get("tab") as TabKey;
|
||||
if (
|
||||
tabFromUrl &&
|
||||
[
|
||||
"mcp-services",
|
||||
"user-management",
|
||||
"revenue-management",
|
||||
"payment-channels",
|
||||
"system-settings",
|
||||
].includes(tabFromUrl)
|
||||
) {
|
||||
return tabFromUrl;
|
||||
}
|
||||
return "console";
|
||||
};
|
||||
const _DefaultSubTab = "general";
|
||||
|
||||
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
|
||||
const sidebarItems: SidebarItem[] = [
|
||||
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)
|
||||
) {
|
||||
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 sidebarItems: SidebarItem[] = [
|
||||
{
|
||||
key: TabKey.CONSOLE,
|
||||
icon: <Home size={18} />,
|
||||
label: t("Dashboard"),
|
||||
description: t("Overview and analytics"),
|
||||
},
|
||||
{
|
||||
key: TabKey.MCP_SERVICES,
|
||||
icon: <ServerIcon size={18} />,
|
||||
label: t("MCP Services"),
|
||||
description: t("Manage MCP services and API tools"),
|
||||
},
|
||||
{
|
||||
key: TabKey.USER_MANAGEMENT,
|
||||
icon: <Users size={18} />,
|
||||
label: t("User Management"),
|
||||
description: t("Manage registered users"),
|
||||
},
|
||||
{
|
||||
key: TabKey.REVENUE_MANAGEMENT,
|
||||
icon: <DollarSign size={18} />,
|
||||
label: t("Revenue Management"),
|
||||
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: "console",
|
||||
icon: <Home className="w-5 h-5" />,
|
||||
label: t("Dashboard"),
|
||||
description: t("Overview and analytics"),
|
||||
key: "general",
|
||||
label: "General",
|
||||
description: "Platform basic configuration",
|
||||
},
|
||||
{
|
||||
key: "mcp-services",
|
||||
icon: <Settings className="w-5 h-5" />,
|
||||
label: t("MCP Services"),
|
||||
description: t("Manage MCP services and API tools"),
|
||||
key: "login-settings",
|
||||
label: "Login Settings",
|
||||
description: "Configure authentication methods",
|
||||
},
|
||||
{
|
||||
key: "user-management",
|
||||
icon: <Users className="w-5 h-5" />,
|
||||
label: t("User Management"),
|
||||
description: t("Manage registered users"),
|
||||
key: "homepage",
|
||||
label: "Homepage",
|
||||
description: "Homepage content and theme settings",
|
||||
},
|
||||
{
|
||||
key: "revenue-management",
|
||||
icon: <DollarSign className="w-5 h-5" />,
|
||||
label: t("Revenue Management"),
|
||||
description: t("View user recharge history"),
|
||||
key: "about-page",
|
||||
label: "About Page",
|
||||
description: "About page content configuration",
|
||||
},
|
||||
{
|
||||
key: "payment-channels",
|
||||
icon: <CreditCard className="w-5 h-5" />,
|
||||
label: t("Payment Channels"),
|
||||
description: t("Configure payment channels"),
|
||||
key: "email-admin",
|
||||
label: "Email & Admin",
|
||||
description: "Email and administrator settings",
|
||||
},
|
||||
{
|
||||
key: "system-settings",
|
||||
icon: <Cog className="w-5 h-5" />,
|
||||
label: t("System Settings"),
|
||||
description: t("Platform basic configuration"),
|
||||
},
|
||||
];
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// If admin is not logged in, redirect to admin login page
|
||||
useEffect(() => {
|
||||
if (!admin_token) {
|
||||
router.push("/admin");
|
||||
}
|
||||
}, [admin_token, router]);
|
||||
|
||||
// If admin is not logged in, redirect to admin login page
|
||||
useEffect(() => {
|
||||
if (!admin_token) {
|
||||
router.push("/admin-signin");
|
||||
}
|
||||
}, [admin_token, router]);
|
||||
const handleTabNavigate = (tab: TabKey, subTab?: string) => {
|
||||
setActiveTab(tab);
|
||||
setActiveSubTab(subTab || _DefaultSubTab);
|
||||
|
||||
const handleTabNavigate = (tab: TabKey) => {
|
||||
setActiveTab(tab);
|
||||
// update url params
|
||||
if (tab === "console") {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
router.push("/console", { scroll: false });
|
||||
} else {
|
||||
// other tabs set corresponding tab params
|
||||
const params = new URLSearchParams();
|
||||
params.set("tab", tab);
|
||||
router.push(`/console?${params.toString()}`, { scroll: false });
|
||||
}
|
||||
};
|
||||
// update url params
|
||||
if (tab === TabKey.CONSOLE) {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
router.push("/console", { scroll: false });
|
||||
} else {
|
||||
// other tabs set corresponding tab params
|
||||
const params = new URLSearchParams();
|
||||
params.set("tab", tab);
|
||||
|
||||
const { adminLogout } = useAdminLogin();
|
||||
// add subtab parameter if provided
|
||||
if (subTab) {
|
||||
params.set("subtab", subTab);
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
// use admin logout method
|
||||
adminLogout();
|
||||
};
|
||||
router.push(`/console?${params.toString()}`, { scroll: false });
|
||||
}
|
||||
};
|
||||
|
||||
// render different content based on activeTab
|
||||
const renderContent = () => {
|
||||
switch (activeTab) {
|
||||
case "mcp-services":
|
||||
return <MCPServicesManagement />;
|
||||
case "user-management":
|
||||
return (
|
||||
<div className="h-full overflow-auto">
|
||||
<UserManagement />
|
||||
</div>
|
||||
);
|
||||
case "revenue-management":
|
||||
return (
|
||||
<div className="h-full overflow-auto">
|
||||
<RevenueManagement />
|
||||
</div>
|
||||
);
|
||||
case "payment-channels":
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t("Payment Channels")}
|
||||
description={t("Configure payment channels")}
|
||||
>
|
||||
<PaymentChannelsContent />
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
case "system-settings":
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t("System Settings")}
|
||||
description={t("Platform basic configuration")}
|
||||
>
|
||||
<SystemSettingsContent />
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t("Admin Dashboard")}
|
||||
description={t("Platform management and analytics")}
|
||||
>
|
||||
<ConsoleStats />
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
}
|
||||
};
|
||||
const { adminLogout } = useAdminLogin();
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<div className="flex">
|
||||
{/* Sidebar */}
|
||||
<DashboardSidebar
|
||||
activeTab={activeTab}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
onLogout={handleLogout}
|
||||
sidebarItems={sidebarItems}
|
||||
/>
|
||||
const handleLogout = () => {
|
||||
// use admin logout method
|
||||
adminLogout();
|
||||
};
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
// render different content based on activeTab
|
||||
const renderContent = () => {
|
||||
switch (activeTab) {
|
||||
case TabKey.MCP_SERVICES:
|
||||
return <MCPServicesManagement />;
|
||||
case TabKey.USER_MANAGEMENT:
|
||||
return (
|
||||
<div className="h-full overflow-auto">
|
||||
<UserManagement />
|
||||
</div>
|
||||
);
|
||||
case TabKey.REVENUE_MANAGEMENT:
|
||||
return (
|
||||
<div className="h-full overflow-auto">
|
||||
<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 (
|
||||
<DashboardDemoContent
|
||||
title={t("Admin Dashboard")}
|
||||
description={t("Platform management and analytics")}
|
||||
>
|
||||
<ConsoleStats />
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<div className="flex">
|
||||
{/* Sidebar */}
|
||||
<ConsoleSidebar
|
||||
activeTab={activeTab}
|
||||
activeSubTab={activeSubTab}
|
||||
onTabNavigate={handleTabNavigate}
|
||||
onLogout={handleLogout}
|
||||
sidebarItems={sidebarItems}
|
||||
/>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const ConsoleMain: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="min-h-screen bg-background flex items-center justify-center">
|
||||
{t("Loading...")}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<ConsoleContent />
|
||||
</Suspense>
|
||||
);
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
<div className="min-h-screen bg-background flex items-center justify-center">
|
||||
{t("Loading...")}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<ConsoleContent />
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleMain;
|
||||
@@ -1,46 +1,56 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { StripeConfigForm } from './StripeConfigForm';
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import React from "react";
|
||||
import { StripeConfigForm } from "../payment/StripeConfigForm";
|
||||
import { AlipayConfigForm } from "../payment/AlipayConfigForm";
|
||||
import { WechatConfigForm } from "../payment/WechatConfigForm";
|
||||
import { usePaymentChannelManagement } from "@/hooks/usePaymentChannelManagement";
|
||||
import { StripeConfig } from "@/types/payment";
|
||||
import { toast } from "react-hot-toast";
|
||||
|
||||
export const PaymentChannelsContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const {
|
||||
stripeConfig,
|
||||
isSaving,
|
||||
alipayConfig,
|
||||
wechatConfig,
|
||||
isWechatSaving,
|
||||
isStripeSaving,
|
||||
isAlipaySaving,
|
||||
saveStripeConfig,
|
||||
testStripeConnection,
|
||||
saveAlipayConfig,
|
||||
saveWechatConfig,
|
||||
enableChannel,
|
||||
disableChannel,
|
||||
} = usePaymentChannelManagement();
|
||||
|
||||
|
||||
// test stripe connection
|
||||
const handleTestStripeConnection = async (config: StripeConfig) => {
|
||||
const result = await testStripeConnection(config);
|
||||
|
||||
if (result.success) {
|
||||
toast.success(t("Stripe connection test successful"));
|
||||
} else {
|
||||
toast.error(result.message || t("Stripe connection test failed"));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 w-full">
|
||||
{/* stripe configuration */}
|
||||
<StripeConfigForm
|
||||
config={stripeConfig}
|
||||
onSave={saveStripeConfig}
|
||||
onTest={handleTestStripeConnection}
|
||||
isLoading={isSaving}
|
||||
isTestLoading={false}
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isStripeSaving}
|
||||
/>
|
||||
{/* coming soon */}
|
||||
{/* alipay configuration */}
|
||||
{/* <AlipayConfigForm
|
||||
config={alipayConfig}
|
||||
onSave={saveAlipayConfig}
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isAlipaySaving}
|
||||
/> */}
|
||||
{/* coming soon */}
|
||||
{/* wechat configuration */}
|
||||
{/* <WechatConfigForm
|
||||
config={wechatConfig}
|
||||
onSave={saveWechatConfig}
|
||||
onEnable={enableChannel}
|
||||
onDisable={disableChannel}
|
||||
isLoading={isWechatSaving}
|
||||
/> */}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PaymentChannelsContent;
|
||||
export default PaymentChannelsContent;
|
||||
@@ -0,0 +1,161 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Button, Divider, Link, Tooltip } from "@nextui-org/react";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { DashboardSidebarProps } from "@/shared/types/dashboard";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { FaDiscord } from "react-icons/fa";
|
||||
|
||||
const ConsoleSidebar: React.FC<DashboardSidebarProps> = ({
|
||||
activeTab,
|
||||
activeSubTab,
|
||||
onTabNavigate,
|
||||
onLogout,
|
||||
sidebarItems,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSubItemClick = (parentKey: string, subKey: string) => {
|
||||
onTabNavigate?.(parentKey as any, subKey);
|
||||
};
|
||||
|
||||
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"
|
||||
>
|
||||
<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>
|
||||
|
||||
<div>
|
||||
<Divider className="my-2" />
|
||||
|
||||
<div className="space-y-2">
|
||||
<Tooltip
|
||||
content={t("Discord")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<Button
|
||||
variant="light"
|
||||
startContent={<FaDiscord size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
onPress={() => {
|
||||
window.open("https://discord.gg/cyZfcdCXkW", "_blank");
|
||||
}}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
|
||||
{/* Logout */}
|
||||
<Tooltip
|
||||
content={t("Log Out")}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
placement="right"
|
||||
>
|
||||
<Button
|
||||
variant="light"
|
||||
color="danger"
|
||||
startContent={<LogOut size={18} />}
|
||||
className="w-full h-auto p-4"
|
||||
onPress={onLogout}
|
||||
isIconOnly
|
||||
></Button>
|
||||
</Tooltip>
|
||||
</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>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConsoleSidebar;
|
||||
@@ -1,121 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Input, Button, AccordionItem, Accordion } from '@nextui-org/react';
|
||||
import { Eye, EyeOff } from 'lucide-react';
|
||||
import { StripeConfig } from '@/types/payment';
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface StripeConfigFormProps {
|
||||
config: StripeConfig;
|
||||
onSave: (config: StripeConfig) => void;
|
||||
onTest: (config: StripeConfig) => void;
|
||||
isLoading?: boolean;
|
||||
isTestLoading?: boolean;
|
||||
}
|
||||
|
||||
export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<StripeConfig>(config);
|
||||
const [showSecretKey, setShowSecretKey] = useState(false);
|
||||
const [showWebhookSecret, setShowWebhookSecret] = useState(false);
|
||||
useEffect(() => {
|
||||
console.log("config", config);
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (field: keyof StripeConfig, value: string) => {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
}));
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
|
||||
const isFormValid = formData.secret.trim() !== '' && formData.webhook_secret.trim() !== '';
|
||||
|
||||
return (
|
||||
<Accordion variant='splitted' itemClasses={{
|
||||
base: 'shadow-none border-1',
|
||||
}} defaultExpandedKeys={['stripe-config']} className='px-0'>
|
||||
<AccordionItem key="stripe-config" title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">{t('Stripe Configuration')}</h3>
|
||||
<p className="text-sm text-gray-500">{t('Configure Stripe payment interface')}</p>
|
||||
</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
|
||||
/>
|
||||
|
||||
{/* 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>
|
||||
}
|
||||
/>
|
||||
</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>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -1,17 +1,33 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { PlatformConfigForm } from '@/components/system-setting/PlatformConfigForm';
|
||||
import { AdminConfigForm } from '@/components/system-setting/AdminConfigForm';
|
||||
import { EmailConfigForm } from '@/components/system-setting/EmailConfigForm';
|
||||
import { GoogleAuthConfigForm } from '@/components/system-setting/GoogleAuthConfigForm';
|
||||
import { useSystemConfigManagement } from '@/hooks/useSystemConfigManagement';
|
||||
import { usePlatformConfig } from '@/shared/contexts/PlatformConfigContext';
|
||||
import i18n from '@/shared/lib/i18n';
|
||||
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";
|
||||
|
||||
export const SystemSettingsContent: React.FC = () => {
|
||||
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,
|
||||
@@ -28,11 +44,12 @@ export const SystemSettingsContent: React.FC = () => {
|
||||
emailLoading,
|
||||
saveEmailConfig,
|
||||
|
||||
// google auth config
|
||||
googleAuthConfig,
|
||||
googleAuthLoading,
|
||||
saveGoogleAuthConfig,
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// login config
|
||||
loginConfig,
|
||||
saveLoginConfig,
|
||||
} = useSystemConfigManagement();
|
||||
|
||||
// save admin config
|
||||
@@ -45,22 +62,10 @@ export const SystemSettingsContent: React.FC = () => {
|
||||
await saveEmailConfig(config);
|
||||
};
|
||||
|
||||
// save google auth config
|
||||
const handleSaveGoogleAuthConfig = async (config: typeof googleAuthConfig) => {
|
||||
const result = await saveGoogleAuthConfig(config);
|
||||
if (!result) return
|
||||
updateClientConfig({
|
||||
platform: platformConfig,
|
||||
login: {
|
||||
google: config,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
// save platform config
|
||||
const handleSavePlatformConfig = async (config: typeof platformConfig) => {
|
||||
const result = await savePlatformConfig(config);
|
||||
if (!result) return
|
||||
if (!result) return;
|
||||
updateClientConfig({
|
||||
platform: config,
|
||||
});
|
||||
@@ -69,38 +74,83 @@ export const SystemSettingsContent: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 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 (
|
||||
<div className="space-y-6 w-full">
|
||||
{/* platform config */}
|
||||
<PlatformConfigForm
|
||||
config={platformConfig}
|
||||
onSave={handleSavePlatformConfig}
|
||||
isLoading={platformLoading}
|
||||
/>
|
||||
|
||||
{/* admin config */}
|
||||
<AdminConfigForm
|
||||
config={adminConfig}
|
||||
onSave={handleSaveAdminConfig}
|
||||
isLoading={adminLoading}
|
||||
/>
|
||||
|
||||
{/* email config */}
|
||||
<EmailConfigForm
|
||||
config={emailConfig}
|
||||
onSave={handleSaveEmailConfig}
|
||||
isLoading={emailLoading}
|
||||
/>
|
||||
|
||||
{/* google auth config */}
|
||||
<GoogleAuthConfigForm
|
||||
config={googleAuthConfig}
|
||||
onSave={handleSaveGoogleAuthConfig}
|
||||
isLoading={googleAuthLoading}
|
||||
/>
|
||||
</div>
|
||||
<DashboardDemoContent
|
||||
title={t(subTab?.label || "System Settings")}
|
||||
description={t(subTab?.description || "Platform basic configuration")}
|
||||
>
|
||||
{renderSubTabContent()}
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
};
|
||||
|
||||
export default SystemSettingsContent;
|
||||
export default SystemSettingsContent;
|
||||
@@ -6,22 +6,30 @@ import { useGlobalStore } from "@/shared/store/global";
|
||||
import DashboardSidebar from "@/shared/components/DashboardSidebar";
|
||||
import { SidebarItem, TabKey } from "@/shared/types/dashboard";
|
||||
import { useSharedStore } from "@/shared/store/share";
|
||||
import { formatCurrency } from '@/shared/utils/currency';
|
||||
import { formatCurrency } from "@/shared/utils/currency";
|
||||
|
||||
// Import dashboard content components
|
||||
import DashboardOverview from "@/components/dashboard/DashboardOverview";
|
||||
import WalletManagement from "@/components/wallet/WalletManagement";
|
||||
import { Home, Wallet } from "lucide-react";
|
||||
import { Home, Key, Wallet } from "lucide-react";
|
||||
import { Avatar, Card, CardBody, Button, Divider } from "@nextui-org/react";
|
||||
import { RechargeModal } from "@/shared/components/modal/RechargeModal";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { ChangePasswordModal } from "@/components/common/ChangePasswordModal";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { RegisterType } from "@/shared/store/User";
|
||||
import { EmailMode } from "@/shared/types/system";
|
||||
|
||||
const DashboardContent: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const router = useRouter();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const [user_token, user] = useSharedStore((state) => [state.user_token, state.user]);
|
||||
const [user_token, user] = useSharedStore((state) => [
|
||||
state.user_token,
|
||||
state.user,
|
||||
]);
|
||||
const { loginConfig, paymentChannels } = usePlatformConfig();
|
||||
|
||||
const [logOut, useGetUser] = useGlobalStore((state) => [
|
||||
state.logOut,
|
||||
@@ -33,20 +41,23 @@ const DashboardContent: React.FC = () => {
|
||||
const [isRechargeModalOpen, setIsRechargeModalOpen] = useState(false);
|
||||
const getInitialTab = (): TabKey => {
|
||||
const tabFromUrl = searchParams.get("tab") as TabKey;
|
||||
if (
|
||||
tabFromUrl &&
|
||||
[
|
||||
"overview",
|
||||
"wallet"
|
||||
].includes(tabFromUrl)
|
||||
) {
|
||||
if (tabFromUrl && [TabKey.OVERVIEW, TabKey.WALLET].includes(tabFromUrl)) {
|
||||
return tabFromUrl;
|
||||
}
|
||||
return "overview";
|
||||
return TabKey.OVERVIEW;
|
||||
};
|
||||
|
||||
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
|
||||
const [isChangePasswordModalOpen, setIsChangePasswordModalOpen] =
|
||||
React.useState(false);
|
||||
|
||||
const handleChangePassword = () => {
|
||||
setIsChangePasswordModalOpen(true);
|
||||
};
|
||||
|
||||
const handleChangePasswordClose = () => {
|
||||
setIsChangePasswordModalOpen(false);
|
||||
};
|
||||
useEffect(() => {
|
||||
if (!data) return;
|
||||
if (data.code === "1000001") {
|
||||
@@ -55,8 +66,6 @@ const DashboardContent: React.FC = () => {
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
|
||||
|
||||
// If user is not logged in, redirect to login page
|
||||
useEffect(() => {
|
||||
if (!user_token) {
|
||||
@@ -64,7 +73,6 @@ const DashboardContent: React.FC = () => {
|
||||
}
|
||||
}, [user_token]);
|
||||
|
||||
|
||||
const handleLogout = () => {
|
||||
// use global store logout method
|
||||
logOut();
|
||||
@@ -78,24 +86,17 @@ const DashboardContent: React.FC = () => {
|
||||
|
||||
const sidebarItems: SidebarItem[] = [
|
||||
{
|
||||
key: "overview",
|
||||
key: TabKey.OVERVIEW,
|
||||
icon: <Home className="w-5 h-5" />,
|
||||
label: "Dashboard",
|
||||
description: "Manage your integration and auth key",
|
||||
},
|
||||
|
||||
// {
|
||||
// key: "wallet",
|
||||
// icon: <Wallet className="w-5 h-5" />,
|
||||
// label: "My Wallet",
|
||||
// description: "Manage your balance and recharge history",
|
||||
// },
|
||||
];
|
||||
|
||||
const handleTabNavigate = (tab: TabKey) => {
|
||||
setActiveTab(tab);
|
||||
// update url params
|
||||
if (tab === "overview") {
|
||||
if (tab === TabKey.OVERVIEW) {
|
||||
// when switch to dashboard, clear all query params, only keep base path
|
||||
router.push("/dashboard", { scroll: false });
|
||||
} else {
|
||||
@@ -115,6 +116,21 @@ const DashboardContent: React.FC = () => {
|
||||
onTabNavigate={handleTabNavigate}
|
||||
onLogout={handleLogout}
|
||||
sidebarItems={sidebarItems}
|
||||
bottomPanel={
|
||||
loginConfig?.email?.is_enabled &&
|
||||
loginConfig?.email?.mode === EmailMode.PASSWORD &&
|
||||
user?.register_type === RegisterType.EMAIL && (
|
||||
<Button
|
||||
variant="light"
|
||||
color="default"
|
||||
startContent={<Key className="w-4 h-4" />}
|
||||
className="w-full justify-start mb-2"
|
||||
onPress={handleChangePassword}
|
||||
>
|
||||
{t("Change Password")}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
userProfilePanel={
|
||||
user && (
|
||||
<div className="mb-6 space-y-3">
|
||||
@@ -132,9 +148,7 @@ const DashboardContent: React.FC = () => {
|
||||
{user.user_name || "Jack Liu"}
|
||||
</p>
|
||||
<p className="text-tiny text-default-600">
|
||||
{user.user_name
|
||||
? `${user.user_name.toLowerCase()}@gmail.com`
|
||||
: "xpack@gmail.com"}
|
||||
{user.user_email || "dev@xpack.ai"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,21 +156,26 @@ const DashboardContent: React.FC = () => {
|
||||
<div className="flex justify-between text-xs">
|
||||
<div className="flex gap-2 items-center">
|
||||
<Wallet size={16} />
|
||||
<span>{t("Balance: {{amount}}", { amount: formatCurrency(user?.wallet?.balance || 0) })}</span>
|
||||
<span>
|
||||
{t("Balance: {{amount}}", {
|
||||
amount: formatCurrency(user?.wallet?.balance || 0),
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
variant="bordered"
|
||||
onPress={handleRecharge}
|
||||
aria-label="Recharge wallet"
|
||||
size="sm"
|
||||
>
|
||||
{t("Recharge")}
|
||||
</Button>
|
||||
{paymentChannels.length > 0 && (
|
||||
<Button
|
||||
variant="bordered"
|
||||
onPress={handleRecharge}
|
||||
aria-label="Recharge wallet"
|
||||
size="sm"
|
||||
>
|
||||
{t("Recharge")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -164,8 +183,8 @@ const DashboardContent: React.FC = () => {
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="flex-1 h-screen overflow-y-auto">
|
||||
{activeTab === "overview" && <DashboardOverview />}
|
||||
{activeTab === "wallet" && (
|
||||
{activeTab === TabKey.OVERVIEW && <DashboardOverview />}
|
||||
{activeTab === TabKey.WALLET && (
|
||||
<WalletManagement onRecharge={() => setIsRechargeModalOpen(true)} />
|
||||
)}
|
||||
</div>
|
||||
@@ -176,6 +195,11 @@ const DashboardContent: React.FC = () => {
|
||||
isOpen={isRechargeModalOpen}
|
||||
onClose={() => setIsRechargeModalOpen(false)}
|
||||
/>
|
||||
{/* Change Password Modal */}
|
||||
<ChangePasswordModal
|
||||
isOpen={isChangePasswordModalOpen}
|
||||
onClose={handleChangePasswordClose}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -194,4 +218,4 @@ const DashboardMain: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default DashboardMain;
|
||||
export default DashboardMain;
|
||||
@@ -0,0 +1,210 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Switch,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Select,
|
||||
SelectItem,
|
||||
Button,
|
||||
Alert,
|
||||
Link,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EmailMode, LoginConfig } from "@/shared/types/system";
|
||||
import { EmailConfig } from "@/types/system";
|
||||
import { TabKey } from "@/shared/types/dashboard";
|
||||
|
||||
interface EmailConfigFormProps {
|
||||
config: LoginConfig;
|
||||
emailConfig: EmailConfig;
|
||||
onSave: (config: LoginConfig) => Promise<void>;
|
||||
isLoading?: boolean;
|
||||
onTabNavigate?: (tab: TabKey) => void;
|
||||
}
|
||||
|
||||
export const EmailConfigForm: React.FC<EmailConfigFormProps> = ({
|
||||
config,
|
||||
emailConfig,
|
||||
onSave,
|
||||
isLoading = false,
|
||||
onTabNavigate,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<LoginConfig>(config);
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleToggleEnabled = async (enabled: boolean) => {
|
||||
const updatedConfig = {
|
||||
...config,
|
||||
email: {
|
||||
...config.email,
|
||||
is_enabled: enabled,
|
||||
mode: config.email?.mode || EmailMode.PASSWORD,
|
||||
},
|
||||
};
|
||||
// when toggle the switch, save directly, same as GoogleAuthConfigForm
|
||||
await onSave(updatedConfig);
|
||||
};
|
||||
|
||||
const handleModeChange = (mode: EmailMode) => {
|
||||
// no longer save directly, but update the local state
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
email: {
|
||||
...prev.email,
|
||||
is_enabled: prev.email?.is_enabled || false,
|
||||
mode,
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
await onSave(formData);
|
||||
};
|
||||
|
||||
const isEmailConfigured = !!emailConfig?.smtp_host;
|
||||
const isCaptchaMode = formData.email?.mode === EmailMode.CAPTCHA;
|
||||
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>
|
||||
|
||||
{/* 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("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."
|
||||
)}
|
||||
</span>
|
||||
<Link
|
||||
className="text-sm underline cursor-pointer"
|
||||
onPress={() => {
|
||||
onTabNavigate?.(TabKey.SYSTEM_SETTINGS);
|
||||
}}
|
||||
>
|
||||
{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>
|
||||
)}
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,161 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
Switch,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
} from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { getGoogleRedirectUri } from "@/hooks/useLogin";
|
||||
import { GoogleAuthConfig } from "@/shared/types/system";
|
||||
|
||||
interface GoogleAuthConfigFormProps {
|
||||
config: GoogleAuthConfig;
|
||||
onSave: (config: GoogleAuthConfig) => void;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export const GoogleAuthConfigForm: React.FC<GoogleAuthConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<GoogleAuthConfig>(config);
|
||||
const [showClientSecret, setShowClientSecret] = useState(false);
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
const handleInputChange = (
|
||||
field: keyof GoogleAuthConfig,
|
||||
value: string | boolean
|
||||
) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
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>
|
||||
}
|
||||
>
|
||||
<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}
|
||||
/>
|
||||
</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>
|
||||
)}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Accordion, AccordionItem } from "@nextui-org/react";
|
||||
import { Plus } from "lucide-react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
function FaqClient() {
|
||||
const { faqItems } = usePlatformConfig();
|
||||
const { t } = useTranslation();
|
||||
// Custom indicator component with plus sign that fades out when expanded
|
||||
const CustomIndicator = ({ isOpen }: { isOpen?: boolean }) => (
|
||||
<Plus
|
||||
className={`text-black transition-all duration-300 ${
|
||||
isOpen ? "rotate-0 opacity-0" : "rotate-0 opacity-100"
|
||||
}`}
|
||||
size={16}
|
||||
/>
|
||||
);
|
||||
if (faqItems.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 sm:py-20 px-4 sm:px-6" id="faqs">
|
||||
<div className="max-w-7xl mx-auto">
|
||||
<h2 className="text-2xl sm:text-3xl font-bold mb-8 sm:mb-12 text-center">
|
||||
{t("FAQs")}
|
||||
</h2>
|
||||
{/**content */}
|
||||
<div className="relative bg-white rounded-lg">
|
||||
<Accordion variant="light">
|
||||
{faqItems.map((faq, index) => (
|
||||
<AccordionItem
|
||||
key={index}
|
||||
aria-label={faq.question}
|
||||
title={
|
||||
<span className="text-base sm:text-lg font-medium">
|
||||
{faq.question}
|
||||
</span>
|
||||
}
|
||||
className="pt-2 px-2"
|
||||
indicator={({ isOpen }) => <CustomIndicator isOpen={isOpen} />}
|
||||
>
|
||||
<div className="text-sm sm:text-base text-foreground-600 leading-relaxed space-y-2">
|
||||
{faq.answer}
|
||||
</div>
|
||||
</AccordionItem>
|
||||
))}
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function Faq() {
|
||||
return <FaqClient />;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export const BasicInfoTab: React.FC<BasicInfoTabProps> = ({
|
||||
>
|
||||
<SelectItem key="none" value="none">{t('None')}</SelectItem>
|
||||
<SelectItem key="apikey" value="apikey">{t('API Key')}</SelectItem>
|
||||
<SelectItem key="bearer-token" value="bearer-token">{t('Bearer Token')}</SelectItem>
|
||||
<SelectItem key="token" value="token">{t('Bearer Token')}</SelectItem>
|
||||
</Select>
|
||||
|
||||
{/* auth config input fields */}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { MCPServiceFormData } from '@/types/mcp-service';
|
||||
import dynamic from 'next/dynamic';
|
||||
import React from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { MCPServiceFormData } from "@/types/mcp-service";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
// dynamic import MDEditor to avoid SSR problem
|
||||
const MDEditor = dynamic(
|
||||
() => import('@uiw/react-md-editor').then((mod) => mod.default),
|
||||
() => import("@uiw/react-md-editor").then((mod) => mod.default),
|
||||
{ ssr: false }
|
||||
);
|
||||
|
||||
@@ -18,29 +18,30 @@ interface DescriptionTabProps {
|
||||
|
||||
export const DescriptionTab: React.FC<DescriptionTabProps> = ({
|
||||
formData,
|
||||
onInputChange
|
||||
onInputChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleMarkdownChange = (value?: string) => {
|
||||
onInputChange('long_description', value || '');
|
||||
onInputChange("long_description", value || "");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4 h-full">
|
||||
<div className="w-full h-full">
|
||||
<MDEditor
|
||||
value={formData.long_description || ''}
|
||||
value={formData.long_description || ""}
|
||||
onChange={handleMarkdownChange}
|
||||
preview="live"
|
||||
hideToolbar={false}
|
||||
visibleDragbar={true}
|
||||
textareaProps={{
|
||||
placeholder: t('Detailed description of the service (supports Markdown)'),
|
||||
placeholder: t("Detailed description of the service"),
|
||||
style: {
|
||||
fontSize: 14,
|
||||
lineHeight: 1.5,
|
||||
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
||||
fontFamily:
|
||||
'ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace',
|
||||
},
|
||||
}}
|
||||
height="100%"
|
||||
@@ -49,4 +50,4 @@ export const DescriptionTab: React.FC<DescriptionTabProps> = ({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,15 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Input,
|
||||
Select,
|
||||
SelectItem,
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { MCPServiceFormData } from '@/types/mcp-service';
|
||||
import { getCurrencySymbol } from '@/shared/utils/currency';
|
||||
import { ChargeType } from '@/shared/types/marketplace';
|
||||
import React from "react";
|
||||
import { Input, Select, SelectItem } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { MCPServiceFormData } from "@/types/mcp-service";
|
||||
import { getCurrencySymbol } from "@/shared/utils/currency";
|
||||
import { ChargeType } from "@/shared/types/marketplace";
|
||||
|
||||
interface PricingTabProps {
|
||||
formData: MCPServiceFormData;
|
||||
@@ -18,52 +14,111 @@ interface PricingTabProps {
|
||||
|
||||
export const PricingTab: React.FC<PricingTabProps> = ({
|
||||
formData,
|
||||
onInputChange
|
||||
onInputChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<Select
|
||||
label={t('Charge Type')}
|
||||
label={t("Charge Type")}
|
||||
selectedKeys={formData.charge_type ? [formData.charge_type] : []}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
onInputChange('charge_type', selectedKey);
|
||||
onInputChange("charge_type", selectedKey);
|
||||
}}
|
||||
renderValue={() => {
|
||||
const selectedKey = formData.charge_type || ChargeType.PerCall;
|
||||
if (selectedKey === ChargeType.Free) return t('Free');
|
||||
return t(selectedKey === ChargeType.PerCall ? 'Per Call' : 'Per Token');
|
||||
if (selectedKey === ChargeType.Free) return t("Free");
|
||||
return t(
|
||||
selectedKey === ChargeType.PerCall
|
||||
? "Per Call"
|
||||
: "Per Million Tokens"
|
||||
);
|
||||
}}
|
||||
>
|
||||
<SelectItem key="free" value={ChargeType.Free}>
|
||||
<div className="flex flex-col">
|
||||
<span>{t('Free')}</span>
|
||||
<span className="text-xs text-gray-500">{t('No charge for API calls')}</span>
|
||||
<span>{t("Free")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("No charge for API calls")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
<SelectItem key="per_call" value={ChargeType.PerCall}>
|
||||
<div className="flex flex-col">
|
||||
<span>{t('Per Call')}</span>
|
||||
<span className="text-xs text-gray-500">{t('Fixed price per API call')}</span>
|
||||
<span>{t("Per Call")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Fixed price per API call")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
|
||||
<SelectItem key="per_token" value={ChargeType.PerToken}>
|
||||
<div className="flex flex-col">
|
||||
<span>{t("Per Million Tokens")}</span>
|
||||
<span className="text-xs text-gray-500">
|
||||
{t("Price per million tokens consumed")}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
</Select>
|
||||
|
||||
{formData.charge_type !== ChargeType.Free && (
|
||||
<Input
|
||||
label={t('Price')}
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={formData.price || ''}
|
||||
onChange={(e) => onInputChange('price', e.target.value)}
|
||||
description={t('Price per unit (call or token)')}
|
||||
startContent={<span className="text-gray-500 leading-[20px]">{getCurrencySymbol()}</span>}
|
||||
/>
|
||||
<>
|
||||
{formData.charge_type === ChargeType.PerToken ? (
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
label={t("Input Token Price")}
|
||||
value={formData.input_token_price || ""}
|
||||
onChange={(e) =>
|
||||
onInputChange("input_token_price", e.target.value)
|
||||
}
|
||||
placeholder={t("Price per million input tokens")}
|
||||
startContent={
|
||||
<span className="text-gray-500 leading-[20px]">
|
||||
{getCurrencySymbol()}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<Input
|
||||
type="number"
|
||||
step="0.01"
|
||||
min="0"
|
||||
label={t("Output Token Price")}
|
||||
value={formData.output_token_price || ""}
|
||||
onChange={(e) =>
|
||||
onInputChange("output_token_price", e.target.value)
|
||||
}
|
||||
placeholder={t("Price per million output tokens")}
|
||||
startContent={
|
||||
<span className="text-gray-500 leading-[20px]">
|
||||
{getCurrencySymbol()}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<Input
|
||||
label={t("Price")}
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={formData.price || ""}
|
||||
onChange={(e) => onInputChange("price", e.target.value)}
|
||||
description={t("Price per API call")}
|
||||
startContent={
|
||||
<span className="text-gray-500 leading-[20px]">
|
||||
{getCurrencySymbol()}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import { Input, Select, SelectItem, Button } from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { ServiceFilters } from '@/types/mcp-service';
|
||||
import { Search, Plus } from 'lucide-react';
|
||||
import React from "react";
|
||||
import { Input, Select, SelectItem, Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { ServiceFilters } from "@/types/mcp-service";
|
||||
import { Search, Plus } from "lucide-react";
|
||||
|
||||
interface ServiceFiltersBarProps {
|
||||
filters: ServiceFilters;
|
||||
@@ -16,7 +16,7 @@ interface ServiceFiltersBarProps {
|
||||
export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
filters,
|
||||
onFiltersChange,
|
||||
onImportOpenAPI
|
||||
onImportOpenAPI,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -24,20 +24,20 @@ export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
onFiltersChange({ ...filters, search: value });
|
||||
};
|
||||
|
||||
|
||||
const handleStatusChange = (value: string) => {
|
||||
onFiltersChange({ ...filters, status: value });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col sm:flex-row gap-4 mb-6">
|
||||
<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')}
|
||||
{t("Add Service")}
|
||||
</Button>
|
||||
{/* <Input
|
||||
placeholder={t('Search services...')}
|
||||
@@ -74,10 +74,7 @@ export const ServiceFiltersBar: React.FC<ServiceFiltersBarProps> = ({
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select> */}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -12,19 +12,19 @@ import {
|
||||
Button,
|
||||
Tooltip,
|
||||
Pagination,
|
||||
Spinner
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { EnabledEnum, MCPService } from '@/types/mcp-service';
|
||||
Spinner,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EnabledEnum, MCPService } from "@/types/mcp-service";
|
||||
import {
|
||||
Trash2,
|
||||
Zap,
|
||||
PencilIcon,
|
||||
CircleCheckIcon,
|
||||
BanIcon,
|
||||
} from 'lucide-react';
|
||||
import { ChargeType } from '@/shared/types/marketplace';
|
||||
import { Price } from '@/shared/components/marketplace/Price';
|
||||
} from "lucide-react";
|
||||
import { ChargeType } from "@/shared/types/marketplace";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
|
||||
interface ServiceTableProps {
|
||||
services: MCPService[];
|
||||
@@ -58,22 +58,29 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
const items = services;
|
||||
|
||||
const getStatusColor = (enabled: number) => {
|
||||
return enabled === EnabledEnum.Online ? 'success' : 'danger';
|
||||
return enabled === EnabledEnum.Online ? "success" : "danger";
|
||||
};
|
||||
|
||||
const handleEdit = React.useCallback(
|
||||
(service: MCPService) => {
|
||||
onEdit(service);
|
||||
},
|
||||
[onEdit]
|
||||
);
|
||||
|
||||
const handleEdit = React.useCallback((service: MCPService) => {
|
||||
onEdit(service);
|
||||
}, [onEdit]);
|
||||
|
||||
const handleDelete = React.useCallback((service: MCPService) => {
|
||||
onDelete(service);
|
||||
}, [onDelete]);
|
||||
|
||||
const handleToggleStatus = React.useCallback((service: MCPService) => {
|
||||
onToggleStatus(service);
|
||||
}, [onToggleStatus]);
|
||||
const handleDelete = React.useCallback(
|
||||
(service: MCPService) => {
|
||||
onDelete(service);
|
||||
},
|
||||
[onDelete]
|
||||
);
|
||||
|
||||
const handleToggleStatus = React.useCallback(
|
||||
(service: MCPService) => {
|
||||
onToggleStatus(service);
|
||||
},
|
||||
[onToggleStatus]
|
||||
);
|
||||
|
||||
if (loading && services.length === 0) {
|
||||
return (
|
||||
@@ -96,7 +103,7 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
<div className="flex w-full justify-center">
|
||||
<Pagination
|
||||
showControls
|
||||
variant='light'
|
||||
variant="light"
|
||||
color="primary"
|
||||
page={currentPage}
|
||||
total={pages}
|
||||
@@ -107,17 +114,17 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
}
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn>{t('Service Name')}</TableColumn>
|
||||
<TableColumn>{t('API Endpoint')}</TableColumn>
|
||||
<TableColumn>{t('Status')}</TableColumn>
|
||||
<TableColumn>{t('Pricing')}</TableColumn>
|
||||
<TableColumn className='w-20'>{t('Actions')}</TableColumn>
|
||||
<TableColumn>{t("Service Name")}</TableColumn>
|
||||
<TableColumn>{t("API Endpoint")}</TableColumn>
|
||||
<TableColumn>{t("Status")}</TableColumn>
|
||||
<TableColumn>{t("Pricing")}</TableColumn>
|
||||
<TableColumn className="w-20">{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody
|
||||
items={items}
|
||||
isLoading={loading}
|
||||
loadingContent={<Spinner />}
|
||||
emptyContent={t('No services found')}
|
||||
emptyContent={t("No services found")}
|
||||
>
|
||||
{(service) => (
|
||||
<TableRow key={service.id}>
|
||||
@@ -134,17 +141,22 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
size="sm"
|
||||
variant="flat"
|
||||
>
|
||||
{t(service.enabled === 1 ? 'Online' : 'Offline')}
|
||||
{t(service.enabled === 1 ? "Online" : "Offline")}
|
||||
</Chip>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Price price={service.price} charge_type={service.charge_type} />
|
||||
<Price
|
||||
price={service.price}
|
||||
charge_type={service.charge_type}
|
||||
input_token_price={service.input_token_price}
|
||||
output_token_price={service.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="relative flex items-center gap-2">
|
||||
<Tooltip content={t('Edit')} closeDelay={0}>
|
||||
<Tooltip content={t("Edit")} closeDelay={0} disableAnimation>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
@@ -155,22 +167,40 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip content={service.enabled === EnabledEnum.Online ? t('Take Offline') : t('Bring Online')} closeDelay={0} >
|
||||
<Tooltip
|
||||
content={
|
||||
service.enabled === EnabledEnum.Online
|
||||
? t("Take Offline")
|
||||
: t("Bring Online")
|
||||
}
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color={service.enabled === EnabledEnum.Online ? 'danger' : 'success'}
|
||||
color={
|
||||
service.enabled === EnabledEnum.Online
|
||||
? "danger"
|
||||
: "success"
|
||||
}
|
||||
onPress={() => handleToggleStatus(service)}
|
||||
>
|
||||
{service.enabled === EnabledEnum.Online ?
|
||||
<BanIcon className="w-4 h-4" /> :
|
||||
{service.enabled === EnabledEnum.Online ? (
|
||||
<BanIcon className="w-4 h-4" />
|
||||
) : (
|
||||
<CircleCheckIcon className="w-4 h-4" />
|
||||
}
|
||||
)}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip content={t('Delete Service')} color="danger" closeDelay={0}>
|
||||
<Tooltip
|
||||
content={t("Delete Service")}
|
||||
color="danger"
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
@@ -189,4 +219,4 @@ export const ServiceTable: React.FC<ServiceTableProps> = ({
|
||||
</Table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -38,7 +38,8 @@ export const ToolsTab: React.FC<ToolsTabProps> = ({
|
||||
removeWrapper
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn className='w-1/3'>{t('Tool Name')}</TableColumn>
|
||||
<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.')}>
|
||||
@@ -49,7 +50,13 @@ export const ToolsTab: React.FC<ToolsTabProps> = ({
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.name}
|
||||
// onChange={(e) => handleToolChange(index, 'name', e.target.value)}
|
||||
size="sm"
|
||||
isDisabled
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Input
|
||||
value={tool.url}
|
||||
size="sm"
|
||||
isDisabled
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Switch,
|
||||
} from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { AlipayConfig } from "@/types/payment";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface AlipayConfigFormProps {
|
||||
config: AlipayConfig;
|
||||
onSave: (config: AlipayConfig) => void;
|
||||
onEnable: (channelId: string) => Promise<boolean>;
|
||||
onDisable: (channelId: string) => Promise<boolean>;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export const AlipayConfigForm: React.FC<AlipayConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onEnable,
|
||||
onDisable,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<AlipayConfig>(config);
|
||||
const [showAppPrivateKey, setShowAppPrivateKey] = useState(false);
|
||||
const [showAlipayPublicKey, setShowAlipayPublicKey] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (
|
||||
field: keyof AlipayConfig,
|
||||
value: string | boolean
|
||||
) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
const handleEnableDisable = async (value: boolean) => {
|
||||
let result: boolean | null = null;
|
||||
if (value) {
|
||||
result = await onEnable("alipay");
|
||||
} else {
|
||||
result = await onDisable("alipay");
|
||||
}
|
||||
if (result) {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
is_enabled: value,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
const isFormValid =
|
||||
formData.app_id.trim() !== "" &&
|
||||
formData.app_private_key.trim() !== "" &&
|
||||
formData.alipay_public_key.trim() !== "";
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["alipay-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="alipay-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("Alipay Configuration")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure Alipay payment interface")}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={formData.is_enabled || false}
|
||||
onValueChange={handleEnableDisable}
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* App ID */}
|
||||
<Input
|
||||
label={t("App ID")}
|
||||
placeholder={t("Alipay App ID")}
|
||||
value={formData.app_id}
|
||||
onChange={(e) => handleInputChange("app_id", e.target.value)}
|
||||
isRequired
|
||||
autoComplete="off"
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* App Private Key */}
|
||||
<Input
|
||||
label={t("App Private Key")}
|
||||
placeholder={t("Alipay App Private Key")}
|
||||
value={formData.app_private_key}
|
||||
onChange={(e) =>
|
||||
handleInputChange("app_private_key", e.target.value)
|
||||
}
|
||||
type={showAppPrivateKey ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowAppPrivateKey(!showAppPrivateKey)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showAppPrivateKey ? (
|
||||
<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}
|
||||
/>
|
||||
|
||||
{/* Alipay Public Key */}
|
||||
<Input
|
||||
label={t("Alipay Public Key")}
|
||||
placeholder={t("Alipay public key for verification")}
|
||||
value={formData.alipay_public_key || ""}
|
||||
onChange={(e) =>
|
||||
handleInputChange("alipay_public_key", e.target.value)
|
||||
}
|
||||
type={showAlipayPublicKey ? "text" : "password"}
|
||||
isRequired
|
||||
endContent={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowAlipayPublicKey(!showAlipayPublicKey)}
|
||||
className="focus:outline-none"
|
||||
>
|
||||
{showAlipayPublicKey ? (
|
||||
<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>
|
||||
)}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,177 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Switch,
|
||||
} from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { StripeConfig } from "@/types/payment";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface StripeConfigFormProps {
|
||||
config: StripeConfig;
|
||||
onSave: (config: StripeConfig) => void;
|
||||
onEnable: (channelId: string) => Promise<boolean>;
|
||||
onDisable: (channelId: string) => Promise<boolean>;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export const StripeConfigForm: React.FC<StripeConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onEnable,
|
||||
onDisable,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<StripeConfig>(config);
|
||||
const [showSecretKey, setShowSecretKey] = useState(false);
|
||||
const [showWebhookSecret, setShowWebhookSecret] = useState(false);
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (
|
||||
field: keyof StripeConfig,
|
||||
value: string | boolean
|
||||
) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
const handleEnableDisable = async (value: boolean) => {
|
||||
let result: boolean | null = null;
|
||||
if (value) {
|
||||
result = await onEnable("stripe");
|
||||
} else {
|
||||
result = await onDisable("stripe");
|
||||
}
|
||||
if (result) {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
is_enabled: value,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
const isFormValid =
|
||||
formData.secret.trim() !== "" && formData.webhook_secret.trim() !== "";
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["stripe-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="stripe-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("Stripe Configuration")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure Stripe payment interface")}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={formData.is_enabled || false}
|
||||
onValueChange={handleEnableDisable}
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</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>
|
||||
)}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,140 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Switch,
|
||||
} from "@nextui-org/react";
|
||||
import { WechatConfig } from "@/types/payment";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface WechatConfigFormProps {
|
||||
config: WechatConfig;
|
||||
onSave: (config: WechatConfig) => void;
|
||||
onEnable: (channelId: string) => Promise<boolean>;
|
||||
onDisable: (channelId: string) => Promise<boolean>;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export const WechatConfigForm: React.FC<WechatConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onEnable,
|
||||
onDisable,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<WechatConfig>(config);
|
||||
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (
|
||||
field: keyof WechatConfig,
|
||||
value: string | boolean
|
||||
) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
const handleEnableDisable = async (value: boolean) => {
|
||||
let result: boolean | null = null;
|
||||
if (value) {
|
||||
result = await onEnable("wechat");
|
||||
} else {
|
||||
result = await onDisable("wechat");
|
||||
}
|
||||
if (result) {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
is_enabled: value,
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
const isFormValid =
|
||||
formData.app_id.trim() !== "" && formData.mch_id.trim() !== "";
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["wechat-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="wechat-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("WeChat Configuration")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure WeChat payment interface")}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={formData.is_enabled || false}
|
||||
onValueChange={handleEnableDisable}
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* App ID */}
|
||||
<Input
|
||||
label={t("App ID")}
|
||||
placeholder={t("WeChat App ID")}
|
||||
value={formData.app_id}
|
||||
onChange={(e) => handleInputChange("app_id", e.target.value)}
|
||||
isRequired
|
||||
autoComplete="off"
|
||||
isDisabled={!formData.is_enabled}
|
||||
/>
|
||||
|
||||
{/* Merchant ID */}
|
||||
<Input
|
||||
label={t("Merchant ID")}
|
||||
placeholder={t("WeChat Merchant ID")}
|
||||
value={formData.mch_id}
|
||||
onChange={(e) => handleInputChange("mch_id", e.target.value)}
|
||||
isRequired
|
||||
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>
|
||||
)}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,138 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button, AccordionItem, Accordion } from "@nextui-org/react";
|
||||
import MDEditor, { commands } from "@uiw/react-md-editor";
|
||||
import { PlatformConfig } from "@/shared/types/system";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { calculateFileSha256 } from "@/shared/utils/crypto";
|
||||
import "@uiw/react-md-editor/markdown-editor.css";
|
||||
import "@uiw/react-markdown-preview/markdown.css";
|
||||
|
||||
interface AboutPageSettingsProps {
|
||||
config: PlatformConfig;
|
||||
onAboutSave: (aboutContent: string) => Promise<void>;
|
||||
onImageUpload?: (file: File, sha256?: string) => Promise<string>;
|
||||
isAboutLoading?: boolean;
|
||||
}
|
||||
|
||||
export const AboutPageSettings: React.FC<AboutPageSettingsProps> = ({
|
||||
config,
|
||||
onAboutSave,
|
||||
onImageUpload,
|
||||
isAboutLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [aboutContent, setAboutContent] = useState(config.about_page || "");
|
||||
|
||||
useEffect(() => {
|
||||
setAboutContent(config.about_page || "");
|
||||
}, [config.about_page]);
|
||||
|
||||
const handleAboutSave = async () => {
|
||||
await onAboutSave(aboutContent);
|
||||
};
|
||||
|
||||
const handleImageUpload = async (file: File): Promise<string> => {
|
||||
try {
|
||||
// 计算文件的 SHA256 哈希值
|
||||
const sha256 = await calculateFileSha256(file);
|
||||
return await onImageUpload!(file, sha256);
|
||||
} catch (error) {
|
||||
console.error("Image upload failed:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4 justify-between h-full">
|
||||
<div className="flex-1">
|
||||
<MDEditor
|
||||
value={aboutContent}
|
||||
onChange={(value?: string) => setAboutContent(value || "")}
|
||||
preview="live"
|
||||
hideToolbar={false}
|
||||
visibleDragbar={false}
|
||||
data-color-mode="light"
|
||||
textareaProps={{
|
||||
placeholder: t("Enter about page content (supports Markdown)"),
|
||||
style: {
|
||||
fontSize: 14,
|
||||
lineHeight: 1.6,
|
||||
fontFamily:
|
||||
'ui-monospace, SFMono-Regular, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
||||
},
|
||||
}}
|
||||
height="100%"
|
||||
commands={[
|
||||
// 默认命令
|
||||
commands.bold,
|
||||
commands.italic,
|
||||
commands.strikethrough,
|
||||
commands.hr,
|
||||
commands.title,
|
||||
commands.divider,
|
||||
commands.link,
|
||||
commands.quote,
|
||||
commands.code,
|
||||
commands.codeBlock,
|
||||
commands.comment,
|
||||
commands.divider,
|
||||
commands.unorderedListCommand,
|
||||
commands.orderedListCommand,
|
||||
commands.checkedListCommand,
|
||||
commands.divider,
|
||||
// 自定义图片上传命令
|
||||
{
|
||||
name: "image-upload",
|
||||
keyCommand: "image-upload",
|
||||
buttonProps: {
|
||||
"aria-label": "Upload image",
|
||||
title: "Upload image",
|
||||
},
|
||||
icon: (
|
||||
<svg width="12" height="12" viewBox="0 0 20 20">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zM2 17l4.5-6 3.5 4.51 2.5-3.01L17 17H2z"
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
execute: (state, api) => {
|
||||
const input = document.createElement("input");
|
||||
input.type = "file";
|
||||
input.accept = "image/*";
|
||||
input.onchange = async (e) => {
|
||||
const file = (e.target as HTMLInputElement).files?.[0];
|
||||
if (file) {
|
||||
try {
|
||||
const dataUrl = await handleImageUpload(file);
|
||||
const imageMarkdown = ``;
|
||||
api.replaceSelection(imageMarkdown);
|
||||
} catch (error) {
|
||||
console.error("Image upload failed:", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
input.click();
|
||||
},
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* About Save Button */}
|
||||
<div className="flex gap-3 pb-4">
|
||||
<Button
|
||||
color="primary"
|
||||
variant="solid"
|
||||
onPress={handleAboutSave}
|
||||
isLoading={isAboutLoading}
|
||||
size="sm"
|
||||
>
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Input, Button, AccordionItem, Accordion } from '@nextui-org/react';
|
||||
import { Eye, EyeOff } from 'lucide-react';
|
||||
import { AdminConfig } from '@/types/system';
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Input, Button, AccordionItem, Accordion } from "@nextui-org/react";
|
||||
import { Eye, EyeOff } from "lucide-react";
|
||||
import { AdminConfig } from "@/types/system";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
|
||||
interface AdminConfigFormProps {
|
||||
@@ -20,20 +20,20 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<AdminConfig>(config);
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [confirmPassword, setConfirmPassword] = useState('');
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
useEffect(() => {
|
||||
setFormData({
|
||||
...config,
|
||||
password: '',
|
||||
password: "",
|
||||
});
|
||||
setConfirmPassword('');
|
||||
setConfirmPassword("");
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (field: keyof AdminConfig, value: string) => {
|
||||
setFormData(prev => ({
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -42,41 +42,53 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
||||
};
|
||||
|
||||
const isFormValid =
|
||||
formData.username.trim() !== '' &&
|
||||
formData.password.trim() !== '' &&
|
||||
formData.username.trim() !== "" &&
|
||||
formData.password?.trim() !== "" &&
|
||||
formData.password === confirmPassword &&
|
||||
formData.password.length >= 8;
|
||||
formData.password?.length >= 8;
|
||||
|
||||
const passwordsMatch = formData.password === confirmPassword;
|
||||
|
||||
return (
|
||||
<Accordion variant='splitted' itemClasses={{
|
||||
base: 'shadow-none border-1',
|
||||
}} defaultExpandedKeys={['admin-config']} className='px-0'>
|
||||
<AccordionItem key="admin-config" title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">{t('Administrator Account')}</h3>
|
||||
<p className="text-sm text-gray-500">{t('Configure administrator login credentials')}</p>
|
||||
</div>
|
||||
}>
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["admin-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="admin-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("Administrator Account")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure administrator login credentials")}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* admin username */}
|
||||
<Input
|
||||
label={t('Administrator Username')}
|
||||
placeholder={t('Enter administrator username')}
|
||||
description={t('Username for administrator login')}
|
||||
label={t("Administrator Username")}
|
||||
placeholder={t("Enter administrator username")}
|
||||
description={t("Username for administrator login")}
|
||||
value={formData.username}
|
||||
onChange={(e) => handleInputChange('username', e.target.value)}
|
||||
onChange={(e) => handleInputChange("username", e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
|
||||
{/* admin password */}
|
||||
<Input
|
||||
label={t('Administrator Password')}
|
||||
placeholder={t('Enter administrator password')}
|
||||
description={t('Password must be at least 8 characters long')}
|
||||
label={t("Administrator Password")}
|
||||
placeholder={t("Enter administrator password")}
|
||||
description={t("Password must be at least 8 characters long")}
|
||||
value={formData.password}
|
||||
onChange={(e) => handleInputChange('password', e.target.value)}
|
||||
onChange={(e) => handleInputChange("password", e.target.value)}
|
||||
type={showPassword ? "text" : "password"}
|
||||
endContent={
|
||||
<button
|
||||
@@ -92,16 +104,24 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
||||
</button>
|
||||
}
|
||||
isRequired
|
||||
autoComplete='new-password'
|
||||
color={formData.password.length > 0 && formData.password.length < 8 ? "danger" : "default"}
|
||||
errorMessage={formData.password.length > 0 && formData.password.length < 8 ? t('Password must be at least 8 characters') : ""}
|
||||
autoComplete="new-password"
|
||||
color={
|
||||
formData.password?.length > 0 && formData.password?.length < 8
|
||||
? "danger"
|
||||
: "default"
|
||||
}
|
||||
errorMessage={
|
||||
formData.password?.length > 0 && formData.password?.length < 8
|
||||
? t("Password must be at least 8 characters")
|
||||
: ""
|
||||
}
|
||||
/>
|
||||
|
||||
{/* confirm password */}
|
||||
<Input
|
||||
label={t('Confirm Password')}
|
||||
placeholder={t('Confirm administrator password')}
|
||||
description={t('Re-enter the password to confirm')}
|
||||
label={t("Confirm Password")}
|
||||
placeholder={t("Confirm administrator password")}
|
||||
description={t("Re-enter the password to confirm")}
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
type={showConfirmPassword ? "text" : "password"}
|
||||
@@ -118,10 +138,18 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
autoComplete='new-password'
|
||||
autoComplete="new-password"
|
||||
isRequired
|
||||
color={confirmPassword.length > 0 && !passwordsMatch ? "danger" : "default"}
|
||||
errorMessage={confirmPassword.length > 0 && !passwordsMatch ? t('Passwords do not match') : ""}
|
||||
color={
|
||||
confirmPassword?.length > 0 && !passwordsMatch
|
||||
? "danger"
|
||||
: "default"
|
||||
}
|
||||
errorMessage={
|
||||
confirmPassword?.length > 0 && !passwordsMatch
|
||||
? t("Passwords do not match")
|
||||
: ""
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -133,12 +161,12 @@ export const AdminConfigForm: React.FC<AdminConfigFormProps> = ({
|
||||
onPress={handleSave}
|
||||
isLoading={isLoading}
|
||||
isDisabled={!isFormValid}
|
||||
size='sm'
|
||||
size="sm"
|
||||
>
|
||||
{t('Save')}
|
||||
{t("Save")}
|
||||
</Button>
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { EmailConfigForm } from "./EmailConfigForm";
|
||||
import { AdminConfig, EmailConfig } from "@/types/system";
|
||||
import { AdminConfigForm } from "./AdminConfigForm";
|
||||
|
||||
interface EmailAndAdminSettingsProps {
|
||||
emailConfig: EmailConfig;
|
||||
adminConfig: AdminConfig;
|
||||
onSaveEmailConfig: (config: EmailConfig) => void;
|
||||
onSaveAdminConfig: (config: AdminConfig) => void;
|
||||
isLoading?: boolean;
|
||||
isAdminLoading?: boolean;
|
||||
}
|
||||
|
||||
export const EmailAndAdminSettings: React.FC<EmailAndAdminSettingsProps> = ({
|
||||
emailConfig,
|
||||
adminConfig,
|
||||
onSaveEmailConfig,
|
||||
onSaveAdminConfig,
|
||||
isLoading = false,
|
||||
isAdminLoading = false,
|
||||
}) => {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<EmailConfigForm
|
||||
config={emailConfig}
|
||||
onSave={onSaveEmailConfig}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
<AdminConfigForm
|
||||
config={adminConfig}
|
||||
onSave={onSaveAdminConfig}
|
||||
isLoading={isAdminLoading}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,165 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Textarea,
|
||||
Button,
|
||||
Switch,
|
||||
Alert,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { EmbeddedHtmlConfig } from "@/shared/types/system";
|
||||
|
||||
interface EmbeddedHtmlSettingsProps {
|
||||
onSave?: (config: EmbeddedHtmlConfig) => void;
|
||||
config?: EmbeddedHtmlConfig;
|
||||
}
|
||||
|
||||
export const EmbeddedHtmlSettings: React.FC<EmbeddedHtmlSettingsProps> = ({
|
||||
onSave,
|
||||
config = { html: "", is_enabled: false },
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [htmlData, setHtmlData] = useState<EmbeddedHtmlConfig>(config);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
useEffect(() => {
|
||||
setHtmlData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleSave = async () => {
|
||||
setIsSaving(true);
|
||||
try {
|
||||
await onSave?.(htmlData);
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleHtmlChange = (value: string) => {
|
||||
setHtmlData((prev) => ({ ...prev, html: value }));
|
||||
};
|
||||
const handleToggleEnabled = async (enabled: boolean) => {
|
||||
const updatedConfig = {
|
||||
...htmlData,
|
||||
is_enabled: enabled,
|
||||
};
|
||||
// when toggle the switch, save directly, same as GoogleAuthConfigForm
|
||||
const result = await onSave?.(updatedConfig);
|
||||
if (result) {
|
||||
setHtmlData((prev) => ({ ...prev, is_enabled: enabled }));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<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>
|
||||
</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}
|
||||
/>
|
||||
</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"
|
||||
variant="flat"
|
||||
title={t("Usage Instructions")}
|
||||
description={
|
||||
<ul className="text-sm space-y-1 mt-2">
|
||||
<li>
|
||||
•{" "}
|
||||
{t(
|
||||
"You can include Google Analytics, custom CSS, or any tracking scripts"
|
||||
)}
|
||||
</li>
|
||||
<li>
|
||||
•{" "}
|
||||
{t("The HTML will be injected into the document head section")}
|
||||
</li>
|
||||
<li>
|
||||
•{" "}
|
||||
{t(
|
||||
"Make sure your code is valid to avoid breaking the application"
|
||||
)}
|
||||
</li>
|
||||
<li>
|
||||
•{" "}
|
||||
{t("Changes take effect immediately after saving and enabling")}
|
||||
</li>
|
||||
</ul>
|
||||
}
|
||||
/>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,242 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useRef, useEffect } from "react";
|
||||
import {
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Table,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
Button,
|
||||
Input,
|
||||
Textarea,
|
||||
Tooltip,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { GripVertical, Trash2, Plus } from "lucide-react";
|
||||
import { FaqItem } from "@/shared/types/system";
|
||||
|
||||
interface FaqSettingsProps {
|
||||
onSave?: (config: FaqItem[]) => void;
|
||||
config?: FaqItem[];
|
||||
}
|
||||
|
||||
export const FaqSettings: React.FC<FaqSettingsProps> = ({
|
||||
onSave,
|
||||
config = [],
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [faqs, setFaqs] = useState<FaqItem[]>(config || []);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [focusedAnswer, setFocusedAnswer] = useState<number | null>(null);
|
||||
const draggedItem = useRef<number | null>(null);
|
||||
const draggedOverItem = useRef<number | null>(null);
|
||||
useEffect(() => {
|
||||
setFaqs(config);
|
||||
}, [config]);
|
||||
|
||||
const handleQuestionChange = (index: number, value: string) => {
|
||||
setFaqs((prev) =>
|
||||
prev.map((faq, idx) =>
|
||||
idx === index ? { ...faq, question: value } : faq
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const handleAnswerChange = (index: number, value: string) => {
|
||||
setFaqs((prev) =>
|
||||
prev.map((faq, idx) => (idx === index ? { ...faq, answer: value } : faq))
|
||||
);
|
||||
};
|
||||
|
||||
const handleDelete = (index: number) => {
|
||||
setFaqs((prev) => {
|
||||
return prev.filter((_, idx) => idx !== index);
|
||||
});
|
||||
};
|
||||
|
||||
const handleInsertBelow = (index: number) => {
|
||||
setFaqs((prev) => {
|
||||
const newFaqs = [...prev];
|
||||
newFaqs.splice(index + 1, 0, {
|
||||
question: "",
|
||||
answer: "",
|
||||
});
|
||||
return newFaqs;
|
||||
});
|
||||
};
|
||||
|
||||
const handleDragStart = (index: number) => {
|
||||
draggedItem.current = index;
|
||||
};
|
||||
|
||||
const handleDragEnter = (index: number) => {
|
||||
draggedOverItem.current = index;
|
||||
};
|
||||
|
||||
const handleDragEnd = () => {
|
||||
if (draggedItem.current !== null && draggedOverItem.current !== null) {
|
||||
const draggedItemIndex = draggedItem.current;
|
||||
const draggedOverItemIndex = draggedOverItem.current;
|
||||
|
||||
if (draggedItemIndex !== draggedOverItemIndex) {
|
||||
setFaqs((prev) => {
|
||||
const newFaqs = [...prev];
|
||||
const draggedItemContent = newFaqs[draggedItemIndex];
|
||||
newFaqs.splice(draggedItemIndex, 1);
|
||||
newFaqs.splice(draggedOverItemIndex, 0, draggedItemContent);
|
||||
return newFaqs;
|
||||
});
|
||||
}
|
||||
}
|
||||
draggedItem.current = null;
|
||||
draggedOverItem.current = null;
|
||||
};
|
||||
|
||||
const handleSaveAll = async () => {
|
||||
setIsSaving(true);
|
||||
try {
|
||||
await onSave?.(faqs.filter((faq) => faq.question && faq.answer));
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
className="px-0"
|
||||
defaultExpandedKeys={["faq"]}
|
||||
>
|
||||
<AccordionItem
|
||||
key="faq"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold flex items-center gap-2">
|
||||
{t("FAQ Management")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure frequently asked questions for your users")}
|
||||
</p>
|
||||
</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>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -1,136 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Input, Button, Switch, AccordionItem, Accordion } from '@nextui-org/react';
|
||||
import { Eye, EyeOff } from 'lucide-react';
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { getGoogleRedirectUri } from '@/hooks/useLogin';
|
||||
import { GoogleAuthConfig } from '@/shared/types/system';
|
||||
|
||||
interface GoogleAuthConfigFormProps {
|
||||
config: GoogleAuthConfig;
|
||||
onSave: (config: GoogleAuthConfig) => void;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export const GoogleAuthConfigForm: React.FC<GoogleAuthConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<GoogleAuthConfig>(config);
|
||||
const [showClientSecret, setShowClientSecret] = useState(false);
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
const handleInputChange = (field: keyof GoogleAuthConfig, value: string | boolean) => {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
}));
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
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>
|
||||
}>
|
||||
<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) => {
|
||||
handleInputChange('is_enabled', 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}
|
||||
/>
|
||||
|
||||
</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>
|
||||
)
|
||||
}
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { FaqSettings } from "./FaqSettings";
|
||||
import { TopNavigationSettings } from "./TopNavigationSettings";
|
||||
import { EmbeddedHtmlSettings } from "./EmbeddedHtmlSettings";
|
||||
import { useHomepageConfigManagement } from "@/hooks/useHomepageConfigManagement";
|
||||
|
||||
interface HomepageSettingsProps {
|
||||
// 预留接口,后续扩展
|
||||
}
|
||||
|
||||
export const HomepageSettings: React.FC<HomepageSettingsProps> = () => {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
homepageConfig,
|
||||
error,
|
||||
saveFaqConfig,
|
||||
saveNavigationConfig,
|
||||
saveEmbeddedHtmlConfig,
|
||||
} = useHomepageConfigManagement();
|
||||
|
||||
// 显示错误提示
|
||||
useEffect(() => {
|
||||
if (error) {
|
||||
toast.error(t("Failed to load homepage config"));
|
||||
}
|
||||
}, [error, t]);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* FAQ Management */}
|
||||
<FaqSettings onSave={saveFaqConfig} config={homepageConfig.faq} />
|
||||
|
||||
{/* Top Navigation */}
|
||||
<TopNavigationSettings
|
||||
onSave={saveNavigationConfig}
|
||||
config={homepageConfig.top_navigation}
|
||||
/>
|
||||
|
||||
{/* Embedded HTML */}
|
||||
<EmbeddedHtmlSettings
|
||||
onSave={saveEmbeddedHtmlConfig}
|
||||
config={homepageConfig.embeded_html}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,157 +1,317 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Input, Button, AccordionItem, Accordion, Select, SelectItem } from '@nextui-org/react';
|
||||
import { PlatformConfig } from '@/shared/types/system';
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Select,
|
||||
SelectItem,
|
||||
Switch,
|
||||
} from "@nextui-org/react";
|
||||
import { PlatformConfig, Theme } from "@/shared/types/system";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { SUPPORTED_LANGUAGES } from '@/shared/lib/i18n';
|
||||
import { SUPPORTED_LANGUAGES } from "@/shared/lib/i18n";
|
||||
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";
|
||||
|
||||
interface PlatformConfigFormProps {
|
||||
config: PlatformConfig;
|
||||
onSave: (config: PlatformConfig) => void;
|
||||
onThemeChange?: (theme: Theme) => Promise<void>;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
|
||||
config,
|
||||
onSave,
|
||||
onThemeChange,
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState<PlatformConfig>(config);
|
||||
const [validationErrors, setValidationErrors] = useState<{
|
||||
domain?: string;
|
||||
mcp_server_prefix?: string;
|
||||
}>({});
|
||||
|
||||
// when context config updated, sync to form
|
||||
useEffect(() => {
|
||||
setFormData(config);
|
||||
}, [config]);
|
||||
|
||||
const handleInputChange = (field: keyof PlatformConfig, value: string) => {
|
||||
setFormData(prev => ({
|
||||
// URL validation function with strict regex
|
||||
const validateUrl = (url: string): boolean => {
|
||||
if (!url.trim()) return true; // Empty is valid (optional field)
|
||||
|
||||
// Strict regex for domain validation
|
||||
const domainRegex = /^https?:\/\/(?:[-\w.])+(?:\:[0-9]+)?(?:\/.*)?$/;
|
||||
|
||||
// First check with regex
|
||||
if (!domainRegex.test(url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Then validate with URL constructor for additional checks
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
return (
|
||||
(urlObj.protocol === "http:" || urlObj.protocol === "https:") &&
|
||||
urlObj.hostname.length > 0 &&
|
||||
urlObj.hostname.includes(".")
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Validate field and update errors
|
||||
const validateField = (
|
||||
field: "domain" | "mcp_server_prefix",
|
||||
value: string
|
||||
) => {
|
||||
const isValid = validateUrl(value);
|
||||
setValidationErrors((prev) => ({
|
||||
...prev,
|
||||
[field]: value
|
||||
[field]: isValid
|
||||
? undefined
|
||||
: t("Please enter a valid URL with http:// or https://"),
|
||||
}));
|
||||
return isValid;
|
||||
};
|
||||
|
||||
const handleInputChange = (
|
||||
field: keyof PlatformConfig,
|
||||
value: string | boolean
|
||||
) => {
|
||||
// Validate URL fields
|
||||
if (field === "domain" || field === "mcp_server_prefix") {
|
||||
validateField(field, value as string);
|
||||
}
|
||||
|
||||
setFormData((prev) => {
|
||||
const newData = {
|
||||
...prev,
|
||||
[field]: value,
|
||||
};
|
||||
|
||||
return newData;
|
||||
});
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
// Validate all URL fields before saving
|
||||
const domainValid = validateField("domain", formData.domain || "");
|
||||
const mcpServerValid = validateField(
|
||||
"mcp_server_prefix",
|
||||
formData.mcp_server_prefix || ""
|
||||
);
|
||||
|
||||
if (!domainValid || !mcpServerValid) {
|
||||
toast.error(t("Please fix validation errors before saving"));
|
||||
return;
|
||||
}
|
||||
|
||||
onSave(formData);
|
||||
};
|
||||
|
||||
const isFormValid = formData.name.trim() !== '' && formData.currency?.trim() !== '';
|
||||
const handleThemeChange = async (theme: Theme) => {
|
||||
handleInputChange("theme", theme);
|
||||
onThemeChange?.(theme);
|
||||
};
|
||||
|
||||
return (
|
||||
<Accordion variant='splitted' itemClasses={{
|
||||
base: 'shadow-none border-1',
|
||||
}} defaultExpandedKeys={['platform-config']} className='px-0'>
|
||||
<AccordionItem key="platform-config" title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">{t('Platform Information')}</h3>
|
||||
<p className="text-sm text-gray-500">{t('Configure platform logo, name, titles, language')}</p>
|
||||
</div>
|
||||
}>
|
||||
<div className="space-y-4">
|
||||
{/* platform name */}
|
||||
<Input
|
||||
label={t('Platform Name')}
|
||||
placeholder={t('Enter platform name')}
|
||||
description={t('The name displayed across the platform')}
|
||||
value={formData.name}
|
||||
onChange={(e) => handleInputChange('name', e.target.value)}
|
||||
isRequired
|
||||
/>
|
||||
<div className="space-y-4">
|
||||
{/* Platform Information Accordion */}
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["platform-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="platform-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">
|
||||
{t("Platform Information")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure platform logo, name, titles, language")}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{/* platform name */}
|
||||
<Input
|
||||
label={t("Platform Name")}
|
||||
placeholder={t("Enter platform name")}
|
||||
description={t("The name displayed across the platform")}
|
||||
value={formData.name}
|
||||
onChange={(e) => handleInputChange("name", e.target.value)}
|
||||
/>
|
||||
|
||||
{/* 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)}
|
||||
/>
|
||||
{/* 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)}
|
||||
/>
|
||||
|
||||
{/* website title */}
|
||||
<Input
|
||||
label={t('Website Title')}
|
||||
placeholder={t('Enter website title')}
|
||||
description={t('The title displayed in browser tab and search results')}
|
||||
value={formData.website_title || ''}
|
||||
onChange={(e) => handleInputChange('website_title', e.target.value)}
|
||||
/>
|
||||
|
||||
{/* homepage headline */}
|
||||
<Input
|
||||
label={t('Headline')}
|
||||
placeholder={t('Enter homepage headline')}
|
||||
description={t('Main headline displayed on the homepage')}
|
||||
value={formData.headline || ''}
|
||||
onChange={(e) => handleInputChange('headline', e.target.value)}
|
||||
/>
|
||||
|
||||
{/* homepage subheadline */}
|
||||
<Input
|
||||
label={t('Subheadline')}
|
||||
placeholder={t('Enter homepage subheadline')}
|
||||
description={t('Secondary headline displayed below the main headline')}
|
||||
value={formData.subheadline || ''}
|
||||
onChange={(e) => handleInputChange('subheadline', e.target.value)}
|
||||
/>
|
||||
|
||||
{/* platform language */}
|
||||
<Select
|
||||
label={t('Platform Language')}
|
||||
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);
|
||||
{/* website title */}
|
||||
<Input
|
||||
label={t("Website Title")}
|
||||
placeholder={t("Enter website title")}
|
||||
description={t(
|
||||
"The title displayed in browser tab and search results"
|
||||
)}
|
||||
value={formData.website_title || ""}
|
||||
onChange={(e) =>
|
||||
handleInputChange("website_title", e.target.value)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{SUPPORTED_LANGUAGES.map((language) => (
|
||||
<SelectItem key={language.name} value={language.name}>
|
||||
{language.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
/>
|
||||
|
||||
{/* comming soon:currency unit */}
|
||||
{/* <Select
|
||||
label={t('Currency Unit')}
|
||||
placeholder={t('Select currency')}
|
||||
description={t('Default currency for the platform')}
|
||||
selectedKeys={formData.currency ? [formData.currency] : []}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
if (selectedKey) {
|
||||
handleInputChange('currency', selectedKey);
|
||||
{/* homepage headline */}
|
||||
<Input
|
||||
label={t("Headline")}
|
||||
placeholder={t("Enter homepage headline")}
|
||||
description={t("Main headline displayed on the homepage")}
|
||||
value={formData.headline || ""}
|
||||
onChange={(e) => handleInputChange("headline", e.target.value)}
|
||||
/>
|
||||
|
||||
{/* homepage subheadline */}
|
||||
<Input
|
||||
label={t("Subheadline")}
|
||||
placeholder={t("Enter homepage subheadline")}
|
||||
description={t(
|
||||
"Secondary headline displayed below the main headline"
|
||||
)}
|
||||
value={formData.subheadline || ""}
|
||||
onChange={(e) => handleInputChange("subheadline", e.target.value)}
|
||||
/>
|
||||
|
||||
{/* platform language */}
|
||||
<Select
|
||||
label={t("Platform Language")}
|
||||
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);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{SUPPORTED_LANGUAGES.map((language) => (
|
||||
<SelectItem key={language.name} value={language.name}>
|
||||
{language.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
{/* platform domain */}
|
||||
<Input
|
||||
label={t("Platform Domain")}
|
||||
placeholder={t(
|
||||
"Enter platform domain (e.g., https://example.com)"
|
||||
)}
|
||||
description={t("The domain name of your platform")}
|
||||
value={formData.domain || ""}
|
||||
onChange={(e) => handleInputChange("domain", e.target.value)}
|
||||
isInvalid={!!validationErrors.domain}
|
||||
errorMessage={validationErrors.domain}
|
||||
/>
|
||||
|
||||
{/* mcp server prefix */}
|
||||
<Input
|
||||
label={t("MCP Server Domain")}
|
||||
placeholder={t(
|
||||
"Enter MCP server domain (e.g., https://mcp.example.com)"
|
||||
)}
|
||||
description={t("The domain for MCP server API calls")}
|
||||
value={formData.mcp_server_prefix || ""}
|
||||
onChange={(e) =>
|
||||
handleInputChange("mcp_server_prefix", e.target.value)
|
||||
}
|
||||
}}
|
||||
isRequired
|
||||
>
|
||||
{getCurrencyOptions().map((currency) => (
|
||||
<SelectItem key={currency.value} value={currency.value}>
|
||||
{currency.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select> */}
|
||||
</div>
|
||||
isInvalid={!!validationErrors.mcp_server_prefix}
|
||||
errorMessage={validationErrors.mcp_server_prefix}
|
||||
/>
|
||||
|
||||
{/* 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>
|
||||
{/* 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={formData.is_showcased ?? false}
|
||||
onValueChange={(value) => {
|
||||
handleInputChange("is_showcased", value);
|
||||
}}
|
||||
color="primary"
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</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>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
{/* Theme Accordion */}
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
defaultExpandedKeys={["theme-config"]}
|
||||
className="px-0"
|
||||
>
|
||||
<AccordionItem
|
||||
key="theme-config"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold">{t("Theme")}</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Choose your preferred theme style")}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<ThemeSelector
|
||||
value={formData.theme || Theme.DEFAULT}
|
||||
onChange={handleThemeChange}
|
||||
/>
|
||||
</div>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
.xpack-theme-card-panel-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Card, CardBody, CardFooter } from "@nextui-org/react";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import DefaultDemo from "../theme/default/Demo";
|
||||
import ModernDemo from "../theme/modern/Demo";
|
||||
import ClassicDemo from "../theme/classic/Demo";
|
||||
import CreativeDemo from "../theme/creative/Demo";
|
||||
import TemuDemo from "../theme/temu/Demo";
|
||||
import "./ThemeCardPanel.css";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
// Available theme options
|
||||
export const THEME_OPTIONS = [
|
||||
{
|
||||
value: Theme.DEFAULT,
|
||||
label: "Default",
|
||||
description: "Standard layout with clean and simple design",
|
||||
component: DefaultDemo,
|
||||
},
|
||||
{
|
||||
value: Theme.MODERN,
|
||||
label: "Modern",
|
||||
description: "Clean and minimalist design with modern UI elements",
|
||||
component: ModernDemo,
|
||||
},
|
||||
{
|
||||
value: Theme.CLASSIC,
|
||||
label: "Classic",
|
||||
description: "Traditional layout with professional appearance",
|
||||
component: ClassicDemo,
|
||||
},
|
||||
{
|
||||
value: Theme.CREATIVE,
|
||||
label: "Creative",
|
||||
description: "Bold and artistic design with vibrant colors",
|
||||
component: CreativeDemo,
|
||||
},
|
||||
{
|
||||
value: Theme.TEMU,
|
||||
label: "Temu",
|
||||
description: "E-commerce style with vibrant orange gradient background",
|
||||
component: TemuDemo,
|
||||
},
|
||||
] as const;
|
||||
|
||||
interface ThemeSelectorProps {
|
||||
value: Theme;
|
||||
onChange: (theme: Theme) => void;
|
||||
}
|
||||
|
||||
export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="xpack-theme-card-panel-grid gap-4">
|
||||
{THEME_OPTIONS.map((theme) => {
|
||||
const DemoComponent = theme.component;
|
||||
const isSelected = value === theme.value;
|
||||
return (
|
||||
<Card
|
||||
key={theme.value}
|
||||
isPressable
|
||||
onPress={() => onChange(theme.value)}
|
||||
className={`transition-all duration-200 border-1 hover:border-blue-300 ${
|
||||
isSelected
|
||||
? "border-blue-200 ring-1 ring-blue-200"
|
||||
: "border-gray-200"
|
||||
}`}
|
||||
shadow="none"
|
||||
radius="lg"
|
||||
>
|
||||
<CardBody className="p-0">
|
||||
{/* Theme Preview */}
|
||||
<div className="border-b-1">
|
||||
<div className="aspect-video w-full">
|
||||
<DemoComponent />
|
||||
</div>
|
||||
</div>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
{/* Theme Info */}
|
||||
<div className="space-y-2 w-full text-left">
|
||||
<div className="flex items-center justify-between">
|
||||
<h4 className="font-semibold text-gray-900">
|
||||
{t(theme.label)}
|
||||
</h4>
|
||||
<div
|
||||
className={`h-4 w-4 rounded-full border-2 transition-colors duration-200 ${
|
||||
isSelected
|
||||
? "border-blue-500 bg-blue-500"
|
||||
: "border-gray-300"
|
||||
}`}
|
||||
>
|
||||
{isSelected && (
|
||||
<div className="h-full w-full rounded-full bg-white scale-50"></div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-sm text-gray-600">{t(theme.description)}</p>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,262 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useRef, useEffect } from "react";
|
||||
import {
|
||||
AccordionItem,
|
||||
Accordion,
|
||||
Table,
|
||||
TableHeader,
|
||||
TableColumn,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
Button,
|
||||
Input,
|
||||
Tooltip,
|
||||
Select,
|
||||
SelectItem,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Plus, Trash2, GripVertical } from "lucide-react";
|
||||
import {
|
||||
TopNavigationItem,
|
||||
TopNavigationTargetEnum,
|
||||
} from "@/shared/types/system";
|
||||
|
||||
interface TopNavigationSettingsProps {
|
||||
onSave?: (config: TopNavigationItem[]) => void;
|
||||
config?: TopNavigationItem[];
|
||||
}
|
||||
|
||||
export const TopNavigationSettings: React.FC<TopNavigationSettingsProps> = ({
|
||||
onSave,
|
||||
config = [],
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [navigationItems, setNavigationItems] =
|
||||
useState<TopNavigationItem[]>(config);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const draggedItem = useRef<number | null>(null);
|
||||
const draggedOverItem = useRef<number | null>(null);
|
||||
useEffect(() => {
|
||||
setNavigationItems(config);
|
||||
}, [config]);
|
||||
|
||||
const handleTitleChange = (index: number, value: string) => {
|
||||
setNavigationItems((prev) =>
|
||||
prev.map((item, idx) =>
|
||||
idx === index ? { ...item, title: value } : item
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const handleHrefChange = (index: number, value: string) => {
|
||||
setNavigationItems((prev) =>
|
||||
prev.map((item, idx) => (idx === index ? { ...item, link: value } : item))
|
||||
);
|
||||
};
|
||||
|
||||
const handleTargetChange = (
|
||||
index: number,
|
||||
target: TopNavigationTargetEnum
|
||||
) => {
|
||||
setNavigationItems((prev) =>
|
||||
prev.map((item, idx) => (idx === index ? { ...item, target } : item))
|
||||
);
|
||||
};
|
||||
|
||||
const handleDelete = (index: number) => {
|
||||
setNavigationItems((prev) => {
|
||||
return prev.filter((_, idx) => idx !== index);
|
||||
});
|
||||
};
|
||||
|
||||
const handleInsertBelow = (index: number) => {
|
||||
setNavigationItems((prev) => {
|
||||
const newItem: TopNavigationItem = {
|
||||
title: "",
|
||||
link: "",
|
||||
target: TopNavigationTargetEnum.BLANK,
|
||||
};
|
||||
const newItems = [...prev];
|
||||
newItems.splice(index + 1, 0, newItem);
|
||||
return newItems;
|
||||
});
|
||||
};
|
||||
|
||||
const handleDragStart = (index: number) => {
|
||||
draggedItem.current = index;
|
||||
};
|
||||
|
||||
const handleDragEnter = (index: number) => {
|
||||
draggedOverItem.current = index;
|
||||
};
|
||||
|
||||
const handleDragEnd = () => {
|
||||
if (draggedItem.current !== null && draggedOverItem.current !== null) {
|
||||
const draggedItemIndex = draggedItem.current;
|
||||
const draggedOverItemIndex = draggedOverItem.current;
|
||||
|
||||
if (draggedItemIndex !== draggedOverItemIndex) {
|
||||
setNavigationItems((prev) => {
|
||||
const newItems = [...prev];
|
||||
const draggedItemContent = newItems[draggedItemIndex];
|
||||
newItems.splice(draggedItemIndex, 1);
|
||||
newItems.splice(draggedOverItemIndex, 0, draggedItemContent);
|
||||
return newItems;
|
||||
});
|
||||
}
|
||||
}
|
||||
draggedItem.current = null;
|
||||
draggedOverItem.current = null;
|
||||
};
|
||||
|
||||
const handleSaveAll = async () => {
|
||||
setIsSaving(true);
|
||||
try {
|
||||
await onSave?.(navigationItems.filter((item) => item.title && item.link));
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Accordion
|
||||
variant="splitted"
|
||||
itemClasses={{
|
||||
base: "shadow-none border-1",
|
||||
}}
|
||||
className="px-0"
|
||||
defaultExpandedKeys={["top-navigation"]}
|
||||
>
|
||||
<AccordionItem
|
||||
key="top-navigation"
|
||||
title={
|
||||
<div className="flex flex-col justify-between">
|
||||
<h3 className="text-lg font-semibold flex items-center gap-2">
|
||||
{t("Top Navigation")}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-500">
|
||||
{t("Configure top navigation menu items and links")}
|
||||
</p>
|
||||
</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>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import { About as ModernAbout } from "@/components/theme/modern/About";
|
||||
import { About as ClassicAbout } from "@/components/theme/classic/About";
|
||||
import { About as CreativeAbout } from "@/components/theme/creative/About";
|
||||
import { About as TemuAbout } from "@/components/theme/temu/About";
|
||||
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";
|
||||
|
||||
export const AboutThemeSelector: React.FC = () => {
|
||||
const { platformConfig, topNavigation } = usePlatformConfig();
|
||||
const currentTheme = platformConfig.theme || Theme.DEFAULT;
|
||||
const navigationItems = [
|
||||
...NavigationItems,
|
||||
...topNavigation.map((item) => ({
|
||||
label: item.title,
|
||||
href: item.link,
|
||||
target: item.target,
|
||||
})),
|
||||
];
|
||||
|
||||
// Render the About page based on the current theme
|
||||
switch (currentTheme) {
|
||||
case Theme.MODERN:
|
||||
return <ModernAbout navItems={navigationItems} />;
|
||||
case Theme.CLASSIC:
|
||||
return <ClassicAbout navItems={navigationItems} />;
|
||||
case Theme.CREATIVE:
|
||||
return <CreativeAbout navItems={navigationItems} />;
|
||||
case Theme.TEMU:
|
||||
return <TemuAbout navItems={navigationItems} />;
|
||||
case Theme.DEFAULT:
|
||||
default:
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex flex-col justify-between">
|
||||
<Navigation items={navigationItems} />
|
||||
<main className="flex-1 max-w-7xl mx-auto px-4 py-8">
|
||||
<AboutContent />
|
||||
</main>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,156 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import { Detail as ModernDetail } from "./modern/Detail";
|
||||
import { Detail as ClassicDetail } from "./classic/Detail";
|
||||
import { Detail as CreativeDetail } from "./creative/Detail";
|
||||
import { Detail as TemuDetail } from "./temu/Detail";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ProductDetailClient } from "@/shared/components/marketplace/ProductDetail";
|
||||
import { Navigation } from "@/shared/components/Navigation";
|
||||
import { Footer } from "@/shared/components/Footer";
|
||||
import { NavigationItems } from "./Theme.const";
|
||||
import { copyToClipboard } from "@/shared/utils/clipboard";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface ProductDetailThemeSelectorProps {
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
export const ProductDetailThemeSelector: React.FC<
|
||||
ProductDetailThemeSelectorProps
|
||||
> = ({ product, breadcrumbs }) => {
|
||||
const { platformConfig, topNavigation } = usePlatformConfig();
|
||||
const currentTheme = platformConfig.theme || Theme.DEFAULT;
|
||||
const mcpServerPrefix =
|
||||
platformConfig.mcp_server_prefix || process.env.NEXT_PUBLIC_MCP_URL || "";
|
||||
const [url, setUrl] = useState<string>("");
|
||||
const [mcpName, setMcpName] = useState<string>("");
|
||||
const { t } = useTranslation();
|
||||
const navigationItems = [
|
||||
...NavigationItems,
|
||||
...topNavigation.map((item) => ({
|
||||
label: item.title,
|
||||
href: item.link,
|
||||
target: item.target,
|
||||
})),
|
||||
];
|
||||
useEffect(() => {
|
||||
if (url || !product.slug_name) return;
|
||||
setUrl(
|
||||
`${mcpServerPrefix || `${window.location.protocol}//${window.location.hostname}:8002`}/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]);
|
||||
const getCodeContent = () => {
|
||||
return `{
|
||||
"mcpServers": {
|
||||
"${mcpName || "xpack-mcp-market"}": {
|
||||
"type": "sse",
|
||||
"autoApprove":"all",
|
||||
"url": "${url}?apikey={Your-${platformConfig?.name}-API-Key}"
|
||||
}
|
||||
}
|
||||
}`;
|
||||
};
|
||||
|
||||
const handleCopy = async () => {
|
||||
const result = await copyToClipboard(getCodeContent());
|
||||
if (result.success) {
|
||||
toast.success(t("Copied to clipboard"));
|
||||
} else {
|
||||
toast.error(t("Copy failed, please copy manually"));
|
||||
}
|
||||
};
|
||||
|
||||
//Render the About page based on the current theme
|
||||
switch (currentTheme) {
|
||||
case Theme.MODERN:
|
||||
return (
|
||||
<ModernDetail
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={navigationItems}
|
||||
mcpName={mcpName}
|
||||
onCopy={handleCopy}
|
||||
/>
|
||||
);
|
||||
case Theme.CLASSIC:
|
||||
return (
|
||||
<ClassicDetail
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={navigationItems}
|
||||
mcpName={mcpName}
|
||||
onCopy={handleCopy}
|
||||
/>
|
||||
);
|
||||
case Theme.CREATIVE:
|
||||
return (
|
||||
<CreativeDetail
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={navigationItems}
|
||||
mcpName={mcpName}
|
||||
onCopy={handleCopy}
|
||||
/>
|
||||
);
|
||||
case Theme.TEMU:
|
||||
return (
|
||||
<TemuDetail
|
||||
product={product}
|
||||
breadcrumbs={breadcrumbs}
|
||||
url={url}
|
||||
navItems={navigationItems}
|
||||
mcpName={mcpName}
|
||||
onCopy={handleCopy}
|
||||
/>
|
||||
);
|
||||
case Theme.DEFAULT:
|
||||
default:
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex flex-col justify-between">
|
||||
<Navigation items={navigationItems} />
|
||||
<main className="flex-1">
|
||||
<ProductDetailClient
|
||||
product={product}
|
||||
mcpName={mcpName}
|
||||
url={url}
|
||||
/>
|
||||
</main>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
export const NavigationItems: NavigationItem[] = [
|
||||
{
|
||||
label: "Home",
|
||||
href: "/",
|
||||
},
|
||||
{
|
||||
label: "About",
|
||||
href: "/about",
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,210 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Theme } from "@/shared/types/system";
|
||||
import { Home as ModernHome } from "./modern/Home";
|
||||
import { Home as ClassicHome } from "./classic/Home";
|
||||
import { Home as CreativeHome } from "./creative/Home";
|
||||
import { Home as TemuHome } from "./temu/Home";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { fetchServices } from "@/services/marketplaceService";
|
||||
import { Navigation } from "@/shared/components/Navigation";
|
||||
import { MarketplaceMain } from "../marketplace/Main";
|
||||
import { Footer } from "@/shared/components/Footer";
|
||||
import { NavigationItems } from "./Theme.const";
|
||||
import { Faq } from "../marketplace/Faq";
|
||||
|
||||
interface ThemeSelectorProps {
|
||||
initialServices: ServiceData[];
|
||||
initialTotal: number;
|
||||
initialPage: number;
|
||||
initialSearch: string;
|
||||
pageSize: number;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export const ThemeSelector: React.FC<ThemeSelectorProps> = ({
|
||||
initialServices,
|
||||
initialTotal,
|
||||
initialPage,
|
||||
initialSearch,
|
||||
pageSize,
|
||||
error,
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
const { platformConfig, topNavigation } = usePlatformConfig();
|
||||
const currentTheme = platformConfig.theme || Theme.DEFAULT;
|
||||
const navigationItems = [
|
||||
...NavigationItems,
|
||||
...topNavigation.map((item) => ({
|
||||
label: item.title,
|
||||
href: item.link,
|
||||
target: item.target,
|
||||
})),
|
||||
];
|
||||
|
||||
// state management for services, search query, pagination, and loading state
|
||||
const [searchQuery, setSearchQuery] = useState(initialSearch);
|
||||
const [services, setServices] = useState<ServiceData[]>(initialServices);
|
||||
const [currentPage, setCurrentPage] = useState(initialPage);
|
||||
const [total, setTotal] = useState(initialTotal);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
// search suggestion
|
||||
const searchSuggestions = ["Search services..."];
|
||||
|
||||
// loading service data
|
||||
const loadServices = async (page: number, search: string) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const result = await fetchServices({
|
||||
page,
|
||||
page_size: pageSize,
|
||||
keyword: search,
|
||||
});
|
||||
|
||||
setServices(result.data.services);
|
||||
setTotal(result.page.total);
|
||||
setCurrentPage(page);
|
||||
} catch (error) {
|
||||
console.error("Failed to load services:", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// when search and page change,scrolling to the page top
|
||||
useEffect(() => {
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}, [currentPage, searchQuery]);
|
||||
|
||||
// update url param
|
||||
const updateURL = (page: number, search: string) => {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (page > 1) {
|
||||
params.set("page", page.toString());
|
||||
}
|
||||
|
||||
if (search.trim()) {
|
||||
params.set("search", search.trim());
|
||||
}
|
||||
|
||||
const queryString = params.toString();
|
||||
const newURL = queryString ? `?${queryString}` : window.location.pathname;
|
||||
|
||||
router.push(newURL);
|
||||
};
|
||||
|
||||
// page change handler
|
||||
const handlePageChange = (page: number) => {
|
||||
updateURL(page, searchQuery);
|
||||
loadServices(page, searchQuery);
|
||||
};
|
||||
|
||||
// search submit handler
|
||||
const handleSearch = () => {
|
||||
updateURL(1, searchQuery);
|
||||
loadServices(1, searchQuery);
|
||||
};
|
||||
|
||||
// search input change handler
|
||||
const handleSearchChange = (value: string) => {
|
||||
setSearchQuery(value);
|
||||
};
|
||||
|
||||
// render the theme page based on the current theme
|
||||
switch (currentTheme) {
|
||||
case Theme.MODERN:
|
||||
return (
|
||||
<ModernHome
|
||||
searchQuery={searchQuery}
|
||||
services={services}
|
||||
currentPage={currentPage}
|
||||
total={total}
|
||||
pageSize={pageSize}
|
||||
loading={loading}
|
||||
error={error}
|
||||
onSearchChange={handleSearchChange}
|
||||
onSearch={handleSearch}
|
||||
onPageChange={handlePageChange}
|
||||
searchSuggestions={searchSuggestions}
|
||||
navItems={navigationItems}
|
||||
/>
|
||||
);
|
||||
case Theme.CLASSIC:
|
||||
return (
|
||||
<ClassicHome
|
||||
searchQuery={searchQuery}
|
||||
services={services}
|
||||
currentPage={currentPage}
|
||||
total={total}
|
||||
pageSize={pageSize}
|
||||
loading={loading}
|
||||
error={error}
|
||||
onSearchChange={handleSearchChange}
|
||||
onSearch={handleSearch}
|
||||
onPageChange={handlePageChange}
|
||||
searchSuggestions={searchSuggestions}
|
||||
navItems={navigationItems}
|
||||
/>
|
||||
);
|
||||
case Theme.CREATIVE:
|
||||
return (
|
||||
<CreativeHome
|
||||
searchQuery={searchQuery}
|
||||
services={services}
|
||||
currentPage={currentPage}
|
||||
total={total}
|
||||
pageSize={pageSize}
|
||||
loading={loading}
|
||||
error={error}
|
||||
onSearchChange={handleSearchChange}
|
||||
onSearch={handleSearch}
|
||||
onPageChange={handlePageChange}
|
||||
searchSuggestions={searchSuggestions}
|
||||
navItems={navigationItems}
|
||||
/>
|
||||
);
|
||||
case Theme.TEMU:
|
||||
return (
|
||||
<TemuHome
|
||||
searchQuery={searchQuery}
|
||||
services={services}
|
||||
currentPage={currentPage}
|
||||
total={total}
|
||||
pageSize={pageSize}
|
||||
loading={loading}
|
||||
error={error}
|
||||
onSearchChange={handleSearchChange}
|
||||
onSearch={handleSearch}
|
||||
onPageChange={handlePageChange}
|
||||
searchSuggestions={searchSuggestions}
|
||||
navItems={navigationItems}
|
||||
/>
|
||||
);
|
||||
case Theme.DEFAULT:
|
||||
default:
|
||||
return (
|
||||
<div className="min-h-screen bg-background flex flex-col justify-between">
|
||||
<Navigation items={navigationItems} />
|
||||
<main className="flex-1">
|
||||
<MarketplaceMain
|
||||
initialServices={services}
|
||||
initialTotal={total}
|
||||
initialPage={currentPage}
|
||||
initialSearch={searchQuery}
|
||||
pageSize={pageSize}
|
||||
error={error}
|
||||
/>
|
||||
<Faq />
|
||||
</main>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Card, CardBody } from "@nextui-org/react";
|
||||
import { AboutContent } from "@/components/about/AboutContent";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface AboutProps {
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col justify-between">
|
||||
<div className="bg-gradient-to-b from-gray-800 to-gray-900 text-white">
|
||||
<Navigation items={navItems} />
|
||||
</div>
|
||||
|
||||
<main className="flex-1 bg-gray-100 mt-20">
|
||||
<div className="max-w-7xl mx-auto px-6 py-12">
|
||||
<Card className="border border-gray-200 shadow-md rounded-md">
|
||||
<CardBody className="p-8">
|
||||
<AboutContent />
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,92 @@
|
||||
import React from "react";
|
||||
|
||||
const ClassicDemo: React.FC = () => {
|
||||
return (
|
||||
<div className="w-full h-full bg-gray-50 relative overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="bg-slate-800 text-white px-4 py-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-6 h-6 bg-red-600 rounded-sm"></div>
|
||||
<span className="text-sm font-bold">PLATFORM</span>
|
||||
</div>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
|
||||
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
|
||||
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<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">About</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="px-4 py-6 bg-white border-b border-gray-200">
|
||||
<div className="text-center">
|
||||
<h1 className="text-lg font-bold text-slate-800 mb-1">
|
||||
Professional Platform
|
||||
</h1>
|
||||
<p className="text-xs text-gray-600 mb-3">
|
||||
Traditional & Reliable Business Solution
|
||||
</p>
|
||||
|
||||
{/* CTA Button */}
|
||||
<div className="inline-block bg-red-600 text-white text-xs px-4 py-2 rounded-sm shadow-md font-medium">
|
||||
Learn More
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Content Section */}
|
||||
<div className="px-4 py-4 bg-gray-50">
|
||||
<div className="grid grid-cols-1 gap-3">
|
||||
{/* Service 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
|
||||
</div>
|
||||
<div className="text-xs text-gray-600">
|
||||
Professional solutions for enterprise
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service 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>
|
||||
<div className="flex-1">
|
||||
<div className="text-xs font-semibold text-slate-800 mb-1">
|
||||
Consulting
|
||||
</div>
|
||||
<div className="text-xs text-gray-600">
|
||||
Expert guidance and support
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-slate-700 px-4 py-2">
|
||||
<div className="text-center">
|
||||
<div className="text-xs text-gray-300">© 2025 Platform</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ClassicDemo;
|
||||
@@ -0,0 +1,271 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Tabs, Tab, Chip, Card, CardBody, Button } from "@nextui-org/react";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
|
||||
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
|
||||
import { FileText, Wrench, Cog, Copy } from "lucide-react";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import Link from "next/link";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface DetailProps {
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
onCopy: () => void;
|
||||
}
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
onCopy,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
|
||||
if (!product) {
|
||||
return <ProductNotFound />;
|
||||
}
|
||||
|
||||
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} />
|
||||
<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-gray-50 rounded-sm p-6 border border-gray-200">
|
||||
<Card shadow="none" className="bg-gray-50">
|
||||
<CardBody>
|
||||
{/* Breadcrumb */}
|
||||
<nav className="text-sm text-default-500 flex items-center gap-1 mb-10">
|
||||
<Link href="/" className="hover:underline">
|
||||
{t("Home")}
|
||||
</Link>
|
||||
<span>/</span>
|
||||
<b className="text-default-700">{t(product.name)}</b>
|
||||
</nav>
|
||||
|
||||
{/* Header with title and price */}
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex-1">
|
||||
<h1 className="text-3xl font-bold mb-2">
|
||||
{product.name}
|
||||
</h1>
|
||||
|
||||
{/* Tags */}
|
||||
{product.tags && product.tags.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2 my-3">
|
||||
{product.tags.map((tag, index) => (
|
||||
<Chip
|
||||
key={index}
|
||||
size="sm"
|
||||
variant="flat"
|
||||
color="primary"
|
||||
radius="sm"
|
||||
className="text-xs h-5"
|
||||
>
|
||||
{tag}
|
||||
</Chip>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<p className="text-sm mb-4">
|
||||
{product.short_description ||
|
||||
t("No description available")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Price section */}
|
||||
{product.charge_type && (
|
||||
<div className="flex gap-2 items-center">
|
||||
<b className="text-md">{t("Price")}:</b>
|
||||
<Price
|
||||
price={product.price}
|
||||
charge_type={product.charge_type}
|
||||
input_token_price={product.input_token_price}
|
||||
output_token_price={product.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="mx-auto p-6 max-w-7xl">
|
||||
<div className="flex gap-6 mt-6">
|
||||
{/* Left side - Main content */}
|
||||
<div className="flex-1">
|
||||
<Card className="bg-white border border-gray-200 shadow-sm rounded-sm">
|
||||
<CardBody className="p-0">
|
||||
<Tabs
|
||||
selectedKey={activeTab}
|
||||
onSelectionChange={(key) => setActiveTab(key as string)}
|
||||
variant="underlined"
|
||||
color="primary"
|
||||
className="px-6 pt-6"
|
||||
classNames={{
|
||||
tabList:
|
||||
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
|
||||
cursor: "w-full bg-red-600",
|
||||
tab: "max-w-fit px-0 h-12",
|
||||
tabContent:
|
||||
"group-data-[selected=true]:text-red-600 font-semibold text-gray-700",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="overview"
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<FileText className="w-4 h-4" />
|
||||
<span>{t("Overview")}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
<ProductOverview product={product} />
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab
|
||||
key="tools"
|
||||
title={
|
||||
<div className="flex gap-2 items-center">
|
||||
<Wrench className="w-4 h-4" />
|
||||
<span>{t("Tools")}</span>
|
||||
<Chip
|
||||
size="sm"
|
||||
className="h-4 text-xs bg-red-600 text-white rounded-sm"
|
||||
>
|
||||
{product.tools.length}
|
||||
</Chip>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
<div className="space-y-4 px-3">
|
||||
{product.tools.length > 0 ? (
|
||||
product.tools.map((tool, index) => (
|
||||
<Card
|
||||
radius="sm"
|
||||
key={`${product.service_id}-tool-${index}`}
|
||||
shadow="none"
|
||||
className="border-1"
|
||||
>
|
||||
<CardBody>
|
||||
<h4 className="font-semibold text-sm mb-2 text-red-600">
|
||||
{tool.name}
|
||||
</h4>
|
||||
<p className="text-sm mb-3">
|
||||
{tool.description ||
|
||||
t("No description available")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<Card>
|
||||
<CardBody>
|
||||
<p className="text-center">
|
||||
{t("No tools available in this service.")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Right side - Server Config */}
|
||||
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
|
||||
<Card className="bg-white border border-gray-200 shadow-sm rounded-sm">
|
||||
<CardBody>
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<div className="w-8 h-8 bg-red-600 rounded-sm flex items-center justify-center">
|
||||
<Cog className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<h3 className="font-semibold text-lg text-gray-900">
|
||||
{t("Configuration")}
|
||||
</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>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* SEO-friendly: Simple text content for search engines */}
|
||||
<div className="hidden" aria-hidden="true">
|
||||
<h2>Tools ({product.tools.length})</h2>
|
||||
{product.tools.length > 0 &&
|
||||
product.tools.map((tool, index) => (
|
||||
<div key={`seo-${product.service_id}-tool-${index}`}>
|
||||
<h4>{tool.name}</h4>
|
||||
<p>{tool.description || ""}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import Link from "next/link";
|
||||
|
||||
interface FooterProps {}
|
||||
|
||||
export const Footer: React.FC<FooterProps> = ({}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
return (
|
||||
<>
|
||||
{/* Classic Footer */}
|
||||
<footer className="bg-slate-700 text-white py-1">
|
||||
<div className="mx-auto px-6 max-w-7xl">
|
||||
<div className="text-center">
|
||||
<span className="text-gray-300 text-xs mr-2">
|
||||
© 2025 {platformConfig?.name}
|
||||
</span>
|
||||
|
||||
<Link
|
||||
className="text-xs text-primary-500 hover:text-primary-600 transition-colors"
|
||||
href="https://xpack.ai"
|
||||
>
|
||||
Powered By XPack.AI
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,259 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Spinner } from "@nextui-org/react";
|
||||
import { Search, Star, Grid, ArrowRight } from "lucide-react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
Pagination,
|
||||
Card,
|
||||
CardBody,
|
||||
CardFooter,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
import {
|
||||
_DefaultPlatformConfig,
|
||||
usePlatformConfig,
|
||||
} from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
import { Footer } from "./Footer";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import { Faq } from "@/components/marketplace/Faq";
|
||||
|
||||
interface HomeProps {
|
||||
// 状态
|
||||
searchQuery: string;
|
||||
services: ServiceData[];
|
||||
currentPage: number;
|
||||
total: number;
|
||||
pageSize: number;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
|
||||
// 事件处理函数
|
||||
onSearchChange: (value: string) => void;
|
||||
onSearch: () => void;
|
||||
onPageChange: (page: number) => void;
|
||||
|
||||
// 可选配置
|
||||
searchSuggestions?: string[];
|
||||
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Home: React.FC<HomeProps> = ({
|
||||
searchQuery,
|
||||
services,
|
||||
currentPage,
|
||||
total,
|
||||
pageSize,
|
||||
loading,
|
||||
error,
|
||||
onSearchChange,
|
||||
onSearch,
|
||||
onPageChange,
|
||||
searchSuggestions = [],
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
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} />
|
||||
<div>
|
||||
{/* Classic Hero Section */}
|
||||
<div className="bg-white border-b border-gray-200 pt-20">
|
||||
<div className="mx-auto px-6 py-16 max-w-6xl">
|
||||
<div className="text-center mb-12">
|
||||
{/* Classic Icon */}
|
||||
<div className="flex justify-center mb-6">
|
||||
<div className="w-12 h-12 bg-red-600 rounded-sm flex items-center justify-center">
|
||||
<Grid className="w-6 h-6 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Classic Title */}
|
||||
<h1 className="text-4xl lg:text-5xl font-bold mb-6 text-slate-800">
|
||||
{t(
|
||||
platformConfig.headline ||
|
||||
_DefaultPlatformConfig.headline ||
|
||||
""
|
||||
)}
|
||||
</h1>
|
||||
|
||||
{/* Classic Subtitle */}
|
||||
<p className="text-xl text-gray-600 max-w-3xl mx-auto leading-relaxed">
|
||||
{t(
|
||||
platformConfig.subheadline ||
|
||||
_DefaultPlatformConfig.subheadline ||
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Classic Search Bar */}
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<div className="bg-white border border-gray-300 rounded-sm shadow-md overflow-hidden">
|
||||
<div className="flex">
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
size="lg"
|
||||
placeholder={
|
||||
searchSuggestions.length > 0
|
||||
? t(searchSuggestions[0])
|
||||
: t("Search services...")
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && onSearch()}
|
||||
startContent={
|
||||
<Search className="w-5 h-5 text-gray-400" />
|
||||
}
|
||||
className="w-full"
|
||||
classNames={{
|
||||
input:
|
||||
"text-lg text-gray-900 placeholder:text-gray-500",
|
||||
inputWrapper: "h-14 shadow-none px-4 bg-white border-0",
|
||||
}}
|
||||
variant="flat"
|
||||
radius="none"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
onPress={onSearch}
|
||||
className="bg-red-600 text-white hover:bg-red-700 transition-colors duration-200 h-14 px-8 rounded-sm font-medium"
|
||||
size="lg"
|
||||
>
|
||||
{t("Search")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service List Section */}
|
||||
{loading ? (
|
||||
<div className="mx-auto h-[200px] flex items-center justify-center">
|
||||
<div className="bg-white p-8 rounded-lg shadow-md">
|
||||
<Spinner size="lg" color="primary" />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-gray-50 py-16">
|
||||
<div className="mx-auto px-6 max-w-7xl">
|
||||
{/* Services 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)]"
|
||||
>
|
||||
<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="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">
|
||||
{service.name}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<ArrowRight className="w-4 h-4 text-gray-400 group-hover:text-slate-600 transition-colors" />
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<p className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
|
||||
{service.short_description ||
|
||||
t("No description available")}
|
||||
</p>
|
||||
</CardBody>
|
||||
|
||||
{/* Footer */}
|
||||
<CardFooter className="pt-0 px-4 pb-4">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
{/* Tools count */}
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-2 h-2 bg-slate-600 rounded-full"></div>
|
||||
<span className="text-sm font-medium text-gray-700">
|
||||
{t("{{count}} Tools", {
|
||||
count: service.tools.length,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Price */}
|
||||
<div className="flex flex-col items-end">
|
||||
<Price
|
||||
price={service.price}
|
||||
charge_type={service.charge_type}
|
||||
input_token_price={service.input_token_price}
|
||||
output_token_price={service.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Classic Pagination */}
|
||||
{totalPages > 1 && (
|
||||
<div className="flex justify-center mt-8">
|
||||
<Pagination
|
||||
total={totalPages}
|
||||
page={currentPage}
|
||||
onChange={onPageChange}
|
||||
showControls
|
||||
classNames={{
|
||||
wrapper:
|
||||
"gap-0 overflow-visible h-8 border border-gray-300 bg-white shadow-sm rounded-none overflow-hidden",
|
||||
item: "w-8 h-8 text-small rounded-none bg-transparent text-gray-700 hover:bg-gray-50 rounded-none",
|
||||
cursor:
|
||||
"bg-red-600 border-red-600 text-white font-medium rounded-none",
|
||||
next: "rounded-none",
|
||||
prev: "rounded-none",
|
||||
}}
|
||||
size="sm"
|
||||
variant="light"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<Faq />
|
||||
</div>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
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";
|
||||
|
||||
interface NavigationProps {
|
||||
items?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
|
||||
return (
|
||||
<div className="fixed top-0 left-0 right-0 z-50">
|
||||
{/* Classic Header */}
|
||||
<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" />
|
||||
</div>
|
||||
<div className="flex space-x-2">
|
||||
<Button
|
||||
color="primary"
|
||||
className="bg-red-600 hover:bg-red-700 text-white text-sm px-4 py-1 rounded-sm font-medium"
|
||||
size="sm"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
{t("Get Started")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Classic Navigation */}
|
||||
<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) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
target={item.target}
|
||||
className="text-sm text-gray-500"
|
||||
>
|
||||
{t(item.label)}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Card, CardBody } from "@nextui-org/react";
|
||||
import { AboutContent } from "@/components/about/AboutContent";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface AboutProps {
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col justify-between bg-gradient-to-br from-pink-50 via-white to-blue-50">
|
||||
<Navigation items={navItems} />
|
||||
|
||||
<main className="flex-1 relative mt-20">
|
||||
{/* Creative background elements */}
|
||||
<div className="absolute inset-0 overflow-hidden pointer-events-none">
|
||||
<div className="absolute -top-24 -right-24 w-96 h-96 bg-pink-200 rounded-full opacity-20 blur-3xl"></div>
|
||||
<div className="absolute top-1/3 -left-24 w-80 h-80 bg-blue-200 rounded-full opacity-20 blur-3xl"></div>
|
||||
<div className="absolute bottom-1/4 right-1/4 w-64 h-64 bg-purple-200 rounded-full opacity-20 blur-3xl"></div>
|
||||
</div>
|
||||
|
||||
<div className="max-w-7xl mx-auto px-6 py-12 relative z-10">
|
||||
<Card className="border-none shadow-xl rounded-3xl overflow-hidden bg-white/80 backdrop-blur-sm">
|
||||
<CardBody className="p-8">
|
||||
<AboutContent />
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,69 @@
|
||||
import React from 'react';
|
||||
|
||||
const CreativeDemo: React.FC = () => {
|
||||
return (
|
||||
<div className="w-full h-full bg-gradient-to-br from-pink-50 via-orange-50 to-yellow-50 relative overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="bg-white/80 backdrop-blur-sm border-b border-pink-200 px-4 py-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-6 h-6 bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 rounded-2xl transform rotate-12"></div>
|
||||
<span className="text-sm font-bold bg-gradient-to-r from-pink-600 to-orange-600 bg-clip-text text-transparent">Creative</span>
|
||||
</div>
|
||||
<div className="flex space-x-1">
|
||||
<div className="w-2 h-2 bg-pink-400 rounded-full"></div>
|
||||
<div className="w-2 h-2 bg-orange-400 rounded-full"></div>
|
||||
<div className="w-2 h-2 bg-yellow-400 rounded-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="px-4 py-6 text-center relative">
|
||||
<div className="mb-3">
|
||||
<h1 className="text-lg font-bold bg-gradient-to-r from-pink-600 via-red-500 to-orange-600 bg-clip-text text-transparent mb-1">
|
||||
Creative Platform
|
||||
</h1>
|
||||
<p className="text-xs text-gray-700">Bold & Artistic Design Experience</p>
|
||||
</div>
|
||||
|
||||
{/* CTA Button */}
|
||||
<div className="mb-4">
|
||||
<div className="inline-block bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white text-xs px-4 py-2 rounded-2xl shadow-lg transform hover:scale-105 transition-transform">
|
||||
Explore Now
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Feature Cards */}
|
||||
<div className="px-4 pb-4">
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div className="bg-white/70 backdrop-blur-sm rounded-2xl p-3 shadow-lg border border-pink-200/50 transform rotate-1">
|
||||
<div className="w-4 h-4 bg-gradient-to-r from-pink-400 to-red-400 rounded-xl mb-2 transform rotate-12"></div>
|
||||
<div className="text-xs font-bold text-gray-800 mb-1">Creative Tools</div>
|
||||
<div className="text-xs text-gray-600">Artistic Design</div>
|
||||
</div>
|
||||
<div className="bg-white/70 backdrop-blur-sm rounded-2xl p-3 shadow-lg border border-orange-200/50 transform -rotate-1">
|
||||
<div className="w-4 h-4 bg-gradient-to-r from-orange-400 to-yellow-400 rounded-xl mb-2 transform -rotate-12"></div>
|
||||
<div className="text-xs font-bold text-gray-800 mb-1">Innovation</div>
|
||||
<div className="text-xs text-gray-600">Bold Ideas</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Floating Elements */}
|
||||
<div className="absolute top-4 right-2 w-8 h-8 bg-gradient-to-r from-pink-400/30 to-red-400/30 rounded-full transform rotate-45"></div>
|
||||
<div className="absolute top-12 right-8 w-4 h-4 bg-gradient-to-r from-orange-400/40 to-yellow-400/40 rounded-full"></div>
|
||||
<div className="absolute bottom-8 left-2 w-6 h-6 bg-gradient-to-r from-red-400/30 to-pink-400/30 rounded-full transform -rotate-12"></div>
|
||||
<div className="absolute bottom-4 left-8 w-3 h-3 bg-gradient-to-r from-yellow-400/40 to-orange-400/40 rounded-full"></div>
|
||||
|
||||
{/* Decorative Shapes */}
|
||||
<div className="absolute top-0 left-1/2 w-16 h-16 bg-gradient-to-br from-pink-300/20 to-orange-300/20 rounded-full transform -translate-x-1/2 -translate-y-8 rotate-45"></div>
|
||||
<div className="absolute bottom-0 right-0 w-12 h-12 bg-gradient-to-tl from-orange-300/20 to-yellow-300/20 transform translate-x-6 translate-y-6 rotate-12">
|
||||
<div className="w-full h-full rounded-2xl"></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CreativeDemo;
|
||||
@@ -0,0 +1,232 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Tabs, Tab, Chip, Card, CardBody, Button } from "@nextui-org/react";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
|
||||
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
|
||||
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
|
||||
import { Sparkles, Zap, Settings2, Copy } from "lucide-react";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface DetailProps {
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
onCopy: () => void;
|
||||
}
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
onCopy,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
|
||||
if (!product) {
|
||||
return <ProductNotFound />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-pink-50 via-orange-50 to-yellow-50 relative overflow-hidden flex flex-col justify-between">
|
||||
<Navigation items={navItems} />
|
||||
{/* Creative Background */}
|
||||
<div className="flex-1 relative">
|
||||
<div className="absolute inset-0">
|
||||
{/* Artistic decorative elements */}
|
||||
<div className="absolute top-20 left-20 w-32 h-32 bg-gradient-to-br from-pink-200/30 to-orange-200/30 rounded-full blur-2xl" />
|
||||
<div className="absolute top-40 right-32 w-24 h-24 bg-gradient-to-br from-orange-200/40 to-yellow-200/40 rounded-2xl rotate-45 blur-xl" />
|
||||
<div className="absolute bottom-32 left-1/4 w-40 h-40 bg-gradient-to-br from-yellow-200/25 to-pink-200/25 rounded-full blur-3xl" />
|
||||
<div className="absolute bottom-20 right-20 w-28 h-28 bg-gradient-to-br from-pink-200/35 to-red-200/35 rounded-2xl rotate-12 blur-xl" />
|
||||
|
||||
{/* Additional artistic elements */}
|
||||
<div className="absolute top-1/3 left-1/3 w-20 h-20 bg-gradient-to-br from-orange-300/20 to-yellow-300/20 rounded-full blur-xl" />
|
||||
<div className="absolute top-2/3 right-1/3 w-16 h-16 bg-gradient-to-br from-pink-300/25 to-orange-300/25 rounded-lg rotate-45 blur-lg" />
|
||||
</div>
|
||||
|
||||
<div className="relative z-10">
|
||||
{/* 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">
|
||||
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="mx-auto p-6 max-w-7xl">
|
||||
<div className="flex gap-6 mt-6">
|
||||
{/* Left side - Main content */}
|
||||
<div className="flex-1">
|
||||
<Card className="bg-white/95 backdrop-blur-sm border border-pink-200/50 shadow-lg overflow-hidden rounded-2xl">
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-pink-500/5 via-transparent to-orange-500/5" />
|
||||
<CardBody className="p-0 relative">
|
||||
<Tabs
|
||||
selectedKey={activeTab}
|
||||
onSelectionChange={(key) => setActiveTab(key as string)}
|
||||
variant="underlined"
|
||||
color="secondary"
|
||||
className="px-6 pt-6"
|
||||
classNames={{
|
||||
tabList:
|
||||
"gap-6 w-full relative rounded-none p-0 border-b border-pink-200/50",
|
||||
cursor:
|
||||
"w-full bg-gradient-to-r from-pink-500 via-red-500 to-orange-500",
|
||||
tab: "max-w-fit px-0 h-12",
|
||||
tabContent:
|
||||
"group-data-[selected=true]:text-pink-600 font-semibold",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="overview"
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<Sparkles className="w-4 h-4" />
|
||||
<span>{t("Overview")}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
<ProductOverview product={product} />
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab
|
||||
key="tools"
|
||||
title={
|
||||
<div className="flex gap-2 items-center">
|
||||
<Zap className="w-4 h-4" />
|
||||
<span>{t("Tools")}</span>
|
||||
<Chip
|
||||
size="sm"
|
||||
className="h-4 text-xs bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white shadow-lg"
|
||||
>
|
||||
{product.tools.length}
|
||||
</Chip>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
{product.tools.length > 0 ? (
|
||||
product.tools.map((tool, index) => (
|
||||
<Card
|
||||
radius="sm"
|
||||
key={`${product.service_id}-tool-${index}`}
|
||||
shadow="none"
|
||||
className="border-1"
|
||||
>
|
||||
<CardBody>
|
||||
<h4 className="font-semibold text-sm mb-2 text-pink-600">
|
||||
{tool.name}
|
||||
</h4>
|
||||
<p className="text-sm mb-3">
|
||||
{tool.description ||
|
||||
t("No description available")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<Card>
|
||||
<CardBody>
|
||||
<p className="text-center">
|
||||
{t("No tools available in this service.")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Right side - Server Config */}
|
||||
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
|
||||
<Card className="bg-white/95 backdrop-blur-sm border border-pink-200/50 shadow-lg overflow-hidden rounded-2xl">
|
||||
<div className="absolute inset-0 bg-gradient-to-br from-orange-500/5 via-transparent to-pink-500/5" />
|
||||
<CardBody className="relative">
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<div className="p-2 bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 rounded-lg">
|
||||
<Settings2 className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<h3 className="font-semibold text-lg bg-gradient-to-r from-pink-600 to-orange-600 bg-clip-text text-transparent">
|
||||
{t("Configuration")}
|
||||
</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>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* SEO-friendly: Simple text content for search engines */}
|
||||
<div className="hidden" aria-hidden="true">
|
||||
<h2>Tools ({product.tools.length})</h2>
|
||||
{product.tools.length > 0 &&
|
||||
product.tools.map((tool, index) => (
|
||||
<div key={`seo-${product.service_id}-tool-${index}`}>
|
||||
<h4>{tool.name}</h4>
|
||||
<p>{tool.description || ""}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
interface FooterProps {}
|
||||
|
||||
export const Footer: React.FC<FooterProps> = ({}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
return (
|
||||
<>
|
||||
{/* Creative Footer */}
|
||||
<footer className="py-4 px-4 sm:px-6 text-center sm:text-end mx-auto text-xs max-w-7xl mx-auto">
|
||||
<span className="mr-1">
|
||||
© 2025 {platformConfig?.name}. All rights reserved.
|
||||
</span>
|
||||
<a className="text-xs text-primary-500 hover:text-primary-600 transition-colors" href="https://xpack.ai">
|
||||
Powered By XPack.AI
|
||||
</a>
|
||||
</footer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,325 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Spinner } from "@nextui-org/react";
|
||||
import { Sparkles, Palette, SearchIcon } from "lucide-react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
Pagination,
|
||||
Card,
|
||||
CardBody,
|
||||
CardFooter,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
import {
|
||||
_DefaultPlatformConfig,
|
||||
usePlatformConfig,
|
||||
} from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
import { Footer } from "./Footer";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import { Faq } from "@/components/marketplace/Faq";
|
||||
|
||||
interface HomeProps {
|
||||
// 状态
|
||||
searchQuery: string;
|
||||
services: ServiceData[];
|
||||
currentPage: number;
|
||||
total: number;
|
||||
pageSize: number;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
|
||||
// 事件处理函数
|
||||
onSearchChange: (value: string) => void;
|
||||
onSearch: () => void;
|
||||
onPageChange: (page: number) => void;
|
||||
|
||||
// 可选配置
|
||||
searchSuggestions?: string[];
|
||||
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Home: React.FC<HomeProps> = ({
|
||||
searchQuery,
|
||||
services,
|
||||
currentPage,
|
||||
total,
|
||||
pageSize,
|
||||
loading,
|
||||
onSearchChange,
|
||||
onSearch,
|
||||
onPageChange,
|
||||
searchSuggestions = [],
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const { t } = useTranslation();
|
||||
const totalPages = Math.ceil(total / pageSize);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen relative overflow-hidden bg-gradient-to-br from-pink-50 via-orange-50 to-yellow-50">
|
||||
<Navigation items={navItems} />
|
||||
|
||||
{/* Creative Background decorative elements */}
|
||||
<div className="absolute inset-0 overflow-hidden pointer-events-none z-50">
|
||||
{/* main decorative circles */}
|
||||
<div className="absolute top-1/4 left-1/4 w-64 h-64 bg-gradient-to-r from-pink-400/15 to-orange-400/15 rounded-full blur-3xl animate-pulse"></div>
|
||||
<div className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-gradient-to-r from-orange-400/10 to-yellow-400/10 rounded-full blur-3xl"></div>
|
||||
|
||||
{/* small decorative circles */}
|
||||
<div className="absolute top-10 right-20 w-16 h-16 bg-gradient-to-br from-pink-400/20 to-red-500/20 rounded-full transform rotate-12"></div>
|
||||
<div className="absolute top-32 left-16 w-12 h-12 bg-gradient-to-br from-orange-400/25 to-yellow-400/25 rounded-full transform -rotate-12"></div>
|
||||
<div className="absolute bottom-20 left-1/3 w-20 h-20 bg-gradient-to-br from-yellow-400/15 to-pink-400/15 rounded-full transform rotate-6"></div>
|
||||
<div className="absolute bottom-32 right-16 w-14 h-14 bg-gradient-to-br from-purple-400/20 to-pink-400/20 rounded-full transform -rotate-6"></div>
|
||||
|
||||
{/* small decorative points */}
|
||||
<div className="absolute top-1/3 right-1/3 w-4 h-4 bg-pink-400/30 rounded-full"></div>
|
||||
<div className="absolute top-2/3 left-1/5 w-3 h-3 bg-orange-400/40 rounded-full"></div>
|
||||
<div className="absolute bottom-1/3 right-1/5 w-5 h-5 bg-yellow-400/25 rounded-full"></div>
|
||||
</div>
|
||||
|
||||
{/* Creative Hero Section */}
|
||||
<div className="relative z-10 pt-32">
|
||||
<div className="mx-auto px-6 py-12 max-w-6xl">
|
||||
<div className="text-center mb-12">
|
||||
{/* Creative Icon */}
|
||||
<div className="flex justify-center mb-6">
|
||||
<div className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 p-4 rounded-2xl shadow-lg transform rotate-12">
|
||||
<Palette className="w-8 h-8 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Creative Title */}
|
||||
<h1 className="text-4xl lg:text-6xl font-black mb-6 leading-tight">
|
||||
<span className="bg-clip-text text-transparent bg-gradient-to-r from-pink-600 via-red-500 to-orange-600">
|
||||
{t(
|
||||
platformConfig.headline ||
|
||||
_DefaultPlatformConfig.headline ||
|
||||
""
|
||||
)}
|
||||
</span>
|
||||
</h1>
|
||||
|
||||
{/* Creative Subtitle */}
|
||||
<p className="text-lg font-medium max-w-3xl mx-auto leading-relaxed text-gray-700">
|
||||
{t(
|
||||
platformConfig.subheadline ||
|
||||
_DefaultPlatformConfig.subheadline ||
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Creative Search Bar */}
|
||||
<div className="max-w-3xl mx-auto relative">
|
||||
<div className="relative">
|
||||
{/* Search container */}
|
||||
<div className="relative bg-white/70 backdrop-blur-sm p-2 rounded-2xl border border-pink-200/50 shadow-lg">
|
||||
<div className="flex gap-2">
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
size="lg"
|
||||
placeholder={
|
||||
searchSuggestions.length > 0
|
||||
? t(searchSuggestions[0])
|
||||
: t("✨ Discover amazing services...")
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && onSearch()}
|
||||
startContent={
|
||||
<div className="flex items-center gap-2 ml-2">
|
||||
<Sparkles className="w-5 h-5 text-pink-500" />
|
||||
</div>
|
||||
}
|
||||
className="w-full"
|
||||
classNames={{
|
||||
input:
|
||||
"text-lg text-gray-800 placeholder:text-gray-500 font-medium",
|
||||
inputWrapper:
|
||||
"h-16 shadow-none px-4 bg-transparent border-0",
|
||||
}}
|
||||
variant="flat"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
onPress={onSearch}
|
||||
className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-105 h-16 w-16 rounded-2xl"
|
||||
size="lg"
|
||||
isIconOnly
|
||||
>
|
||||
<SearchIcon size={32} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Creative Service 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">
|
||||
<div className="flex items-center gap-4">
|
||||
<Spinner size="lg" color="secondary" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="relative z-10">
|
||||
<div className="relative mx-auto px-6 py-16 max-w-8xl">
|
||||
{/* Creative Services Grid */}
|
||||
<div className="flex flex-wrap justify-center gap-4 mb-12">
|
||||
{services.map((service, index) => {
|
||||
const gradientBorders = [
|
||||
"border-pink-200/50",
|
||||
"border-orange-200/50",
|
||||
"border-yellow-200/50",
|
||||
"border-red-200/50",
|
||||
"border-purple-200/50",
|
||||
"border-blue-200/50",
|
||||
];
|
||||
const iconGradients = [
|
||||
"bg-gradient-to-r from-pink-500 via-red-500 to-orange-500",
|
||||
"bg-gradient-to-r from-orange-400 to-yellow-400",
|
||||
"bg-gradient-to-r from-yellow-400 to-pink-400",
|
||||
"bg-gradient-to-r from-red-400 to-pink-500",
|
||||
"bg-gradient-to-r from-purple-400 to-pink-400",
|
||||
"bg-gradient-to-r from-blue-400 to-purple-400",
|
||||
];
|
||||
const iconRotations = [
|
||||
"transform rotate-12",
|
||||
"transform -rotate-12",
|
||||
"transform rotate-6",
|
||||
"transform -rotate-6",
|
||||
"transform rotate-12",
|
||||
"transform -rotate-12",
|
||||
];
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={service.service_id}
|
||||
href={`/marketplace/${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={`
|
||||
bg-white/80 backdrop-blur-sm shadow-lg
|
||||
border ${gradientBorders[index % 6]}
|
||||
hover:scale-105 hover:shadow-xl
|
||||
transition-all duration-300 ease-out
|
||||
group-hover:bg-white/90 relative
|
||||
h-[200px] w-full
|
||||
`}
|
||||
>
|
||||
<CardBody className="p-6">
|
||||
{/* creative icon */}
|
||||
<div
|
||||
className={` absolute -top-2 -left-2
|
||||
w-8 h-8 ${iconGradients[index % 6]}
|
||||
rounded-2xl mb-4 ${iconRotations[index % 6]}
|
||||
group-hover:scale-110 transition-transform duration-300
|
||||
`}
|
||||
></div>
|
||||
|
||||
{/* service title */}
|
||||
<div className="text-lg font-bold text-gray-800 mb-2 group-hover:text-gray-900 transition-colors">
|
||||
{service.name}
|
||||
</div>
|
||||
|
||||
{/* service description */}
|
||||
<div className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
|
||||
{service.short_description ||
|
||||
t("No description available")}
|
||||
</div>
|
||||
|
||||
{/* decorative elements */}
|
||||
<div className="absolute top-2 right-2 w-3 h-3 bg-gradient-to-r from-pink-400/30 to-orange-400/30 rounded-full opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
|
||||
</CardBody>
|
||||
|
||||
{/* Footer */}
|
||||
<CardFooter className="pt-0 px-4 pb-4">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
{/* Tools count */}
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-2 h-2 bg-blue-600 rounded-full"></div>
|
||||
<span className="text-sm font-medium text-gray-700">
|
||||
{t("{{count}} Tools", {
|
||||
count: service.tools.length,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Price */}
|
||||
<div className="flex flex-col items-end">
|
||||
<Price
|
||||
price={service.price}
|
||||
charge_type={service.charge_type}
|
||||
input_token_price={service.input_token_price}
|
||||
output_token_price={service.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Creative Pagination */}
|
||||
{totalPages > 1 && (
|
||||
<div className="flex justify-center mt-12">
|
||||
<div className="bg-white/90 backdrop-blur-xl p-4 rounded-2xl shadow-lg border border-pink-200/50">
|
||||
<Pagination
|
||||
total={totalPages}
|
||||
page={currentPage}
|
||||
onChange={onPageChange}
|
||||
showControls
|
||||
color="secondary"
|
||||
variant="light"
|
||||
size="lg"
|
||||
classNames={{
|
||||
wrapper: "gap-2",
|
||||
item: "w-10 h-10 text-sm font-bold text-gray-700 hover:bg-pink-100/50 transition-all duration-300",
|
||||
cursor:
|
||||
"bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 shadow-lg text-white font-bold",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<style jsx>{`
|
||||
@keyframes fade-in-up {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(50px) scale(0.9);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-fade-in-up {
|
||||
animation: fade-in-up 0.8s ease-out;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
)}
|
||||
<Faq />
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,124 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Navbar,
|
||||
NavbarContent,
|
||||
NavbarMenuToggle,
|
||||
NavbarMenu,
|
||||
NavbarMenuItem,
|
||||
} from "@nextui-org/react";
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { useAuth } from "@/shared/lib/useAuth";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface NavigationProps {
|
||||
items?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Creative Navigation */}
|
||||
<Navbar
|
||||
onMenuOpenChange={setIsMenuOpen}
|
||||
maxWidth="full"
|
||||
className="bg-white/95 backdrop-blur-[15px] border-b border-pink-200/50 shadow-sm fixed top-0 left-0 right-0 z-50 "
|
||||
height="66px"
|
||||
isBordered={false}
|
||||
position="static"
|
||||
classNames={{
|
||||
wrapper: "max-w-7xl mx-auto",
|
||||
}}
|
||||
>
|
||||
<NavbarContent>
|
||||
<NavbarMenuToggle
|
||||
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
|
||||
className="sm:hidden text-gray-700"
|
||||
/>
|
||||
<div className="flex justify-start bg-transparent w-max">
|
||||
<Link href="/">
|
||||
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="hidden lg:flex gap-6 justify-center">
|
||||
{items?.map((item) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
target={item.target}
|
||||
className="text-sm text-gray-500"
|
||||
>
|
||||
{t(item.label)}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</NavbarContent>
|
||||
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
|
||||
<div className="hidden sm:block">
|
||||
<Button
|
||||
color="primary"
|
||||
className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 hover:from-pink-600 hover:via-red-600 hover:to-orange-600 text-white shadow-lg hover:shadow-xl transition-all duration-300 hover:scale-105 flex items-center justify-center gap-4 pr-1 h-[45px]"
|
||||
radius="full"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
<b className="text-md">{t("Get Started")}</b>
|
||||
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
|
||||
<ArrowRightIcon
|
||||
size={16}
|
||||
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px] text-white"
|
||||
/>
|
||||
</div>
|
||||
</Button>
|
||||
</div>
|
||||
<div className="sm:hidden">
|
||||
<Button
|
||||
className="bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white"
|
||||
onPress={handleLogin}
|
||||
size="sm"
|
||||
>
|
||||
<b className="text-md">{t("Get Started")}</b>
|
||||
</Button>
|
||||
</div>
|
||||
</NavbarContent>
|
||||
<NavbarMenu className="pt-6 pb-6 bg-white/95 backdrop-blur-sm border-l border-pink-200/50">
|
||||
<NavbarMenuItem className="mt-4">
|
||||
<Button
|
||||
color="primary"
|
||||
className="w-full bg-gradient-to-r from-pink-500 via-red-500 to-orange-500 text-white flex items-center justify-between gap-4 pr-1 h-[45px]"
|
||||
radius="full"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
<b className="text-md">{t("Get Started")}</b>
|
||||
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
|
||||
<ArrowRightIcon
|
||||
size={16}
|
||||
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px]"
|
||||
/>
|
||||
</div>
|
||||
</Button>
|
||||
</NavbarMenuItem>
|
||||
</NavbarMenu>
|
||||
{/* Floating Elements - Demo Style */}
|
||||
<div className="absolute top-4 -right-12 w-8 h-8 bg-gradient-to-r from-pink-400/30 to-red-400/30 rounded-full transform rotate-45 z-50"></div>
|
||||
<div className="absolute top-12 -right-8 w-4 h-4 bg-gradient-to-r from-orange-400/40 to-yellow-400/40 rounded-full z-50"></div>
|
||||
<div className="absolute bottom-8 left-2 w-6 h-6 bg-gradient-to-r from-red-400/30 to-pink-400/30 rounded-full transform -rotate-12 z-50"></div>
|
||||
<div className="absolute bottom-4 left-8 w-3 h-3 bg-gradient-to-r from-yellow-400/40 to-orange-400/40 rounded-full z-50"></div>
|
||||
{/* Decorative Shapes - Demo Style */}
|
||||
<div className="absolute top-0 left-1/2 w-16 h-16 bg-gradient-to-br from-pink-300/20 to-orange-300/20 rounded-full transform -translate-x-1/2 -translate-y-8 rotate-45 z-50"></div>
|
||||
<div className="absolute bottom-0 -right-10 w-12 h-12 bg-gradient-to-tl from-orange-300/20 to-yellow-300/20 transform translate-x-6 translate-y-6 rotate-12 z-50">
|
||||
<div className="w-full h-full rounded-2xl"></div>
|
||||
</div>
|
||||
</Navbar>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,118 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Search } from "lucide-react";
|
||||
|
||||
const DefaultDemo: React.FC = () => {
|
||||
return (
|
||||
<div className="w-full h-full bg-white relative overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="absolute top-0 left-0 right-0 bg-white px-4 py-2 border-b border-gray-100">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-6 h-6 bg-blue-600 rounded flex items-center justify-center">
|
||||
<span className="text-white text-xs font-bold">M</span>
|
||||
</div>
|
||||
<span className="text-gray-900 font-semibold text-sm">
|
||||
MCP Store
|
||||
</span>
|
||||
</div>
|
||||
<div className="bg-gray-900 text-white px-4 py-1 rounded-full text-sm">
|
||||
Get Started
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="absolute top-10 left-0 right-0 bottom-0 px-6 py-8">
|
||||
{/* Hero Section */}
|
||||
<div className="text-center mb-4">
|
||||
<h1 className="text-lg font-bold text-blue-600 mb-2">
|
||||
Default Platform
|
||||
</h1>
|
||||
<p className="text-gray-700 mb-2 text-xs">Clean & Simple Design</p>
|
||||
|
||||
{/* Search Bar */}
|
||||
<div className="max-w-md mx-auto mb-8">
|
||||
<div className="relative">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search services..."
|
||||
className="w-full px-4 py-3 border border-gray-300 rounded-full text-sm focus:outline-none focus:border-blue-500"
|
||||
/>
|
||||
<Search className="absolute right-4 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Services Grid */}
|
||||
<div className="grid grid-cols-4 gap-4 max-w-4xl mx-auto">
|
||||
{/* Service Card 1 */}
|
||||
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||
<h3 className="font-medium text-gray-900 mb-1 text-sm">测试1</h3>
|
||||
<p className="text-xs text-gray-600 mb-2">xpack-opensource-1</p>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
|
||||
Beta
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">Free</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service Card 2 */}
|
||||
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||
<h3 className="font-medium text-gray-900 mb-1 text-sm">
|
||||
xpack-opensource
|
||||
</h3>
|
||||
<p className="text-xs text-gray-600 mb-2">xpack-opensource-1</p>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
|
||||
Beta
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">$0.02 /Per Call</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service Card 3 */}
|
||||
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||
<h3 className="font-medium text-gray-900 mb-1 text-sm">
|
||||
xpack-opensource
|
||||
</h3>
|
||||
<p className="text-xs text-gray-600 mb-2">xpack-opensource</p>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
|
||||
Beta
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">$0.02 /Per Call</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service Card 4 */}
|
||||
<div className="bg-white border border-gray-200 rounded-lg p-4 hover:shadow-md transition-shadow">
|
||||
<h3 className="font-medium text-gray-900 mb-1 text-sm">
|
||||
Pet Store API
|
||||
</h3>
|
||||
<p className="text-xs text-gray-600 mb-2">
|
||||
A comprehensive API for managing pet store...
|
||||
</p>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs">
|
||||
Beta
|
||||
</span>
|
||||
<span className="text-xs text-gray-500">Free</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-white px-6 py-2 border-t border-gray-100">
|
||||
<div className="flex items-center justify-end text-xs text-gray-500">
|
||||
<span>© 2025 Platform</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default DefaultDemo;
|
||||
@@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Card, CardBody } from "@nextui-org/react";
|
||||
import { AboutContent } from "@/components/about/AboutContent";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface AboutProps {
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 flex flex-col justify-between">
|
||||
<Navigation items={navItems} />
|
||||
<div className="relative z-10 mt-20">
|
||||
{/* Clean Background Pattern */}
|
||||
<div className="absolute inset-0 opacity-30">
|
||||
<div
|
||||
className="w-full h-full"
|
||||
style={{
|
||||
backgroundImage: `url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.05'%3E%3Ccircle cx='20' cy='20' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`,
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<main className="flex-1 relative z-10">
|
||||
<div className="max-w-7xl mx-auto px-6 py-12">
|
||||
<Card className="bg-white/90 backdrop-blur-sm border border-white/20 shadow-lg rounded-2xl">
|
||||
<CardBody className="p-8">
|
||||
<AboutContent />
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
import React from 'react';
|
||||
|
||||
const ModernDemo: React.FC = () => {
|
||||
return (
|
||||
<div className="w-full h-full bg-gradient-to-br from-blue-50 to-indigo-100 relative overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="bg-white shadow-sm border-b border-gray-100 px-4 py-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className="w-6 h-6 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-lg"></div>
|
||||
<span className="text-sm font-semibold text-gray-800">Platform</span>
|
||||
</div>
|
||||
<div className="flex space-x-1">
|
||||
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
|
||||
<div className="w-2 h-2 bg-gray-300 rounded-full"></div>
|
||||
<div className="w-2 h-2 bg-gray-300 rounded-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="px-4 py-6 text-center">
|
||||
<div className="mb-3">
|
||||
<h1 className="text-lg font-bold text-gray-900 mb-1">Modern Platform</h1>
|
||||
<p className="text-xs text-gray-600">Clean & Minimalist Design</p>
|
||||
</div>
|
||||
|
||||
{/* CTA Button */}
|
||||
<div className="mb-4">
|
||||
<div className="inline-block bg-gradient-to-r from-blue-500 to-indigo-600 text-white text-xs px-4 py-2 rounded-full shadow-lg">
|
||||
Get Started
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Feature Cards */}
|
||||
<div className="px-4 pb-4">
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="bg-white rounded-xl p-3 shadow-sm border border-gray-100">
|
||||
<div className="w-4 h-4 bg-blue-100 rounded-lg mb-2"></div>
|
||||
<div className="text-xs font-medium text-gray-800 mb-1">Feature 1</div>
|
||||
<div className="text-xs text-gray-500">Modern UI</div>
|
||||
</div>
|
||||
<div className="bg-white rounded-xl p-3 shadow-sm border border-gray-100">
|
||||
<div className="w-4 h-4 bg-indigo-100 rounded-lg mb-2"></div>
|
||||
<div className="text-xs font-medium text-gray-800 mb-1">Feature 2</div>
|
||||
<div className="text-xs text-gray-500">Clean Design</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Decorative Elements */}
|
||||
<div className="absolute top-0 right-0 w-16 h-16 bg-gradient-to-br from-blue-400/20 to-indigo-500/20 rounded-full -translate-y-8 translate-x-8"></div>
|
||||
<div className="absolute bottom-0 left-0 w-12 h-12 bg-gradient-to-tr from-indigo-400/20 to-blue-500/20 rounded-full translate-y-6 -translate-x-6"></div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModernDemo;
|
||||
@@ -0,0 +1,199 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Tabs, Tab, Chip, Card, CardBody, Button } from "@nextui-org/react";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
|
||||
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
|
||||
import { ProductTools } from "@/shared/components/marketplace/ProductTools";
|
||||
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
|
||||
import { Monitor, Code, Settings, Copy } from "lucide-react";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface DetailProps {
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
onCopy: () => void;
|
||||
}
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
onCopy,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
if (!product) {
|
||||
return <ProductNotFound />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 flex flex-col justify-between">
|
||||
<Navigation items={navItems} />
|
||||
<div>
|
||||
{/* Clean Background */}
|
||||
<div className="absolute inset-0 opacity-30">
|
||||
<div
|
||||
className="w-full h-full"
|
||||
style={{
|
||||
backgroundImage: `url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.05'%3E%3Ccircle cx='20' cy='20' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`,
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div className="relative z-10">
|
||||
{/* Modern Product Header */}
|
||||
<div className="pt-20">
|
||||
<div className="mx-auto pt-6 px-6 max-w-7xl">
|
||||
<div className="bg-white/80 backdrop-blur-sm rounded-2xl p-6 shadow-lg border border-white/20">
|
||||
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="mx-auto pb-6 px-6 max-w-7xl">
|
||||
<div className="flex gap-6 mt-6">
|
||||
{/* Left side - Main content */}
|
||||
<div className="flex-1">
|
||||
<Card className="bg-white/90 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-2xl">
|
||||
<CardBody className="p-0">
|
||||
<Tabs
|
||||
selectedKey={activeTab}
|
||||
onSelectionChange={(key) => setActiveTab(key as string)}
|
||||
variant="underlined"
|
||||
color="primary"
|
||||
className="px-6 pt-6"
|
||||
classNames={{
|
||||
tabList:
|
||||
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
|
||||
cursor: "w-full bg-blue-600",
|
||||
tab: "max-w-fit px-0 h-12",
|
||||
tabContent:
|
||||
"group-data-[selected=true]:text-blue-600 font-semibold text-gray-600",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="overview"
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<Monitor className="w-4 h-4" />
|
||||
<span>{t("Overview")}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
<ProductOverview product={product} />
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab
|
||||
key="tools"
|
||||
title={
|
||||
<div className="flex gap-2 items-center">
|
||||
<Code className="w-4 h-4" />
|
||||
<span>{t("Tools")}</span>
|
||||
<Chip
|
||||
size="sm"
|
||||
className="h-4 text-xs bg-blue-600 text-white"
|
||||
>
|
||||
{product.tools.length}
|
||||
</Chip>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6 pt-4">
|
||||
<ProductTools product={product} />
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Right side - Server Config */}
|
||||
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
|
||||
<Card className="bg-white/90 backdrop-blur-sm border border-gray-200/50 shadow-lg rounded-2xl">
|
||||
<CardBody>
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<div className="p-2 bg-blue-600 rounded-lg">
|
||||
<Settings className="w-5 h-5 text-white" />
|
||||
</div>
|
||||
<h3 className="font-semibold text-lg text-gray-900">
|
||||
{t("Configuration")}
|
||||
</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>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* SEO-friendly: Simple text content for search engines */}
|
||||
<div className="hidden" aria-hidden="true">
|
||||
<h2>Tools ({product.tools.length})</h2>
|
||||
{product.tools.length > 0 &&
|
||||
product.tools.map((tool, index) => (
|
||||
<div key={`seo-${product.service_id}-tool-${index}`}>
|
||||
<h4>{tool.name}</h4>
|
||||
<p>{tool.description || ""}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { Sparkles } from "lucide-react";
|
||||
import React from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
interface FooterProps {}
|
||||
|
||||
export const Footer: React.FC<FooterProps> = ({}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
return (
|
||||
<>
|
||||
{/* Modern Footer */}
|
||||
<footer className="relative z-10">
|
||||
<div className="bg-gradient-to-r from-slate-800 via-gray-800 to-slate-900">
|
||||
<div className="mx-auto px-6 py-2 max-w-7xl">
|
||||
<div className=" flex justify-between items-center gap-2">
|
||||
<span className="text-gray-300 text-sm">
|
||||
© 2025 {platformConfig?.name}. All rights reserved.
|
||||
</span>
|
||||
|
||||
<a
|
||||
href="https://xpack.ai"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 text-primary-400 text-xs"
|
||||
>
|
||||
<span>Powered By XPack.AI</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,246 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Spinner } from "@nextui-org/react";
|
||||
import { Search, Sparkles, Zap } from "lucide-react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
Pagination,
|
||||
Card,
|
||||
CardBody,
|
||||
CardFooter,
|
||||
Chip,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
import { ArrowRight } from "lucide-react";
|
||||
import {
|
||||
_DefaultPlatformConfig,
|
||||
usePlatformConfig,
|
||||
} from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import { Faq } from "@/components/marketplace/Faq";
|
||||
|
||||
interface HomeProps {
|
||||
// 状态
|
||||
searchQuery: string;
|
||||
services: ServiceData[];
|
||||
currentPage: number;
|
||||
total: number;
|
||||
pageSize: number;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
|
||||
// 事件处理函数
|
||||
onSearchChange: (value: string) => void;
|
||||
onSearch: () => void;
|
||||
onPageChange: (page: number) => void;
|
||||
|
||||
// 可选配置
|
||||
searchSuggestions?: string[];
|
||||
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Home: React.FC<HomeProps> = ({
|
||||
searchQuery,
|
||||
services,
|
||||
currentPage,
|
||||
total,
|
||||
pageSize,
|
||||
loading,
|
||||
onSearchChange,
|
||||
onSearch,
|
||||
onPageChange,
|
||||
searchSuggestions = [],
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const { t } = useTranslation();
|
||||
const totalPages = Math.ceil(total / pageSize);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 relative overflow-hidden">
|
||||
{/* Decorative Elements */}
|
||||
<div className="absolute top-20 right-10 w-16 h-16 bg-gradient-to-br from-blue-400/20 to-indigo-500/20 rounded-full animate-pulse"></div>
|
||||
<div className="absolute top-40 left-10 w-12 h-12 bg-gradient-to-tr from-indigo-400/20 to-blue-500/20 rounded-full animate-bounce"></div>
|
||||
<div className="absolute bottom-40 right-20 w-8 h-8 bg-gradient-to-bl from-blue-300/30 to-indigo-400/30 rounded-full animate-pulse"></div>
|
||||
<div className="absolute bottom-20 left-1/4 w-6 h-6 bg-gradient-to-tl from-indigo-300/30 to-blue-400/30 rounded-full animate-bounce"></div>
|
||||
|
||||
{/* Modern Navigation */}
|
||||
<Navigation items={navItems} />
|
||||
{/* Modern Hero Section */}
|
||||
<div className="pt-32">
|
||||
<div className="mx-auto px-6 py-20 max-w-6xl">
|
||||
<div className="text-center mb-16">
|
||||
{/* Modern Icon */}
|
||||
<div className="flex justify-center mb-8">
|
||||
<div className="w-12 h-12 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-lg flex items-center justify-center">
|
||||
<Sparkles className="w-6 h-6 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Modern Title */}
|
||||
<h1 className="text-4xl lg:text-6xl font-bold mb-6 text-gray-900 leading-tight">
|
||||
{t(
|
||||
platformConfig.headline || _DefaultPlatformConfig.headline || ""
|
||||
)}
|
||||
</h1>
|
||||
|
||||
{/* Modern Subtitle */}
|
||||
<p className="text-lg text-gray-600 max-w-2xl mx-auto leading-relaxed">
|
||||
{t(
|
||||
platformConfig.subheadline ||
|
||||
_DefaultPlatformConfig.subheadline ||
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Modern Search Bar */}
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<div className="bg-white p-1 rounded-xl shadow-sm border border-gray-100">
|
||||
<div className="flex gap-1">
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
size="lg"
|
||||
placeholder={
|
||||
searchSuggestions.length > 0
|
||||
? t(searchSuggestions[0])
|
||||
: t("Search services...")
|
||||
}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && onSearch()}
|
||||
startContent={<Search className="w-5 h-5 text-gray-400" />}
|
||||
className="w-full"
|
||||
classNames={{
|
||||
input:
|
||||
"text-base text-gray-900 placeholder:text-gray-500",
|
||||
inputWrapper: "h-12 shadow-none px-4 bg-white border-0",
|
||||
}}
|
||||
variant="flat"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
onPress={onSearch}
|
||||
className="bg-gradient-to-r from-blue-500 to-indigo-600 text-white h-12 px-6 rounded-lg shadow-sm"
|
||||
size="lg"
|
||||
>
|
||||
{t("Search")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section>
|
||||
{/* Service List Section */}
|
||||
{loading ? (
|
||||
<div className="mx-auto h-[200px] flex items-center justify-center">
|
||||
<div className="bg-white p-8 rounded-lg shadow-md">
|
||||
<Spinner size="lg" color="primary" />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="py-16">
|
||||
<div className="mx-auto px-6 max-w-7xl">
|
||||
{/* Services 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)]"
|
||||
>
|
||||
<Card className="group h-[200px] w-full hover:shadow-lg transition-all duration-200 cursor-pointer bg-white border border-gray-100 rounded-xl 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="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center">
|
||||
<Zap className="w-4 h-4 text-blue-600" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<h3 className="font-semibold text-gray-900 text-base mb-1 truncate group-hover:text-blue-600 transition-colors">
|
||||
{service.name}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<ArrowRight className="w-4 h-4 text-gray-400 group-hover:text-blue-600 transition-colors" />
|
||||
</div>
|
||||
|
||||
{/* Description */}
|
||||
<p className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
|
||||
{service.short_description ||
|
||||
t("No description available")}
|
||||
</p>
|
||||
</CardBody>
|
||||
|
||||
{/* Footer */}
|
||||
<CardFooter className="pt-0 px-4 pb-4">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
{/* Tools count */}
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-2 h-2 bg-blue-600 rounded-full"></div>
|
||||
<span className="text-sm font-medium text-gray-700">
|
||||
{t("{{count}} Tools", {
|
||||
count: service.tools.length,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Price */}
|
||||
<div className="flex flex-col items-end">
|
||||
<Price
|
||||
price={service.price}
|
||||
charge_type={service.charge_type}
|
||||
input_token_price={service.input_token_price}
|
||||
output_token_price={service.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Pagination */}
|
||||
{totalPages > 1 && (
|
||||
<div className="flex justify-center">
|
||||
<Pagination
|
||||
total={totalPages}
|
||||
page={currentPage}
|
||||
onChange={onPageChange}
|
||||
showControls
|
||||
color="primary"
|
||||
variant="light"
|
||||
size="lg"
|
||||
classNames={{
|
||||
wrapper: "gap-2",
|
||||
item: "w-10 h-10 text-sm font-medium",
|
||||
cursor:
|
||||
"bg-gradient-to-r from-blue-500 to-indigo-600 shadow-sm",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
<Faq />
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,110 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Navbar,
|
||||
NavbarContent,
|
||||
NavbarMenuToggle,
|
||||
NavbarMenu,
|
||||
NavbarMenuItem,
|
||||
} from "@nextui-org/react";
|
||||
import { ArrowRightIcon } from "lucide-react";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { useAuth } from "@/shared/lib/useAuth";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface NavigationProps {
|
||||
items?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Modern Navigation */}
|
||||
<Navbar
|
||||
onMenuOpenChange={setIsMenuOpen}
|
||||
maxWidth="full"
|
||||
className="mt-0 rounded-full bg-white/95 backdrop-blur-[10px] border-1 border-white/20 fixed top-2 sm:top-5 max-w-7xl mx-auto"
|
||||
height="66px"
|
||||
isBordered={false}
|
||||
>
|
||||
<NavbarContent>
|
||||
<NavbarMenuToggle
|
||||
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
|
||||
className="sm:hidden text-gray-700"
|
||||
/>
|
||||
<div className="flex justify-start bg-transparent w-max">
|
||||
<Link href="/">
|
||||
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="hidden lg:flex gap-6 justify-center">
|
||||
{items?.map((item) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
target={item.target}
|
||||
className="text-sm text-gray-500"
|
||||
>
|
||||
{t(item.label)}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</NavbarContent>
|
||||
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
|
||||
<div className="hidden sm:block">
|
||||
<Button
|
||||
color="primary"
|
||||
className="bg-gradient-to-r from-blue-500 to-purple-600 text-white hover:from-blue-600 hover:to-purple-700 flex items-center justify-center gap-4 pr-1 h-[45px] shadow-lg"
|
||||
radius="full"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
<b className="text-md">{t("Get Started")}</b>
|
||||
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
|
||||
<ArrowRightIcon
|
||||
size={16}
|
||||
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px] text-white"
|
||||
/>
|
||||
</div>
|
||||
</Button>
|
||||
</div>
|
||||
<div className="sm:hidden">
|
||||
<Button
|
||||
className="bg-gradient-to-r from-blue-500 to-purple-600 text-white hover:from-blue-600 hover:to-purple-700"
|
||||
onPress={handleLogin}
|
||||
size="sm"
|
||||
>
|
||||
<b className="text-md">{t("Get Started")}</b>
|
||||
</Button>
|
||||
</div>
|
||||
</NavbarContent>
|
||||
<NavbarMenu className="pt-6 pb-6 bg-white/95 backdrop-blur-sm">
|
||||
<NavbarMenuItem className="mt-4">
|
||||
<Button
|
||||
color="primary"
|
||||
className="w-full bg-gradient-to-r from-blue-500 to-purple-600 text-white flex items-center justify-between gap-4 pr-1 h-[45px]"
|
||||
radius="full"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
<b className="text-md">{t("Get Started")}</b>
|
||||
<div className="w-8 h-8 bg-white/20 flex items-center justify-center rounded-full">
|
||||
<ArrowRightIcon
|
||||
size={16}
|
||||
className="transition-transform duration-200 ease-in-out group-hover:translate-x-[3px]"
|
||||
/>
|
||||
</div>
|
||||
</Button>
|
||||
</NavbarMenuItem>
|
||||
</NavbarMenu>
|
||||
</Navbar>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { AboutContent } from "@/components/about/AboutContent";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface AboutProps {
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 absolute top-0 left-0 right-0 bottom-0 flex flex-col justify-between bg-white">
|
||||
<Navigation items={navItems} />
|
||||
|
||||
<main className="flex-1 pt-32">
|
||||
<div className="max-w-7xl mx-auto px-6 pb-12">
|
||||
<AboutContent />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,103 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { ShoppingBag, Search, Tag, Star } from "lucide-react";
|
||||
|
||||
const TemuDemo: React.FC = () => {
|
||||
return (
|
||||
<div className="w-full h-full bg-gradient-to-r from-orange-400 via-orange-500 to-red-500 relative overflow-hidden">
|
||||
{/* Header */}
|
||||
<div className="absolute top-0 left-0 right-0 bg-white/10 backdrop-blur-sm px-3 py-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<ShoppingBag className="w-4 h-4 text-white" />
|
||||
<span className="text-white font-bold text-sm">MCP Store</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
|
||||
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
|
||||
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Hero Section */}
|
||||
<div className="absolute top-8 left-0 right-0 px-3 py-4">
|
||||
<div className="text-center">
|
||||
{/* Title */}
|
||||
<h1 className="text-lg font-bold text-white mb-1">
|
||||
Discover Amazing Services
|
||||
</h1>
|
||||
|
||||
{/* Subtitle */}
|
||||
<p className="text-xs text-white/90 mb-3">
|
||||
Find the perfect MCP service for your needs
|
||||
</p>
|
||||
|
||||
{/* Search Bar */}
|
||||
<div className="flex gap-1 mb-3">
|
||||
<div className="flex-1 bg-white rounded-md px-2 py-1 flex items-center gap-1">
|
||||
<Search className="w-3 h-3 text-gray-400" />
|
||||
<span className="text-xs text-gray-500">Search...</span>
|
||||
</div>
|
||||
<div className="bg-white px-3 py-1 rounded-md">
|
||||
<span className="text-xs text-orange-500 font-medium">Go</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Products Section */}
|
||||
<div className="absolute top-[150px] left-0 right-0 bg-white rounded-t-lg px-3 py-3">
|
||||
{/* Section Header */}
|
||||
<div className="flex items-center gap-1 mb-2">
|
||||
<Tag className="w-3 h-3 text-orange-500" />
|
||||
<span className="text-sm font-bold text-gray-900">Featured</span>
|
||||
</div>
|
||||
|
||||
{/* Products Grid */}
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{/* Product 1 */}
|
||||
<div className="bg-gray-50 rounded-lg p-2 border border-gray-100">
|
||||
<div className="mb-1">
|
||||
<h3 className="text-xs font-semibold text-gray-900 line-clamp-1">
|
||||
AI Assistant
|
||||
</h3>
|
||||
<p className="text-xs text-gray-600 line-clamp-1">
|
||||
Smart AI helper
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs font-bold text-orange-600">$9.99</span>
|
||||
<div className="flex items-center gap-1">
|
||||
<Star className="w-2 h-2 text-yellow-400 fill-current" />
|
||||
<span className="text-xs text-gray-500">4.8</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Product 2 */}
|
||||
<div className="bg-gray-50 rounded-lg p-2 border border-gray-100">
|
||||
<div className="mb-1">
|
||||
<h3 className="text-xs font-semibold text-gray-900 line-clamp-1">
|
||||
Data Analyzer
|
||||
</h3>
|
||||
<p className="text-xs text-gray-600 line-clamp-1">
|
||||
Powerful analytics
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs font-bold text-orange-600">$14.99</span>
|
||||
<div className="flex items-center gap-1">
|
||||
<Star className="w-2 h-2 text-yellow-400 fill-current" />
|
||||
<span className="text-xs text-gray-500">4.9</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TemuDemo;
|
||||
@@ -0,0 +1,205 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { Tabs, Tab, Chip, Card, CardBody, Button } from "@nextui-org/react";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
|
||||
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
|
||||
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
|
||||
import { FileText, Wrench, Cog, Copy } from "lucide-react";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { Footer } from "./Footer";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface DetailProps {
|
||||
product: ServiceData;
|
||||
breadcrumbs?: {
|
||||
link: string;
|
||||
name: string;
|
||||
}[];
|
||||
url?: string;
|
||||
mcpName?: string;
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
onCopy: () => void;
|
||||
}
|
||||
|
||||
export const Detail: React.FC<DetailProps> = ({
|
||||
product,
|
||||
breadcrumbs,
|
||||
url,
|
||||
mcpName,
|
||||
navItems = [],
|
||||
onCopy,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
if (!product) {
|
||||
return <ProductNotFound />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 flex flex-col justify-between">
|
||||
<Navigation items={navItems} />
|
||||
<div>
|
||||
{/* Temu Style Product Header */}
|
||||
<div className="bg-white border-b border-gray-200 shadow-sm pt-20">
|
||||
<div className="mx-auto p-6 max-w-7xl">
|
||||
{/* Breadcrumbs */}
|
||||
{breadcrumbs && breadcrumbs.length > 0 && (
|
||||
<nav className="mb-4">
|
||||
<ol className="flex items-center space-x-2 text-sm text-gray-600">
|
||||
{breadcrumbs.map((crumb, index) => (
|
||||
<li key={index} className="flex items-center">
|
||||
{index > 0 && (
|
||||
<span className="mx-2 text-gray-400">/</span>
|
||||
)}
|
||||
<a
|
||||
href={crumb.link}
|
||||
className="hover:text-orange-500 transition-colors"
|
||||
>
|
||||
{crumb.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</nav>
|
||||
)}
|
||||
|
||||
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<div className="mx-auto p-6 max-w-7xl mt-6">
|
||||
<Card className="bg-white border border-gray-200 shadow-sm">
|
||||
<CardBody className="p-0">
|
||||
<Tabs
|
||||
selectedKey={activeTab}
|
||||
onSelectionChange={(key) => setActiveTab(key as string)}
|
||||
variant="underlined"
|
||||
color="warning"
|
||||
className="px-6 pt-6"
|
||||
classNames={{
|
||||
tabList:
|
||||
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
|
||||
cursor: "w-full bg-orange-500",
|
||||
tab: "max-w-fit px-0 h-12",
|
||||
tabContent:
|
||||
"group-data-[selected=true]:text-orange-600 font-medium text-gray-700",
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="overview"
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<FileText className="w-4 h-4" />
|
||||
<span>{t("Overview")}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6">
|
||||
<ProductOverview product={product} />
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab
|
||||
key="tools"
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<Wrench className="w-4 h-4" />
|
||||
<span>{t("Tools")}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-2">
|
||||
<div className="space-y-4 px-3">
|
||||
{product.tools.length > 0 ? (
|
||||
product.tools.map((tool, index) => (
|
||||
<Card
|
||||
radius="sm"
|
||||
key={`${product.service_id}-tool-${index}`}
|
||||
shadow="none"
|
||||
className="border-1"
|
||||
>
|
||||
<CardBody>
|
||||
<h4 className="font-semibold text-sm mb-2 text-orange-600">
|
||||
{tool.name}
|
||||
</h4>
|
||||
<p className="text-sm mb-3">
|
||||
{tool.description ||
|
||||
t("No description available")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<Card>
|
||||
<CardBody>
|
||||
<p className="text-center">
|
||||
{t("No tools available in this service.")}
|
||||
</p>
|
||||
</CardBody>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab
|
||||
key="config"
|
||||
title={
|
||||
<div className="flex items-center gap-2">
|
||||
<Cog className="w-4 h-4" />
|
||||
<span>{t("Configuration")}</span>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className="p-6">
|
||||
{/* Code Snippet */}
|
||||
<Card className="w-full 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>
|
||||
</div>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { ShoppingBag, Star, Heart } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface FooterProps {}
|
||||
|
||||
export const Footer: React.FC<FooterProps> = ({}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
{/* Temu Style Footer */}
|
||||
<footer className="bg-gray-50 border-t border-gray-200">
|
||||
<div className="mx-auto px-6 pt-12 pb-6 max-w-7xl">
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
|
||||
{/* Company Info */}
|
||||
<div>
|
||||
<h3 className="text-lg font-bold text-gray-900 mb-4">
|
||||
{platformConfig?.name}
|
||||
</h3>
|
||||
<p className="text-gray-600 text-sm mb-4">
|
||||
{t(
|
||||
"A marketplace for AI tools and services. Discover and integrate powerful AI solutions for your projects."
|
||||
)}
|
||||
</p>
|
||||
<div className="flex items-center gap-2 text-orange-500">
|
||||
<ShoppingBag className="w-5 h-5" />
|
||||
<span className="text-sm font-medium">
|
||||
{t("AI Tools Marketplace")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bottom Section */}
|
||||
<div className="border-t border-gray-200 pt-8">
|
||||
<div className="flex flex-col md:flex-row justify-between items-center gap-4">
|
||||
{/* Copyright */}
|
||||
<div className="flex items-center gap-2 text-gray-600 text-sm">
|
||||
<span>
|
||||
© 2025 {platformConfig?.name}. All rights reserved.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Powered By */}
|
||||
<div className="flex items-center gap-4">
|
||||
<a
|
||||
href="https://xpack.ai"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 text-gray-600 hover:text-orange-500 transition-colors text-sm font-medium"
|
||||
>
|
||||
<div className="flex items-center gap-2 bg-white px-3 py-1 rounded-full border border-gray-200 hover:border-orange-200 transition-all duration-200">
|
||||
<Star className="w-4 h-4 text-orange-500" />
|
||||
<span>Powered By XPack.AI</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,224 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { CardFooter, Spinner } from "@nextui-org/react";
|
||||
import { Search, ShoppingBag, Tag, TrendingUp } from "lucide-react";
|
||||
import {
|
||||
Input,
|
||||
Button,
|
||||
Pagination,
|
||||
Card,
|
||||
CardBody,
|
||||
Chip,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { ServiceData } from "@/shared/types/marketplace";
|
||||
import { Price } from "@/shared/components/marketplace/Price";
|
||||
import {
|
||||
_DefaultPlatformConfig,
|
||||
usePlatformConfig,
|
||||
} from "@/shared/contexts/PlatformConfigContext";
|
||||
import { Footer } from "./Footer";
|
||||
import { Navigation } from "./Navigation";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
import { Faq } from "@/components/marketplace/Faq";
|
||||
|
||||
interface HomeProps {
|
||||
// 状态
|
||||
searchQuery: string;
|
||||
services: ServiceData[];
|
||||
currentPage: number;
|
||||
total: number;
|
||||
pageSize: number;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
|
||||
// 事件处理函数
|
||||
onSearchChange: (value: string) => void;
|
||||
onSearch: () => void;
|
||||
onPageChange: (page: number) => void;
|
||||
|
||||
// 可选配置
|
||||
searchSuggestions?: string[];
|
||||
|
||||
// navigation items
|
||||
navItems?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Home: React.FC<HomeProps> = ({
|
||||
searchQuery,
|
||||
services,
|
||||
currentPage,
|
||||
total,
|
||||
pageSize,
|
||||
loading,
|
||||
error,
|
||||
onSearchChange,
|
||||
onSearch,
|
||||
onPageChange,
|
||||
navItems = [],
|
||||
}) => {
|
||||
const { platformConfig } = usePlatformConfig();
|
||||
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 absolute top-0 left-0 right-0 bottom-0">
|
||||
<Navigation items={navItems} />
|
||||
|
||||
{/* Temu Style Hero Section */}
|
||||
<div className="bg-gradient-to-r from-orange-400 via-orange-500 to-red-500 pt-20">
|
||||
<div className="mx-auto px-6 py-16 max-w-7xl">
|
||||
<div className="text-center mb-12">
|
||||
{/* Icon */}
|
||||
<div className="flex justify-center mb-6">
|
||||
<div className="bg-white/20 p-4 rounded-2xl backdrop-blur-sm">
|
||||
<ShoppingBag className="w-10 h-10 text-white" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Title */}
|
||||
<h1 className="text-4xl lg:text-6xl font-bold mb-6 text-white">
|
||||
{t(
|
||||
platformConfig.headline || _DefaultPlatformConfig.headline || ""
|
||||
)}
|
||||
</h1>
|
||||
|
||||
{/* Subtitle */}
|
||||
<p className="text-xl text-white/90 mb-8 max-w-2xl mx-auto">
|
||||
{t(
|
||||
platformConfig.subheadline ||
|
||||
_DefaultPlatformConfig.subheadline ||
|
||||
""
|
||||
)}
|
||||
</p>
|
||||
|
||||
{/* Search Bar */}
|
||||
<div className="max-w-2xl mx-auto mb-8">
|
||||
<div className="flex gap-3">
|
||||
<Input
|
||||
placeholder={t("Search services...")}
|
||||
value={searchQuery}
|
||||
onChange={(e) => onSearchChange(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && onSearch()}
|
||||
startContent={<Search className="w-5 h-5 text-gray-400" />}
|
||||
className="flex-1"
|
||||
classNames={{
|
||||
input: "text-lg",
|
||||
inputWrapper: "h-14 bg-white shadow-lg border-0",
|
||||
}}
|
||||
radius="lg"
|
||||
/>
|
||||
<Button
|
||||
onPress={onSearch}
|
||||
className="bg-white text-orange-500 hover:bg-gray-50 font-semibold px-8 h-14 shadow-lg"
|
||||
radius="lg"
|
||||
>
|
||||
{t("Search")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Products Section */}
|
||||
<div className="mx-auto px-6 py-12 max-w-7xl">
|
||||
{/* Section Header */}
|
||||
<div className="flex items-center justify-between mb-8">
|
||||
<div className="flex items-center gap-3">
|
||||
<Tag className="w-6 h-6 text-orange-500" />
|
||||
<h2 className="text-2xl font-bold text-gray-900">
|
||||
{searchQuery ? t("Search Results") : t("Featured Products")}
|
||||
</h2>
|
||||
{searchQuery && (
|
||||
<Chip color="warning" variant="flat">
|
||||
{total} {t("results")}
|
||||
</Chip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Loading State */}
|
||||
{loading && (
|
||||
<div className="flex justify-center items-center py-20">
|
||||
<Spinner size="lg" color="warning" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Products Grid */}
|
||||
{!loading && (
|
||||
<>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 mb-12">
|
||||
{services.map((service) => (
|
||||
<Link
|
||||
key={service.service_id}
|
||||
href={`/marketplace/${service.service_id}`}
|
||||
>
|
||||
<Card className="group hover:shadow-xl transition-all duration-300 hover:-translate-y-1 border border-gray-200 hover:border-orange-200 h-[200px]">
|
||||
<CardBody className="p-0">
|
||||
{/* Product Info */}
|
||||
<div className="p-4">
|
||||
<h3 className="font-semibold text-gray-900 mb-2 line-clamp-2 group-hover:text-orange-600 transition-colors">
|
||||
{service.name}
|
||||
</h3>
|
||||
<p className="text-gray-600 text-sm mb-3 line-clamp-2">
|
||||
{service.short_description ||
|
||||
service.long_description ||
|
||||
"No description available"}
|
||||
</p>
|
||||
</div>
|
||||
</CardBody>
|
||||
<CardFooter>
|
||||
{/* Price */}
|
||||
<div className="flex items-center gap-2">
|
||||
<Price
|
||||
price={service.price}
|
||||
charge_type={service.charge_type}
|
||||
input_token_price={service.input_token_price}
|
||||
output_token_price={service.output_token_price}
|
||||
/>
|
||||
</div>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Pagination */}
|
||||
{totalPages > 1 && (
|
||||
<div className="flex justify-center">
|
||||
<Pagination
|
||||
total={totalPages}
|
||||
page={currentPage}
|
||||
onChange={onPageChange}
|
||||
color="warning"
|
||||
size="lg"
|
||||
showControls
|
||||
className="gap-2"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<Faq />
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Button } from "@nextui-org/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
Navbar,
|
||||
NavbarContent,
|
||||
NavbarMenuToggle,
|
||||
NavbarMenu,
|
||||
NavbarMenuItem,
|
||||
} from "@nextui-org/react";
|
||||
import { ArrowRightIcon, ShoppingCart } from "lucide-react";
|
||||
import { DynamicLogo } from "@/shared/components/DynamicLogo";
|
||||
import { useAuth } from "@/shared/lib/useAuth";
|
||||
import { NavigationItem } from "@/shared/components/Navigation";
|
||||
|
||||
interface NavigationProps {
|
||||
items?: NavigationItem[];
|
||||
}
|
||||
|
||||
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
|
||||
const { t } = useTranslation();
|
||||
const { handleLogin } = useAuth();
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Temu Style Navigation */}
|
||||
<Navbar
|
||||
onMenuOpenChange={setIsMenuOpen}
|
||||
maxWidth="full"
|
||||
className="mt-0 bg-white border-b border-gray-200 shadow-sm fixed top-0 z-50"
|
||||
height="70px"
|
||||
isBordered={false}
|
||||
classNames={{
|
||||
wrapper: "max-w-7xl mx-auto",
|
||||
}}
|
||||
>
|
||||
<NavbarContent>
|
||||
<NavbarMenuToggle
|
||||
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
|
||||
className="sm:hidden text-gray-700"
|
||||
/>
|
||||
<div className="flex justify-start bg-transparent w-max">
|
||||
<Link href="/">
|
||||
<DynamicLogo alt="Platform Logo" className="h-[24px]" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="hidden lg:flex gap-8 justify-center ml-8">
|
||||
{items?.map((item) => (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
target={item.target}
|
||||
className="text-gray-700 hover:text-orange-500 font-medium transition-colors"
|
||||
>
|
||||
{t(item.label)}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</NavbarContent>
|
||||
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
|
||||
<div className="hidden sm:flex items-center gap-3">
|
||||
<Button
|
||||
className="bg-orange-500 hover:bg-orange-600 text-white font-semibold px-6 h-[40px] transition-all duration-200"
|
||||
radius="md"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
{t("Sign In")}
|
||||
</Button>
|
||||
</div>
|
||||
<div className="sm:hidden">
|
||||
<Button
|
||||
className="bg-orange-500 hover:bg-orange-600 text-white font-semibold"
|
||||
onPress={handleLogin}
|
||||
size="sm"
|
||||
>
|
||||
{t("Sign In")}
|
||||
</Button>
|
||||
</div>
|
||||
</NavbarContent>
|
||||
<NavbarMenu className="pt-6 pb-6 bg-white border-r border-gray-200">
|
||||
<NavbarMenuItem className="mb-4">
|
||||
<Link
|
||||
href="/"
|
||||
className="text-gray-700 hover:text-orange-500 font-medium text-lg"
|
||||
>
|
||||
Home
|
||||
</Link>
|
||||
</NavbarMenuItem>
|
||||
<NavbarMenuItem className="mb-4">
|
||||
<Link
|
||||
href="/marketplace"
|
||||
className="text-gray-700 hover:text-orange-500 font-medium text-lg"
|
||||
>
|
||||
Marketplace
|
||||
</Link>
|
||||
</NavbarMenuItem>
|
||||
<NavbarMenuItem className="mt-6">
|
||||
<Button
|
||||
className="w-full bg-orange-500 hover:bg-orange-600 text-white font-semibold h-[45px]"
|
||||
radius="md"
|
||||
onPress={handleLogin}
|
||||
>
|
||||
{t("Sign In")}
|
||||
</Button>
|
||||
</NavbarMenuItem>
|
||||
</NavbarMenu>
|
||||
</Navbar>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,131 @@
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
Button,
|
||||
Input,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { User } from "@/types/user";
|
||||
|
||||
interface AdminRechargeModalProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
user: User | null;
|
||||
onRecharge: (id: string, amount: number) => Promise<boolean>;
|
||||
}
|
||||
|
||||
export const AdminRechargeModal: React.FC<AdminRechargeModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
user,
|
||||
onRecharge,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [amount, setAmount] = useState<string>("");
|
||||
const [error, setError] = useState<string>("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = e.target.value;
|
||||
// 只允许输入数字和小数点
|
||||
if (/^\d*\.?\d*$/.test(value) || value === "") {
|
||||
setAmount(value);
|
||||
setError("");
|
||||
}
|
||||
};
|
||||
|
||||
const handleRecharge = async () => {
|
||||
const numAmount = parseFloat(amount);
|
||||
if (isNaN(numAmount) || numAmount <= 0) {
|
||||
setError(t("Please enter a valid amount"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (numAmount < 1) {
|
||||
setError(t("Minimum recharge amount is $1"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
setError(t("User not selected"));
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const success = await onRecharge(user.id, numAmount);
|
||||
|
||||
if (success) {
|
||||
handleClose();
|
||||
}
|
||||
} catch (error) {
|
||||
setError(t("Network error, please try again"));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAmount("");
|
||||
setError("");
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={handleClose} size="sm">
|
||||
<ModalContent>
|
||||
{() => (
|
||||
<>
|
||||
<ModalHeader className="flex flex-col gap-1">
|
||||
{t("Recharge User")}
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
{user && (
|
||||
<div className="mb-4 p-3 bg-gray-50 rounded-lg">
|
||||
<p className="text-sm text-gray-600">
|
||||
{t("User")}: {user.email}
|
||||
</p>
|
||||
<p className="text-sm text-gray-600">
|
||||
{t("Current Balance")}: ${user.balance.toFixed(2)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<Input
|
||||
autoFocus
|
||||
label={t("Recharge Amount")}
|
||||
placeholder="0.00"
|
||||
value={amount}
|
||||
onChange={handleAmountChange}
|
||||
startContent={
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<span className="text-default-400 text-small">$</span>
|
||||
</div>
|
||||
}
|
||||
isInvalid={!!error}
|
||||
errorMessage={error}
|
||||
type="number"
|
||||
/>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="danger" variant="light" onPress={handleClose}>
|
||||
{t("Cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
onPress={handleRecharge}
|
||||
isLoading={loading}
|
||||
isDisabled={!amount || !!error}
|
||||
>
|
||||
{t("Confirm")}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</>
|
||||
)}
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
@@ -15,11 +15,10 @@ const UserManagement: React.FC = () => {
|
||||
const {
|
||||
users,
|
||||
loading,
|
||||
searchQuery,
|
||||
pagination,
|
||||
handleDeleteUser,
|
||||
setSearch,
|
||||
setPage,
|
||||
handleRechargeUser,
|
||||
} = useUserManagement();
|
||||
|
||||
// Modal states
|
||||
@@ -54,22 +53,26 @@ const UserManagement: React.FC = () => {
|
||||
setDeleteModal({ isOpen: false, user: null });
|
||||
}, []);
|
||||
|
||||
const handleRecharge = useCallback(
|
||||
async (id: string, amount: number): Promise<boolean> => {
|
||||
return await handleRechargeUser(id, amount);
|
||||
},
|
||||
[handleRechargeUser]
|
||||
);
|
||||
|
||||
return (
|
||||
<DashboardDemoContent
|
||||
title={t("User Management")}
|
||||
description={t("Manage registered users, view user information, and handle user operations")}
|
||||
description={t(
|
||||
"Manage registered users, view user information, and handle user operations"
|
||||
)}
|
||||
>
|
||||
<div className="space-y-6 w-full">
|
||||
{/* comming soon:Filters */}
|
||||
{/* <UserFiltersBar
|
||||
searchQuery={searchQuery}
|
||||
onSearchChange={setSearch}
|
||||
/> */}
|
||||
|
||||
<UserTable
|
||||
users={users}
|
||||
loading={loading}
|
||||
onDelete={handleDeleteUserClick}
|
||||
onRecharge={handleRecharge}
|
||||
pagination={pagination}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
@@ -80,9 +83,7 @@ const UserManagement: React.FC = () => {
|
||||
onClose={handleCloseDeleteModal}
|
||||
onConfirm={handleConfirmDelete}
|
||||
title={t("Delete User")}
|
||||
description={t(
|
||||
"Are you sure you want to delete this user? "
|
||||
)}
|
||||
description={t("Are you sure you want to delete this user? ")}
|
||||
/>
|
||||
</DashboardDemoContent>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -11,16 +11,18 @@ import {
|
||||
Button,
|
||||
Pagination,
|
||||
Tooltip,
|
||||
Spinner
|
||||
} from '@nextui-org/react';
|
||||
import { useTranslation } from '@/shared/lib/useTranslation';
|
||||
import { User } from '@/types/user';
|
||||
import { Trash2 } from 'lucide-react';
|
||||
Spinner,
|
||||
} from "@nextui-org/react";
|
||||
import { useTranslation } from "@/shared/lib/useTranslation";
|
||||
import { User } from "@/types/user";
|
||||
import { Trash2, CreditCard } from "lucide-react";
|
||||
import { AdminRechargeModal } from "@/components/user-management/AdminRechargeModal";
|
||||
|
||||
interface UserTableProps {
|
||||
users: User[];
|
||||
loading?: boolean;
|
||||
onDelete: (user: User) => void;
|
||||
onRecharge: (id: string, amount: number) => Promise<boolean>;
|
||||
pagination: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
@@ -33,6 +35,7 @@ export const UserTable: React.FC<UserTableProps> = ({
|
||||
users,
|
||||
loading = false,
|
||||
onDelete,
|
||||
onRecharge,
|
||||
pagination,
|
||||
onPageChange,
|
||||
}) => {
|
||||
@@ -45,10 +48,25 @@ export const UserTable: React.FC<UserTableProps> = ({
|
||||
// 直接显示传入的用户数据(已经是当前页的数据)
|
||||
const items = users;
|
||||
|
||||
const [isRechargeModalOpen, setIsRechargeModalOpen] = React.useState(false);
|
||||
const [selectedUser, setSelectedUser] = React.useState<User | null>(null);
|
||||
|
||||
const handleDelete = React.useCallback((user: User) => {
|
||||
onDelete(user);
|
||||
}, [onDelete]);
|
||||
const handleDelete = React.useCallback(
|
||||
(user: User) => {
|
||||
onDelete(user);
|
||||
},
|
||||
[onDelete]
|
||||
);
|
||||
|
||||
const handleRecharge = React.useCallback((user: User) => {
|
||||
setSelectedUser(user);
|
||||
setIsRechargeModalOpen(true);
|
||||
}, []);
|
||||
|
||||
const handleRechargeClose = React.useCallback(() => {
|
||||
setIsRechargeModalOpen(false);
|
||||
setSelectedUser(null);
|
||||
}, []);
|
||||
|
||||
if (loading && users.length === 0) {
|
||||
return (
|
||||
@@ -68,33 +86,50 @@ export const UserTable: React.FC<UserTableProps> = ({
|
||||
removeWrapper
|
||||
>
|
||||
<TableHeader>
|
||||
<TableColumn>{t('Email')}</TableColumn>
|
||||
<TableColumn>{t('Register Date')}</TableColumn>
|
||||
<TableColumn>{t('Balance')}</TableColumn>
|
||||
<TableColumn>{t('Actions')}</TableColumn>
|
||||
<TableColumn>{t("Email")}</TableColumn>
|
||||
<TableColumn>{t("Register Date")}</TableColumn>
|
||||
<TableColumn>{t("Balance")}</TableColumn>
|
||||
<TableColumn>{t("Actions")}</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody
|
||||
items={items}
|
||||
isLoading={loading}
|
||||
loadingContent={<Spinner />}
|
||||
emptyContent={t('No users found')}
|
||||
emptyContent={t("No users found")}
|
||||
>
|
||||
{(user) => (
|
||||
<TableRow key={user.id}>
|
||||
<TableCell>
|
||||
<span className="text-sm">{user.email}</span>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{user.created_at || '-'}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{user.balance.toFixed(2) || "-"}
|
||||
</TableCell>
|
||||
<TableCell>{user.created_at || "-"}</TableCell>
|
||||
<TableCell>{user.balance.toFixed(2) || "-"}</TableCell>
|
||||
|
||||
<TableCell>
|
||||
<div className="relative flex items-center gap-2">
|
||||
<Tooltip
|
||||
content={t("Recharge User")}
|
||||
color="primary"
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
variant="light"
|
||||
color="primary"
|
||||
onPress={() => handleRecharge(user)}
|
||||
>
|
||||
<CreditCard className="w-4 h-4" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip content={t('Delete User')} color="danger" closeDelay={0}>
|
||||
<Tooltip
|
||||
content={t("Delete User")}
|
||||
color="danger"
|
||||
closeDelay={0}
|
||||
disableAnimation
|
||||
>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="sm"
|
||||
@@ -124,6 +159,14 @@ export const UserTable: React.FC<UserTableProps> = ({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Admin Recharge Modal */}
|
||||
<AdminRechargeModal
|
||||
isOpen={isRechargeModalOpen}
|
||||
onClose={handleRechargeClose}
|
||||
user={selectedUser}
|
||||
onRecharge={onRecharge}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -44,7 +44,7 @@ export const useAdminLogin = () => {
|
||||
// call store logout method
|
||||
adminLogOut();
|
||||
// redirect to login page
|
||||
router.push("/admin-signin");
|
||||
router.push("/admin");
|
||||
toast.success(i18n.t("Logged out successfully"));
|
||||
};
|
||||
|
||||
@@ -53,4 +53,4 @@ export const useAdminLogin = () => {
|
||||
adminLogin,
|
||||
adminLogout,
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,119 @@
|
||||
import { useState, useCallback, useEffect } from "react";
|
||||
import { HomepageConfig } from "@/services/homepageConfigService";
|
||||
import {
|
||||
FaqItem,
|
||||
TopNavigationItem,
|
||||
EmbeddedHtmlConfig,
|
||||
} from "@/shared/types/system";
|
||||
import { homepageConfigService } from "@/services/homepageConfigService";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { revalidatePlatformConfig } from "@/app/actions/revalidate";
|
||||
|
||||
export const useHomepageConfigManagement = () => {
|
||||
const { updateClientConfig } = usePlatformConfig();
|
||||
|
||||
// homepage config state
|
||||
const [homepageConfig, setHomepageConfig] = useState<HomepageConfig>({
|
||||
faq: [],
|
||||
top_navigation: [],
|
||||
embeded_html: {
|
||||
is_enabled: false,
|
||||
html: "",
|
||||
},
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// load homepage config
|
||||
const loadHomepageConfig = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const config = await homepageConfigService.getHomepageConfig();
|
||||
setHomepageConfig(config);
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Failed to load homepage config";
|
||||
setError(errorMessage);
|
||||
console.error("Failed to load homepage config:", err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// save homepage config
|
||||
const saveHomepageConfig = useCallback(
|
||||
async (config: {
|
||||
faq?: FaqItem[];
|
||||
top_navigation?: TopNavigationItem[];
|
||||
embeded_html?: EmbeddedHtmlConfig;
|
||||
}): Promise<boolean> => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
try {
|
||||
const result = await homepageConfigService.updateHomepageConfig(config);
|
||||
if (result) {
|
||||
updateClientConfig(config);
|
||||
await revalidatePlatformConfig();
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Failed to save homepage config";
|
||||
setError(errorMessage);
|
||||
console.error("Failed to save homepage config:", err);
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
// save FAQ data
|
||||
const saveFaqConfig = useCallback(
|
||||
async (faqs: FaqItem[]): Promise<boolean> => {
|
||||
return await saveHomepageConfig({ faq: faqs });
|
||||
},
|
||||
[saveHomepageConfig]
|
||||
);
|
||||
|
||||
// save navigation data
|
||||
const saveNavigationConfig = useCallback(
|
||||
async (navigationItems: TopNavigationItem[]): Promise<boolean> => {
|
||||
return await saveHomepageConfig({ top_navigation: navigationItems });
|
||||
},
|
||||
[saveHomepageConfig]
|
||||
);
|
||||
|
||||
// save embedded HTML data
|
||||
const saveEmbeddedHtmlConfig = useCallback(
|
||||
async (htmlData: EmbeddedHtmlConfig): Promise<boolean> => {
|
||||
return await saveHomepageConfig({ embeded_html: htmlData });
|
||||
},
|
||||
[saveHomepageConfig]
|
||||
);
|
||||
|
||||
// clear error
|
||||
const clearError = useCallback(() => setError(null), []);
|
||||
|
||||
// load config on init
|
||||
useEffect(() => {
|
||||
loadHomepageConfig();
|
||||
}, [loadHomepageConfig]);
|
||||
|
||||
return {
|
||||
// state
|
||||
homepageConfig,
|
||||
loading,
|
||||
error,
|
||||
|
||||
// actions
|
||||
loadHomepageConfig,
|
||||
saveHomepageConfig,
|
||||
saveFaqConfig,
|
||||
saveNavigationConfig,
|
||||
saveEmbeddedHtmlConfig,
|
||||
clearError,
|
||||
};
|
||||
};
|
||||
@@ -11,9 +11,11 @@ import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
|
||||
// get redirect uri
|
||||
export const getGoogleRedirectUri = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||
const baseUrl = isDevelopment ? "http://localhost:3000" : window.location.origin;
|
||||
if (typeof window !== "undefined") {
|
||||
const isDevelopment = process.env.NODE_ENV === "development";
|
||||
const baseUrl = isDevelopment
|
||||
? "http://localhost:3000"
|
||||
: window.location.origin;
|
||||
return `${baseUrl}/loginSuccess`;
|
||||
}
|
||||
return "";
|
||||
@@ -21,7 +23,7 @@ export const getGoogleRedirectUri = () => {
|
||||
|
||||
export const useLogin = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { googleAuthConfig } = usePlatformConfig();
|
||||
const { loginConfig } = usePlatformConfig();
|
||||
const [user, setUserToken] = useSharedStore((state: any) => [
|
||||
state.user,
|
||||
state.setUserToken,
|
||||
@@ -30,8 +32,6 @@ export const useLogin = () => {
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
|
||||
const login = () => {
|
||||
if (user) {
|
||||
router.push("/dashboard");
|
||||
@@ -82,9 +82,13 @@ export const useLogin = () => {
|
||||
|
||||
const googleLoginOrSignUp = () => {
|
||||
// check if google login is enabled and configured properly
|
||||
if (!googleAuthConfig?.is_enabled || !googleAuthConfig?.client_id) {
|
||||
if (!loginConfig?.google?.is_enabled || !loginConfig?.google?.client_id) {
|
||||
console.error("Google login is not enabled or not configured properly");
|
||||
toast.error(i18n.t("Google login is not available. Please contact the administrator."));
|
||||
toast.error(
|
||||
i18n.t(
|
||||
"Google login is not available. Please contact the administrator."
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,7 +98,7 @@ export const useLogin = () => {
|
||||
form.setAttribute("action", oauth2Endpoint);
|
||||
|
||||
const params: { [key: string]: string } = {
|
||||
client_id: googleAuthConfig.client_id,
|
||||
client_id: loginConfig.google.client_id,
|
||||
redirect_uri: getGoogleRedirectUri(),
|
||||
scope: "https://www.googleapis.com/auth/userinfo.email",
|
||||
state: new URLSearchParams({
|
||||
@@ -118,7 +122,7 @@ export const useLogin = () => {
|
||||
const googleLoginRedirect = async () => {
|
||||
setLoading(true);
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
if (typeof window === "undefined") {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
@@ -180,17 +184,53 @@ export const useLogin = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const emailPasswordLogin = async (data: {
|
||||
user_email: string;
|
||||
password: string;
|
||||
}) => {
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
const result = await fetchAPI("/api/auth/email/sign", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
setLoading(false);
|
||||
|
||||
if (!result.success) {
|
||||
setStatus("error");
|
||||
toast.error(result.error_message || i18n.t("Login failed"));
|
||||
return result;
|
||||
}
|
||||
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
afterLoginSuccess(searchParams, result.data);
|
||||
toast.success(i18n.t("Login successful"));
|
||||
return result;
|
||||
} catch (error) {
|
||||
setLoading(false);
|
||||
setStatus("error");
|
||||
console.error("Email password login error:", error);
|
||||
toast.error(i18n.t("Login failed"));
|
||||
return { success: false, error };
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
loading,
|
||||
status,
|
||||
isOpen,
|
||||
onOpen,
|
||||
onClose,
|
||||
googleAuthConfig,
|
||||
afterLoginSuccess,
|
||||
login,
|
||||
googleLoginOrSignUp,
|
||||
googleLoginRedirect,
|
||||
emailLoginOrSignUp,
|
||||
emailPasswordLogin,
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -2,22 +2,41 @@ import { useState, useEffect, useCallback } from "react";
|
||||
import {
|
||||
PaymentChannelApiItem,
|
||||
StripeConfig,
|
||||
AlipayConfig,
|
||||
WechatConfig,
|
||||
PaymentChannelTestResult,
|
||||
} from "@/types/payment";
|
||||
import { paymentChannelService } from "@/services/paymentChannelService";
|
||||
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
|
||||
import { revalidatePlatformConfig } from "@/app/actions/revalidate";
|
||||
|
||||
export const usePaymentChannelManagement = () => {
|
||||
const { updateClientConfig, paymentChannels } = usePlatformConfig();
|
||||
const [channels, setChannels] = useState<PaymentChannelApiItem[]>([]);
|
||||
const [stripeConfig, setStripeConfig] = useState<StripeConfig>({
|
||||
secret: "",
|
||||
webhook_secret: "",
|
||||
is_enabled: false,
|
||||
});
|
||||
const [alipayConfig, setAlipayConfig] = useState<AlipayConfig>({
|
||||
app_id: "",
|
||||
app_private_key: "",
|
||||
alipay_public_key: "",
|
||||
is_enabled: false,
|
||||
});
|
||||
const [wechatConfig, setWechatConfig] = useState<WechatConfig>({
|
||||
app_id: "",
|
||||
mch_id: "",
|
||||
is_enabled: false,
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [testResult, setTestResult] = useState<PaymentChannelTestResult | null>(
|
||||
null
|
||||
);
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [isWechatSaving, setIsWechatSaving] = useState(false);
|
||||
const [isStripeSaving, setIsStripeSaving] = useState(false);
|
||||
const [isAlipaySaving, setIsAlipaySaving] = useState(false);
|
||||
|
||||
// get payment channel list
|
||||
const fetchChannels = useCallback(async () => {
|
||||
@@ -29,12 +48,35 @@ export const usePaymentChannelManagement = () => {
|
||||
|
||||
setChannels(response.data);
|
||||
|
||||
// find stripe channel and get config
|
||||
// find channels and get configs
|
||||
const stripeChannel = response.data.find(
|
||||
(channel) => channel.id === "stripe"
|
||||
);
|
||||
if (stripeChannel) {
|
||||
setStripeConfig(stripeChannel.config);
|
||||
setStripeConfig({
|
||||
...stripeChannel.config,
|
||||
is_enabled: stripeChannel.is_enabled,
|
||||
} as StripeConfig);
|
||||
}
|
||||
|
||||
const alipayChannel = response.data.find(
|
||||
(channel) => channel.id === "alipay"
|
||||
);
|
||||
if (alipayChannel) {
|
||||
setAlipayConfig({
|
||||
...alipayChannel.config,
|
||||
is_enabled: alipayChannel.is_enabled,
|
||||
} as AlipayConfig);
|
||||
}
|
||||
|
||||
const wechatChannel = response.data.find(
|
||||
(channel) => channel.id === "wechat"
|
||||
);
|
||||
if (wechatChannel) {
|
||||
setWechatConfig({
|
||||
...wechatChannel.config,
|
||||
is_enabled: wechatChannel.is_enabled,
|
||||
} as WechatConfig);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(
|
||||
@@ -48,9 +90,103 @@ export const usePaymentChannelManagement = () => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
// test alipay connection
|
||||
const testAlipayConnection = useCallback(async (config: AlipayConfig) => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const result = await paymentChannelService.testAlipayConnection(config);
|
||||
setTestResult(result);
|
||||
return result;
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Failed to test alipay connection";
|
||||
const failedResult: PaymentChannelTestResult = {
|
||||
success: false,
|
||||
message: errorMessage,
|
||||
};
|
||||
setTestResult(failedResult);
|
||||
setError(errorMessage);
|
||||
return failedResult;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// test wechat connection
|
||||
const testWechatConnection = useCallback(async (config: WechatConfig) => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const result = await paymentChannelService.testWechatConnection(config);
|
||||
setTestResult(result);
|
||||
return result;
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Failed to test wechat connection";
|
||||
const failedResult: PaymentChannelTestResult = {
|
||||
success: false,
|
||||
message: errorMessage,
|
||||
};
|
||||
setTestResult(failedResult);
|
||||
setError(errorMessage);
|
||||
return failedResult;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// save alipay config
|
||||
const saveAlipayConfig = useCallback(async (config: AlipayConfig) => {
|
||||
setIsAlipaySaving(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const result = await paymentChannelService.saveAlipayConfig(config);
|
||||
if (result) {
|
||||
setAlipayConfig(config);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Failed to save alipay config";
|
||||
setError(errorMessage);
|
||||
return false;
|
||||
} finally {
|
||||
setIsAlipaySaving(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// save wechat config
|
||||
const saveWechatConfig = useCallback(async (config: WechatConfig) => {
|
||||
setIsWechatSaving(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const result = await paymentChannelService.saveWechatConfig(config);
|
||||
if (result) {
|
||||
setWechatConfig(config);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error ? err.message : "Failed to save wechat config";
|
||||
setError(errorMessage);
|
||||
return false;
|
||||
} finally {
|
||||
setIsWechatSaving(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// save stripe config
|
||||
const saveStripeConfig = useCallback(async (config: StripeConfig) => {
|
||||
setIsSaving(true);
|
||||
setIsStripeSaving(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
@@ -67,7 +203,7 @@ export const usePaymentChannelManagement = () => {
|
||||
setError(errorMessage);
|
||||
return false;
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
setIsStripeSaving(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -102,16 +238,25 @@ export const usePaymentChannelManagement = () => {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
await paymentChannelService.enablePaymentChannel(channelId);
|
||||
await fetchChannels(); // re-fetch list
|
||||
return { success: true };
|
||||
const result =
|
||||
await paymentChannelService.enablePaymentChannel(channelId);
|
||||
if (result) {
|
||||
updateClientConfig({
|
||||
payment_channels: [
|
||||
...paymentChannels,
|
||||
{ id: channelId, name: channelId },
|
||||
],
|
||||
});
|
||||
await revalidatePlatformConfig();
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Failed to enable payment channel";
|
||||
setError(errorMessage);
|
||||
return { success: false, message: errorMessage };
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -126,16 +271,24 @@ export const usePaymentChannelManagement = () => {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
await paymentChannelService.disablePaymentChannel(channelId);
|
||||
await fetchChannels(); // re-fetch list
|
||||
return { success: true };
|
||||
const result =
|
||||
await paymentChannelService.disablePaymentChannel(channelId);
|
||||
if (result) {
|
||||
updateClientConfig({
|
||||
payment_channels: paymentChannels.filter(
|
||||
(channel) => channel.id !== channelId
|
||||
),
|
||||
});
|
||||
await revalidatePlatformConfig();
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
const errorMessage =
|
||||
err instanceof Error
|
||||
? err.message
|
||||
: "Failed to disable payment channel";
|
||||
setError(errorMessage);
|
||||
return { success: false, message: errorMessage };
|
||||
return false;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -161,13 +314,21 @@ export const usePaymentChannelManagement = () => {
|
||||
return {
|
||||
channels,
|
||||
stripeConfig,
|
||||
isSaving,
|
||||
alipayConfig,
|
||||
wechatConfig,
|
||||
isWechatSaving,
|
||||
isStripeSaving,
|
||||
isAlipaySaving,
|
||||
loading,
|
||||
error,
|
||||
testResult,
|
||||
fetchChannels,
|
||||
saveStripeConfig,
|
||||
saveAlipayConfig,
|
||||
saveWechatConfig,
|
||||
testStripeConnection,
|
||||
testAlipayConnection,
|
||||
testWechatConnection,
|
||||
enableChannel,
|
||||
disableChannel,
|
||||
clearTestResult,
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import { useState, useCallback, useEffect } from "react";
|
||||
import { GoogleAuthConfig, PlatformConfig } from "@/shared/types/system";
|
||||
import {
|
||||
PlatformConfig,
|
||||
LoginConfig,
|
||||
EmailMode,
|
||||
FaqItem,
|
||||
TopNavigationItem,
|
||||
EmbeddedHtmlConfig,
|
||||
PaymentChannel
|
||||
} from "@/shared/types/system";
|
||||
import { systemConfigService } from "@/services/systemConfigService";
|
||||
import { AdminConfig, EmailConfig } from "@/types/system";
|
||||
import { md5Encrypt } from "@/shared/utils/crypto";
|
||||
@@ -34,14 +42,43 @@ export const useSystemConfigManagement = () => {
|
||||
const [emailLoading, setEmailLoading] = useState(false);
|
||||
const [emailError, setEmailError] = useState<string | null>(null);
|
||||
|
||||
// google auth config
|
||||
const [googleAuthConfig, setGoogleAuthConfig] = useState<GoogleAuthConfig>({
|
||||
client_id: "",
|
||||
client_secret: "",
|
||||
is_enabled: false,
|
||||
// login config
|
||||
const [loginConfig, setLoginConfig] = useState<LoginConfig>({
|
||||
google: {
|
||||
client_id: "",
|
||||
client_secret: "",
|
||||
is_enabled: false,
|
||||
},
|
||||
email: {
|
||||
is_enabled: true, // 默认启用邮箱登录
|
||||
mode: EmailMode.PASSWORD, // 默认使用密码模式
|
||||
},
|
||||
});
|
||||
const [googleAuthLoading, setGoogleAuthLoading] = useState(false);
|
||||
const [googleAuthError, setGoogleAuthError] = useState<string | null>(null);
|
||||
const [loginLoading, setLoginLoading] = useState(false);
|
||||
const [loginError, setLoginError] = useState<string | null>(null);
|
||||
|
||||
// faq config
|
||||
const [faqItems, setFaqItems] = useState<FaqItem[]>([]);
|
||||
const [faqLoading, setFaqLoading] = useState(false);
|
||||
const [faqError, setFaqError] = useState<string | null>(null);
|
||||
|
||||
// top navigation config
|
||||
const [topNavigation, setTopNavigation] = useState<TopNavigationItem[]>([]);
|
||||
const [navigationLoading, setNavigationLoading] = useState(false);
|
||||
const [navigationError, setNavigationError] = useState<string | null>(null);
|
||||
|
||||
// embedded html config
|
||||
const [embeddedHtml, setEmbeddedHtml] = useState<EmbeddedHtmlConfig | null>(null);
|
||||
const [embeddedHtmlLoading, setEmbeddedHtmlLoading] = useState(false);
|
||||
const [embeddedHtmlError, setEmbeddedHtmlError] = useState<string | null>(null);
|
||||
|
||||
// payment channels config
|
||||
const [paymentChannels, setPaymentChannels] = useState<PaymentChannel[]>([]);
|
||||
const [paymentLoading, setPaymentLoading] = useState(false);
|
||||
const [paymentError, setPaymentError] = useState<string | null>(null);
|
||||
|
||||
// installation status
|
||||
const [isInstalled, setIsInstalled] = useState<boolean>(false);
|
||||
|
||||
// global loading
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -63,7 +100,22 @@ export const useSystemConfigManagement = () => {
|
||||
smtp_sender: "",
|
||||
}
|
||||
);
|
||||
setGoogleAuthConfig(response.login?.google);
|
||||
setLoginConfig({
|
||||
google: response.login?.google || {
|
||||
client_id: "",
|
||||
client_secret: "",
|
||||
is_enabled: false,
|
||||
},
|
||||
email: response.login?.email || {
|
||||
is_enabled: true,
|
||||
mode: EmailMode.PASSWORD,
|
||||
},
|
||||
});
|
||||
setFaqItems(response.faq || []);
|
||||
setTopNavigation(response.top_navigation || []);
|
||||
setEmbeddedHtml(response.embeded_html || null);
|
||||
setPaymentChannels(response.payment_channels || []);
|
||||
setIsInstalled(response.is_installed || false);
|
||||
} catch (error) {
|
||||
console.error("Failed to load configurations:", error);
|
||||
} finally {
|
||||
@@ -72,25 +124,31 @@ export const useSystemConfigManagement = () => {
|
||||
}, []);
|
||||
|
||||
// save platform config
|
||||
const savePlatformConfig = useCallback(async (config: PlatformConfig) => {
|
||||
setPlatformLoading(true);
|
||||
setPlatformError(null);
|
||||
const result = await systemConfigService.updateSystemConfig({
|
||||
platform: config,
|
||||
});
|
||||
if (result) {
|
||||
setPlatformConfig(config);
|
||||
// 重新验证平台配置缓存
|
||||
try {
|
||||
await revalidatePlatformConfig();
|
||||
console.info("Platform config cache revalidated successfully");
|
||||
} catch (error) {
|
||||
console.error("Failed to revalidate platform config cache:", error);
|
||||
const savePlatformConfig = useCallback(
|
||||
async (config: PlatformConfig, key?: "theme" | "about") => {
|
||||
if (!key) setPlatformLoading(true);
|
||||
setPlatformError(null);
|
||||
const result = await systemConfigService.updateSystemConfig(
|
||||
{
|
||||
platform: config,
|
||||
},
|
||||
key
|
||||
);
|
||||
if (result) {
|
||||
setPlatformConfig(config);
|
||||
// 重新验证平台配置缓存
|
||||
try {
|
||||
await revalidatePlatformConfig();
|
||||
console.info("Platform config cache revalidated successfully");
|
||||
} catch (error) {
|
||||
console.error("Failed to revalidate platform config cache:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
setPlatformLoading(false);
|
||||
return result;
|
||||
}, []);
|
||||
setPlatformLoading(false);
|
||||
return result;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
// save admin config
|
||||
const saveAdminConfig = useCallback(async (config: AdminConfig) => {
|
||||
@@ -123,20 +181,74 @@ export const useSystemConfigManagement = () => {
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
// save google auth config
|
||||
const saveGoogleAuthConfig = useCallback(async (config: GoogleAuthConfig) => {
|
||||
setGoogleAuthLoading(true);
|
||||
setGoogleAuthError(null);
|
||||
// save login config
|
||||
const saveLoginConfig = useCallback(async (config: LoginConfig) => {
|
||||
setLoginLoading(true);
|
||||
setLoginError(null);
|
||||
const result = await systemConfigService.updateSystemConfig({
|
||||
login: {
|
||||
google: config,
|
||||
},
|
||||
login: config,
|
||||
});
|
||||
if (result) {
|
||||
setGoogleAuthConfig(config);
|
||||
setLoginConfig(config);
|
||||
await revalidatePlatformConfig();
|
||||
}
|
||||
setGoogleAuthLoading(false);
|
||||
setLoginLoading(false);
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
// save faq config
|
||||
const saveFaqConfig = useCallback(async (items: FaqItem[]) => {
|
||||
setFaqLoading(true);
|
||||
setFaqError(null);
|
||||
const result = await systemConfigService.updateSystemConfig({
|
||||
faq: items,
|
||||
}, "faq");
|
||||
if (result) {
|
||||
setFaqItems(items);
|
||||
}
|
||||
setFaqLoading(false);
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
// save top navigation config
|
||||
const saveTopNavigationConfig = useCallback(async (items: TopNavigationItem[]) => {
|
||||
setNavigationLoading(true);
|
||||
setNavigationError(null);
|
||||
const result = await systemConfigService.updateSystemConfig({
|
||||
top_navigation: items,
|
||||
}, "navigation");
|
||||
if (result) {
|
||||
setTopNavigation(items);
|
||||
}
|
||||
setNavigationLoading(false);
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
// save embedded html config
|
||||
const saveEmbeddedHtmlConfig = useCallback(async (config: EmbeddedHtmlConfig) => {
|
||||
setEmbeddedHtmlLoading(true);
|
||||
setEmbeddedHtmlError(null);
|
||||
const result = await systemConfigService.updateSystemConfig({
|
||||
embeded_html: config,
|
||||
}, "embedded_html");
|
||||
if (result) {
|
||||
setEmbeddedHtml(config);
|
||||
}
|
||||
setEmbeddedHtmlLoading(false);
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
// save payment channels config
|
||||
const savePaymentChannelsConfig = useCallback(async (channels: PaymentChannel[]) => {
|
||||
setPaymentLoading(true);
|
||||
setPaymentError(null);
|
||||
const result = await systemConfigService.updateSystemConfig({
|
||||
payment_channels: channels,
|
||||
}, "payment");
|
||||
if (result) {
|
||||
setPaymentChannels(channels);
|
||||
}
|
||||
setPaymentLoading(false);
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
@@ -144,13 +256,30 @@ export const useSystemConfigManagement = () => {
|
||||
const clearPlatformError = useCallback(() => setPlatformError(null), []);
|
||||
const clearAdminError = useCallback(() => setAdminError(null), []);
|
||||
const clearEmailError = useCallback(() => setEmailError(null), []);
|
||||
const clearGoogleAuthError = useCallback(() => setGoogleAuthError(null), []);
|
||||
const clearLoginError = useCallback(() => setLoginError(null), []);
|
||||
const clearFaqError = useCallback(() => setFaqError(null), []);
|
||||
const clearNavigationError = useCallback(() => setNavigationError(null), []);
|
||||
const clearEmbeddedHtmlError = useCallback(() => setEmbeddedHtmlError(null), []);
|
||||
const clearPaymentError = useCallback(() => setPaymentError(null), []);
|
||||
|
||||
// load configs on init
|
||||
useEffect(() => {
|
||||
loadConfigurations();
|
||||
}, [loadConfigurations]);
|
||||
|
||||
// upload image
|
||||
const uploadImage = useCallback(
|
||||
async (file: File, sha256?: string): Promise<string> => {
|
||||
try {
|
||||
return await systemConfigService.uploadImage(file, sha256);
|
||||
} catch (error) {
|
||||
console.error("Failed to upload image:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return {
|
||||
// platform config
|
||||
platformConfig,
|
||||
@@ -176,13 +305,52 @@ export const useSystemConfigManagement = () => {
|
||||
saveEmailConfig,
|
||||
clearEmailError,
|
||||
|
||||
// google auth config
|
||||
googleAuthConfig,
|
||||
setGoogleAuthConfig,
|
||||
googleAuthLoading,
|
||||
googleAuthError,
|
||||
saveGoogleAuthConfig,
|
||||
clearGoogleAuthError,
|
||||
// login config
|
||||
loginConfig,
|
||||
setLoginConfig,
|
||||
loginLoading,
|
||||
loginError,
|
||||
saveLoginConfig,
|
||||
clearLoginError,
|
||||
|
||||
// faq config
|
||||
faqItems,
|
||||
setFaqItems,
|
||||
faqLoading,
|
||||
faqError,
|
||||
saveFaqConfig,
|
||||
clearFaqError,
|
||||
|
||||
// top navigation config
|
||||
topNavigation,
|
||||
setTopNavigation,
|
||||
navigationLoading,
|
||||
navigationError,
|
||||
saveTopNavigationConfig,
|
||||
clearNavigationError,
|
||||
|
||||
// embedded html config
|
||||
embeddedHtml,
|
||||
setEmbeddedHtml,
|
||||
embeddedHtmlLoading,
|
||||
embeddedHtmlError,
|
||||
saveEmbeddedHtmlConfig,
|
||||
clearEmbeddedHtmlError,
|
||||
|
||||
// payment channels config
|
||||
paymentChannels,
|
||||
setPaymentChannels,
|
||||
paymentLoading,
|
||||
paymentError,
|
||||
savePaymentChannelsConfig,
|
||||
clearPaymentError,
|
||||
|
||||
// installation status
|
||||
isInstalled,
|
||||
setIsInstalled,
|
||||
|
||||
// image upload
|
||||
uploadImage,
|
||||
|
||||
// global operations
|
||||
isLoading,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { User } from "@/types/user";
|
||||
import { getUserList, deleteUser } from "@/services/userService";
|
||||
import { getUserList, deleteUser, rechargeUser } from "@/services/userService";
|
||||
|
||||
interface PaginationInfo {
|
||||
page: number;
|
||||
@@ -67,6 +67,28 @@ export const useUserManagement = () => {
|
||||
},
|
||||
[fetchUsers]
|
||||
);
|
||||
const handleRechargeUser = async (
|
||||
userId: string,
|
||||
amount: number
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
const result = await rechargeUser(userId, amount);
|
||||
if (result) {
|
||||
// after recharge, fetch users again
|
||||
setUsers((prevUsers: User[]) =>
|
||||
prevUsers.map((user: User) =>
|
||||
user.id === userId
|
||||
? { ...user, balance: user.balance + amount }
|
||||
: user
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "Recharge user failed");
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const setSearch = useCallback((search: string) => {
|
||||
setSearchQuery(search);
|
||||
@@ -88,6 +110,7 @@ export const useUserManagement = () => {
|
||||
|
||||
return {
|
||||
users,
|
||||
handleRechargeUser,
|
||||
loading,
|
||||
error,
|
||||
searchQuery,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { fetchAdminAPI } from "@/rpc/admin-api";
|
||||
import i18n from "@/shared/lib/i18n";
|
||||
import {
|
||||
EmbeddedHtmlConfig,
|
||||
FaqItem,
|
||||
TopNavigationItem,
|
||||
} from "@/shared/types/system";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
export interface HomepageConfig {
|
||||
faq: FaqItem[];
|
||||
top_navigation: TopNavigationItem[];
|
||||
embeded_html: EmbeddedHtmlConfig;
|
||||
}
|
||||
|
||||
export class HomepageConfigService {
|
||||
// get homepage config
|
||||
async getHomepageConfig(): Promise<HomepageConfig> {
|
||||
const response = await fetchAdminAPI<HomepageConfig>(
|
||||
"/api/sysconfig/homepage",
|
||||
{
|
||||
method: "GET",
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.success) {
|
||||
throw new Error(
|
||||
response.error_message || "Failed to fetch homepage config"
|
||||
);
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// update homepage config
|
||||
async updateHomepageConfig(config: {
|
||||
faq?: FaqItem[];
|
||||
top_navigation?: TopNavigationItem[];
|
||||
embeded_html?: EmbeddedHtmlConfig;
|
||||
}): Promise<boolean> {
|
||||
const response = await fetchAdminAPI("/api/sysconfig/homepage", {
|
||||
method: "PUT",
|
||||
body: config as unknown as BodyInit,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
toast.error(
|
||||
response.error_message || i18n.t("Failed to update homepage config")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
toast.success(i18n.t("Homepage config updated successfully"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export const homepageConfigService = new HomepageConfigService();
|
||||
@@ -1,5 +1,7 @@
|
||||
import {
|
||||
StripeConfig,
|
||||
AlipayConfig,
|
||||
WechatConfig,
|
||||
PaymentChannelApiItem,
|
||||
PaymentChannelListResponse,
|
||||
PaymentChannelTestResult,
|
||||
@@ -52,50 +54,74 @@ export class PaymentChannelService {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// Save Stripe configuration
|
||||
async saveStripeConfig(config: StripeConfig): Promise<boolean> {
|
||||
const response = await fetchAdminAPI<StripeConfig>(
|
||||
"/api/payment_channel/info",
|
||||
{
|
||||
method: "PUT",
|
||||
body: {
|
||||
id: "stripe",
|
||||
config: config,
|
||||
} as unknown as BodyInit,
|
||||
}
|
||||
);
|
||||
// Generic method to save payment channel configuration
|
||||
async savePaymentChannelConfig<T>(
|
||||
channelId: string,
|
||||
config: T,
|
||||
channelName: string
|
||||
): Promise<boolean> {
|
||||
const response = await fetchAdminAPI<T>("/api/payment_channel/info", {
|
||||
method: "PUT",
|
||||
body: {
|
||||
id: channelId,
|
||||
config: {
|
||||
...config,
|
||||
is_enabled: undefined,
|
||||
},
|
||||
} as unknown as BodyInit,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
toast.error(
|
||||
response.error_message || i18n.t("Failed to save Stripe config")
|
||||
response.error_message ||
|
||||
i18n.t("Failed to save {{channelName}} config", { channelName })
|
||||
);
|
||||
return false;
|
||||
}
|
||||
toast.success(i18n.t("Stripe config saved successfully"));
|
||||
toast.success(
|
||||
i18n.t("{{channelName}} config saved successfully", { channelName })
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Test Stripe connection
|
||||
async testStripeConnection(
|
||||
config: StripeConfig
|
||||
// Save Stripe configuration
|
||||
async saveStripeConfig(config: StripeConfig): Promise<boolean> {
|
||||
return this.savePaymentChannelConfig("stripe", config, "Stripe");
|
||||
}
|
||||
|
||||
// Generic method to test payment channel connection
|
||||
async testPaymentChannelConnection<T>(
|
||||
channelId: string,
|
||||
config: T,
|
||||
channelName: string
|
||||
): Promise<PaymentChannelTestResult> {
|
||||
try {
|
||||
const response = await fetchAdminAPI<any>("/api/payment_channel/info", {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(config),
|
||||
const response = await fetchAdminAPI<any>("/api/payment_channel/test", {
|
||||
method: "POST",
|
||||
body: {
|
||||
id: channelId,
|
||||
config: {
|
||||
...config,
|
||||
is_enabled: undefined,
|
||||
},
|
||||
} as unknown as BodyInit,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
return {
|
||||
success: false,
|
||||
message: response.error_message || "Stripe connection test failed",
|
||||
message:
|
||||
response.error_message ||
|
||||
i18n.t("{{channelName}} connection test failed", { channelName }),
|
||||
details: response.data,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Stripe connection test successful",
|
||||
message: i18n.t("{{channelName}} connection test successful", {
|
||||
channelName,
|
||||
}),
|
||||
details: response.data,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -106,36 +132,73 @@ export class PaymentChannelService {
|
||||
}
|
||||
}
|
||||
|
||||
// Test Stripe connection
|
||||
async testStripeConnection(
|
||||
config: StripeConfig
|
||||
): Promise<PaymentChannelTestResult> {
|
||||
return this.testPaymentChannelConnection("stripe", config, "Stripe");
|
||||
}
|
||||
|
||||
// enable payment channel
|
||||
async enablePaymentChannel(id: string): Promise<void> {
|
||||
async enablePaymentChannel(id: string): Promise<boolean> {
|
||||
const response = await fetchAdminAPI("/api/payment_channel/enable", {
|
||||
method: "POST",
|
||||
method: "PUT",
|
||||
body: {
|
||||
id,
|
||||
} as unknown as BodyInit,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
throw new Error(
|
||||
response.error_message || "Failed to enable payment channel"
|
||||
toast.error(
|
||||
response.error_message || i18n.t("Failed to enable payment channel")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
toast.success(i18n.t("Payment channel enabled successfully"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// disable payment channel
|
||||
async disablePaymentChannel(id: string): Promise<void> {
|
||||
async disablePaymentChannel(id: string): Promise<boolean> {
|
||||
const response = await fetchAdminAPI("/api/payment_channel/disable", {
|
||||
method: "POST",
|
||||
method: "PUT",
|
||||
body: {
|
||||
id,
|
||||
} as unknown as BodyInit,
|
||||
});
|
||||
|
||||
if (!response.success) {
|
||||
throw new Error(
|
||||
response.error_message || "Failed to disable payment channel"
|
||||
toast.error(
|
||||
response.error_message || i18n.t("Failed to disable payment channel")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
toast.success(i18n.t("Payment channel disabled successfully"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Save Alipay configuration
|
||||
async saveAlipayConfig(config: AlipayConfig): Promise<boolean> {
|
||||
return this.savePaymentChannelConfig("alipay", config, "Alipay");
|
||||
}
|
||||
|
||||
// Save WeChat configuration
|
||||
async saveWechatConfig(config: WechatConfig): Promise<boolean> {
|
||||
return this.savePaymentChannelConfig("wechat", config, "WeChat");
|
||||
}
|
||||
|
||||
// Test Alipay connection
|
||||
async testAlipayConnection(
|
||||
config: AlipayConfig
|
||||
): Promise<PaymentChannelTestResult> {
|
||||
return this.testPaymentChannelConnection("alipay", config, "Alipay");
|
||||
}
|
||||
|
||||
// Test WeChat connection
|
||||
async testWechatConnection(
|
||||
config: WechatConfig
|
||||
): Promise<PaymentChannelTestResult> {
|
||||
return this.testPaymentChannelConnection("wechat", config, "WeChat");
|
||||
}
|
||||
|
||||
// validate stripe config
|
||||
|
||||
@@ -37,10 +37,26 @@ export class PlatformConfigService {
|
||||
console.error(response.error_message);
|
||||
return {
|
||||
platform: _DefaultPlatformConfig,
|
||||
login: undefined,
|
||||
faq: [],
|
||||
top_navigation: [],
|
||||
embeded_html: undefined,
|
||||
payment_channels: [],
|
||||
is_installed: false,
|
||||
};
|
||||
}
|
||||
|
||||
return response.data;
|
||||
// 确保返回的数据结构正确
|
||||
const data = response.data;
|
||||
return {
|
||||
platform: data.platform || _DefaultPlatformConfig,
|
||||
login: data.login,
|
||||
faq: data.faq || [],
|
||||
top_navigation: data.top_navigation || [],
|
||||
embeded_html: data.embeded_html,
|
||||
payment_channels: data.payment_channels || [],
|
||||
is_installed: data.is_installed || false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { fetchAdminAPI } from "@/rpc/admin-api";
|
||||
import i18n from "@/shared/lib/i18n";
|
||||
import { GoogleAuthConfig, PlatformConfig } from "@/shared/types/system";
|
||||
import {
|
||||
PlatformConfig,
|
||||
LoginConfig,
|
||||
FaqItem,
|
||||
TopNavigationItem,
|
||||
EmbeddedHtmlConfig,
|
||||
PaymentChannel
|
||||
} from "@/shared/types/system";
|
||||
import { AdminConfig, EmailConfig, SystemConfigApiData } from "@/types/system";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
@@ -23,14 +30,20 @@ export class SystemConfigService {
|
||||
}
|
||||
|
||||
// update system config
|
||||
async updateSystemConfig(config: {
|
||||
platform?: PlatformConfig;
|
||||
account?: AdminConfig;
|
||||
email?: EmailConfig;
|
||||
login?: {
|
||||
google?: GoogleAuthConfig;
|
||||
};
|
||||
}): Promise<boolean> {
|
||||
async updateSystemConfig(
|
||||
config: {
|
||||
platform?: PlatformConfig;
|
||||
account?: AdminConfig;
|
||||
email?: EmailConfig;
|
||||
login?: LoginConfig;
|
||||
faq?: FaqItem[];
|
||||
top_navigation?: TopNavigationItem[];
|
||||
embeded_html?: EmbeddedHtmlConfig;
|
||||
payment_channels?: PaymentChannel[];
|
||||
is_installed?: boolean;
|
||||
},
|
||||
key?: "theme" | "about" | "faq" | "navigation" | "embedded_html" | "payment"
|
||||
): Promise<boolean> {
|
||||
const response = await fetchAdminAPI("/api/sysconfig/info", {
|
||||
method: "PUT",
|
||||
body: config as unknown as BodyInit,
|
||||
@@ -42,9 +55,57 @@ export class SystemConfigService {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
toast.success(i18n.t("System config updated successfully"));
|
||||
switch (key) {
|
||||
case "theme":
|
||||
toast.success(i18n.t("Theme changed successfully"));
|
||||
break;
|
||||
case "about":
|
||||
toast.success(i18n.t("About page saved successfully"));
|
||||
break;
|
||||
case "faq":
|
||||
toast.success(i18n.t("FAQ updated successfully"));
|
||||
break;
|
||||
case "navigation":
|
||||
toast.success(i18n.t("Navigation updated successfully"));
|
||||
break;
|
||||
case "embedded_html":
|
||||
toast.success(i18n.t("Embedded HTML updated successfully"));
|
||||
break;
|
||||
case "payment":
|
||||
toast.success(i18n.t("Payment channels updated successfully"));
|
||||
break;
|
||||
default: {
|
||||
toast.success(i18n.t("System config updated successfully"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// upload image
|
||||
async uploadImage(file: File, sha256?: string): Promise<string> {
|
||||
const formData = new FormData();
|
||||
formData.append("img", file);
|
||||
|
||||
// add sha256 parameter for image uniqueness verification
|
||||
if (sha256) {
|
||||
formData.append("sha256", sha256);
|
||||
}
|
||||
|
||||
const response = await fetchAdminAPI<{ file_path: string }>(
|
||||
"/api/upload/image",
|
||||
{
|
||||
method: "POST",
|
||||
body: formData,
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.success) {
|
||||
toast.error(response.error_message || i18n.t("Failed to upload image"));
|
||||
throw new Error(response.error_message || "Failed to upload image");
|
||||
}
|
||||
return response.data.file_path;
|
||||
}
|
||||
}
|
||||
|
||||
export const systemConfigService = new SystemConfigService();
|
||||
Loaded 100 of 193 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user