This commit is contained in:
eric
2026-06-06 04:29:46 -05:00
parent 88aa96a2a1
commit 41493c35ca
50 changed files with 4666 additions and 416 deletions

View File

@@ -10,6 +10,7 @@ import {
import { usePayStatusPoll } from "@/app/lib/payment/usePayStatusPoll";
import type { PayEnv } from "@/app/lib/payment";
import AuthModal from "@/app/components/AuthModal";
import { apiUrl } from "@/app/lib/api-client";
const genderOptions = ["男", "女"];
const singleOptions = ["单身", "恋爱中", "已婚"];
@@ -67,13 +68,13 @@ export default function JoinPage() {
return;
}
const checkExisting = async () => {
const meRes = await fetch("/api/auth/me", { credentials: "include" });
const meRes = await fetch(apiUrl("/api/auth/me"), { credentials: "include" });
const meData = await meRes.json();
if (!meData?.user) {
setCheckingStatus(false);
return;
}
const statusRes = await fetch("/api/join/status", { credentials: "include", cache: "no-store" });
const statusRes = await fetch(apiUrl("/api/join/status"), { credentials: "include", cache: "no-store" });
const statusData = await statusRes.json();
if (statusData?.hasRecord && statusData?.isComplete) {
setIsAlreadyRecorded(true);
@@ -105,7 +106,7 @@ export default function JoinPage() {
setError(null);
setSubmitting(true);
try {
const res = await fetch("/api/join", {
const res = await fetch(apiUrl("/api/join"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ ...form, media: media?.url }),
@@ -121,7 +122,7 @@ export default function JoinPage() {
return;
}
// 再次确认 VIP,防止 handleAuthSuccess 等路径绕过
const vipRes2 = await fetch("/api/vip/check", { credentials: "include", cache: "no-store" });
const vipRes2 = await fetch(apiUrl("/api/vip/check"), { credentials: "include", cache: "no-store" });
const vipData2 = await vipRes2.json();
if (vipData2?.vip) {
setIsVipSubmit(true);
@@ -152,14 +153,14 @@ export default function JoinPage() {
const handleSubmit = async (e: FormEvent) => {
e.preventDefault();
const meRes = await fetch("/api/auth/me", { credentials: "include" });
const meRes = await fetch(apiUrl("/api/auth/me"), { credentials: "include" });
const meData = await meRes.json();
if (!meData?.user) {
setPendingSubmit(true);
setAuthOpen(true);
return;
}
const vipRes = await fetch("/api/vip/check", { credentials: "include", cache: "no-store" });
const vipRes = await fetch(apiUrl("/api/vip/check"), { credentials: "include", cache: "no-store" });
const vipData = await vipRes.json();
if (vipData?.vip) {
setIsVipSubmit(true);
@@ -401,7 +402,7 @@ export default function JoinPage() {
try {
const fd = new FormData();
fd.append("file", file);
const res = await fetch("/api/upload-media", {
const res = await fetch(apiUrl("/api/upload-media"), {
method: "POST",
body: fd,
});

View File

@@ -2,6 +2,7 @@
import { useState, useEffect } from "react";
import { Link } from "@/i18n/navigation";
import { apiUrl } from "@/app/lib/api-client";
const DEFAULT_PASSWORD = "12345678";
@@ -33,7 +34,7 @@ export default function JoinPaidPage() {
let cancelled = false;
const tryComplete = async (orderId: string): Promise<{ ok: boolean; error?: string }> => {
const r = await fetch("/api/meetup/complete-order", {
const r = await fetch(apiUrl("/api/meetup/complete-order"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ order_id: orderId }),
@@ -43,7 +44,7 @@ export default function JoinPaidPage() {
if (!d?.ok) return { ok: false, error: d?.error || `HTTP ${r.status}` };
if (d?.token && d?.record) {
await fetch("/api/auth/sync-session", {
await fetch(apiUrl("/api/auth/sync-session"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ token: d.token, record: d.record }),
@@ -59,13 +60,13 @@ export default function JoinPaidPage() {
window.dispatchEvent(new CustomEvent("vip:updated"));
}, 400);
if (d.is_new) {
await fetch("/api/meetup/set-needs-password-change", { method: "POST", credentials: "include" });
await fetch(apiUrl("/api/meetup/set-needs-password-change"), { method: "POST", credentials: "include" });
if (!cancelled) {
setNeedPasswordChange(true);
setShowPasswordModal(true);
}
} else {
const needRes = await fetch("/api/meetup/need-password-change", { credentials: "include" });
const needRes = await fetch(apiUrl("/api/meetup/need-password-change"), { credentials: "include" });
const needData = await needRes.json().catch(() => ({}));
if (!cancelled && needData?.need === true) {
setNeedPasswordChange(true);
@@ -121,7 +122,7 @@ export default function JoinPaidPage() {
setErrorDetail(lastError);
}
fetch("/api/meetup/need-password-change")
fetch(apiUrl("/api/meetup/need-password-change"))
.then((res) => res.json())
.then((d) => {
if (cancelled) return;
@@ -166,7 +167,7 @@ export default function JoinPaidPage() {
}
setChanging(true);
try {
const res = await fetch("/api/auth/change-password", {
const res = await fetch(apiUrl("/api/auth/change-password"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ newPassword, passwordConfirm }),