This commit is contained in:
eric
2026-03-16 01:09:13 -05:00
parent 91d56fa086
commit ff135563fb
15 changed files with 532 additions and 143 deletions

View File

@@ -29,6 +29,7 @@ export async function POST(request: NextRequest) {
const session = String(formData.session || "").trim();
const ageRange = String(formData.age_range || "").trim();
const wechatOrPhone = String(formData.wechat_or_phone || "").trim();
const xiaohongshuUrl = String(formData.xiaohongshu_url || "").trim();
let intro = String(formData.intro || "").trim();
const firstTime = String(formData.first_time || "").trim();
const agreeRules = !!formData.agree_rules;
@@ -42,9 +43,9 @@ export async function POST(request: NextRequest) {
intro = extra;
}
if (!nickname || !wechatOrPhone || !intro || !session || !agreeRules) {
if (!nickname || !wechatOrPhone || !intro || !session || !agreeRules || !xiaohongshuUrl) {
return NextResponse.json(
{ ok: false, error: "请填写必填项" },
{ ok: false, error: "请填写必填项(含小红书主页地址)" },
{ status: 400 }
);
}
@@ -57,6 +58,7 @@ export async function POST(request: NextRequest) {
occupation: city,
reason: intro,
wechatId: wechatOrPhone,
xiaohongshu_url: xiaohongshuUrl,
gender: "",
education: "",
gradYear: "",
@@ -114,11 +116,13 @@ async function tryPocketBaseDirect(
const base = pb.url.replace(/\/$/, "");
const url = `${base}/api/collections/${pb.joinCollection}/records`;
const reasonParts = [record.reason, record.age_range, record.first_time];
if (record.xiaohongshu_url) reasonParts.push(`小红书:${record.xiaohongshu_url}`);
const body: Record<string, unknown> = {
user_id: record.user_id,
nickname: record.nickname,
occupation: record.occupation ?? "",
reason: [record.reason, record.age_range, record.first_time].filter(Boolean).join(" | "),
reason: reasonParts.filter(Boolean).join(" | "),
wechatId: record.wechatId ?? "",
gender: record.gender ?? "",
education: record.education ?? "",