feat: implement new AccountCenter component for user profile, authentication, and payment management

This commit is contained in:
2569718930@qq.com
2026-03-13 10:52:31 +08:00
parent 25f11912dd
commit 534eef4197
@@ -252,9 +252,14 @@ export function AccountCenter() {
if (withJson) headers["Content-Type"] = "application/json"; if (withJson) headers["Content-Type"] = "application/json";
if (!supabaseReady) return headers; if (!supabaseReady) return headers;
try { try {
const client = getSupabaseBrowserClient();
const {
data: { user },
} = await client.auth.getUser();
if (!user) return headers;
const { const {
data: { session }, data: { session },
} = await getSupabaseBrowserClient().auth.getSession(); } = await client.auth.getSession();
const accessToken = String(session?.access_token || "").trim(); const accessToken = String(session?.access_token || "").trim();
if (accessToken) headers.Authorization = `Bearer ${accessToken}`; if (accessToken) headers.Authorization = `Bearer ${accessToken}`;
} catch { } catch {
@@ -546,7 +551,8 @@ export function AccountCenter() {
(await eth.request({ method: "eth_chainId" })) || "", (await eth.request({ method: "eth_chainId" })) || "",
); );
const targetChainHex = `0x${targetChainId.toString(16)}`; const targetChainHex = `0x${targetChainId.toString(16)}`;
if (currentChainIdHex.toLowerCase() === targetChainHex.toLowerCase()) return; if (currentChainIdHex.toLowerCase() === targetChainHex.toLowerCase())
return;
try { try {
await eth.request({ await eth.request({
method: "wallet_switchEthereumChain", method: "wallet_switchEthereumChain",
@@ -595,8 +601,6 @@ export function AccountCenter() {
if (!address) throw new Error("钱包账户为空"); if (!address) throw new Error("钱包账户为空");
const authHeaders = await buildAuthedHeaders(true); const authHeaders = await buildAuthedHeaders(true);
if (!authHeaders.Authorization)
throw new Error("登录会话失效,请重新登录后再绑定钱包。");
setWalletAddress(address); setWalletAddress(address);
const challengeRes = await fetch("/api/payments/wallets/challenge", { const challengeRes = await fetch("/api/payments/wallets/challenge", {
@@ -668,8 +672,6 @@ export function AccountCenter() {
setPaymentBusy(true); setPaymentBusy(true);
try { try {
const authHeaders = await buildAuthedHeaders(true); const authHeaders = await buildAuthedHeaders(true);
if (!authHeaders.Authorization)
throw new Error("登录会话失效,请重新登录后再支付。");
const targetChainId = Number(paymentConfig.chain_id || 137); const targetChainId = Number(paymentConfig.chain_id || 137);
await ensureTargetChain(eth, targetChainId); await ensureTargetChain(eth, targetChainId);
@@ -1077,7 +1079,7 @@ export function AccountCenter() {
<Bot size={22} /> Telegram Bot <Bot size={22} /> Telegram Bot
</h3> </h3>
<p className="text-slate-400 text-sm mb-6"> <p className="text-slate-400 text-sm mb-6">
https://t.me/+nMG7SjziUKYyZmM1
</p> </p>
<div className="flex gap-2"> <div className="flex gap-2">
<code className="flex-grow bg-black/40 border border-white/10 p-4 rounded-xl font-mono text-xs text-blue-300 overflow-hidden text-ellipsis whitespace-nowrap"> <code className="flex-grow bg-black/40 border border-white/10 p-4 rounded-xl font-mono text-xs text-blue-300 overflow-hidden text-ellipsis whitespace-nowrap">