{"ast":null,"code":"import React,{useState}from'react';import{Form,Input,Button,Card,message}from'antd';import{UserOutlined,LockOutlined}from'@ant-design/icons';import{useAuth}from'../contexts/AuthContext';import{useNavigate,useLocation}from'react-router-dom';import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";const Login=()=>{var _location$state,_location$state$from;const[loading,setLoading]=useState(false);const{login}=useAuth();const navigate=useNavigate();const location=useLocation();const from=((_location$state=location.state)===null||_location$state===void 0?void 0:(_location$state$from=_location$state.from)===null||_location$state$from===void 0?void 0:_location$state$from.pathname)||'/';const onFinish=async values=>{setLoading(true);try{await login(values);message.success('登录成功');navigate(from,{replace:true});}catch(error){var _error$response,_error$response$data;message.error(((_error$response=error.response)===null||_error$response===void 0?void 0:(_error$response$data=_error$response.data)===null||_error$response$data===void 0?void 0:_error$response$data.message)||'登录失败');}finally{setLoading(false);}};return/*#__PURE__*/_jsx(\"div\",{className:\"login-container\",children:/*#__PURE__*/_jsxs(Card,{className:\"login-card\",children:[/*#__PURE__*/_jsxs(\"div\",{style:{textAlign:'center',marginBottom:24},children:[/*#__PURE__*/_jsx(\"h1\",{style:{fontSize:24,marginBottom:8},children:\"\\u79C1\\u52DF\\u80A1\\u6743\\u6295\\u8D44\\u7BA1\\u7406\\u7CFB\\u7EDF\"}),/*#__PURE__*/_jsx(\"p\",{style:{color:'#666'},children:\"\\u8BF7\\u767B\\u5F55\\u60A8\\u7684\\u8D26\\u6237\"})]}),/*#__PURE__*/_jsxs(Form,{name:\"login\",onFinish:onFinish,autoComplete:\"off\",size:\"large\",children:[/*#__PURE__*/_jsx(Form.Item,{name:\"username\",rules:[{required:true,message:'请输入用户名'}],children:/*#__PURE__*/_jsx(Input,{prefix:/*#__PURE__*/_jsx(UserOutlined,{}),placeholder:\"\\u7528\\u6237\\u540D\"})}),/*#__PURE__*/_jsx(Form.Item,{name:\"password\",rules:[{required:true,message:'请输入密码'}],children:/*#__PURE__*/_jsx(Input.Password,{prefix:/*#__PURE__*/_jsx(LockOutlined,{}),placeholder:\"\\u5BC6\\u7801\"})}),/*#__PURE__*/_jsx(Form.Item,{children:/*#__PURE__*/_jsx(Button,{type:\"primary\",htmlType:\"submit\",loading:loading,block:true,children:\"\\u767B\\u5F55\"})})]}),/*#__PURE__*/_jsx(\"div\",{style:{textAlign:'center',color:'#999',fontSize:12},children:\"\\u9ED8\\u8BA4\\u7BA1\\u7406\\u5458: admin / admin123\"})]})});};export default Login;","map":{"version":3,"names":["React","useState","Form","Input","Button","Card","message","UserOutlined","LockOutlined","useAuth","useNavigate","useLocation","jsx","_jsx","jsxs","_jsxs","Login","_location$state","_location$state$from","loading","setLoading","login","navigate","location","from","state","pathname","onFinish","values","success","replace","error","_error$response","_error$response$data","response","data","className","children","style","textAlign","marginBottom","fontSize","color","name","autoComplete","size","Item","rules","required","prefix","placeholder","Password","type","htmlType","block"],"sources":["/Users/nili/Documents/trae_projects/client/src/pages/Login.js"],"sourcesContent":["import React, { useState } from 'react';\nimport { Form, Input, Button, Card, message } from 'antd';\nimport { UserOutlined, LockOutlined } from '@ant-design/icons';\nimport { useAuth } from '../contexts/AuthContext';\nimport { useNavigate, useLocation } from 'react-router-dom';\n\nconst Login = () => {\n  const [loading, setLoading] = useState(false);\n  const { login } = useAuth();\n  const navigate = useNavigate();\n  const location = useLocation();\n\n  const from = location.state?.from?.pathname || '/';\n\n  const onFinish = async (values) => {\n    setLoading(true);\n    try {\n      await login(values);\n      message.success('登录成功');\n      navigate(from, { replace: true });\n    } catch (error) {\n      message.error(error.response?.data?.message || '登录失败');\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  return (\n    <div className=\"login-container\">\n      <Card className=\"login-card\">\n        <div style={{ textAlign: 'center', marginBottom: 24 }}>\n          <h1 style={{ fontSize: 24, marginBottom: 8 }}>私募股权投资管理系统</h1>\n          <p style={{ color: '#666' }}>请登录您的账户</p>\n        </div>\n        <Form\n          name=\"login\"\n          onFinish={onFinish}\n          autoComplete=\"off\"\n          size=\"large\"\n        >\n          <Form.Item\n            name=\"username\"\n            rules={[{ required: true, message: '请输入用户名' }]}\n          >\n            <Input\n              prefix={<UserOutlined />}\n              placeholder=\"用户名\"\n            />\n          </Form.Item>\n\n          <Form.Item\n            name=\"password\"\n            rules={[{ required: true, message: '请输入密码' }]}\n          >\n            <Input.Password\n              prefix={<LockOutlined />}\n              placeholder=\"密码\"\n            />\n          </Form.Item>\n\n          <Form.Item>\n            <Button type=\"primary\" htmlType=\"submit\" loading={loading} block>\n              登录\n            </Button>\n          </Form.Item>\n        </Form>\n        <div style={{ textAlign: 'center', color: '#999', fontSize: 12 }}>\n          默认管理员: admin / admin123\n        </div>\n      </Card>\n    </div>\n  );\n};\n\nexport default Login;\n"],"mappings":"AAAA,MAAO,CAAAA,KAAK,EAAIC,QAAQ,KAAQ,OAAO,CACvC,OAASC,IAAI,CAAEC,KAAK,CAAEC,MAAM,CAAEC,IAAI,CAAEC,OAAO,KAAQ,MAAM,CACzD,OAASC,YAAY,CAAEC,YAAY,KAAQ,mBAAmB,CAC9D,OAASC,OAAO,KAAQ,yBAAyB,CACjD,OAASC,WAAW,CAAEC,WAAW,KAAQ,kBAAkB,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAE5D,KAAM,CAAAC,KAAK,CAAGA,CAAA,GAAM,KAAAC,eAAA,CAAAC,oBAAA,CAClB,KAAM,CAACC,OAAO,CAAEC,UAAU,CAAC,CAAGnB,QAAQ,CAAC,KAAK,CAAC,CAC7C,KAAM,CAAEoB,KAAM,CAAC,CAAGZ,OAAO,CAAC,CAAC,CAC3B,KAAM,CAAAa,QAAQ,CAAGZ,WAAW,CAAC,CAAC,CAC9B,KAAM,CAAAa,QAAQ,CAAGZ,WAAW,CAAC,CAAC,CAE9B,KAAM,CAAAa,IAAI,CAAG,EAAAP,eAAA,CAAAM,QAAQ,CAACE,KAAK,UAAAR,eAAA,kBAAAC,oBAAA,CAAdD,eAAA,CAAgBO,IAAI,UAAAN,oBAAA,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