# aichat **Repository Path**: xhyKeyNG/aichat ## Basic Information - **Project Name**: aichat - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-02 - **Last Updated**: 2025-03-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ProtoQA - AI问答平台 ProtoQA是一个基于Vue 3和Express的AI问答平台,支持多种AI模型,提供聊天、历史记录管理等功能。 ## 项目结构 项目分为前端和后端两部分: - `frontend/`: Vue 3 + TypeScript + Vant UI的前端应用 - `backend/`: Express + SQLite的后端API服务 ## 本地开发环境配置 ### 后端配置 1. 进入后端目录并安装依赖: ```bash cd backend npm install ``` 2. 创建`.env`文件配置环境变量: ``` PORT=1111 NODE_ENV=development AI_API_KEY=your_api_key_here AI_API_URL=https://api.example.com/v1 ``` 3. 启动开发服务器: ```bash npm run dev ``` 后端服务将在 http://localhost:1111 运行。 ### 前端配置 1. 进入前端目录并安装依赖: ```bash cd frontend npm install ``` 2. 启动开发服务器: ```bash npm run dev ``` 前端应用将在 http://localhost:1112 运行。 ## 服务器部署指南 ### 后端部署 1. 在服务器上克隆代码库: ```bash git clone https://github.com/yourusername/protoqa.git cd protoqa/backend ``` 2. 安装依赖: ```bash npm install --production ``` 3. 创建`.env`文件配置生产环境变量: ``` PORT=1111 NODE_ENV=production AI_API_KEY=your_api_key_here AI_API_URL=https://api.example.com/v1 ``` 4. 使用PM2启动服务(需要先安装PM2: `npm install -g pm2`): ```bash pm2 start app.js --name "protoqa-backend" ``` ### 前端部署 1. 在本地构建前端应用: ```bash cd frontend npm run build:prod ``` 2. 将`dist`目录上传到服务器,可以使用Nginx或其他Web服务器提供静态文件服务。 3. Nginx配置示例: ```nginx server { listen 80; server_name your-domain.com; root /path/to/protoqa/frontend/dist; index index.html; # 处理前端路由 location / { try_files $uri $uri/ /index.html; } # 代理API请求到后端服务 location /api { proxy_pass http://localhost:1111; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } ``` 4. 重启Nginx: ```bash sudo systemctl restart nginx ``` ## 使用Docker部署(可选) ### 创建Docker镜像 1. 后端Dockerfile (backend/Dockerfile): ```dockerfile FROM node:18-alpine WORKDIR /app COPY package*.json ./ RUN npm install --production COPY . . EXPOSE 1111 CMD ["node", "app.js"] ``` 2. 前端Dockerfile (frontend/Dockerfile): ```dockerfile # 构建阶段 FROM node:18-alpine as build-stage WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build:prod # 生产阶段 FROM nginx:stable-alpine as production-stage COPY --from=build-stage /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 1112 CMD ["nginx", "-g", "daemon off;"] ``` 3. 前端Nginx配置 (frontend/nginx.conf): ```nginx server { listen 1112; server_name localhost; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } location /api { proxy_pass http://backend:1111; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } ``` 4. Docker Compose配置 (docker-compose.yml): ```yaml version: '3' services: backend: build: ./backend container_name: protoqa-backend restart: always ports: - "1111:1111" env_file: - ./backend/.env volumes: - ./backend/data:/app/data frontend: build: ./frontend container_name: protoqa-frontend restart: always ports: - "1112:1112" depends_on: - backend networks: default: name: protoqa-network ``` 5. 使用Docker Compose启动服务: ```bash docker-compose up -d ``` ## 更新日志 - 1.0.0: 初始版本发布 ## 许可证 MIT