From e40fe98b42480d59f70aa66071116f07a5921001 Mon Sep 17 00:00:00 2001 From: canglan Date: Wed, 6 May 2026 18:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 70 +++++++++++++++++++++------------ app/Config/.gitkeep | 0 app/Controllers/.gitkeep | 0 app/Middleware/.gitkeep | 0 app/Models/.gitkeep | 0 app/Services/Providers/.gitkeep | 0 app/Views/layout/.gitkeep | 0 public/.gitkeep | 0 public/assets/css/.gitkeep | 0 public/assets/js/.gitkeep | 0 scripts/.gitkeep | 0 tests/.gitkeep | 0 tests/backend/.gitkeep | 0 tests/frontend/.gitkeep | 0 14 files changed, 44 insertions(+), 26 deletions(-) delete mode 100644 app/Config/.gitkeep delete mode 100644 app/Controllers/.gitkeep delete mode 100644 app/Middleware/.gitkeep delete mode 100644 app/Models/.gitkeep delete mode 100644 app/Services/Providers/.gitkeep delete mode 100644 app/Views/layout/.gitkeep delete mode 100644 public/.gitkeep delete mode 100644 public/assets/css/.gitkeep delete mode 100644 public/assets/js/.gitkeep delete mode 100644 scripts/.gitkeep delete mode 100644 tests/.gitkeep delete mode 100644 tests/backend/.gitkeep delete mode 100644 tests/frontend/.gitkeep diff --git a/README.md b/README.md index f176f1d..80e7c99 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,21 @@ 一个基于 PHP 8.0 的 AI 聊天 Web 应用,支持多种 AI 服务供应商,提供流式对话体验。 -## ✨ 功能特性 +## 功能特性 -- 🔐 用户认证系统(JWT) -- 🤖 多 AI 服务供应商支持(OpenAI、Claude、DeepSeek 等 12+ 供应商) -- 💭 思考/非思考模式切换 -- 📡 SSE 流式响应(打字机效果) -- 💬 多会话管理 -- 📁 文件上传(图片 + 代码文件) -- 🎨 代码高亮和 Markdown 渲染 -- 🧠 自定义提示词和可配置人格(预设 + 自定义) -- 💾 双重历史记录存储(服务器 + 本地缓存) -- 🌐 Web 安装界面(零配置部署) -- ⚙️ API 配置管理界面 +- 用户认证系统(JWT) +- 多 AI 服务供应商支持(OpenAI、Claude、DeepSeek 等 12+ 供应商) +- 思考/非思考模式切换 +- SSE 流式响应(打字机效果) +- 多会话管理 +- 文件上传(图片 + 代码文件) +- 代码高亮和 Markdown 渲染 +- 自定义提示词和可配置人格(预设 + 自定义) +- 双重历史记录存储(服务器 + 本地缓存) +- Web 安装界面(零配置部署) +- API 配置管理界面 -## 🛠️ 技术栈 +## 技术栈 | 组件 | 技术 | |------|------| @@ -26,21 +26,27 @@ | 数据库 | MySQL 5.7+ / 8.0(PDO 驱动) | | 前端 | PHP 模板 + 原生 JavaScript + AJAX | | Web 服务器 | Nginx + PHP-FPM | -| 认证 | JWT(firebase/php-jwt) | +| 认证 | JWT(firebase/php-jwt v7.0.5) | | 依赖管理 | Composer(PSR-4 自动加载) | | 代码高亮 | highlight.js(CDN) | | Markdown 渲染 | marked.js(CDN) | -## 📁 项目结构 +## 项目结构 ``` ai-chat/ ├── public/ # Web 根目录(Nginx 指向此目录) +│ ├── index.php # 首页入口(自动路由到登录/安装页) │ ├── api.php # API 统一入口 │ ├── login.php # 登录页面 │ ├── chat.php # 聊天主页面 │ ├── config.php # 配置管理页面 -│ └── install.php # 安装向导页面 +│ ├── install.php # 安装向导页面 +│ ├── assets/ # 前端静态资源 +│ │ ├── css/ # 样式文件 +│ │ ├── js/ # JavaScript 文件 +│ │ └── img/ # 图片资源 +│ └── uploads/ # 用户上传文件 ├── app/ # 应用代码(PSR-4 自动加载) │ ├── Config/ # 配置管理(Database、AppConfig) │ ├── Controllers/ # 控制器(Auth、Chat、Session 等) @@ -48,19 +54,14 @@ ai-chat/ │ ├── Models/ # 数据模型(User、Session、Message 等) │ ├── Services/ # 服务层(AIService、Installer、Providers) │ └── Views/ # 视图模板(login、chat、config、layout) -├── assets/ # 前端静态资源 -│ ├── css/ # 样式文件 -│ ├── js/ # JavaScript 文件 -│ └── img/ # 图片资源 ├── config/ # JSON 配置文件(安装后生成) -├── uploads/ # 用户上传文件 ├── docs/ # 文档 ├── vendor/ # Composer 依赖(安装后生成) ├── composer.json # PHP 依赖配置 └── .gitignore ``` -## 🚀 快速开始 +## 快速开始 ### 环境要求 @@ -87,13 +88,30 @@ ai-chat/ - 将网站根目录指向 `public/` 目录 - 参考 `docs/nginx.conf` 或 `docs/baota-nginx-snippet.conf` 配置 Nginx -4. **运行安装向导** +4. **设置目录权限** + ```bash + chmod -R 755 . + chown -R www:www . + ``` + +5. **运行安装向导** - 访问 `http://your-domain.com/install.php` - 按照向导步骤完成安装 详细安装说明请查看 [INSTALL.md](INSTALL.md)。 -## 📖 文档 +## 页面说明 + +| 页面 | 路径 | 说明 | +|------|------|------| +| 首页 | `/` | 自动重定向到登录页或安装页 | +| 登录 | `/login.php` | 用户登录 | +| 聊天 | `/chat.php` | AI 对话主界面 | +| 配置 | `/config.php` | 系统配置(需管理员权限) | +| 安装 | `/install.php` | 安装向导(安装后自动跳转) | +| API | `/api.php` | RESTful API 统一入口 | + +## 文档 - [安装指南](INSTALL.md) - [部署文档](docs/DEPLOY.md) @@ -103,11 +121,11 @@ ai-chat/ - [Nginx 配置](docs/nginx.conf) - [宝塔面板配置](docs/baota-nginx-snippet.conf) -## 📄 开源协议 +## 开源协议 本项目基于 [GNU Affero General Public License v3.0 (AGPLv3)](LICENSE) 开源。 -## 📌 版本历史 +## 版本历史 | 版本 | 日期 | 说明 | |------|------|------| diff --git a/app/Config/.gitkeep b/app/Config/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/Controllers/.gitkeep b/app/Controllers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/Middleware/.gitkeep b/app/Middleware/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/Models/.gitkeep b/app/Models/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/Services/Providers/.gitkeep b/app/Services/Providers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/Views/layout/.gitkeep b/app/Views/layout/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/.gitkeep b/public/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/assets/css/.gitkeep b/public/assets/css/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/public/assets/js/.gitkeep b/public/assets/js/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/.gitkeep b/scripts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/.gitkeep b/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/backend/.gitkeep b/tests/backend/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/frontend/.gitkeep b/tests/frontend/.gitkeep deleted file mode 100644 index e69de29..0000000