Spaces:
Running

sdex / src /components /ProfileView.tsx
vip
Update Shengda latest frontend
ad4c5d2
Raw History Blame Contribute Delete
53.5 kB
import React from "react"; import { ScreenId, AppState } from "../types"; import { ArrowLeft, LogOut, Landmark, Shield, LifeBuoy, ChevronRight, RefreshCw, BarChart2, Award, Globe, Lock, Key, Check, Smartphone, AlertCircle, Upload, Camera, User, X } from "lucide-react"; import { translations } from "../lib/translations"; interface ProfileViewProps { state: AppState; onNavigate: (screen: ScreenId) => void; onSetState: (updater: (prev: AppState) => AppState) => void; } export const ProfileView: React.FC<ProfileViewProps> = ({ state, onNavigate, onSetState }) => { const [subMode, setSubMode] = React.useState<"MAIN" | "SECURITY" | "GOOGLE_AUTH" | "CHANGE_PASSWORD">("MAIN"); const [isGoogleAuthBound, setIsGoogleAuthBound] = React.useState(false); const [copied, setCopied] = React.useState(false); const [gaCode, setGaCode] = React.useState(""); const [currentPwd, setCurrentPwd] = React.useState(""); const [newPwd, setNewPwd] = React.useState(""); const [confirmPwd, setConfirmPwd] = React.useState(""); const [loading, setLoading] = React.useState(false); const [successMsg, setSuccessMsg] = React.useState(""); const [errorMsg, setErrorMsg] = React.useState(""); const [showAvatarDialog, setShowAvatarDialog] = React.useState(false); const [dragActive, setDragActive] = React.useState(false); const fileInputRef = React.useRef<HTMLInputElement>(null); const visibleBalance = state.isLoggedIn ? state.balance : 0; const vipPresets = [ "https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&w=150&h=150&q=80", "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?auto=format&fit=crop&w=150&h=150&q=80", "https://images.unsplash.com/photo-1494790108377-be9c29b29330?auto=format&fit=crop&w=150&h=150&q=80", "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&w=150&h=150&q=80", "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?auto=format&fit=crop&w=150&h=150&q=80" ]; const handleDrag = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); if (e.type === "dragenter" || e.type === "dragover") { setDragActive(true); } else if (e.type === "dragleave") { setDragActive(false); } }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setDragActive(false); if (e.dataTransfer.files && e.dataTransfer.files[0]) { const file = e.dataTransfer.files[0]; readAndSetAvatar(file); } }; const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { if (e.target.files && e.target.files[0]) { const file = e.target.files[0]; readAndSetAvatar(file); } }; const readAndSetAvatar = (file: File) => { const reader = new FileReader(); reader.onloadend = () => { const base64String = reader.result as string; onSetState(prev => ({ ...prev, avatarUrl: base64String })); }; reader.readAsDataURL(file); }; const handleLogout = () => { onSetState((prev) => ({ ...prev, isLoggedIn: false, username: "未登录" })); onNavigate(ScreenId.HOME); }; return ( <div className="bg-[#000B14] text-[#d1e4ff] min-h-screen pb-24 font-sans select-none overflow-x-hidden"> {subMode === "MAIN" && ( <> {/* Header */} <header className="bg-[#0b2135] h-14 border-b border-[#414755] flex items-center px-4 justify-between sticky top-0 z-40"> <div className="flex items-center gap-2"> <button onClick={() => onNavigate(ScreenId.HOME)} className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]" > <ArrowLeft className="w-5 h-5" /> </button> <span className="text-white text-base font-bold"> {state.language === "zh" ? "盛大 - 个人中心" : "Shengda - User Center"} </span> </div> <div className="flex items-center gap-2"> {/* Quick toggle next to logout */} <button onClick={() => onSetState(prev => ({ ...prev, language: prev.language === "zh" ? "en" : "zh" }))} className="p-2 bg-[#22364c] hover:bg-[#2c4764] text-amber-400 rounded-full border border-white/5 active:scale-90 transition-transform flex items-center justify-center" title={state.language === "zh" ? "切换语言" : "Switch Language"} > <Globe className="w-4 h-4" /> </button> <button onClick={handleLogout} className="p-2 bg-[#22364c] hover:bg-rose-950/40 text-rose-400 hover:text-rose-300 rounded-full border border-rose-900/30 active:scale-90 transition-transform" title={translations[state.language || "zh"].logout} > <LogOut className="w-4 h-4" /> </button> </div> </header> {/* User Information Premium Intro Card */} <section className="px-4 mt-6"> <div className="bg-gradient-to-br from-[#0b2135] via-[#071d31] to-[#001428] border border-white/5 rounded-2xl p-5 shadow-xl relative overflow-hidden"> <div className="absolute right-0 top-0 translate-x-1/3 -translate-y-1/3 w-32 h-32 rounded-full bg-[#afc6ff]/5 blur-xl"></div> <div className="flex items-center gap-4 relative"> <div onClick={() => setShowAvatarDialog(true)} className="relative cursor-pointer group active:scale-95 transition-all duration-200" title={state.language === "zh" ? "点击上传或更换头像" : "Click to change avatar"} > <div className="w-16 h-16 rounded-full bg-gradient-to-tr from-amber-400 to-[#FFD700] p-[2px] shadow-[0_4px_20px_rgba(251,191,36,0.3)] hover:shadow-[0_4px_24px_rgba(251,191,36,0.5)] hover:scale-105 transition-all duration-300 relative overflow-hidden"> <div className="w-full h-full rounded-full bg-slate-900 flex items-center justify-center font-bold text-white text-lg overflow-hidden relative"> {state.avatarUrl ? ( <img src={state.avatarUrl} alt="User Avatar" className="w-full h-full object-cover transition-transform duration-300 group-hover:scale-110" referrerPolicy="no-referrer" /> ) : ( <span className="bg-[#122e47] w-full h-full flex items-center justify-center font-black tracking-wider text-amber-300"> {state.isLoggedIn ? state.username.slice(0, 2).toUpperCase() : "G"} </span> )} {/* Subtle Camera edit banner on hover */} <div className="absolute inset-0 bg-black/70 flex flex-col items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300"> <Camera className="w-4 h-4 text-amber-400 shrink-0" /> <span className="text-[8px] text-amber-300 font-bold uppercase mt-0.5 scale-90"> {state.language === "zh" ? "更换" : "Edit"} </span> </div> </div> </div> <span className="absolute -bottom-1 -right-1 flex items-center gap-0.5 bg-gradient-to-r from-amber-400 via-yellow-300 to-amber-500 text-slate-950 text-[9px] px-2 py-0.5 rounded-full font-black border border-amber-300 shadow-[0_2px_4px_rgba(0,0,0,0.6)]"> VIP {state.vipLevel} </span> </div> <div> <h2 className="text-base font-bold text-white flex items-center gap-2"> {state.isLoggedIn ? state.username : (state.language === "zh" ? "未登录游客试玩" : "Guest Player")} </h2> <div className="flex items-center gap-2 mt-1"> <span className="text-xs text-[#c1c6d7] font-mono">ID: 88472910</span> <span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"></span> <span className="text-[10px] text-emerald-400 font-semibold uppercase"> {translations[state.language || "zh"].onlineGuarantee} </span> </div> </div> </div> {/* Account Balance Overview Container */} <div className="mt-5 pt-4 border-t border-white/5"> <div className="bg-slate-900/60 p-4 rounded-xl border border-white/5"> <span className="text-[10px] text-[#c1c6d7]/80 block font-medium"> {translations[state.language || "zh"].balance} (USDT) </span> <span className="text-2xl font-bold text-white font-mono tracking-tight mt-1 block"> {visibleBalance.toFixed(2)} <span className="text-xs text-emerald-400 font-sans font-semibold ml-0.5">USDT</span> </span> </div> </div> {/* Quick Actions Grid */} <div className="grid grid-cols-2 gap-3 mt-4"> <button onClick={() => onNavigate(ScreenId.DEPOSIT)} className="py-2.5 bg-[#528dff] hover:bg-[#528dff]/90 text-[#00275f] font-bold rounded-xl text-xs active:scale-95 transition-transform" > {translations[state.language || "zh"].deposit} </button> <button onClick={() => onNavigate(ScreenId.WITHDRAWAL)} className="py-2.5 bg-gradient-to-r from-amber-400 to-[#FFD700] hover:brightness-105 text-slate-950 font-bold rounded-xl text-xs active:scale-95 transition-transform" > {translations[state.language || "zh"].withdraw} </button> </div> </div> </section> {/* Menu Settings */} <section className="px-4 mt-6"> <div className="bg-[#0b2135] border border-white/5 rounded-2xl overflow-hidden divide-y divide-white/5"> {/* Agency cooperation */} <div onClick={() => onNavigate(ScreenId.REVENUE_DASHBOARD)} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <Award className="w-5 h-5 text-amber-500" /> <span className="text-xs font-semibold text-white"> {state.language === "zh" ? "代理合作" : "Agency Cooperation"} </span> </div> <div className="flex items-center gap-1.5"> <span className="text-[10px] text-amber-400 font-bold bg-amber-400/10 px-1.5 py-0.5 rounded border border-amber-500/25"> {state.language === "zh" ? "佣金最高 50%" : "Up to 50%"} </span> <ChevronRight className="w-4 h-4 text-slate-500 group-hover:text-amber-500 transition-colors" /> </div> </div> {/* Transaction History Filter and view */} <div onClick={() => onNavigate(ScreenId.TRANSACTION_DETAILS)} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <RefreshCw className="w-5 h-5 text-[#afc6ff]" /> <span className="text-xs font-semibold text-white"> {translations[state.language || "zh"].transactionHistory} </span> </div> <div className="flex items-center gap-1.5"> <span className="text-[10px] text-[#c1c6d7]"> {state.language === "zh" ? "查询最新流水" : "Query Transactions"} </span> <ChevronRight className="w-4 h-4 text-slate-500 group-hover:text-white transition-colors" /> </div> </div> {/* Bet history */} <div onClick={() => onNavigate(ScreenId.BET_HISTORY)} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <BarChart2 className="w-5 h-5 text-indigo-400" /> <span className="text-xs font-semibold text-white"> {translations[state.language || "zh"].betHistory} </span> </div> <ChevronRight className="w-4 h-4 text-slate-500 group-hover:text-white transition-colors" /> </div> {/* Secure Center */} <div className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" onClick={() => setSubMode("SECURITY")} > <div className="flex items-center gap-3"> <Shield className="w-5 h-5 text-emerald-400" /> <span className="text-xs font-semibold text-white"> {translations[state.language || "zh"].securityCenter} </span> </div> <span className="text-[10px] text-emerald-400 font-bold bg-[#071d31] border border-emerald-400/20 rounded px-1 py-0.5"> {state.language === "zh" ? "进入设置" : "Setup Center"} </span> </div> {/* Language Selection System */} <div onClick={() => { onSetState(prev => { const nextLang = prev.language === "zh" ? "en" : "zh"; alert(nextLang === "zh" ? "语言已切换为简体中文" : "Language switched to English"); return { ...prev, language: nextLang }; }); }} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group bg-[#112d47]/20" > <div className="flex items-center gap-3"> <Globe className="w-5 h-5 text-amber-400 animate-pulse" /> <span className="text-xs font-bold text-white"> {state.language === "zh" ? "语言选择" : "Language"} </span> </div> <div className="flex items-center gap-1.5"> <span className="text-[11px] font-bold text-amber-400 bg-amber-400/10 px-2 py-0.5 rounded border border-amber-500/30"> {state.language === "zh" ? "简体中文🇨🇳" : "English🇺🇸"} </span> <ChevronRight className="w-4 h-4 text-slate-500 group-hover:text-white transition-colors" /> </div> </div> {/* Help Center */} <div onClick={() => onNavigate(ScreenId.CUSTOMER_SUPPORT)} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <LifeBuoy className="w-5 h-5 text-[#afc6ff]" /> <span className="text-xs font-semibold text-white"> {translations[state.language || "zh"].support} </span> </div> <ChevronRight className="w-4 h-4 text-slate-500 group-hover:text-[#afc6ff] transition-colors" /> </div> </div> </section> {/* Quick Stats Summary */} <section className="px-4 mt-6"> <div className="bg-[#0b2135]/55 border border-white/5 rounded-2xl p-4 flex justify-around text-center"> <div> <span className="text-lg font-bold text-[#FFD700] block">0.8%</span> <span className="text-[9px] text-[#c1c6d7]"> {translations[state.language || "zh"].rebateRatio} </span> </div> <div className="w-[1px] bg-white/5"></div> <div> <span className="text-lg font-bold text-white block">31{state.language === "zh" ? "次" : " times"}</span> <span className="text-[9px] text-[#c1c6d7]"> {translations[state.language || "zh"].successfulDeposits} </span> </div> <div className="w-[1px] bg-white/5"></div> <div> <span className="text-lg font-bold text-white block">0 {state.language === "zh" ? "元" : "USDT"}</span> <span className="text-[9px] text-[#c1c6d7]"> {translations[state.language || "zh"].pendingBets} </span> </div> </div> </section> {/* Floating Recharge Access FAB */} <div className="fixed bottom-5 left-1/2 -translate-x-1/2 z-[60]"> <div className="relative"> <div className="absolute -inset-1 bg-[#afc6ff]/35 blur-xl rounded-full animate-pulse"></div> <button onClick={() => onNavigate(ScreenId.DEPOSIT)} className="w-14 h-14 bg-gradient-to-b from-[#528dff] to-[#afc6ff] text-[#002d6c] rounded-full shadow-[0_4px_16px_rgba(82,141,255,0.4)] border-4 border-[#0b2135] flex flex-col items-center justify-center active:scale-90 transition-transform relative hover:brightness-105 cursor-pointer" > <Landmark className="w-5 h-5 mx-auto" /> <span className="text-[10px] font-bold mt-0.5"> {state.language === "zh" ? "充值" : "Recharge"} </span> </button> </div> </div> {/* Absolute Bottom Navigation Bar */} <nav className="bg-[#22364c] border-t border-[#414755] fixed bottom-0 left-0 w-full z-50 rounded-t-xl shadow-xl flex justify-around items-center h-16 px-1"> <a onClick={() => onNavigate(ScreenId.HOME)} className="flex flex-col items-center justify-center text-[#c1c6d7] hover:text-[#afc6ff] transition-colors cursor-pointer flex-1" > <span className="text-sm font-semibold">{translations[state.language || "zh"].home}</span> <span className="text-[9px] mt-0.5">Home</span> </a> <a onClick={() => onNavigate(ScreenId.GAME_CENTER)} className="flex flex-col items-center justify-center text-[#c1c6d7] hover:text-[#afc6ff] transition-colors cursor-pointer flex-1" > <span className="text-sm font-semibold"> {state.language === "zh" ? "游戏" : "Games"} </span> <span className="text-[9px] mt-0.5">Games</span> </a> <div className="w-16"></div> <a onClick={() => onNavigate(ScreenId.PROMOTIONS)} className="flex flex-col items-center justify-center text-[#c1c6d7] hover:text-[#afc6ff] transition-colors cursor-pointer flex-1" > <span className="text-sm font-semibold"> {state.language === "zh" ? "活动" : "Promos"} </span> <span className="text-[9px] mt-0.5">Promos</span> </a> <a onClick={() => onNavigate(ScreenId.PROFILE)} className="flex flex-col items-center justify-center text-[#afc6ff] font-bold drop-shadow-[0_0_8px_rgba(175,198,255,0.5)] scale-105 cursor-pointer flex-1" > <span className="text-xl"> {translations[state.language || "zh"].mine} </span> <span className="text-[10px] tracking-wide mt-1">Profile</span> </a> </nav> </> )} {/* SECURITY CENTER */} {subMode === "SECURITY" && ( <> <header className="bg-[#0b2135] h-14 border-b border-[#414755] flex items-center px-4 justify-between sticky top-0 z-40"> <div className="flex items-center gap-2"> <button onClick={() => setSubMode("MAIN")} className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]" > <ArrowLeft className="w-5 h-5" /> </button> <span className="text-white text-base font-bold"> {state.language === "zh" ? "系统安全中心" : "System Security Center"} </span> </div> <div className="w-6"></div> </header> <main className="p-4 space-y-4 max-w-md mx-auto"> {/* Security index display card */} <div className="bg-gradient-to-br from-[#0c253d] to-[#041525] border border-white/10 rounded-2xl p-5 relative overflow-hidden"> <div className="absolute right-0 top-0 translate-x-1/4 -translate-y-1/4 w-24 h-24 rounded-full bg-emerald-500/10 blur-lg"></div> <div className="flex items-center justify-between"> <div> <h3 className="text-xs font-bold text-[#afc6ff]"> {state.language === "zh" ? "账号安全指数" : "Account Security Rating"} </h3> <div className="flex items-baseline gap-1 mt-2"> <span className="text-3xl font-extrabold text-white font-mono"> {isGoogleAuthBound ? "100%" : "70%"} </span> <span className="text-xs text-[#c1c6d7]"> {isGoogleAuthBound ? (state.language === "zh" ? "(安全)" : "(Secure)") : (state.language === "zh" ? "(中等)" : "(Medium)")} </span> </div> <p className="text-[10px] text-[#c1c6d7] mt-1.5 leading-normal"> {isGoogleAuthBound ? (state.language === "zh" ? "您的账户已激活最高等级2FA安全防护,资金完全隔离" : "Your account is fully secured with 2FA protection, funds completely isolated.") : (state.language === "zh" ? "建议立即绑定谷歌双重验证,100%预防粘贴板截获与仿冒登录" : "Strongly recommend Google 2FA setup to 100% prevent clipboard exploits.")} </p> </div> <div className="flex flex-col items-center"> <div className={`w-14 h-14 rounded-full border-4 ${isGoogleAuthBound ? "border-emerald-500/30" : "border-amber-500/30"} flex items-center justify-center relative`}> <Shield className={`w-6 h-6 ${isGoogleAuthBound ? "text-emerald-400" : "text-amber-400"} animate-pulse`} /> </div> </div> </div> </div> {/* Menu options list */} <div className="bg-[#0b2135] border border-white/5 rounded-2xl overflow-hidden divide-y divide-white/5"> {/* Google auth switcher */} <div onClick={() => { setSuccessMsg(""); setErrorMsg(""); setGaCode(""); setSubMode("GOOGLE_AUTH"); }} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <Smartphone className="w-5 h-5 text-amber-400" /> <div> <span className="text-xs font-semibold text-white block"> {state.language === "zh" ? "谷歌身份验证器 (Google 2FA)" : "Google Authenticator Dual Check"} </span> <span className="text-[10px] text-[#c1c6d7] mt-0.5 block"> {state.language === "zh" ? "最高防护,出币提现安全锁组件" : "Highest protection, vital for high-volume transactions"} </span> </div> </div> <div className="flex items-center gap-1"> <span className={`text-[10px] font-bold px-1.5 py-0.5 rounded border ${ isGoogleAuthBound ? "text-emerald-400 bg-emerald-400/10 border-emerald-500/20" : "text-amber-400 bg-amber-400/10 border-amber-500/20" }`}> {isGoogleAuthBound ? (state.language === "zh" ? "已激活" : "Active") : (state.language === "zh" ? "未绑定" : "Unbound")} </span> <ChevronRight className="w-4 h-4 text-slate-500" /> </div> </div> {/* Modify login password */} <div onClick={() => { setSuccessMsg(""); setErrorMsg(""); setCurrentPwd(""); setNewPwd(""); setConfirmPwd(""); setSubMode("CHANGE_PASSWORD"); }} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <Lock className="w-5 h-5 text-[#528dff]" /> <div> <span className="text-xs font-semibold text-white block"> {state.language === "zh" ? "登录密码修改" : "Modify Login Password"} </span> <span className="text-[10px] text-[#c1c6d7] mt-0.5 block"> {state.language === "zh" ? "建议定期轮换以防账户被泄露" : "Regular rotation highly advised for security"} </span> </div> </div> <ChevronRight className="w-4 h-4 text-slate-500" /> </div> {/* Safety Vault Key */} <div onClick={() => alert(state.language === "zh" ? "安全金库密码已于注册时强制启用,提现将自动进入全自动隔离节点校验。" : "Withdrawal vault verification security is fully enforced automatically.")} className="p-4 flex items-center justify-between hover:bg-[#22364c]/20 transition-colors cursor-pointer group" > <div className="flex items-center gap-3"> <Key className="w-5 h-5 text-indigo-400" /> <div> <span className="text-xs font-semibold text-white block"> {state.language === "zh" ? "独立安全资金密码" : "Isolated Smart Vault Pin"} </span> <span className="text-[10px] text-[#c1c6d7] mt-0.5 block"> {state.language === "zh" ? "提取款时用于防止被劫持转账" : "Stops rogue transactions from hijacking payments"} </span> </div> </div> <div className="flex items-center gap-1"> <span className="text-[10px] text-indigo-300 font-bold bg-indigo-500/10 border border-indigo-500/20 rounded px-1.5 py-0.5"> {state.language === "zh" ? "全隔离校验" : "Isolated Check"} </span> <ChevronRight className="w-4 h-4 text-slate-500" /> </div> </div> </div> {/* Login history logs */} <div className="bg-[#0b2135] border border-white/5 rounded-2xl p-4 space-y-3"> <div className="flex items-center justify-between"> <span className="text-xs font-bold text-white flex items-center gap-1.5"> <Shield className="w-3.5 h-3.5 text-[#528dff]" /> {state.language === "zh" ? "近期安全登录记录" : "Recent Security Login Attempts"} </span> <span className="text-[9px] text-[#528dff] font-bold uppercase tracking-wider animate-pulse"> {state.language === "zh" ? "● 防控防护中" : "● Guarding Active"} </span> </div> <div className="space-y-2 mt-2 font-sans text-left"> <div className="flex justify-between items-center text-[10px] border-b border-white/5 pb-2"> <div className="space-y-0.5"> <p className="text-[#afc6ff] font-mono">103.245.24.* (Manila, PH)</p> <p className="text-[#8e98b0]">Chrome / Windows 11</p> </div> <div className="text-right"> <p className="text-emerald-400 font-medium">{state.language === "zh" ? "成功登录" : "Succeeded"}</p> <p className="text-[#8e98b0] font-mono mt-0.5">2026-06-05 20:12:45</p> </div> </div> <div className="flex justify-between items-center text-[10px] border-b border-white/5 pb-2"> <div className="space-y-0.5"> <p className="text-[#afc6ff] font-mono">112.198.81.* (Cebu, PH)</p> <p className="text-[#8e98b0]">Shengda iOS App Sandbox</p> </div> <div className="text-right"> <p className="text-emerald-400 font-medium">{state.language === "zh" ? "成功登录" : "Succeeded"}</p> <p className="text-[#8e98b0] font-mono mt-0.5">2026-06-03 14:02:11</p> </div> </div> <div className="flex justify-between items-center text-[10px]"> <div className="space-y-0.5"> <p className="text-[#afc6ff] font-mono">222.127.42.* (Makati, PH)</p> <p className="text-[#8e98b0]">Chrome / MacOS</p> </div> <div className="text-right"> <p className="text-[#994747] font-semibold flex items-center gap-0.5 justify-end"> <AlertCircle className="w-3 h-3 text-[#f05252]" /> {state.language === "zh" ? "密码校验阻断" : "Block Alert"} </p> <p className="text-[#8e98b0] font-mono mt-0.5">2026-05-28 09:14:55</p> </div> </div> </div> </div> </main> </> )} {/* GOOGLE AUTH SETUP */} {subMode === "GOOGLE_AUTH" && ( <> <header className="bg-[#0b2135] h-14 border-b border-[#414755] flex items-center px-4 justify-between sticky top-0 z-40"> <div className="flex items-center gap-2"> <button onClick={() => setSubMode("SECURITY")} className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]" > <ArrowLeft className="w-5 h-5" /> </button> <span className="text-white text-base font-bold"> {state.language === "zh" ? "谷歌双重验证器" : "Google Dual Authenticator"} </span> </div> <div className="w-6"></div> </header> <main className="p-4 space-y-4 max-w-md mx-auto text-left"> {/* Steps & QR code */} <div className="bg-[#0b2135] border border-white/5 rounded-2xl p-4 space-y-4"> <div className="flex gap-2"> <span className="w-5 h-5 rounded-full bg-amber-400 text-slate-950 flex items-center justify-center font-bold text-xs shrink-0">1</span> <div> <h4 className="text-xs font-bold text-white"> {state.language === "zh" ? "获取谷歌验证器应用程序" : "Download Google Authenticator"} </h4> <p className="text-[10px] text-[#c1c6d7] mt-1 pr-2 leading-relaxed"> {state.language === "zh" ? "在您的 iOS / Android 移动设备的应用商店搜索并下载:Google Authenticator" : "Search & download 'Google Authenticator' in your App Store or Google Play."} </p> </div> </div> <div className="flex gap-2 border-t border-white/5 pt-4"> <span className="w-5 h-5 rounded-full bg-amber-400 text-slate-950 flex items-center justify-center font-bold text-xs shrink-0">2</span> <div className="w-full"> <h4 className="text-xs font-bold text-white"> {state.language === "zh" ? "手动添加密钥或扫描条形码" : "Import Key or Scan QR"} </h4> {/* Styled QR placeholder art */} <div className="mt-3 bg-white p-3 rounded-xl w-32 h-32 mx-auto flex items-center justify-center relative shadow-lg"> {/* Simplified geometric QR block art */} <div className="grid grid-cols-5 gap-1.5 w-24 h-24"> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-transparent"></div> <div className="bg-slate-900 rounded-[1px]"></div> <div className="bg-slate-900 rounded-[1px]"></div> </div> {/* Crown or lock element in center */} <div className="absolute inset-0 m-auto w-8 h-8 rounded bg-slate-950 flex items-center justify-center"> <Shield className="w-4 h-4 text-amber-400" /> </div> </div> <p className="text-[10px] text-[#c1c6d7] text-center mt-2.5"> {state.language === "zh" ? "手动输入密钥" : "Key String for Manual Entry"} </p> <div className="mt-1.5 flex items-center justify-between gap-2 bg-[#001428] border border-[#414755]/50 rounded-xl px-3 py-2.5"> <span className="font-mono text-white text-[11px] tracking-wider select-text">SDYL7G7GA666X9Y2</span> <button onClick={() => { navigator.clipboard.writeText("SDYL7G7GA666X9Y2"); setCopied(true); setTimeout(() => setCopied(false), 2000); }} className="px-2.5 py-1 text-[10px] bg-[#22364c] hover:bg-[#2d4763] text-amber-400 border border-amber-400/20 rounded font-bold transition-all transition-colors active:scale-95 shrink-0" > {copied ? (state.language === "zh" ? "已复制" : "Copied!") : (state.language === "zh" ? "复制" : "Copy")} </button> </div> </div> </div> <div className="flex gap-2 border-t border-[#414755]/30 pt-4"> <span className="w-5 h-5 rounded-full bg-amber-400 text-slate-950 flex items-center justify-center font-bold text-xs shrink-0">3</span> <div className="w-full space-y-3"> <h4 className="text-xs font-bold text-white"> {state.language === "zh" ? "输入6位数字动态验证码完成激活" : "Verify 6-Digit Authenticator Factor"} </h4> <div className="relative"> <input type="text" maxLength={6} value={gaCode} onChange={(e) => setGaCode(e.target.value.replace(/\D/g, ''))} placeholder="000000" className="w-full bg-[#001428] border border-[#414755]/50 text-white font-mono text-base tracking-[0.75em] text-center rounded-xl py-3 placeholder:text-slate-700 placeholder:tracking-normal focus:outline-none focus:border-amber-400/80" /> </div> {errorMsg && ( <div className="bg-red-500/10 border border-red-500/20 text-red-300 text-[10px] p-2.5 rounded-lg flex items-center gap-1.5 leading-normal"> <AlertCircle className="w-3.5 h-3.5 text-red-400 shrink-0" /> <span>{errorMsg}</span> </div> )} {successMsg && ( <div className="bg-emerald-500/10 border border-emerald-500/20 text-emerald-300 text-[10px] p-2.5 rounded-lg flex items-center gap-1.5 leading-normal"> <Check className="w-3.5 h-3.5 text-emerald-400 shrink-0" /> <span>{successMsg}</span> </div> )} <button disabled={loading} onClick={() => { if (gaCode.length !== 6) { setErrorMsg(state.language === "zh" ? "请输入合法的6位数字验证码!" : "Please input a valid 6-digit authenticator code."); return; } setErrorMsg(""); setLoading(true); setTimeout(() => { setLoading(false); setIsGoogleAuthBound(true); setSuccessMsg(state.language === "zh" ? "谷歌身份验证双重保护激活成功!" : "Google dual authenticator activated successfully!"); setTimeout(() => { setSubMode("SECURITY"); }, 1800); }, 1500); }} className="w-full py-3 bg-gradient-to-r from-amber-400 to-[#FFD700] hover:brightness-105 hover:shadow-[0_0_12px_rgba(245,158,11,0.25)] text-slate-950 font-bold rounded-xl text-xs flex justify-center items-center gap-2 active:scale-95 transition-transform" > {loading ? ( <> <RefreshCw className="w-3.5 h-3.5 animate-spin" /> <span>{state.language === "zh" ? "加密中..." : "Encrypting..."}</span> </> ) : ( <span>{state.language === "zh" ? "确认并激活一键身份锁定" : "Confirm & Enable Key Vault Protection"}</span> )} </button> </div> </div> </div> </main> </> )} {/* CHANGE PASSWORD */} {subMode === "CHANGE_PASSWORD" && ( <> <header className="bg-[#0b2135] h-14 border-b border-[#414755] flex items-center px-4 justify-between sticky top-0 z-40"> <div className="flex items-center gap-2"> <button onClick={() => setSubMode("SECURITY")} className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]" > <ArrowLeft className="w-5 h-5" /> </button> <span className="text-white text-base font-bold"> {state.language === "zh" ? "修改登录密码" : "Change Password"} </span> </div> <div className="w-6"></div> </header> <main className="p-4 space-y-4 max-w-md mx-auto text-left"> <div className="bg-[#0b2135] border border-white/5 rounded-2xl p-4 space-y-4"> <div className="space-y-1.5"> <label className="text-xs font-semibold text-[#afc6ff]"> {state.language === "zh" ? "当前登录密码" : "Current Password"} </label> <div className="relative"> <input type="password" value={currentPwd} onChange={(e) => setCurrentPwd(e.target.value)} placeholder={state.language === "zh" ? "请输入您当前使用的密码" : "Enter old password"} className="w-full bg-[#001428] border border-[#414755]/50 text-white text-xs rounded-xl py-3 px-4 focus:outline-none focus:border-amber-400" /> </div> </div> <div className="space-y-1.5"> <label className="text-xs font-semibold text-[#afc6ff]"> {state.language === "zh" ? "设置新登录密码" : "New Secure Password"} </label> <div className="relative"> <input type="password" value={newPwd} onChange={(e) => setNewPwd(e.target.value)} placeholder={state.language === "zh" ? "8-20位包含英文字母和数字" : "8-20 alphanumeric characters"} className="w-full bg-[#001428] border border-[#414755]/50 text-white text-xs rounded-xl py-3 px-4 focus:outline-none focus:border-amber-400" /> </div> </div> <div className="space-y-1.5"> <label className="text-xs font-semibold text-[#afc6ff]"> {state.language === "zh" ? "确认新登录密码" : "Confirm New Password"} </label> <div className="relative"> <input type="password" value={confirmPwd} onChange={(e) => setConfirmPwd(e.target.value)} placeholder={state.language === "zh" ? "请再次提交您的新密码确保正确" : "Re-enter new password"} className="w-full bg-[#001428] border border-[#414755]/50 text-white text-xs rounded-xl py-3 px-4 focus:outline-none focus:border-amber-400" /> </div> </div> {errorMsg && ( <div className="bg-red-500/10 border border-red-500/20 text-red-300 text-[10px] p-2.5 rounded-lg flex items-center gap-1.5 leading-normal"> <AlertCircle className="w-3.5 h-3.5 text-red-400 shrink-0" /> <span>{errorMsg}</span> </div> )} {successMsg && ( <div className="bg-emerald-500/10 border border-emerald-500/20 text-emerald-300 text-[10px] p-2.5 rounded-lg flex items-center gap-1.5 leading-normal"> <Check className="w-3.5 h-3.5 text-emerald-400 shrink-0" /> <span>{successMsg}</span> </div> )} <button disabled={loading} onClick={() => { if (!currentPwd || !newPwd || !confirmPwd) { setErrorMsg(state.language === "zh" ? "请完整填写密码修改表格!" : "Please fill out all fields."); return; } if (newPwd.length < 8) { setErrorMsg(state.language === "zh" ? "为了安全防盗,新密码长度不能少于8位!" : "Passwords must be at least 8 characters."); return; } if (newPwd !== confirmPwd) { setErrorMsg(state.language === "zh" ? "两次输入的新密码不一致,请仔细检查!" : "New password confirmations do not match."); return; } setErrorMsg(""); setLoading(true); setTimeout(() => { setLoading(false); setSuccessMsg(state.language === "zh" ? "盛大账号登录密码修改同步修改成功!" : "Shengda account password rotated successfully!"); setCurrentPwd(""); setNewPwd(""); setConfirmPwd(""); setTimeout(() => { setSubMode("SECURITY"); }, 1800); }, 1500); }} className="w-full py-3 bg-[#528dff] hover:bg-[#528dff]/90 text-[#00275f] font-bold rounded-xl text-xs flex justify-center items-center gap-2 active:scale-95 transition-transform" > {loading ? ( <> <RefreshCw className="w-3.5 h-3.5 animate-spin" /> <span>{state.language === "zh" ? "正在同步安全网络..." : "Syncing security nodes..."}</span> </> ) : ( <span>{state.language === "zh" ? "提交保存登录新密码" : "Rotate Password"}</span> )} </button> </div> </main> </> )} {/* Premium Avatar Dialog Modal */} {showAvatarDialog && ( <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm animate-fade-in animate-duration-200"> <div className="bg-[#0b2135] border border-white/10 rounded-3xl w-full max-w-sm overflow-hidden shadow-[0_20px_50px_rgba(0,0,0,0.8)] relative"> {/* Header */} <div className="p-5 border-b border-white/5 flex justify-between items-center bg-[#071d31]"> <div> <h3 className="text-sm font-bold text-white flex items-center gap-1.5"> <User className="w-4 h-4 text-amber-400" /> {state.language === "zh" ? "更换尊贵头像" : "Select VIP Avatar"} </h3> <p className="text-[10px] text-[#c1c6d7] mt-0.5 opacity-80"> {state.language === "zh" ? "支持拖拽或选择本地图片上传" : "Drag-and-drop or upload custom photos"} </p> </div> <button onClick={() => setShowAvatarDialog(false)} className="p-1 rounded-full text-slate-400 hover:bg-[#22364c] hover:text-white transition-colors" type="button" > <X className="w-5 h-5" /> </button> </div> <div className="p-5 space-y-4"> {/* Drag and Drop File Upload Area */} <div onDragEnter={handleDrag} onDragOver={handleDrag} onDragLeave={handleDrag} onDrop={handleDrop} onClick={() => fileInputRef.current?.click()} className={`border-2 border-dashed rounded-2xl p-6 text-center cursor-pointer transition-all ${ dragActive ? "border-amber-400 bg-amber-400/5" : "border-white/10 bg-slate-900/40 hover:border-amber-400/50 hover:bg-slate-900/60" }`} > <input ref={fileInputRef} type="file" accept="image/*" className="hidden" onChange={handleFileInputChange} /> <div className="flex flex-col items-center gap-2"> <div className="p-3 bg-[#22364c]/50 rounded-full text-amber-400"> <Upload className="w-5 h-5" /> </div> <span className="text-xs font-semibold text-white"> {state.language === "zh" ? "点击或拖拽图片到这里" : "Click or drag/drop image here"} </span> <span className="text-[10px] text-zinc-500 font-mono"> 支持 JPEG / PNG / WEBP </span> </div> </div> {/* Presets Grid */} <div className="space-y-2"> <span className="text-[10px] font-bold text-amber-400 uppercase tracking-wider block"> {state.language === "zh" ? "或者选择皇室 VIP 预设头像" : "Or Choose Royal VIP Presets"} </span> <div className="grid grid-cols-5 gap-2.5"> {vipPresets.map((url, i) => ( <button key={i} type="button" onClick={() => { onSetState(prev => ({ ...prev, avatarUrl: url })); }} className={`relative aspect-square rounded-xl overflow-hidden p-[1.5px] transition-all duration-300 active:scale-95 ${ state.avatarUrl === url ? "bg-gradient-to-tr from-amber-400 to-yellow-300 scale-105 shadow-[0_0_12px_rgba(251,191,36,0.5)]" : "bg-white/10 hover:bg-white/20" }`} > <img src={url} alt={`Preset ${i+1}`} className="w-full h-full object-cover rounded-xl" referrerPolicy="no-referrer" /> {state.avatarUrl === url && ( <div className="absolute inset-0 bg-amber-500/10 flex items-center justify-center"> <Check className="w-4 h-4 text-white filter drop-shadow" /> </div> )} </button> ))} </div> </div> {/* Current Preview */} <div className="bg-slate-900/60 p-3 rounded-2xl border border-white/5 flex items-center justify-between"> <div className="flex items-center gap-3"> <div className="w-10 h-10 rounded-full p-[1.5px] bg-[#FFD700]"> {state.avatarUrl ? ( <img src={state.avatarUrl} alt="Current Avatar" className="w-full h-full object-cover rounded-full" referrerPolicy="no-referrer" /> ) : ( <div className="w-full h-full bg-[#122e47] flex items-center justify-center rounded-full font-bold text-white text-xs"> {state.isLoggedIn ? state.username.slice(0, 2).toUpperCase() : "G"} </div> )} </div> <div> <span className="text-xs font-bold text-white block col-span-2"> {state.isLoggedIn ? state.username : (state.language === "zh" ? "试玩玩家" : "Guest Player")} </span> <span className="text-[10px] text-amber-400 font-extrabold uppercase font-mono tracking-wider flex items-center gap-1"> VIP 等级: {state.vipLevel} 级会员 </span> </div> </div> <span className="text-[9px] bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-2 py-0.5 rounded-full font-bold uppercase font-sans"> {state.language === "zh" ? "已激活" : "Active"} </span> </div> </div> {/* Footer with actions */} <div className="p-4 bg-[#071d31] border-t border-[#414755]/30 flex gap-2.5"> <button type="button" onClick={() => { onSetState(prev => ({ ...prev, avatarUrl: undefined })); }} className="flex-1 py-2.5 bg-slate-900 hover:bg-slate-950 border border-white/5 rounded-xl text-[11px] font-semibold text-slate-300 active:scale-95 transition-transform" > {state.language === "zh" ? "重置默认" : "Reset Default"} </button> <button type="button" onClick={() => setShowAvatarDialog(false)} className="flex-1 py-2.5 bg-gradient-to-r from-amber-400 to-[#FFD700] hover:brightness-105 text-slate-950 font-black rounded-xl text-[11px] active:scale-95 transition-transform" > {state.language === "zh" ? "保存并完成" : "Save & Close"} </button> </div> </div> </div> )} </div> ); };
import React from "react";
import { ScreenId, AppState } from "../types";
import {
ArrowLeft, LogOut, Landmark, Shield, LifeBuoy, ChevronRight, RefreshCw,
BarChart2, Award, Globe, Lock, Key, Check, Smartphone, AlertCircle, Upload,
Camera, User, X
} from "lucide-react";
import { translations } from "../lib/translations";
interface ProfileViewProps {
state: AppState;
onNavigate: (screen: ScreenId) => void;
onSetState: (updater: (prev: AppState) => AppState) => void;
}
export const ProfileView: React.FC<ProfileViewProps> = ({ state, onNavigate, onSetState }) => {
const [subMode, setSubMode] = React.useState<"MAIN" | "SECURITY" | "GOOGLE_AUTH" | "CHANGE_PASSWORD">("MAIN");
const [isGoogleAuthBound, setIsGoogleAuthBound] = React.useState(false);
const [copied, setCopied] = React.useState(false);
const [gaCode, setGaCode] = React.useState("");
const [currentPwd, setCurrentPwd] = React.useState("");
const [newPwd, setNewPwd] = React.useState("");
const [confirmPwd, setConfirmPwd] = React.useState("");
const [loading, setLoading] = React.useState(false);
const [successMsg, setSuccessMsg] = React.useState("");
const [errorMsg, setErrorMsg] = React.useState("");
const [showAvatarDialog, setShowAvatarDialog] = React.useState(false);
const [dragActive, setDragActive] = React.useState(false);
const fileInputRef = React.useRef<HTMLInputElement>(null);
const visibleBalance = state.isLoggedIn ? state.balance : 0;
const vipPresets = [
"https://images.unsplash.com/photo-1544005313-94ddf0286df2?auto=format&fit=crop&w=150&h=150&q=80",
"https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?auto=format&fit=crop&w=150&h=150&q=80",
"https://images.unsplash.com/photo-1494790108377-be9c29b29330?auto=format&fit=crop&w=150&h=150&q=80",
"https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?auto=format&fit=crop&w=150&h=150&q=80",
"https://images.unsplash.com/photo-1438761681033-6461ffad8d80?auto=format&fit=crop&w=150&h=150&q=80"
];
const handleDrag = (e: React.DragEvent) => {
e.preventDefault();
e.stopPropagation();
if (e.type === "dragenter" || e.type === "dragover") {
setDragActive(true);
} else if (e.type === "dragleave") {
setDragActive(false);
}
};
const handleDrop = (e: React.DragEvent) => {
e.preventDefault();
e.stopPropagation();
setDragActive(false);
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
const file = e.dataTransfer.files[0];
readAndSetAvatar(file);
}
};
const handleFileInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.files && e.target.files[0]) {
const file = e.target.files[0];
readAndSetAvatar(file);
}
};
const readAndSetAvatar = (file: File) => {
const reader = new FileReader();
reader.onloadend = () => {
const base64String = reader.result as string;
onSetState(prev => ({
...prev,
avatarUrl: base64String
}));
};
reader.readAsDataURL(file);
};
const handleLogout = () => {
onSetState((prev) => ({
...prev,
isLoggedIn: false,
username: "未登录"
}));
onNavigate(ScreenId.HOME);
};
return (
<div className="bg-[#000B14] text-[#d1e4ff] min-h-screen pb-24 font-sans select-none overflow-x-hidden">
{subMode === "MAIN" && (
<>
{/* Header */}
<header className="bg-[#0b2135] h-14 border-b border-[#414755] flex items-center px-4 justify-between sticky top-0 z-40">
<div className="flex items-center gap-2">
<button
onClick={() => onNavigate(ScreenId.HOME)}
className="p-1 rounded-full text-[#afc6ff] hover:bg-[#22364c]"
>