feat: 实现Vue驱动的云存储系统初始功能

- 后端: Node.js + Express + SQLite架构
- 前端: Vue 3 + Axios实现
- 功能: 用户认证、文件上传/下载、分享链接、密码重置
- 安全: 密码加密、分享链接过期机制、缓存一致性
- 部署: Docker + Nginx容器化配置
- 测试: 完整的边界测试、并发测试和状态一致性测试
This commit is contained in:
Dev Team
2026-01-20 23:23:51 +08:00
commit b7b00fff48
45 changed files with 51758 additions and 0 deletions

327
INSTALL_GUIDE.md Normal file
View File

@@ -0,0 +1,327 @@
# 玩玩云 - 手动部署指南
本指南详细说明如何手动部署玩玩云系统。
## 环境要求
### 服务器要求
- **操作系统**: Linux (Ubuntu 18.04+ / Debian 10+ / CentOS 7+)
- **内存**: 最低 1GB RAM推荐 2GB+
- **磁盘空间**: 至少 2GB 可用空间
### 软件依赖
- **Node.js**: 20.x LTS
- **Nginx**: 1.18+
- **Git**: 2.x
## 部署步骤
### 1. 安装 Node.js 20.x
#### Ubuntu/Debian
```bash
# 安装 NodeSource 仓库
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
# 安装 Node.js
sudo apt-get install -y nodejs
# 验证安装
node -v # 应显示 v20.x.x
npm -v
```
#### CentOS/RHEL
```bash
# 安装 NodeSource 仓库
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
# 安装 Node.js
sudo yum install -y nodejs
# 验证安装
node -v
npm -v
```
### 2. 安装 Nginx
#### Ubuntu/Debian
```bash
sudo apt-get update
sudo apt-get install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
```
#### CentOS/RHEL
```bash
sudo yum install -y epel-release
sudo yum install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
```
### 3. 克隆项目
```bash
# 创建部署目录
sudo mkdir -p /var/www
cd /var/www
# 克隆项目
sudo git clone https://git.workyai.cn/237899745/vue-driven-cloud-storage.git wanwanyun
# 设置目录权限
sudo chown -R $USER:$USER /var/www/wanwanyun
```
### 4. 安装后端依赖
```bash
cd /var/www/wanwanyun/backend
# 安装依赖
npm install --production
# 创建数据目录
mkdir -p data storage
```
### 5. 配置环境变量
```bash
# 复制环境变量模板
cp .env.example .env
# 编辑配置文件
nano .env
```
**必须修改的配置**
```bash
# 生成随机 JWT 密钥
JWT_SECRET=$(node -e "console.log(require('crypto').randomBytes(32).toString('hex'))")
echo "JWT_SECRET=$JWT_SECRET"
# 修改管理员密码
ADMIN_PASSWORD=你的强密码
```
### 6. 配置 Nginx
```bash
# 复制 Nginx 配置
sudo cp /var/www/wanwanyun/nginx/nginx.conf /etc/nginx/sites-available/wanwanyun
# 修改配置中的路径
sudo sed -i 's|/usr/share/nginx/html|/var/www/wanwanyun/frontend|g' /etc/nginx/sites-available/wanwanyun
sudo sed -i 's|backend:40001|127.0.0.1:40001|g' /etc/nginx/sites-available/wanwanyun
# 创建软链接启用配置
sudo ln -sf /etc/nginx/sites-available/wanwanyun /etc/nginx/sites-enabled/
# 删除默认配置(可选)
sudo rm -f /etc/nginx/sites-enabled/default
# 测试配置
sudo nginx -t
# 重新加载 Nginx
sudo systemctl reload nginx
```
### 7. 配置系统服务
创建 systemd 服务文件:
```bash
sudo tee /etc/systemd/system/wanwanyun.service > /dev/null << 'EOF'
[Unit]
Description=WanWanYun Cloud Storage Service
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
WorkingDirectory=/var/www/wanwanyun/backend
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=10
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
EOF
```
设置目录权限:
```bash
sudo chown -R www-data:www-data /var/www/wanwanyun
```
启动服务:
```bash
sudo systemctl daemon-reload
sudo systemctl enable wanwanyun
sudo systemctl start wanwanyun
```
### 8. 验证部署
```bash
# 检查服务状态
sudo systemctl status wanwanyun
# 检查后端是否启动
curl http://127.0.0.1:40001/api/health
# 检查 Nginx 是否正常
curl http://localhost
```
## 配置 HTTPS推荐
### 使用 Let's Encrypt 免费证书
```bash
# 安装 Certbot
sudo apt-get install -y certbot python3-certbot-nginx
# 获取证书(替换为你的域名和邮箱)
sudo certbot --nginx -d your-domain.com --email your@email.com --agree-tos --non-interactive
# 验证自动续期
sudo certbot renew --dry-run
```
### 更新后端配置
获取证书后,编辑 `/var/www/wanwanyun/backend/.env`
```bash
ENFORCE_HTTPS=true
COOKIE_SECURE=true
TRUST_PROXY=1
```
重启服务:
```bash
sudo systemctl restart wanwanyun
```
## 防火墙配置
### UFW (Ubuntu)
```bash
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
```
### firewalld (CentOS)
```bash
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
```
## 日常维护
### 查看日志
```bash
# 查看服务日志
sudo journalctl -u wanwanyun -f
# 查看 Nginx 错误日志
sudo tail -f /var/log/nginx/error.log
```
### 更新系统
```bash
cd /var/www/wanwanyun
sudo git pull
cd backend && npm install --production
sudo systemctl restart wanwanyun
```
### 备份数据
```bash
# 备份数据库
sudo cp /var/www/wanwanyun/backend/data/database.db /backup/database.db.$(date +%Y%m%d)
# 备份上传文件(本地存储模式)
sudo tar -czf /backup/storage-$(date +%Y%m%d).tar.gz /var/www/wanwanyun/backend/storage/
```
## 故障排查
### 服务无法启动
```bash
# 检查日志
sudo journalctl -u wanwanyun -n 100
# 检查端口占用
sudo lsof -i :40001
# 检查 Node.js 版本
node -v
```
### 无法访问网页
```bash
# 检查 Nginx 状态
sudo systemctl status nginx
# 检查 Nginx 配置
sudo nginx -t
# 检查防火墙
sudo ufw status
```
### 数据库错误
```bash
# 检查数据库文件权限
ls -la /var/www/wanwanyun/backend/data/
# 修复权限
sudo chown -R www-data:www-data /var/www/wanwanyun/backend/data/
```
## 性能优化
### 启用 Nginx 缓存
在 Nginx 配置的 `location /` 中添加:
```nginx
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
```
### 配置日志轮转
```bash
sudo tee /etc/logrotate.d/wanwanyun > /dev/null << 'EOF'
/var/log/nginx/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
EOF
```
## 相关链接
- [项目主页](https://git.workyai.cn/237899745/vue-driven-cloud-storage)
- [问题反馈](https://git.workyai.cn/237899745/vue-driven-cloud-storage/issues)
- [README](./README.md)