Compare commits

..
31 Commits
Author SHA1 Message Date
lethe 224a209fea fix/ui-0.2:mcp config text error 2025-07-25 15:04:29 +08:00
Liujian 99c33234bf update docker build scripts 2025-07-24 15:38:26 +08:00
lethe deb0161a3a feat:only use email and password register person can change password 2025-07-24 15:27:50 +08:00
lethe babb007082 feat/0.2:perfect ui experience:default expand about page setting and theme setting 2025-07-24 10:45:13 +08:00
lethe ca2b732952 feat/0.2:add theme setting and about page setting and support use email and password login 2025-07-24 10:28:42 +08:00
Dot.L 58292b0e6e Merge pull request #6 from xpack-ai/feature/optimize-auth
Fix: Error in obtaining user information: incorrect register_type
2025-07-24 10:02:31 +08:00
Liujian 63c44b6929 Fix: Error in obtaining user information: incorrect register_type 2025-07-24 10:00:18 +08:00
Dot.L 3a6508d214 Merge pull request #5 from xpack-ai/feature/optimize-auth
update init.sql
2025-07-23 19:59:13 +08:00
Liujian b90c8c4d30 update init.sql 2025-07-23 19:58:14 +08:00
Dot.L a20f0ca920 Merge pull request #4 from xpack-ai/feature/optimize-auth
Feature/optimize auth
2025-07-23 19:22:42 +08:00
Liujian 8ba3592035 support upload image 2025-07-23 19:21:36 +08:00
Liujian f0696ace22 support update password 2025-07-23 19:20:49 +08:00
Dot.L f984855871 Merge pull request #3 from xpack-ai/feature/optimize-auth
Fix the issue of failing to obtain the link of uploaded images
2025-07-23 18:24:35 +08:00
Liujian bf18fffc5a Fix the issue of failing to obtain the link of uploaded images 2025-07-23 18:23:27 +08:00
Dot.L a1b78da6a0 Merge pull request #2 from xpack-ai/feature/optimize-auth
Email supports password login
2025-07-23 15:51:15 +08:00
Liujian 4d4f63a911 Email supports password login, and the system configuration has added a new email login switch. 2025-07-23 15:50:14 +08:00
JackLiu 3e9f0fcf43 Update README-zh-cn.md 2025-07-22 19:07:25 +08:00
JackLiu fcb073f53c Update README-zh-cn.md 2025-07-22 16:07:46 +08:00
JackLiu c773797a82 Update README.md 2025-07-22 16:06:42 +08:00
Dot.L 6368727409 Update README.md 2025-07-21 11:14:12 +08:00
JackLiu c531aadb6b Update README.md 2025-07-21 11:05:27 +08:00
JackLiu f3850856eb Update README.md 2025-07-21 10:53:36 +08:00
JackLiu bd41154b2d Update README.md 2025-07-21 10:53:18 +08:00
JackLiu 018256530c Update and rename README_zh.md to README-zh-cn.md 2025-07-21 10:53:01 +08:00
JackLiu cb719d8c69 Update README.md 2025-07-21 10:49:46 +08:00
JackLiu 4e4f3eeffb Update README.md 2025-07-21 10:45:49 +08:00
Liujian d76e674e69 update README.md and docker-compose.yml 2025-07-21 01:21:04 +08:00
JackLiu 4468d2c2b1 Update README.md 2025-07-21 00:40:15 +08:00
JackLiu 3f3a2358a7 Update README.md 2025-07-21 00:36:31 +08:00
JackLiu b46ea0db17 Update README.md 2025-07-21 00:31:37 +08:00
JackLiu ef4839de39 Update README.md 2025-07-21 00:28:04 +08:00
115 changed files with 7777 additions and 1263 deletions

No files matched your search

+1
View File
@@ -40,3 +40,4 @@ htmlcov/
# Ignore local config
local_settings.py
/.secrets
/uploads/
+175
View File
@@ -0,0 +1,175 @@
# XPack(全球首个开源 MCP 交易计费平台)
![b1](https://github.com/user-attachments/assets/3d50cd9a-9d28-4ec8-bb5f-d3668475b49e)
<p align="center">
<a href="/README.md">English</a>
|
<a href="/README-zh-cn.md">简体中文</a>
</p>
**XPack** 是一款轻量级、开源的 MCP(Model Context Protocol)服务市场框架。
它可以将任何符合 OpenAPI 规范的接口快速转换为 MCP 服务,并帮助你在数分钟内搭建自己的 API 商店。
<br>
✨ 使用 XPack,你可以:
- ✅ **一键将 OpenAPI 转换为 MCP 服务配置**
- 🧾 **自动生成 SEO 友好的主页和服务页**
- 💳 **内置调用计费功能(支持按次收费)**
- 👥 **用户账户体系与管理后台**
- 🛠 **内置 Stripe 支付集成**
- 🔐 **支持邮箱 & Google 登录认证**
本项目基于 **Apache 2.0 协议开源**,可放心用于商业用途。
<br>
# ✨ 快速开始
😍 只需一行命令,即可在 10 分钟内部署你的 MCP 服务市场:
```bash
curl -sSO http://xpack.ai/install/quick-start.sh; bash quick-start.sh
```
该脚本会自动安装 MySQL、Redis、RabbitMQ,并启动 XPack 服务。
<br>
# 📸 功能截图
![b2](https://github.com/user-attachments/assets/c8cc89a4-ab5f-4c90-8c97-9207b5c9f5c1)
![b3](https://github.com/user-attachments/assets/16f74c8a-b35e-40a7-8471-a5736de8e904)
![b4](https://github.com/user-attachments/assets/fc76c215-7544-4267-bc6f-22a719edec00)
![b5](https://github.com/user-attachments/assets/db40ea77-58c3-472d-ba94-35dc9716a980)
<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 http://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)
+271 -179
View File
@@ -1,191 +1,283 @@
# XPack-MCP-Market
![fc52a21a-0ee9-4c95-a1c7-981ae1b397c9](https://github.com/user-attachments/assets/eb14b798-5717-4eab-b7d3-26addb2fa7ff)
# XPack
![b1](https://github.com/user-attachments/assets/3d50cd9a-9d28-4ec8-bb5f-d3668475b49e)
## 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 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.
**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)**
- 👥 **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 http://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
<br>
## 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.
# 📸 Features
![b2](https://github.com/user-attachments/assets/c8cc89a4-ab5f-4c90-8c97-9207b5c9f5c1)
![b3](https://github.com/user-attachments/assets/16f74c8a-b35e-40a7-8471-a5736de8e904)
![b4](https://github.com/user-attachments/assets/fc76c215-7544-4267-bc6f-22a719edec00)
![b5](https://github.com/user-attachments/assets/db40ea77-58c3-472d-ba94-35dc9716a980)
2. Start the UI interface
```
cd frontend/out && node server.js
```
### Backend Build
> Requirements:
> - Python >= 3.11
<br>
#### 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 &
## 🖥️ 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 http://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
View File
@@ -1,206 +0,0 @@
# XPack-MCP-Market
![fc52a21a-0ee9-4c95-a1c7-981ae1b397c9](https://github.com/user-attachments/assets/eb14b798-5717-4eab-b7d3-26addb2fa7ff)
## 硬件要求
**推荐配置**
- 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
View File
@@ -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
```
+1 -1
View File
@@ -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
```
+1 -1
View File
@@ -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**
+5 -1
View File
@@ -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*`,
},
];
},
+13 -1
View File
@@ -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"
}
+52 -5
View File
@@ -139,10 +139,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.",
@@ -680,5 +676,56 @@
"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"
}
+13 -1
View File
@@ -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": "关于我们"
}
+52 -5
View File
@@ -139,10 +139,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而不是千次。",
@@ -682,5 +678,56 @@
"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": "关于页面保存失败"
}
+13
View File
@@ -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 />;
}
@@ -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;
+3
View File
@@ -2,6 +2,9 @@
@tailwind components;
@tailwind utilities;
/* Import theme styles */
@import '../styles/themes.css';
html,
body {
padding: 0;
+15 -20
View File
@@ -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} />;
}
+9 -18
View File
@@ -6,6 +6,7 @@ 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");
@@ -43,23 +44,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>
);
};
+26 -7
View File
@@ -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,106 @@
"use client";
import React from "react";
import { EmailConfigForm } from "@/components/login-setting/EmailConfigForm";
import { GoogleAuthConfigForm } from "@/components/login-setting/GoogleAuthConfigForm";
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { LoginConfig, GoogleAuthConfig } from "@/shared/types/system";
import { TabKey } from "@/shared/types/dashboard";
import { useTranslation } from "@/shared/lib/useTranslation";
import { toast } from "react-hot-toast";
interface LoginSettingsContentProps {
onTabNavigate?: (tab: TabKey) => void;
}
export const LoginSettingsContent: React.FC<LoginSettingsContentProps> = ({
onTabNavigate,
}) => {
const { t } = useTranslation();
const { updateClientConfig } = usePlatformConfig();
const {
// login config
loginConfig,
loginLoading,
saveLoginConfig,
// email config
emailConfig,
// platform config
platformConfig,
} = useSystemConfigManagement();
// 验证至少有一种登录方式启用
const validateLoginMethods = (config: LoginConfig): boolean => {
const isGoogleEnabled =
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;
}
const result = await saveLoginConfig(config);
if (!result) return;
updateClientConfig({
platform: platformConfig,
login: config,
});
};
// save google auth config
const handleSaveGoogleAuthConfig = async (config: GoogleAuthConfig) => {
const updatedLoginConfig = {
...loginConfig,
google: config,
};
if (!validateLoginMethods(updatedLoginConfig)) {
return;
}
const result = await saveLoginConfig(updatedLoginConfig);
if (!result) return;
updateClientConfig({
platform: platformConfig,
login: updatedLoginConfig,
});
};
return (
<div className="space-y-6 w-full">
{/* email config */}
<EmailConfigForm
config={loginConfig}
emailConfig={emailConfig}
onSave={handleSaveLoginConfig}
isLoading={loginLoading}
onTabNavigate={onTabNavigate}
/>
{/* google auth config */}
<GoogleAuthConfigForm
config={loginConfig.google}
onSave={handleSaveGoogleAuthConfig}
isLoading={loginLoading}
/>
</div>
);
};
+198 -158
View File
@@ -14,179 +14,219 @@ 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 {
Cog,
CreditCard,
DollarSign,
Home,
Settings,
Users,
LogIn,
} from "lucide-react";
import { LoginSettingsContent } from "@/components/console/LoginSettingsContent";
import { Button } from "@nextui-org/react";
import { FaDiscord } from "react-icons/fa";
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 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 [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
const sidebarItems: SidebarItem[] = [
{
key: "console",
icon: <Home className="w-5 h-5" />,
label: t("Dashboard"),
description: t("Overview and analytics"),
},
{
key: "mcp-services",
icon: <Settings className="w-5 h-5" />,
label: t("MCP Services"),
description: t("Manage MCP services and API tools"),
},
{
key: "user-management",
icon: <Users className="w-5 h-5" />,
label: t("User Management"),
description: t("Manage registered users"),
},
{
key: "revenue-management",
icon: <DollarSign className="w-5 h-5" />,
label: t("Revenue Management"),
description: t("View user recharge history"),
},
{
key: "payment-channels",
icon: <CreditCard className="w-5 h-5" />,
label: t("Payment Channels"),
description: t("Configure payment channels"),
},
{
key: "system-settings",
icon: <Cog className="w-5 h-5" />,
label: t("System Settings"),
description: t("Platform basic configuration"),
},
];
const [activeTab, setActiveTab] = useState<TabKey>(getInitialTab);
const sidebarItems: SidebarItem[] = [
{
key: TabKey.CONSOLE,
icon: <Home className="w-5 h-5" />,
label: t("Dashboard"),
description: t("Overview and analytics"),
},
{
key: TabKey.MCP_SERVICES,
icon: <Settings className="w-5 h-5" />,
label: t("MCP Services"),
description: t("Manage MCP services and API tools"),
},
{
key: TabKey.USER_MANAGEMENT,
icon: <Users className="w-5 h-5" />,
label: t("User Management"),
description: t("Manage registered users"),
},
{
key: TabKey.REVENUE_MANAGEMENT,
icon: <DollarSign className="w-5 h-5" />,
label: t("Revenue Management"),
description: t("View user recharge history"),
},
{
key: TabKey.PAYMENT_CHANNELS,
icon: <CreditCard className="w-5 h-5" />,
label: t("Payment Channels"),
description: t("Configure payment channels"),
},
{
key: TabKey.LOGIN_SETTINGS,
icon: <LogIn className="w-5 h-5" />,
label: t("Login Settings"),
description: t("Configure authentication methods"),
},
{
key: TabKey.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) => {
setActiveTab(tab);
// 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);
router.push(`/console?${params.toString()}`, { scroll: false });
}
};
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 });
}
};
const { adminLogout } = useAdminLogin();
const { adminLogout } = useAdminLogin();
const handleLogout = () => {
// use admin logout method
adminLogout();
};
const handleLogout = () => {
// use admin logout method
adminLogout();
};
// 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 "login-settings":
return (
<DashboardDemoContent
title={t("Login Settings")}
description={t("Configure authentication methods")}
>
<LoginSettingsContent onTabNavigate={handleTabNavigate} />
</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>
);
}
};
// 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>
);
}
};
return (
<div className="min-h-screen bg-background">
<div className="flex">
{/* Sidebar */}
<DashboardSidebar
activeTab={activeTab}
onTabNavigate={handleTabNavigate}
onLogout={handleLogout}
sidebarItems={sidebarItems}
bottomPanel={
<Button
variant="light"
startContent={<FaDiscord className="w-5 h-5" />}
className="w-full justify-start h-auto p-3"
onPress={() => {
window.open("https://discord.gg/cyZfcdCXkW", "_blank");
}}
>
<div className="flex justify-between items-center w-full">
<span className="font-medium">{t("Discord")}</span>
</div>
</Button>
}
/>
return (
<div className="min-h-screen bg-background">
<div className="flex">
{/* Sidebar */}
<DashboardSidebar
activeTab={activeTab}
onTabNavigate={handleTabNavigate}
onLogout={handleLogout}
sidebarItems={sidebarItems}
/>
{/* Main Content */}
<div className="flex-1 h-screen overflow-y-auto">{renderContent()}</div>
</div>
</div>
);
{/* 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,16 +1,17 @@
'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 { PlatformConfigForm } from "@/components/system-setting/PlatformConfigForm";
import { AdminConfigForm } from "@/components/system-setting/AdminConfigForm";
import { EmailConfigForm } from "@/components/system-setting/EmailConfigForm";
import { useSystemConfigManagement } from "@/hooks/useSystemConfigManagement";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Theme } from "@/shared/types/system";
import i18n from "@/shared/lib/i18n";
export const SystemSettingsContent: React.FC = () => {
const { updateClientConfig } = usePlatformConfig();
const [isAboutLoading, setIsAboutLoading] = useState(false);
const {
// platform config
@@ -28,11 +29,8 @@ export const SystemSettingsContent: React.FC = () => {
emailLoading,
saveEmailConfig,
// google auth config
googleAuthConfig,
googleAuthLoading,
saveGoogleAuthConfig,
// image upload
uploadImage,
} = useSystemConfigManagement();
// save admin config
@@ -45,22 +43,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,6 +55,27 @@ 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,
});
};
return (
<div className="space-y-6 w-full">
@@ -76,7 +83,11 @@ export const SystemSettingsContent: React.FC = () => {
<PlatformConfigForm
config={platformConfig}
onSave={handleSavePlatformConfig}
onThemeChange={handleThemeChange}
onAboutSave={handleAboutSave}
isLoading={platformLoading}
isAboutLoading={isAboutLoading}
onImageUpload={uploadImage}
/>
{/* admin config */}
@@ -92,15 +103,8 @@ export const SystemSettingsContent: React.FC = () => {
onSave={handleSaveEmailConfig}
isLoading={emailLoading}
/>
{/* google auth config */}
<GoogleAuthConfigForm
config={googleAuthConfig}
onSave={handleSaveGoogleAuthConfig}
isLoading={googleAuthLoading}
/>
</div>
);
};
export default SystemSettingsContent;
export default SystemSettingsContent;
+53 -31
View File
@@ -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 } = 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,7 +156,11 @@ 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
@@ -156,7 +174,6 @@ const DashboardContent: React.FC = () => {
</div>
</CardBody>
</Card>
</div>
)
}
@@ -164,8 +181,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 +193,11 @@ const DashboardContent: React.FC = () => {
isOpen={isRechargeModalOpen}
onClose={() => setIsRechargeModalOpen(false)}
/>
{/* Change Password Modal */}
<ChangePasswordModal
isOpen={isChangePasswordModalOpen}
onClose={handleChangePasswordClose}
/>
</div>
);
};
@@ -194,4 +216,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>
);
};
@@ -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>
);
};
@@ -1,21 +1,41 @@
'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 { calculateFileSha256 } from "@/shared/utils/crypto";
import {
Input,
Button,
AccordionItem,
Accordion,
Select,
SelectItem,
} from "@nextui-org/react";
import MDEditor, { commands } from "@uiw/react-md-editor";
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";
interface PlatformConfigFormProps {
config: PlatformConfig;
onSave: (config: PlatformConfig) => void;
onThemeChange?: (theme: Theme) => Promise<void>;
onAboutSave?: (aboutContent: string) => Promise<void>;
onImageUpload?: (file: File, sha256?: string) => Promise<string>;
isLoading?: boolean;
isAboutLoading?: boolean;
}
export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
config,
onSave,
onThemeChange,
onAboutSave,
onImageUpload,
isLoading = false,
isAboutLoading = false,
}) => {
const { t } = useTranslation();
const [formData, setFormData] = useState<PlatformConfig>(config);
@@ -26,9 +46,9 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
}, [config]);
const handleInputChange = (field: keyof PlatformConfig, value: string) => {
setFormData(prev => ({
setFormData((prev) => ({
...prev,
[field]: value
[field]: value,
}));
};
@@ -36,122 +56,279 @@ export const PlatformConfigForm: React.FC<PlatformConfigFormProps> = ({
onSave(formData);
};
const isFormValid = formData.name.trim() !== '' && formData.currency?.trim() !== '';
const handleThemeChange = async (theme: Theme) => {
handleInputChange("theme", theme);
onThemeChange?.(theme);
};
const handleAboutSave = async () => {
onAboutSave?.(formData.about_page || "");
};
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 (
<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>
</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>
{/* About Page Accordion */}
<Accordion
variant="splitted"
itemClasses={{
base: "shadow-none border-1",
}}
className="px-0"
defaultExpandedKeys={["about-config"]}
>
<AccordionItem
key="about-config"
title={
<div className="flex flex-col justify-between">
<h3 className="text-lg font-semibold">
{t("About Page Content")}
</h3>
<p className="text-sm text-gray-500">
{t("Configure about page content")}
</p>
</div>
}
>
<div className="space-y-4">
<MDEditor
value={formData.about_page || ""}
onChange={(value?: string) =>
handleInputChange("about_page", value || "")
}
}}
isRequired
>
{getCurrencyOptions().map((currency) => (
<SelectItem key={currency.value} value={currency.value}>
{currency.label}
</SelectItem>
))}
</Select> */}
</div>
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={300}
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 = `![${file.name}](${window.location.origin}${dataUrl})`;
api.replaceSelection(imageMarkdown);
} catch (error) {
console.error("Image upload failed:", error);
}
}
};
input.click();
},
},
]}
/>
</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>
{/* About Save Button */}
<div className="flex gap-3 py-4">
<Button
color="primary"
variant="solid"
onPress={handleAboutSave}
isLoading={isAboutLoading}
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,43 @@
"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 } = usePlatformConfig();
const currentTheme = platformConfig.theme || Theme.DEFAULT;
// 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,87 @@
"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";
interface ProductDetailThemeSelectorProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
}
export const ProductDetailThemeSelector: React.FC<
ProductDetailThemeSelectorProps
> = ({ product, breadcrumbs }) => {
const { platformConfig } = usePlatformConfig();
const currentTheme = platformConfig.theme || Theme.DEFAULT;
const [url, setUrl] = useState<string>(process.env.NEXT_PUBLIC_MCP_URL || "");
useEffect(() => {
if (url || !product.slug_name) return;
setUrl(`${window.location.origin}/mcp/${product.slug_name}`);
}, [product.slug_name]);
//Render the About page based on the current theme
switch (currentTheme) {
case Theme.MODERN:
return (
<ModernDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.CLASSIC:
return (
<ClassicDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.CREATIVE:
return (
<CreativeDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
navItems={NavigationItems}
/>
);
case Theme.TEMU:
return (
<TemuDetail
product={product}
breadcrumbs={breadcrumbs}
url={url}
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">
<ProductDetailClient product={product} />
</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,200 @@
"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";
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 } = usePlatformConfig();
const currentTheme = platformConfig.theme || Theme.DEFAULT;
// 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}
/>
</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,259 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } 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 } 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;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
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-lg 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-xs">{t("Price")}:</b>
<Price
price={product.price}
charge_type={product.charge_type}
/>
</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">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"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,254 @@
"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";
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="grid grid-cols-1 md: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 h-[200px] 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}
/>
</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>
)}
</div>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,55 @@
"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 href={item.href} 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,191 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } 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 { Sparkles, Zap, Settings2 } 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;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
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">
<Navigation items={navItems} />
{/* Creative Background */}
<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">
<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/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">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"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>
<Footer />
</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,323 @@
"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";
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">
{/* 主要装饰圆圈 */}
<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>
{/* 小装饰圆圈 */}
<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>
{/* 微小装饰点 */}
<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("✨ 发现神奇的服务...")
}
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" />
<span className="text-gray-700 text-lg font-bold">
✨ 加载魔法中...
</span>
</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="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 max-w-6xl mx-auto">
{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"
>
<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]
`}
>
<CardBody className="p-6">
{/* 创意图标 */}
<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>
{/* 服务标题 */}
<div className="text-lg font-bold text-gray-800 mb-2 group-hover:text-gray-900 transition-colors">
{service.name}
</div>
{/* 服务描述 */}
<div className="text-sm text-gray-600 group-hover:text-gray-700 transition-colors flex-1">
{service.short_description || "探索精彩服务"}
</div>
{/* 装饰性元素 */}
<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}
/>
</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>
)}
<Footer />
</div>
);
};
@@ -0,0 +1,119 @@
"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 href={item.href} 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,188 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } 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 } 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;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
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">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"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,239 @@
"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";
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">
<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>
{/* 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="grid grid-cols-1 md: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 h-[200px] 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}
/>
</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>
)}
<Footer />
</div>
);
};
@@ -0,0 +1,105 @@
"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 href={item.href} 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>
);
};
+103
View File
@@ -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,195 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } 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 { FileText, Wrench, Cog } 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;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
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">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"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>
</>
);
};
+220
View File
@@ -0,0 +1,220 @@
"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";
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}
/>
</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>
)}
</>
)}
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,113 @@
"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
href={item.href}
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>
</>
);
};
@@ -12,15 +12,8 @@ const UserManagement: React.FC = () => {
const { t } = useTranslation();
// use custom hook to manage user data
const {
users,
loading,
searchQuery,
pagination,
handleDeleteUser,
setSearch,
setPage,
} = useUserManagement();
const { users, loading, pagination, handleDeleteUser, setPage } =
useUserManagement();
// Modal states
const [deleteModal, setDeleteModal] = useState({
@@ -57,15 +50,11 @@ const UserManagement: React.FC = () => {
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}
@@ -80,9 +69,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>
);
+2 -2
View File
@@ -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,
};
};
};
+52 -12
View File
@@ -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,
};
};
};
+80 -44
View File
@@ -1,5 +1,5 @@
import { useState, useCallback, useEffect } from "react";
import { GoogleAuthConfig, PlatformConfig } from "@/shared/types/system";
import { PlatformConfig, LoginConfig, EmailMode } from "@/shared/types/system";
import { systemConfigService } from "@/services/systemConfigService";
import { AdminConfig, EmailConfig } from "@/types/system";
import { md5Encrypt } from "@/shared/utils/crypto";
@@ -34,14 +34,20 @@ 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);
// global loading
const [isLoading, setIsLoading] = useState(false);
@@ -63,7 +69,17 @@ 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,
},
});
} catch (error) {
console.error("Failed to load configurations:", error);
} finally {
@@ -72,25 +88,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 +145,18 @@ 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;
}, []);
@@ -144,13 +164,26 @@ 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), []);
// 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 +209,16 @@ export const useSystemConfigManagement = () => {
saveEmailConfig,
clearEmailError,
// google auth config
googleAuthConfig,
setGoogleAuthConfig,
googleAuthLoading,
googleAuthError,
saveGoogleAuthConfig,
clearGoogleAuthError,
// login config
loginConfig,
setLoginConfig,
loginLoading,
loginError,
saveLoginConfig,
clearLoginError,
// image upload
uploadImage,
// global operations
isLoading,
+47 -10
View File
@@ -1,6 +1,6 @@
import { fetchAdminAPI } from "@/rpc/admin-api";
import i18n from "@/shared/lib/i18n";
import { GoogleAuthConfig, PlatformConfig } from "@/shared/types/system";
import { PlatformConfig, LoginConfig } from "@/shared/types/system";
import { AdminConfig, EmailConfig, SystemConfigApiData } from "@/types/system";
import toast from "react-hot-toast";
@@ -23,14 +23,15 @@ 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;
},
key?: "theme" | "about"
): Promise<boolean> {
const response = await fetchAdminAPI("/api/sysconfig/info", {
method: "PUT",
body: config as unknown as BodyInit,
@@ -42,9 +43,45 @@ 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;
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();
@@ -1,6 +1,6 @@
"use client";
import React, { useEffect } from "react";
import React, { useEffect, useState } from "react";
import { I18nextProvider } from "react-i18next";
import i18n, { i18nPromise } from "@/shared/lib/i18n";
@@ -11,25 +11,30 @@ interface ClientI18nProviderProps {
export const ClientI18nProvider: React.FC<ClientI18nProviderProps> = ({
children,
}) => {
const [isInitialized, setIsInitialized] = useState(false);
const initAll = async () => {
if (i18n.isInitialized) return
await i18nPromise;
const storedLang = localStorage.getItem("i18nextLng");
// only switch when the stored language is different from the current language
if (storedLang && storedLang !== i18n.language) {
await i18n.changeLanguage(storedLang);
if (!i18n.isInitialized) {
await i18nPromise;
const storedLang = localStorage.getItem("i18nextLng");
// only switch when the stored language is different from the current language
if (storedLang && storedLang !== i18n.language) {
await i18n.changeLanguage(storedLang);
}
}
setIsInitialized(true);
};
useEffect(() => {
initAll();
}, []);
return (
<div style={{
opacity: 1,
transition: 'opacity 0.2s ease-in-out'
}}>
<div
style={{
opacity: isInitialized ? 1 : 0,
transition: "opacity 0.2s ease-in-out",
}}
>
<I18nextProvider i18n={i18n}>{children}</I18nextProvider>
</div>
);
@@ -9,12 +9,11 @@ import { PlatformConfigResponse } from "@/shared/types/system";
export default function ClientRootProviders({
children,
initConfig
initConfig,
}: {
children: React.ReactNode;
initConfig: PlatformConfigResponse;
initConfig?: PlatformConfigResponse;
}) {
return (
<ClientI18nProvider>
<PlatformConfigProvider initConfig={initConfig}>
@@ -2,23 +2,18 @@
import React from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import {
Button,
Divider,
Link,
} from "@nextui-org/react";
import {
LogOut,
} from "lucide-react";
import { Button, Divider, Link } from "@nextui-org/react";
import { LogOut } from "lucide-react";
import { DashboardSidebarProps } from "@/shared/types/dashboard";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
const DashboardSidebar: React.FC<DashboardSidebarProps> = ({
activeTab,
onTabNavigate,
onLogout,
sidebarItems, userProfilePanel
bottomPanel,
sidebarItems,
userProfilePanel,
}) => {
const { t } = useTranslation();
@@ -29,10 +24,7 @@ const DashboardSidebar: React.FC<DashboardSidebarProps> = ({
<div className="mb-8 flex flex-col gap-2">
<div className="flex justify-between items-center gap-2">
<Link href={process.env.NEXT_PUBLIC_DOMAIN || "/"}>
<DynamicLogo
alt="Platform Logo"
className="h-[20px]"
/>
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
</Link>
</div>
<p className="text-default-600 text-sm">
@@ -64,16 +56,20 @@ const DashboardSidebar: React.FC<DashboardSidebarProps> = ({
<Divider className="my-6" />
{/* Logout */}
<Button
variant="light"
color="danger"
startContent={<LogOut className="w-4 h-4" />}
className="w-full justify-start"
onPress={onLogout}
>
{t("Log Out")}
</Button>
<div className="space-y-2">
{bottomPanel}
{/* Logout */}
<Button
variant="light"
color="danger"
startContent={<LogOut className="w-4 h-4" />}
className="w-full justify-start"
onPress={onLogout}
>
{t("Log Out")}
</Button>
</div>
</div>
</div>
);
+7 -3
View File
@@ -2,14 +2,18 @@
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { Link } from "@nextui-org/react";
export function Footer() {
interface FooterProps {
showPoweredBy?: boolean;
}
export function Footer({ showPoweredBy=true }: FooterProps) {
const { platformConfig } = usePlatformConfig();
return (
<footer className="py-4 px-4 sm:px-6 text-center sm:text-end max-w-7xl mx-auto text-xs">
<span className="mr-1">© 2025 {platformConfig?.name}. All rights reserved.</span>
<Link className="text-xs" href="https://xpack.ai">Powered By XPack.AI</Link>
{showPoweredBy && (
<Link className="text-xs" href="https://xpack.ai">Powered By XPack.AI</Link>
)}
</footer>
);
}
+14 -12
View File
@@ -15,22 +15,23 @@ import { useAuth } from "@/shared/lib/useAuth";
import { ArrowRightIcon } from "lucide-react";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import Link from "next/link";
export type NavigationItem = {
label: string;
href: string;
target?: string;
};
interface NavigationProps {
items?: {
label: string;
href: string;
}[];
items?: NavigationItem[];
langNode?: React.ReactNode;
}
// Client-side wrapper for interactive functionality
function NavigationClient({ items = [] }: NavigationProps) {
function NavigationClient({ items = [], langNode }: NavigationProps) {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const { t } = useTranslation();
const { handleLogin } = useAuth();
return (
<>
{/* Main Navigation */}
@@ -53,10 +54,7 @@ function NavigationClient({ items = [] }: NavigationProps) {
<div className="flex justify-start bg-transparent w-max">
{/* Logo using dynamic platform config */}
<Link href="/">
<DynamicLogo
alt="Platform Logo"
className="h-[20px]"
/>
<DynamicLogo alt="Platform Logo" className="h-[20px]" />
</Link>
<Link
href="https://xpack.ai/techblog"
@@ -72,6 +70,8 @@ function NavigationClient({ items = [] }: NavigationProps) {
color="foreground"
href={item.href}
className="font-medium text-foreground-600 hover:text-foreground transition-colors px-2 py-1"
target={item?.target || "_self"}
prefetch={!item.target}
>
{t(item.label)}
</Link>
@@ -82,7 +82,7 @@ function NavigationClient({ items = [] }: NavigationProps) {
{/* Right Side Actions */}
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
{langNode}
{/* Desktop Auth Button */}
<div className="hidden sm:block">
@@ -118,6 +118,8 @@ function NavigationClient({ items = [] }: NavigationProps) {
color="foreground"
href={item.href}
className="w-full py-2 font-medium text-sm"
target={item?.target || "_self"}
prefetch={!item.target}
>
{t(item.label)}
</Link>
@@ -2,20 +2,23 @@ import React, { useState, useEffect, useRef } from "react";
import { Input, Button } from "@nextui-org/react";
import { Search } from "lucide-react";
import { useTranslation } from "react-i18next";
import { _DefaultPlatformConfig, usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import {
_DefaultPlatformConfig,
usePlatformConfig,
} from "@/shared/contexts/PlatformConfigContext";
interface HeroSectionProps {
searchQuery: string;
onSearchChange: (value: string) => void;
onSearch?: () => void;
searchSuggestions?: string[];
}
export const HeroSection: React.FC<HeroSectionProps> = ({
searchQuery,
onSearchChange,
onSearch,
searchSuggestions = [],
}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
@@ -24,22 +27,13 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
const [currentSuggestionIndex, setCurrentSuggestionIndex] = useState(0);
const [isTyping, setIsTyping] = useState(true);
const inputRef = useRef<HTMLInputElement>(null);
const searchSuggestions = [
t("get latest documentation for libraries"),
t("execute terminal commands safely"),
t("find latest scientific research papers"),
t("tools to enhance thinking and reasoning"),
t("find flight tickets and airbnb listings"),
t("automate web browser interactions"),
t("send messages and receive notifications")
];
useEffect(() => {
if (isFocused || searchQuery) {
return;
}
const currentSuggestion = searchSuggestions[currentSuggestionIndex];
const currentSuggestion = t(searchSuggestions[currentSuggestionIndex]);
let timeoutId: NodeJS.Timeout;
if (isTyping) {
@@ -62,7 +56,9 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
}, 50);
} else {
// deleting completed, switch to next suggestion
setCurrentSuggestionIndex((prev) => (prev + 1) % searchSuggestions.length);
setCurrentSuggestionIndex(
(prev) => (prev + 1) % searchSuggestions.length
);
setIsTyping(true);
}
}
@@ -71,7 +67,7 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
}, [animatedText, currentSuggestionIndex, isTyping, isFocused, searchQuery]);
const handleKeyPress = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
if (e.key === "Enter") {
onSearch?.();
}
};
@@ -84,10 +80,14 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
<div className="relative overflow-hidden mx-auto p-6 py-24 max-w-7xl">
<div className="text-center mb-12">
<h1 className="text-5xl lg:text-6xl font-bold mb-6 leading-tight text-primary">
{platformConfig.headline || t(_DefaultPlatformConfig.headline || "")}
{t(platformConfig.headline || _DefaultPlatformConfig.headline || "")}
</h1>
<p className="text-2xl font-medium max-w-3xl mx-auto leading-relaxed">
{platformConfig.subheadline || t(_DefaultPlatformConfig.subheadline || "")}
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
</div>
@@ -96,7 +96,13 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
<Input
ref={inputRef}
size="lg"
placeholder={isFocused || searchQuery ? "" : animatedText}
placeholder={
isFocused || searchQuery
? ""
: searchSuggestions.length > 0
? animatedText
: t("Search services...")
}
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onFocus={() => setIsFocused(true)}
@@ -124,4 +130,4 @@ export const HeroSection: React.FC<HeroSectionProps> = ({
</div>
</div>
);
};
};
@@ -7,44 +7,44 @@ import { Zap } from "lucide-react";
import React from "react";
interface PriceProps {
price?: string;
charge_type: ChargeType;
price?: string;
charge_type?: ChargeType;
}
export const Price: React.FC<PriceProps> = ({
price,
charge_type
}) => {
const { t } = useTranslation();
export const Price: React.FC<PriceProps> = ({ price, charge_type }) => {
const { t } = useTranslation();
if (!charge_type) {
return null;
}
if (charge_type === ChargeType.Free) {
return (
<Chip size="sm" variant="flat" color="default">
{t('Free')}
</Chip>
);
}
if (charge_type === ChargeType.Free) {
return (
<Chip size="sm" variant="flat" color="default">
{t("Free")}
</Chip>
);
}
const priceText = parseFloat(price || '0');
const priceText = parseFloat(price || "0");
if (charge_type === ChargeType.PerCall) {
return (
<div className="flex items-center gap-1">
<span className="text-sm font-medium text-green-600">
${priceText.toFixed(2)}
</span>
<span className="text-xs text-gray-500">/{t('Per Call')}</span>
</div>
);
} else {
return (
<div className="flex items-center gap-1">
<Zap className="w-3 h-3 text-blue-600" />
<span className="text-sm font-medium text-blue-600">
${priceText.toFixed(2)}
</span>
<span className="text-xs text-gray-500">/{t('token')}</span>
</div>
);
}
if (charge_type === ChargeType.PerCall) {
return (
<div className="flex items-center gap-1">
<span className="text-sm font-medium text-green-600">
${priceText.toFixed(2)}
</span>
<span className="text-xs text-gray-500">/{t("Per Call")}</span>
</div>
);
} else {
return (
<div className="flex items-center gap-1">
<Zap className="w-3 h-3 text-blue-600" />
<span className="text-sm font-medium text-blue-600">
${priceText.toFixed(2)}
</span>
<span className="text-xs text-gray-500">/{t("token")}</span>
</div>
);
}
};
@@ -2,11 +2,7 @@
import React from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import {
Card,
CardBody,
Chip,
} from "@nextui-org/react";
import { Card, CardBody, Chip } from "@nextui-org/react";
import { ChargeType, ServiceData } from "@/shared/types/marketplace";
import Link from "next/link";
import { Price } from "./Price";
@@ -15,7 +11,7 @@ interface ProductHeaderProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string
name: string;
}[];
}
@@ -48,9 +44,7 @@ export const ProductHeader: React.FC<ProductHeaderProps> = ({
{/* 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>
<h1 className="text-3xl font-bold mb-2">{product.name}</h1>
{/* Tags */}
{product.tags && product.tags.length > 0 && (
@@ -73,16 +67,16 @@ export const ProductHeader: React.FC<ProductHeaderProps> = ({
{product.short_description || t("No description available")}
</p>
</div>
</div>
{/* Price section */}
<div className="flex gap-2 items-center">
<b className="text-xs">{t("Price")}:</b>
<Price price={product.price} charge_type={product.charge_type || ChargeType.Free} />
</div>
{product.charge_type && (
<div className="flex gap-2 items-center">
<b className="text-xs">{t("Price")}:</b>
<Price price={product.price} charge_type={product.charge_type} />
</div>
)}
</CardBody>
</Card>
);
};
};
@@ -16,7 +16,7 @@ export const ProductOverview: React.FC<ProductOverviewProps> = ({
const { t } = useTranslation();
return (
<Card shadow="none">
<Card shadow="none" className="bg-transparent">
<CardBody className="space-y-4">
<div className="leading-relaxed prose prose-sm max-w-none">
{product.long_description ? (
@@ -28,4 +28,4 @@ export const ProductOverview: React.FC<ProductOverviewProps> = ({
</CardBody>
</Card>
);
};
};
@@ -13,17 +13,15 @@ interface ServerConfigProps {
}
export const ServerConfig: React.FC<ServerConfigProps> = ({ product }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
const { platformConfig } = usePlatformConfig();
const [url, setUrl] = useState<string>(process.env.NEXT_PUBLIC_MCP_URL || "");
useEffect(() => {
if (url || !product.slug_name) return
if (url || !product.slug_name) return;
setUrl(`${window.location.origin}/mcp/${product.slug_name}`);
}, [product.slug_name]);
return (
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0 mt-12">
<div className="mb-4 mt-1">
@@ -46,7 +44,7 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({ product }) => {
"mcpServers": {
"xpack-mcp-market": {
"type": "sse",
"autoApprove"":"all",
"autoApprove":"all",
"url": "${url}?apikey=`}
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
{`"
@@ -59,4 +57,4 @@ export const ServerConfig: React.FC<ServerConfigProps> = ({ product }) => {
</Card>
</div>
);
};
};
@@ -35,8 +35,6 @@ export const ServiceCard: React.FC<ServiceCardProps> = ({ service }) => {
<p className="text-xs text-gray-600 mb-4 line-clamp-2 leading-relaxed">
{service.short_description || t("No description available")}
</p>
</CardBody>
{/* Footer with tools count */}
<CardFooter>
@@ -50,7 +48,7 @@ export const ServiceCard: React.FC<ServiceCardProps> = ({ service }) => {
{t("{{count}} Tools", { count: service.tools.length })}
</Chip>
<div className="flex flex-col gap-1">
<Price price={service.price} charge_type={service.charge_type || ChargeType.Free} />
<Price price={service.price} charge_type={service.charge_type} />
</div>
</div>
</CardFooter>
@@ -1,7 +1,12 @@
'use client';
"use client";
import React, { createContext, useContext, useState, ReactNode, useEffect } from 'react';
import { PlatformConfig, PlatformConfigResponse, GoogleAuthConfig } from '@/shared/types/system';
import React, { createContext, useContext, useState, ReactNode } from "react";
import {
PlatformConfig,
PlatformConfigResponse,
Theme,
LoginConfig,
} from "@/shared/types/system";
export const _DefaultPlatformConfig: PlatformConfig = {
name: "XPack",
logo: "/static/logo/logo.png",
@@ -9,34 +14,43 @@ export const _DefaultPlatformConfig: PlatformConfig = {
language: "en",
website_title: "Connect Your AI Agent to the Real World - XPack",
headline: "Connect Your AI Agent to the Real World",
subheadline: "Open‑source MCP marketplace — publish or consume APIs in minutes.",
subheadline:
"Open‑source MCP marketplace — publish or consume APIs in minutes.",
theme: Theme.DEFAULT,
};
interface PlatformConfigContextType {
platformConfig: PlatformConfig;
googleAuthConfig: GoogleAuthConfig | null;
loginConfig: LoginConfig | null;
updateClientConfig: (config: PlatformConfigResponse) => void;
}
const PlatformConfigContext = createContext<PlatformConfigContextType | undefined>(undefined);
const PlatformConfigContext = createContext<
PlatformConfigContextType | undefined
>(undefined);
interface PlatformConfigProviderProps {
children: ReactNode;
initConfig: PlatformConfigResponse;
initConfig?: PlatformConfigResponse;
}
export const PlatformConfigProvider: React.FC<PlatformConfigProviderProps> = ({
children,
initConfig,
}) => {
const [platformConfig, setPlatformConfig] = useState<PlatformConfig>(initConfig.platform || _DefaultPlatformConfig);
const [googleAuthConfig, setGoogleAuthConfig] = useState<GoogleAuthConfig | null>(initConfig.login?.google || null);
const [platformConfig, setPlatformConfig] = useState<PlatformConfig>(
initConfig?.platform || _DefaultPlatformConfig
);
const [loginConfig, setLoginConfig] = useState<LoginConfig | null>(
initConfig?.login || null
);
const updateClientConfig = (config: PlatformConfigResponse) => {
if (config.platform) setPlatformConfig(config.platform);
if (config.login?.google) setGoogleAuthConfig(config.login?.google);
if (config.login) setLoginConfig(config.login);
};
return (
<PlatformConfigContext.Provider value={{ platformConfig, googleAuthConfig, updateClientConfig }}>
<PlatformConfigContext.Provider
value={{ platformConfig, loginConfig, updateClientConfig }}
>
{children}
</PlatformConfigContext.Provider>
);
@@ -45,7 +59,9 @@ export const PlatformConfigProvider: React.FC<PlatformConfigProviderProps> = ({
export const usePlatformConfig = () => {
const context = useContext(PlatformConfigContext);
if (context === undefined) {
throw new Error('usePlatformConfig must be used within a PlatformConfigProvider');
throw new Error(
"usePlatformConfig must be used within a PlatformConfigProvider"
);
}
return context;
};
};
+25 -8
View File
@@ -3,10 +3,17 @@ import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import Backend from "i18next-http-backend";
import { getDefaultLanguage } from "@/shared/utils/i18n";
import en from "../../../public/locales/en/translation.json";
import enConfig from "../../../public/locales/en/config.json";
import zhCN from "../../../public/locales/zh-CN/translation.json";
import zhCNConfig from "../../../public/locales/zh-CN/config.json";
let resources = {};
if(typeof window !== "undefined" && !window._BACKEND_LOAD_LANG__){
let en=require("../../../public/locales/en/translation.json");
let enConfig=require("../../../public/locales/en/config.json");
let zhCN=require("../../../public/locales/zh-CN/translation.json");
let zhCNConfig=require("../../../public/locales/zh-CN/config.json");
resources = {
en: { translation: en, config: enConfig },
"zh-CN": { translation: zhCN, config: zhCNConfig },
};
}
// Try to read the preferred language from multiple sources:
// 1. URL parameters (lang=zh-CN)
@@ -25,10 +32,20 @@ export const i18nPromise = i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
en: { translation: en, config: enConfig },
"zh-CN": { translation: zhCN, config: zhCNConfig },
},
...(typeof window !== "undefined" && window._BACKEND_LOAD_LANG__
? {
backend: {
// Allow loading multiple namespaces (e.g. translation.json, config.json)
loadPath: `${process.env.NEXT_PUBLIC_STATIC_URL_PREFIX || ""}/locales/{{lng}}/{{ns}}.json`,
// add request options to improve loading speed
requestOptions: {
cache: "default",
},
},
}
: {
resources,
}),
ns: ["translation", "config"],
defaultNS: "translation",
fallbackNS: "config",
+1 -1
View File
@@ -4,7 +4,7 @@ export const SOURCE_TYPE = SourceType.SSG;
// Define base URLs for API requests
export const API_BASE_URL =
process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8100";
process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:8001";
// Helper function for constructing API URLs
export const getApiUrl = (endpoint: string) => {
+6
View File
@@ -4,6 +4,11 @@ interface APIKey {
create_time: number;
apikey_id: string;
}
export enum RegisterType {
EMAIL = "email",
GOOGLE = "google",
INNER = "inner",
}
export interface User {
user_id: string;
user_email: string;
@@ -26,4 +31,5 @@ export interface User {
wallet?: {
balance: number;
};
register_type: RegisterType;
}
+9
View File
@@ -10,6 +10,7 @@ import {
import { fetchAPI } from "../rpc/common-function";
import { shallow } from "zustand/shallow";
import { useSharedStore } from "./share";
import { md5Encrypt } from "@/shared/utils/crypto";
export const StorageGlobalName = "XPack_Global";
@@ -22,6 +23,7 @@ export type GlobalStore = {
getUser: () => Promise<ApiResponse>;
useGetUser: () => SWRResponse<any, any>;
logOut: () => void;
changePassword: (password: string) => Promise<ApiResponse>;
};
export const useGlobalStore = createWithEqualityFn<GlobalStore>()(
@@ -99,6 +101,13 @@ export const useGlobalStore = createWithEqualityFn<GlobalStore>()(
console.error("log out error", e);
}
},
changePassword: async (password: string) => {
const res = await fetchAPI("/api/user/password", {
method: "PUT",
body: { password: md5Encrypt(password) } as unknown as BodyInit,
});
return res;
},
})
)
),
+13 -10
View File
@@ -1,13 +1,15 @@
export type TabKey =
| "console"
| "mcp-services"
| "user-management"
| "revenue-management"
| "payment-channels"
| "system-settings"
| "overview"
| "wallet"
| "account";
export enum TabKey {
CONSOLE = "console",
MCP_SERVICES = "mcp-services",
USER_MANAGEMENT = "user-management",
REVENUE_MANAGEMENT = "revenue-management",
PAYMENT_CHANNELS = "payment-channels",
LOGIN_SETTINGS = "login-settings",
SYSTEM_SETTINGS = "system-settings",
OVERVIEW = "overview",
WALLET = "wallet",
ACCOUNT = "account",
}
export interface SidebarItem {
key: TabKey;
@@ -20,6 +22,7 @@ export interface DashboardSidebarProps {
activeTab: TabKey;
onTabNavigate?: (tab: TabKey) => void;
onLogout: () => void;
bottomPanel?: React.ReactNode;
sidebarItems: SidebarItem[];
userProfilePanel?: React.ReactNode;
}
+30 -6
View File
@@ -1,3 +1,16 @@
// Theme enum
export enum Theme {
DEFAULT = "default",
MODERN = "modern",
CLASSIC = "classic",
CREATIVE = "creative",
TEMU = "temu",
}
export enum EmailMode {
PASSWORD = "password",
CAPTCHA = "captcha",
}
export interface PlatformConfig {
logo?: string; // platform logo url
name: string; // platform name
@@ -6,15 +19,14 @@ export interface PlatformConfig {
website_title?: string; // website title
headline?: string; // homepage headline
subheadline?: string; // homepage subheadline
theme?: Theme; // platform theme for homepage and marketplace templates
about_page?: string; // about page content (markdown)
}
export type ThemeType = Theme;
export interface PlatformConfigResponse {
platform: PlatformConfig;
login?: {
google?: {
client_id: string;
is_enabled: boolean;
};
};
login?: LoginConfig;
}
// google auth config
@@ -23,3 +35,15 @@ export interface GoogleAuthConfig {
client_secret?: string; // Google Client Secret (optional, for server-side validation)
is_enabled: boolean; // whether to enable google login
}
// email login config
export interface EmailLoginConfig {
is_enabled: boolean; // whether to enable email login
mode: EmailMode; // authentication mode
}
// login config
export interface LoginConfig {
google: GoogleAuthConfig;
email?: EmailLoginConfig;
}
+35
View File
@@ -8,3 +8,38 @@ import CryptoJS from "crypto-js";
export const md5Encrypt = (text: string): string => {
return CryptoJS.MD5(text).toString();
};
/**
* SHA256 encrypt function
* @param text text to encrypt
* @returns SHA256 encrypted string
*/
export const sha256Encrypt = (text: string): string => {
return CryptoJS.SHA256(text).toString();
};
/**
* Calculate SHA256 hash of a file
* @param file File to calculate hash for
* @returns Promise resolving to SHA256 hash string
*/
export const calculateFileSha256 = (file: File): Promise<string> => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
try {
const binary = event.target?.result;
if (binary) {
const hash = CryptoJS.SHA256(CryptoJS.lib.WordArray.create(binary as any)).toString();
resolve(hash);
} else {
reject(new Error("Failed to read file"));
}
} catch (error) {
reject(error);
}
};
reader.onerror = (error) => reject(error);
reader.readAsArrayBuffer(file);
});
};
+9
View File
@@ -27,6 +27,7 @@ export type AdminStore = {
// Admin operations
adminLogOut: () => void;
adminLogin: (username: string, password: string) => Promise<ApiResponse>;
getAdminUser: () => Promise<ApiResponse>;
};
const fn: StateCreator<AdminStore, []> = (set, get) => {
@@ -115,6 +116,14 @@ const fn: StateCreator<AdminStore, []> = (set, get) => {
};
}
},
getAdminUser: async () => {
const { setAdmin } = get();
const res = await fetchAdminAPI("/api/user/info");
if (res.success) {
setAdmin(res.data);
}
return res;
},
};
};
+235
View File
@@ -0,0 +1,235 @@
/* Theme Styles */
/* Modern Theme - 现代简约风格 */
.theme-modern {
--theme-primary-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--theme-secondary-bg: #f8fafc;
--theme-accent-color: #3b82f6;
--theme-text-primary: #1e293b;
--theme-text-secondary: #64748b;
--theme-border-radius: 12px;
--theme-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--theme-card-bg: #ffffff;
--theme-hero-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23f1f5f9' fill-opacity='0.4'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
/* Classic Theme - 经典商务风格 */
.theme-classic {
--theme-primary-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
--theme-secondary-bg: #ecf0f1;
--theme-accent-color: #e74c3c;
--theme-text-primary: #2c3e50;
--theme-text-secondary: #7f8c8d;
--theme-border-radius: 6px;
--theme-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--theme-card-bg: #ffffff;
--theme-hero-pattern: 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='%23bdc3c7' fill-opacity='0.3'%3E%3Cpath d='M20 20h20v20H20V20zm-20 0h20v20H0V20z'/%3E%3C/g%3E%3C/svg%3E");
}
/* Creative Theme - 创意活力风格 */
.theme-creative {
--theme-primary-bg: linear-gradient(135deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%);
--theme-secondary-bg: #fff5f5;
--theme-accent-color: #ff6b6b;
--theme-text-primary: #2d3748;
--theme-text-secondary: #718096;
--theme-border-radius: 20px;
--theme-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
--theme-card-bg: #ffffff;
--theme-hero-pattern: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ff6b6b' fill-opacity='0.1'%3E%3Cpath d='M0 0h40v40H0V0zm40 40h40v40H40V40z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
/* Theme-specific component styles */
/* Hero Section Styles */
.theme-modern .hero-section {
background: var(--theme-primary-bg);
background-attachment: fixed;
position: relative;
}
.theme-modern .hero-section::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--theme-hero-pattern);
opacity: 0.1;
}
.theme-classic .hero-section {
background: var(--theme-primary-bg);
position: relative;
}
.theme-classic .hero-section::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--theme-hero-pattern);
opacity: 0.05;
}
.theme-creative .hero-section {
background: var(--theme-primary-bg);
position: relative;
overflow: hidden;
}
.theme-creative .hero-section::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--theme-hero-pattern);
opacity: 0.1;
animation: float 6s ease-in-out infinite;
}
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-10px); }
}
/* Card Styles */
.theme-modern .themed-card {
background: var(--theme-card-bg);
border-radius: var(--theme-border-radius);
box-shadow: var(--theme-shadow);
transition: all 0.3s ease;
}
.theme-modern .themed-card:hover {
transform: translateY(-4px);
box-shadow: 0 20px 40px -7px rgba(0, 0, 0, 0.1);
}
.theme-classic .themed-card {
background: var(--theme-card-bg);
border-radius: var(--theme-border-radius);
box-shadow: var(--theme-shadow);
border: 1px solid #e1e8ed;
transition: all 0.2s ease;
}
.theme-classic .themed-card:hover {
border-color: var(--theme-accent-color);
box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1);
}
.theme-creative .themed-card {
background: var(--theme-card-bg);
border-radius: var(--theme-border-radius);
box-shadow: var(--theme-shadow);
position: relative;
overflow: hidden;
transition: all 0.4s ease;
}
.theme-creative .themed-card::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.5s;
}
.theme-creative .themed-card:hover::before {
left: 100%;
}
.theme-creative .themed-card:hover {
transform: translateY(-8px) scale(1.02);
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}
/* Button Styles */
.theme-modern .themed-button {
background: var(--theme-accent-color);
border-radius: var(--theme-border-radius);
transition: all 0.3s ease;
}
.theme-classic .themed-button {
background: var(--theme-accent-color);
border-radius: var(--theme-border-radius);
transition: all 0.2s ease;
}
.theme-creative .themed-button {
background: var(--theme-accent-color);
border-radius: var(--theme-border-radius);
transition: all 0.4s ease;
position: relative;
overflow: hidden;
}
/* Text Styles */
.themed-text-primary {
color: var(--theme-text-primary);
}
.themed-text-secondary {
color: var(--theme-text-secondary);
}
/* Layout Styles */
.theme-modern .themed-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 24px;
}
.theme-classic .themed-container {
max-width: 1140px;
margin: 0 auto;
padding: 0 20px;
}
.theme-creative .themed-container {
max-width: 1280px;
margin: 0 auto;
padding: 0 32px;
}
/* Themed Pagination Styles */
.themed-pagination {
transform: scale(1.1);
}
.themed-pagination [data-slot="item"] {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-radius: 12px;
font-weight: 600;
transition: all 0.3s ease;
}
.themed-pagination [data-slot="item"]:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px -8px rgba(102, 126, 234, 0.6);
}
.themed-pagination [data-slot="prev"],
.themed-pagination [data-slot="next"] {
background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
color: white;
border-radius: 50%;
font-weight: bold;
}
.themed-pagination [data-slot="prev"]:hover,
.themed-pagination [data-slot="next"]:hover {
transform: scale(1.1) rotate(5deg);
box-shadow: 0 8px 25px -8px rgba(255, 107, 107, 0.6);
}
+1
View File
@@ -3,6 +3,7 @@ import { PlatformConfigResponse } from "@/shared/types/system";
declare global {
interface Window {
__PLATFORM_CONFIG__?: PlatformConfigResponse | null;
_BACKEND_LOAD_LANG__?: boolean;
}
}
+6 -4
View File
@@ -1,15 +1,17 @@
// 系统设置相关类型定义
import { GoogleAuthConfig, PlatformConfig } from "@/shared/types/system";
import {
GoogleAuthConfig,
PlatformConfig,
LoginConfig,
} from "@/shared/types/system";
// API return system config data structure
export interface SystemConfigApiData {
platform: PlatformConfig;
account: AdminConfig;
email: EmailConfig;
login: {
google: GoogleAuthConfig;
};
login: LoginConfig;
}
// admin config
export interface AdminConfig {
+2 -1
View File
@@ -17,10 +17,11 @@ WORKDIR /$APP
COPY requirements.txt /$APP/requirements.txt
RUN uv venv && source .venv/bin/activate && uv pip install -r requirements.txt
RUN echo $VERSION > .version
COPY frontend/out/ /$APP/frontend
COPY scripts/resource/ /$APP
COPY pyproject.toml /$APP/pyproject.toml
COPY services/ /$APP/services
CMD [ "./start.sh" ]
+1
View File
@@ -27,6 +27,7 @@ services:
- xpack
ports:
- "3000:3000"
- "8002:8002"
depends_on:
- xpack-mysql
- xpack-redis
File diff suppressed because it is too large. Load diff
+24 -6
View File
@@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`avatar` VARCHAR(255) DEFAULT NULL COMMENT 'User avatar URL',
`is_active` TINYINT NOT NULL DEFAULT 1 COMMENT 'User status: 0 (inactive), 1 (active)',
`is_deleted` TINYINT NOT NULL DEFAULT 0 COMMENT 'Logical deletion: 0 (normal), 1 (deleted)',
`register_type` ENUM('google', 'email') NOT NULL COMMENT 'Registration method: google or email',
`register_type` ENUM('google', 'email','inner') NOT NULL COMMENT 'Registration method: google or email',
`role_id` INT NOT NULL COMMENT 'Role ID: 1 (admin), 2 (user)',
`last_login_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Last login timestamp',
`last_login_ip` VARCHAR(255) DEFAULT NULL COMMENT 'Last login IP address',
@@ -38,6 +38,8 @@ CREATE TABLE IF NOT EXISTS `user` (
UNIQUE INDEX `uk_email` (`email`) COMMENT 'Unique email index'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Stores user information and status';
ALTER TABLE `user`
MODIFY COLUMN `register_type` ENUM('google', 'email', 'inner') NOT NULL COMMENT 'Registration method';
-- ----------------------------
-- Table structure for user_access_token
-- ----------------------------
@@ -260,17 +262,33 @@ CREATE TABLE IF NOT EXISTS `mcp_call_log` (
FOREIGN KEY (`wallet_history_id`) REFERENCES `user_wallet_history` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Stores API call logs';
# 判断用户是否存在,若不存在则插入
CREATE TABLE IF NOT EXISTS `sys_config_large` (
`id` char(36) NOT NULL COMMENT '主键,UUID',
`key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '配置键名',
`value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '配置值',
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '配置项描述',
`created_at` timestamp NULL DEFAULT NULL COMMENT '记录创建时间',
`updated_at` timestamp NULL DEFAULT NULL COMMENT '记录最后更新时间',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `uk_key` (`key`) USING BTREE COMMENT '配置键名唯一索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='系统参数配置表,用于存储系统级配置信息';
INSERT INTO `user` (`id`, `name`, `email`, `password`, `is_active`, `is_deleted`, `register_type`, `role_id`, `created_at`, `updated_at`)
SELECT 'admin', 'admin', 'admin@xpack.com', '25f9e794323b453885f5181f1b624d0b', 1, 0, 'email', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM `user` WHERE `id` = 'admin');
VALUES ('admin', 'admin', 'admin@xpack.com', '25f9e794323b453885f5181f1b624d0b', 1, 0, 'inner', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
ON DUPLICATE KEY UPDATE
`name` = VALUES(`name`),
`email` = VALUES(`email`),
`password` = VALUES(`password`),
`is_active` = VALUES(`is_active`),
`is_deleted` = VALUES(`is_deleted`),
`register_type` = VALUES(`register_type`),
`role_id` = VALUES(`role_id`),
`updated_at` = CURRENT_TIMESTAMP;
# 判断用户钱包是否存在,若不存在则插入
INSERT INTO `user_wallet` (`id`, `user_id`, `balance`, `frozen_balance`, `created_at`, `updated_at`)
SELECT UUID(), 'admin', 0.00, 0.00, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
WHERE NOT EXISTS (SELECT 1 FROM `user_wallet` WHERE `user_id` = 'admin');
# 判断支付渠道是否存在,若不存在则插入
INSERT INTO `payment_channel` (`id`, `name`, `status`, `config`, `updated_at`)
SELECT 'stripe', 'Stripe', 1, '{\"secret\": \"\", \"webhook_secret\": \"\"}', '2025-07-17 06:42:55'
WHERE NOT EXISTS (SELECT 1 FROM `payment_channel` WHERE `id` = 'stripe');
+3 -3
View File
@@ -27,8 +27,6 @@ fi
# 执行环境检查
check_uv_env
echo $VERSION > .version
if [ -f .env.example ]; then
cp .env.example .env
fi
@@ -38,10 +36,12 @@ python ./init_db.py
nohup uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload > ${LOG_DIR}/admin_service.log 2>&1 &
sleep 5s
nohup uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload > ${LOG_DIR}/api_service.log 2>&1 &
cd frontend/ && nohup node server.js > ${LOG_DIR}//frontend.log 2>&1 &
sleep 5s
sleep 2s
tail -F ${LOG_DIR}/*.log
+36
View File
@@ -0,0 +1,36 @@
{
"version": "v0.1",
"releaseDate": "2025-07-20",
"description": "This is the latest release of the application.",
"downloads": {
"program": {
"xpack_mcp_market": {
"version": "v0.1.0",
"docker": "xpackai/xpack-mcp-market",
"tar": "xpack-mcp-market.tar.gz",
"url": "https://public.eolinker.com/xpack/images/xpack-mcp-market.${VERSION}.${ARCH}.tar.gz"
}
},
"dependencies": {
"mysql": {
"version": "8.0.37",
"docker": "mysql",
"tar": "mysql.tar.gz",
"url": "https://public.eolinker.com/basic/images/mysql.${VERSION}.${ARCH}.tar.gz"
},
"redis":
{
"version": "7.2.4",
"docker": "redis",
"tar": "redis.tar.gz",
"url": "https://public.eolinker.com/basic/images/redis.${VERSION}.${ARCH}.tar.gz"
},
"rabbitmq": {
"version": "4.1.2-alpine",
"docker": "rabbitmq",
"tar": "rabbitmq.tar.gz",
"url": "https://public.eolinker.com/basic/images/rabbitmq.${VERSION}.${ARCH}.tar.gz"
}
}
}
}
@@ -5,6 +5,8 @@ KEY_WEBSITE_TITLE = "website_title"
KEY_HEADLINE = "headline"
KEY_SUBHEADLINE = "subheadline"
KEY_LANGUAGE = "language"
KEY_THEME = "theme"
KEY_ABOUT_PAGE = "about_page"
KEY_ADMIN_USERNAME = "admin_username"
KEY_ADMIN_PASSWORD = "admin_password"
KEY_LOGIN_GOOGLE_CLIENT = "login_google_client_id"
@@ -15,4 +17,7 @@ KEY_EMAIL_SMTP_HOST = "email_smtp_host"
KEY_EMAIL_SMTP_PORT = "email_smtp_port"
KEY_EMAIL_SMTP_USER = "email_smtp_user"
KEY_EMAIL_SMTP_PASSWORD = "email_smtp_password"
KEY_EMAIL_SMTP_SENDER = "email_smtp_sender"
KEY_EMAIL_SMTP_SENDER = "email_smtp_sender"
KEY_LOGIN_EMAIL_ENABLE = "login_email_enable"
KEY_LOGIN_EMAIL_MODE = "login_email_mode"
+30 -7
View File
@@ -3,7 +3,9 @@ from sqlalchemy.orm import Session
from services.common.database import get_db
from services.common.utils.response_utils import ResponseUtils
from services.admin_service.services.auth_service import AuthService
from services.admin_service.services.sys_config_service import SysConfigService
from services.admin_service.utils.user_utils import UserUtils
from services.admin_service.constants import sys_config_key
router = APIRouter()
@@ -11,15 +13,36 @@ router = APIRouter()
def get_auth_service(db: Session = Depends(get_db)) -> AuthService:
return AuthService(db)
def get_sys_config_service(db: Session = Depends(get_db)) -> SysConfigService:
return SysConfigService(db)
@router.post("/email/sign", response_model=dict)
def email_login(body: dict = Body(...), auth_service: AuthService = Depends(get_auth_service)):
def email_login(
body: dict = Body(...),
auth_service: AuthService = Depends(get_auth_service),
sys_config_service: SysConfigService = Depends(get_sys_config_service),
):
"""Authenticate user via email and captcha code."""
email_is_enabled_raw = sys_config_service.get_value_by_key(sys_config_key.KEY_LOGIN_EMAIL_ENABLE) or "false"
# Convert to boolean
email_is_enabled = email_is_enabled_raw.lower() in ("true", "t", "yes", "y", "1")
if not email_is_enabled:
return ResponseUtils.error(message="email login not enabled", code=400)
email_mode = sys_config_service.get_value_by_key(sys_config_key.KEY_LOGIN_EMAIL_MODE) or "password"
email = body.get("user_email")
captcha = body.get("captcha")
if not email or not captcha:
return ResponseUtils.error(message="email and captcha required", code=400)
token = auth_service.email_login(email, captcha)
token = None
match email_mode:
case "password":
password = body.get("password")
if not email or not password:
return ResponseUtils.error(message="email and password required", code=400)
token = auth_service.email_login_by_password(email=email, password=password)
case "captcha":
captcha = body.get("captcha")
if not email or not captcha:
return ResponseUtils.error(message="email and captcha required", code=400)
token = auth_service.email_login_by_captcha(email=email, captcha=captcha)
if token:
return ResponseUtils.success({"user_token": token})
else:
@@ -72,6 +95,6 @@ def google_login(request: Request, body: dict = Body(...), auth_service: AuthSer
@router.delete("/logout", response_model=dict)
def logout(request: Request, auth_service: AuthService = Depends(get_auth_service)):
"""Log out current authenticated user."""
user_id = UserUtils.get_request_user_id(request)
auth_service.logout(user_id)
user_token = UserUtils.get_request_user_token(request)
auth_service.logout(user_token)
return ResponseUtils.success(message="Logout successful")
@@ -13,8 +13,12 @@ from services.admin_service.constants.sys_config_key import (
KEY_HEADLINE,
KEY_SUBHEADLINE,
KEY_LANGUAGE,
KEY_THEME,
KEY_ABOUT_PAGE,
KEY_LOGIN_GOOGLE_CLIENT,
KEY_LOGIN_GOOGLE_ENABLE,
KEY_LOGIN_EMAIL_ENABLE,
KEY_LOGIN_EMAIL_MODE,
)
logger = logging.getLogger(__name__)
@@ -36,16 +40,27 @@ def get_config(db: Session = Depends(get_db)):
headline = sys_config_service.get_value_by_key(KEY_HEADLINE) or ""
subheadline = sys_config_service.get_value_by_key(KEY_SUBHEADLINE) or ""
language = sys_config_service.get_value_by_key(KEY_LANGUAGE) or ""
theme = sys_config_service.get_value_by_key(KEY_THEME) or ""
about_page = sys_config_service.get_value_by_key(KEY_ABOUT_PAGE,True) or ""
# Get login config
google_client_id = sys_config_service.get_value_by_key(KEY_LOGIN_GOOGLE_CLIENT) or ""
google_is_enabled_raw = sys_config_service.get_value_by_key(KEY_LOGIN_GOOGLE_ENABLE) or "false"
# Convert to boolean
google_is_enabled = google_is_enabled_raw.lower() in ("true", "t", "yes", "y", "1")
# Get login email config
email_is_enabled_raw = sys_config_service.get_value_by_key(KEY_LOGIN_EMAIL_ENABLE) or "false"
# Convert to boolean
email_is_enabled = email_is_enabled_raw.lower() in ("true", "t", "yes", "y", "1")
email_mode = sys_config_service.get_value_by_key(KEY_LOGIN_EMAIL_MODE) or "password"
# Build response data
config_data = {
"login": {"google": {"client_id": google_client_id, "is_enabled": google_is_enabled}},
"login": {
"google": {"client_id": google_client_id, "is_enabled": google_is_enabled},
"email": {"is_enabled": email_is_enabled, "mode": email_mode},
},
"platform": {
"name": platform_name,
"logo": platform_logo,
@@ -53,6 +68,8 @@ def get_config(db: Session = Depends(get_db)):
"headline": headline,
"subheadline": subheadline,
"language": language,
"theme": theme,
"about_page": about_page,
},
}
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff. Show more