一个基于 VitePress 构建的现代化文档网站,展示 HuimengAI 产品的功能特性和使用指南。
- 🎨 动态Logo: 自定义SVG动画logo,具有流动光效和脉冲动画
- 📱 响应式设计: 完美适配桌面端、平板和移动设备
- 🚀 快速加载: 基于 VitePress 的静态站点生成
- 🎯 现代化UI: 简洁美观的用户界面设计
- 📖 完整文档: 涵盖产品功能、使用指南和API文档
- VitePress - 静态站点生成器
- Vue 3 - 前端框架
- TypeScript - 类型安全
- Vite - 构建工具
- Node.js >= 16.0.0
- npm >= 7.0.0
# 克隆项目
git clone https://github.com/LingJingAI-Labs/HuimengAI_doc.git
cd HuimengAI_doc
# 安装依赖
npm install
# 启动开发服务器
npm run docs:dev开发服务器将在 http://localhost:5173 启动。
# 构建静态文件
npm run docs:build
# 预览构建结果
npm run docs:preview# 更新系统包
sudo apt update && sudo apt upgrade -y
# 安装 Node.js 和 npm
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# 安装 Nginx
sudo apt install nginx -y
# 安装 Git
sudo apt install git -y# 克隆项目到服务器
cd /var/www
sudo git clone https://github.com/LingJingAI-Labs/HuimengAI_doc.git
cd HuimengAI_doc
# 安装依赖
sudo npm install
# 构建项目
sudo npm run docs:build创建 Nginx 配置文件:
sudo nano /etc/nginx/sites-available/huimengai-doc添加以下配置:
server {
listen 80;
server_name your-domain.com; # 替换为你的域名
root /var/www/HuimengAI_doc/docs/.vitepress/dist;
index index.html;
# 启用 gzip 压缩
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
location / {
try_files $uri $uri/ /index.html;
}
# 静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# 安全头
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
}# 创建软链接
sudo ln -s /etc/nginx/sites-available/huimengai-doc /etc/nginx/sites-enabled/
# 测试配置
sudo nginx -t
# 重启 Nginx
sudo systemctl restart nginx
# 设置开机自启
sudo systemctl enable nginxsudo npm install -g pm2# 在项目根目录创建 ecosystem.config.js
cat > ecosystem.config.js << EOF
module.exports = {
apps: [{
name: 'huimengai-doc',
script: 'npm',
args: 'run docs:preview',
cwd: '/var/www/HuimengAI_doc',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production',
PORT: 4173
}
}]
};
EOF# 启动应用
pm2 start ecosystem.config.js
# 保存 PM2 配置
pm2 save
# 设置开机自启
pm2 startup# 在项目根目录创建 Dockerfile
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run docs:build
FROM nginx:alpine
COPY --from=builder /app/docs/.vitepress/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}
}# 构建镜像
docker build -t huimengai-doc .
# 运行容器
docker run -d -p 80:80 --name huimengai-doc-container huimengai-doc创建 .github/workflows/deploy.yml:
name: Deploy to Server
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run docs:build
- name: Deploy to server
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd /var/www/HuimengAI_doc
git pull origin main
npm ci
npm run docs:build
sudo systemctl reload nginxHuimengAI_doc/
├── docs/ # 文档源文件
│ ├── .vitepress/ # VitePress 配置
│ │ ├── components/ # Vue 组件
│ │ │ └── AnimatedLogo.vue # 动态 Logo 组件
│ │ ├── theme/ # 主题配置
│ │ └── config.mts # 站点配置
│ ├── features/ # 功能介绍页面
│ ├── guide/ # 使用指南
│ ├── assets/ # 静态资源
│ └── index.md # 首页
├── package.json # 项目配置
└── README.md # 项目说明
编辑 docs/.vitepress/theme/index.ts 文件来自定义主题。
- 在
docs/目录下创建新的.md文件 - 在
docs/.vitepress/config.mts中添加导航配置
在 docs/.vitepress/components/ 目录下创建 Vue 组件,然后在主题中注册使用。
# 检查过时的包
npm outdated
# 更新依赖
npm update# 备份重要文件
tar -czf huimengai-doc-backup-$(date +%Y%m%d).tar.gz /var/www/HuimengAI_doc- 构建失败: 检查 Node.js 版本是否符合要求
- 页面无法访问: 检查 Nginx 配置和防火墙设置
- 样式丢失: 确保静态资源路径正确
# Nginx 日志
sudo tail -f /var/log/nginx/error.log
sudo tail -f /var/log/nginx/access.log
# PM2 日志
pm2 logs huimengai-docMIT License
欢迎提交 Issue 和 Pull Request!