diff --git a/client/.env.production b/client/.env.production new file mode 100644 index 0000000..02fd38f --- /dev/null +++ b/client/.env.production @@ -0,0 +1,2 @@ +# 构建时设置API地址(内网穿透地址) +# VITE_API_BASE_URL=https://your-ngrok-url/api diff --git a/client/src/lib/api.ts b/client/src/lib/api.ts index d1b486b..5a1fc3e 100644 --- a/client/src/lib/api.ts +++ b/client/src/lib/api.ts @@ -1,7 +1,7 @@ import axios from 'axios' const api = axios.create({ - baseURL: '/api', + baseURL: import.meta.env.VITE_API_BASE_URL || '/api', timeout: 30000, }) diff --git a/client/src/pages/LoginPage.tsx b/client/src/pages/LoginPage.tsx index a3a5140..f18a4f5 100644 --- a/client/src/pages/LoginPage.tsx +++ b/client/src/pages/LoginPage.tsx @@ -9,7 +9,7 @@ interface LoginPageProps { export function LoginPage({ onLogin }: LoginPageProps) { const navigate = useNavigate() const [username, setUsername] = useState('总部管理员') - const [password, setPassword] = useState('123') + const [password, setPassword] = useState('') const [error, setError] = useState('') const handleLogin = async () => { @@ -34,9 +34,11 @@ export function LoginPage({ onLogin }: LoginPageProps) { setUsername(e.target.value)} + onKeyDown={(e) => e.key === 'Enter' && handleLogin()} className="mt-1 w-full rounded-md border px-3 py-2 text-sm" /> + {error &&

{error}

}
- {error &&

{error}

}