diff --git a/client/src/pages/Home.tsx b/client/src/pages/Home.tsx index 4d9d971..1c0a232 100644 --- a/client/src/pages/Home.tsx +++ b/client/src/pages/Home.tsx @@ -320,8 +320,12 @@ function EVMPurchasePanel({ network, lang, wallet }: { network: "BSC" | "ETH"; l const { purchaseState, buyWithUSDT, reset, calcTokens, getUsdtBalance } = usePresale(wallet, network); const [usdtInput, setUsdtInput] = useState("100"); const [usdtBalance, setUsdtBalance] = useState(null); + const [manualAddress, setManualAddress] = useState(null); const targetChainId = CONTRACTS[network].chainId; const isWrongNetwork = wallet.isConnected && wallet.chainId !== targetChainId; + // effectiveAddress: 真实钱包地址 或 手动输入的地址 + const effectiveAddress = wallet.address || manualAddress; + const isManualMode = !wallet.isConnected && !!manualAddress; const fetchBalance = useCallback(async () => { const bal = await getUsdtBalance(); @@ -388,14 +392,15 @@ function EVMPurchasePanel({ network, lang, wallet }: { network: "BSC" | "ETH"; l return (
- {/* Wallet info — only shown when connected */} - {wallet.isConnected && !isWrongNetwork && ( -
+ {/* Wallet info — shown when connected or manual address entered */} + {effectiveAddress && !isWrongNetwork && ( +
-
- {shortenAddress(wallet.address || "")} +
+ {shortenAddress(effectiveAddress)} + {isManualMode && {lang === "zh" ? "(手动地址)" : "(manual)"}}
- {usdtBalance !== null && ( + {usdtBalance !== null && !isManualMode && ( {t("buy_balance")} {usdtBalance.toFixed(2)} USDT )}
@@ -482,14 +487,15 @@ function EVMPurchasePanel({ network, lang, wallet }: { network: "BSC" | "ETH"; l )} {/* Buy Button — or Connect Wallet if not connected */} - {!wallet.isConnected ? ( + {!wallet.isConnected && !manualAddress ? (

{t("buy_connect_msg")}

{ - toast.success(lang === "zh" ? `已连接: ${addr.slice(0, 6)}...${addr.slice(-4)}` : `Connected: ${addr.slice(0, 6)}...${addr.slice(-4)}`); + setManualAddress(addr); + toast.success(lang === "zh" ? `地址已确认: ${addr.slice(0, 6)}...${addr.slice(-4)}` : `Address confirmed: ${addr.slice(0, 6)}...${addr.slice(-4)}`); }} compact /> @@ -505,6 +511,27 @@ function EVMPurchasePanel({ network, lang, wallet }: { network: "BSC" | "ETH"; l ? `切换到 ${CONTRACTS[network].chainName} 后即可购买` : `Switch to ${CONTRACTS[network].chainName} to Buy`} + ) : isManualMode ? ( +
+
+

+ {lang === "zh" ? "⚠️ 手动地址模式:需连接钱包才能完成链上购买" : "⚠️ Manual mode: Connect wallet to complete on-chain purchase"} +

+

+ {lang === "zh" ? "请点击右上角连接您的钱包" : "Please connect your wallet via the top-right button"} +

+
+ +
) : (