1 line
12 KiB
JSON
1 line
12 KiB
JSON
|
|
{"ast":null,"code":"var _jsxFileName = \"D:\\\\aiproject\\\\goAgent\\\\todo\\\\client\\\\src\\\\components\\\\LoginForm.js\",\n _s = $RefreshSig$();\nimport React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { login } from '../services/api';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst LoginContainer = styled.div`\n background: rgba(255, 255, 255, 0.95);\n backdrop-filter: blur(10px);\n border-radius: 20px;\n padding: 40px;\n box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);\n width: 100%;\n max-width: 400px;\n text-align: center;\n`;\n_c = LoginContainer;\nconst Title = styled.h1`\n color: #333;\n margin-bottom: 30px;\n font-size: 28px;\n font-weight: 300;\n`;\n_c2 = Title;\nconst Form = styled.form`\n display: flex;\n flex-direction: column;\n gap: 20px;\n`;\n_c3 = Form;\nconst Input = styled.input`\n padding: 15px 20px;\n border: 2px solid #e1e5e9;\n border-radius: 12px;\n font-size: 16px;\n transition: all 0.3s ease;\n outline: none;\n\n &:focus {\n border-color: #667eea;\n box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);\n }\n\n &::placeholder {\n color: #a0a0a0;\n }\n`;\n_c4 = Input;\nconst Button = styled.button`\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border: none;\n padding: 15px 20px;\n border-radius: 12px;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.3s ease;\n margin-top: 10px;\n\n &:hover {\n transform: translateY(-2px);\n box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);\n }\n\n &:disabled {\n opacity: 0.6;\n cursor: not-allowed;\n transform: none;\n }\n`;\n_c5 = Button;\nconst ErrorMessage = styled.div`\n color: #e74c3c;\n font-size: 14px;\n margin-top: 10px;\n padding: 10px;\n background: rgba(231, 76, 60, 0.1);\n border-radius: 8px;\n`;\n_c6 = ErrorMessage;\nconst Hint = styled.div`\n color: #666;\n font-size: 14px;\n margin-top: 20px;\n padding: 15px;\n background: rgba(102, 126, 234, 0.1);\n border-radius: 8px;\n border-left: 4px solid #667eea;\n`;\n_c7 = Hint;\nfunction LoginForm({\n onLogin\n}) {\n _s();\n const [password, setPassword] = useState('');\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState('');\n const handleSubmit = async e => {\n e.preventDefault();\n setLoading(true);\n setError('');\n try {\n const response = await login(password);\n onLogin(response.token);\n } catch (err) {\n var _err$response, _err$response$data;\n setError(((_err$response = err.response) === null || _err$response === void 0 ? void 0 : (_err$response$data = _err$response.data) === null || _err$response$data === void 0 ? void 0 : _err$response$data.error) || '登录失败,请重试');\n } finally {\n setLoading(false);\n }\n };\n return /*#__PURE__*/_jsxDEV(LoginContainer, {\n children: [/*#__PURE__*/_jsxDEV(Title, {\n children: \"\\u5DE5\\u4F5C\\u5F85\\u529E\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 112,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(Form, {\n onSubmit: handleSubmit,\n children: [/*#__PURE__*/_jsxDEV(Input, {\n type: \"password\",\n placeholder: \"\\u8BF7\\u8F93\\u5165\\u8BBF\\u95EE\\u5BC6\\u7801\",\n value: password,\n onChange: e => setPassword(e.target.value),\n required: true\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 114,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(Button, {\n type: \"submit\",\n disabled: loading,\n children: loading ? '验证中...' : '进入系统'\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 121,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 113,\n columnNumber: 7\n }, this), error && /*#__PURE__*/_jsxDEV(ErrorMessage, {\n children: error\n }, void 0, false, {\n fileName: _jsxFileName,
|