From d4846869ebd18b638035cc20b663748c486c9a6f Mon Sep 17 00:00:00 2001 From: yorn <1057707203@qq.com> Date: Wed, 11 Jun 2025 21:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A03=E4=B8=AA=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=EF=BC=8C=E6=B3=A8=E9=87=8A=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E9=80=89=E9=A1=B9=EF=BC=8C=E4=BC=98=E5=8C=96=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + app/config/api-config.ts | 2 +- app/routes/login.tsx | 56 ++++++++++++++++++++++++++++++-------- app/styles/pages/login.css | 34 +++++++++++++++++++++++ 4 files changed, 81 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 88a952c..b77a2e7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ node_modules .env .idea +.history logs/ \ No newline at end of file diff --git a/app/config/api-config.ts b/app/config/api-config.ts index 8ffd4cd..22249af 100644 --- a/app/config/api-config.ts +++ b/app/config/api-config.ts @@ -35,7 +35,7 @@ const configs: Record = { // postgrest baseUrl: 'http://10.79.97.16:8000', // minio - documentUrl: 'http://10.76.244.156:9001/docauditai/', + documentUrl: 'http://10.76.244.156:9000/docauditai/', // 文件上传 uploadUrl: 'http://10.79.97.16:8000/admin/documents/upload', }, diff --git a/app/routes/login.tsx b/app/routes/login.tsx index 0d9921e..482a63c 100644 --- a/app/routes/login.tsx +++ b/app/routes/login.tsx @@ -29,8 +29,31 @@ export async function action({ request }: ActionFunctionArgs) { return Response.json({ error: "用户名和密码不能为空" }); } + if(userRole === 'common') { + // console.log("username-----", username); + // console.log("password-----", password); + const validUsers = [ + { username: 'gdycuser', password: 'gdyc06111' }, + { username: 'gdycuser2', password: 'gdyc06112' }, + { username: 'gdycuser3', password: 'gdyc06113' } + ]; + const validUser = validUsers.find(user => user.username === username && user.password === password); + if (!validUser) { + return Response.json({ error: "普通用户用户名或密码错误" }); + } + } + + // console.log("login success", userRole); + + // 管理员登录 if (userRole === 'developer') { - if (username !== 'admin' || password !== 'admin') { + const validAdminUsers = [ + { username: 'admin', password: 'admin0611' }, + // { username: 'admin2', password: 'admin06112' }, + // { username: 'admin3', password: 'admin06113' } + ]; + const validAdminUser = validAdminUsers.find(user => user.username === username && user.password === password); + if (!validAdminUser) { return Response.json({ error: "管理员用户名或密码错误" }); } } @@ -73,6 +96,7 @@ export default function Login() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [userRole, setUserRole] = useState("common"); + const [showPassword, setShowPassword] = useState(false); const actionData = useActionData(); return ( @@ -111,15 +135,25 @@ export default function Login() {
- setPassword(e.target.value)} - className="form-input" - placeholder="请输入密码" - /> +
+ setPassword(e.target.value)} + className="form-input password-input" + placeholder="请输入密码" + /> + +
@@ -133,7 +167,7 @@ export default function Login() { required > - + {/* */}
diff --git a/app/styles/pages/login.css b/app/styles/pages/login.css index a912bc1..4433aa1 100644 --- a/app/styles/pages/login.css +++ b/app/styles/pages/login.css @@ -112,6 +112,40 @@ box-shadow: 0 0 0 2px rgba(44, 173, 125, 0.2); } +/* 密码输入框容器样式 */ +.password-input-container { + position: relative; + display: flex; + align-items: center; +} + +.password-input { + padding-right: 3rem; /* 为眼睛图标留出空间 */ +} + +.password-toggle-btn { + position: absolute; + right: 0.75rem; + top: 50%; + transform: translateY(-50%); + background: none; + border: none; + cursor: pointer; + padding: 0.25rem; + color: #666; + font-size: 1.25rem; + display: flex; + align-items: center; + justify-content: center; + border-radius: 4px; + transition: color 0.2s, background-color 0.2s; +} + +.password-toggle-btn:hover { + color: #2cad7d; +} + + .login-button { margin-top: 1rem; padding: 0.75rem 1.5rem;