Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7089936a4 | ||
|
|
6bca9853b3 |
@@ -8,7 +8,6 @@ import { resolveLocale } from '@/lib/locale';
|
|||||||
import { getSystemConfig } from '@/lib/system-config';
|
import { getSystemConfig } from '@/lib/system-config';
|
||||||
import { resolveEnabledPaymentTypes } from '@/lib/payment/resolve-enabled-types';
|
import { resolveEnabledPaymentTypes } from '@/lib/payment/resolve-enabled-types';
|
||||||
|
|
||||||
|
|
||||||
export async function GET(request: NextRequest) {
|
export async function GET(request: NextRequest) {
|
||||||
const locale = resolveLocale(request.nextUrl.searchParams.get('lang'));
|
const locale = resolveLocale(request.nextUrl.searchParams.get('lang'));
|
||||||
const userId = Number(request.nextUrl.searchParams.get('user_id'));
|
const userId = Number(request.nextUrl.searchParams.get('user_id'));
|
||||||
@@ -54,10 +53,7 @@ export async function GET(request: NextRequest) {
|
|||||||
return { enabledTypes, methodLimits, balanceDisabled: balanceDisabledVal === 'true' };
|
return { enabledTypes, methodLimits, balanceDisabled: balanceDisabledVal === 'true' };
|
||||||
});
|
});
|
||||||
|
|
||||||
const [user, { enabledTypes, methodLimits, balanceDisabled }] = await Promise.all([
|
const [user, { enabledTypes, methodLimits, balanceDisabled }] = await Promise.all([getUser(userId), configPromise]);
|
||||||
getUser(userId),
|
|
||||||
configPromise,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 收集 sublabel 覆盖
|
// 收集 sublabel 覆盖
|
||||||
const sublabelOverrides: Record<string, string> = {};
|
const sublabelOverrides: Record<string, string> = {};
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ function PayContent() {
|
|||||||
const [showTopUpForm, setShowTopUpForm] = useState(false);
|
const [showTopUpForm, setShowTopUpForm] = useState(false);
|
||||||
const [selectedPlan, setSelectedPlan] = useState<PlanInfo | null>(null);
|
const [selectedPlan, setSelectedPlan] = useState<PlanInfo | null>(null);
|
||||||
const [channelsLoaded, setChannelsLoaded] = useState(false);
|
const [channelsLoaded, setChannelsLoaded] = useState(false);
|
||||||
|
const [userLoaded, setUserLoaded] = useState(false);
|
||||||
|
|
||||||
const [config, setConfig] = useState<AppConfig>({
|
const [config, setConfig] = useState<AppConfig>({
|
||||||
enabledPaymentTypes: [],
|
enabledPaymentTypes: [],
|
||||||
@@ -217,7 +218,10 @@ function PayContent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
} finally {
|
||||||
|
setUserLoaded(true);
|
||||||
|
}
|
||||||
}, [token, locale]);
|
}, [token, locale]);
|
||||||
|
|
||||||
// 加载渠道和订阅套餐
|
// 加载渠道和订阅套餐
|
||||||
@@ -487,8 +491,8 @@ function PayContent() {
|
|||||||
|
|
||||||
// ── 渲染 ──
|
// ── 渲染 ──
|
||||||
// R7: 检查是否所有入口都关闭(无可用充值方式 且 无订阅套餐)
|
// R7: 检查是否所有入口都关闭(无可用充值方式 且 无订阅套餐)
|
||||||
const allEntriesClosed = channelsLoaded && !canTopUp && !hasPlans;
|
const allEntriesClosed = channelsLoaded && userLoaded && !canTopUp && !hasPlans;
|
||||||
const showMainTabs = channelsLoaded && !allEntriesClosed && (hasChannels || hasPlans);
|
const showMainTabs = channelsLoaded && userLoaded && !allEntriesClosed && (hasChannels || hasPlans);
|
||||||
const pageTitle = showMainTabs
|
const pageTitle = showMainTabs
|
||||||
? pickLocaleText(locale, '选择适合你的 充值/订阅服务', 'Choose Your Recharge / Subscription')
|
? pickLocaleText(locale, '选择适合你的 充值/订阅服务', 'Choose Your Recharge / Subscription')
|
||||||
: pickLocaleText(locale, 'Sub2API 余额充值', 'Sub2API Balance Recharge');
|
: pickLocaleText(locale, 'Sub2API 余额充值', 'Sub2API Balance Recharge');
|
||||||
@@ -613,7 +617,7 @@ function PayContent() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 加载中 */}
|
{/* 加载中 */}
|
||||||
{!channelsLoaded && config.enabledPaymentTypes.length === 0 && (
|
{(!channelsLoaded || !userLoaded) && !allEntriesClosed && (
|
||||||
<div className="flex items-center justify-center py-12">
|
<div className="flex items-center justify-center py-12">
|
||||||
<div className="h-6 w-6 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
|
<div className="h-6 w-6 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
|
||||||
<span className={['ml-3 text-sm', isDark ? 'text-slate-400' : 'text-gray-500'].join(' ')}>
|
<span className={['ml-3 text-sm', isDark ? 'text-slate-400' : 'text-gray-500'].join(' ')}>
|
||||||
@@ -887,7 +891,7 @@ function PayContent() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ── 无渠道配置:传统充值UI ── */}
|
{/* ── 无渠道配置:传统充值UI ── */}
|
||||||
{channelsLoaded && !showMainTabs && canTopUp && !selectedPlan && (
|
{channelsLoaded && userLoaded && !showMainTabs && canTopUp && !selectedPlan && (
|
||||||
<>
|
<>
|
||||||
{isMobile ? (
|
{isMobile ? (
|
||||||
activeMobileTab === 'pay' ? (
|
activeMobileTab === 'pay' ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user