chenpei cd6e40d9d2 优化:网络传输性能和稳定性 - TCP缓冲区+并发控制优化
主要改动:
1. TCP缓冲区优化(16MB)- 解决公网上传速度慢问题
2. 并发数降低到1-3 - 避免4并发导致ERR_CONNECTION_RESET
3. 动态并发控制 - 根据网络环境自动调整
4. Nginx超时增加到120s - 支持大分片上传
5. 上传进度修复 - 修复剩余时间计算
6. 新增任务-页面上传器和详情组件
7. 统一部署文档为deploy-remote-build.ps1

问题修复:
- 公网用户上传从200-900KB/s提升到预期3-5MB/s
- 内网用户上传更稳定,无连接重置错误
- UploadProgress组件剩余时间计算修正

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-27 09:33:09 +08:00

45 lines
1.2 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
// GET /api/users/list - 获取用户列表(用于下拉选择)
export async function GET(request: NextRequest) {
try {
const session = await getServerSession(authOptions);
if (!session?.user) {
return NextResponse.json({ error: '请先登录' }, { status: 401 });
}
// 只获取激活的用户
const users = await prisma.user.findMany({
where: {
isActive: true,
status: 'active',
},
select: {
id: true,
username: true,
realName: true,
email: true,
},
orderBy: {
username: 'asc',
},
});
// 返回用户列表,优先显示真实姓名
const userList = users.map(user => ({
id: user.id,
username: user.username,
displayName: user.realName || user.username,
email: user.email,
}));
return NextResponse.json(userList, { status: 200 });
} catch (error) {
console.error('Error fetching users:', error);
return NextResponse.json({ error: '获取用户列表失败' }, { status: 500 });
}
}