feat: 完整重构小程序匹配功能 + 修复UI对齐 + 文章数据API
主要更新: 1. 按H5网页端完全重构匹配功能(match页面) - 4种匹配类型: 创业合伙/资源对接/导师顾问/团队招募 - 资源对接等类型弹出手机号/微信号输入框 - 去掉重新匹配按钮,改为返回按钮 2. 修复所有卡片对齐和宽度问题 - 目录页附录卡片居中 - 首页阅读进度卡片满宽度 - 我的页面菜单卡片对齐 - 推广中心分享卡片统一宽度 3. 修复目录页图标和文字对齐 - section-icon固定40rpx宽高 - section-title与图标垂直居中 4. 更新真实完整文章标题(62篇) - 从book目录读取真实markdown文件名 - 替换之前的简化标题 5. 新增文章数据API - /api/db/chapters - 获取完整书籍结构 - 支持按ID获取单篇文章内容
This commit is contained in:
53
app/api/distribution/messages/route.ts
Normal file
53
app/api/distribution/messages/route.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 分销消息API
|
||||
* 用于WebSocket轮询获取实时消息
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getMessages, clearMessages } from '@/lib/modules/distribution/websocket';
|
||||
|
||||
// GET: 获取用户消息
|
||||
export async function GET(req: NextRequest) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const userId = searchParams.get('userId');
|
||||
const since = searchParams.get('since');
|
||||
|
||||
if (!userId) {
|
||||
return NextResponse.json({ error: '缺少用户ID' }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const messages = getMessages(userId, since || undefined);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
messages,
|
||||
count: messages.length,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[MessagesAPI] 获取消息失败:', error);
|
||||
return NextResponse.json({ error: '获取消息失败' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
// POST: 标记消息已读
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
const body = await req.json();
|
||||
const { userId, messageIds } = body;
|
||||
|
||||
if (!userId || !messageIds || !Array.isArray(messageIds)) {
|
||||
return NextResponse.json({ error: '参数错误' }, { status: 400 });
|
||||
}
|
||||
|
||||
clearMessages(userId, messageIds);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '消息已标记为已读',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[MessagesAPI] 标记已读失败:', error);
|
||||
return NextResponse.json({ error: '操作失败' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user