import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { useConfigStore } from '../stores/configStore' export default function ServerSetupPage() { const navigate = useNavigate() const { setCustomServer, config, loading, error } = useConfigStore() const [serverUrl, setServerUrl] = useState('') const [manualMode, setManualMode] = useState(false) const handleAutoConnect = async () => { if (config && config.server_url) { navigate('/login') } } const handleManualConnect = async () => { if (!serverUrl.trim()) return let url = serverUrl.trim() if (!url.startsWith('http://') && !url.startsWith('https://')) { url = 'http://' + url } await setCustomServer(url) const { config: newConfig } = useConfigStore.getState() if (newConfig && newConfig.server_url) { navigate('/login') } } const hasEmbeddedConfig = config && config.server_url && config.server_url !== 'http://localhost:3000' return (
🎮

FunMC

Minecraft 联机工具

{hasEmbeddedConfig ? ( <>
检测到预配置服务器

服务器名称

{config?.server_name || 'FunMC Server'}

服务器地址

{config?.server_url}

) : manualMode || !hasEmbeddedConfig ? ( <>

连接到服务器

setServerUrl(e.target.value)} placeholder="例如: funmc.com:3000 或 192.168.1.100:3000" className="w-full px-4 py-3 bg-gray-700/50 border border-gray-600 rounded-xl text-white placeholder-gray-500 focus:outline-none focus:border-green-500 transition-colors" onKeyDown={(e) => e.key === 'Enter' && handleManualConnect()} />

输入管理员提供的服务器地址

{error && (
{error}
)} {hasEmbeddedConfig && ( )} ) : null}

魔幻方开发

) }