import React, { useState } from 'react'; import { useWeb3 } from '../context/Web3Context'; import { Wallet, TrendingUp, Compass, PieChart, PlusCircle, Droplet, ShieldAlert } from 'lucide-react'; interface NavbarProps { activeTab: string; setActiveTab: (tab: string) => void; } export const WebNavbar: React.FC = ({ activeTab, setActiveTab }) => { const { account, wusdBalance, isCorrectNetwork, connectWallet, switchNetwork, refreshBalance, getCollateralContract } = useWeb3(); const [faucetLoading, setFaucetLoading] = useState(false); const handleQuickFaucet = async () => { if (!account) return; try { setFaucetLoading(true); const collateral = getCollateralContract(); if (!collateral) return; const tx = await collateral.mint(account, "100000000000000000000000000"); // 100M WUSD await tx.wait(); refreshBalance(); alert('🎉 成功领取 100,000,000 WUSD 测试金!'); } catch (e: any) { alert('领水失败: ' + (e.message || e)); } finally { setFaucetLoading(false); } }; const navs = [ { id: 'explore', label: '🔥 市场探索', icon: Compass }, { id: 'trade', label: '⚡ 交易终端', icon: TrendingUp }, { id: 'create', label: '🚀 创建市场', icon: PlusCircle }, { id: 'portfolio', label: '💼 持仓与金库', icon: PieChart }, ]; return (
{/* Logo & Navigation */}
setActiveTab('explore')}>
W
WTFX TESTNET
{/* Right Section / Faucet & Wallet */}
{account && ( )} {account ? (
{!isCorrectNetwork ? ( ) : (
可用: {Number(wusdBalance).toLocaleString(undefined, { maximumFractionDigits: 2 })} WUSD
)}
{account.slice(0, 6)}...{account.slice(-4)}
) : ( )}
); };