From a25572301d99a8fd6740dc70c33b44d702c765c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=89=8D=E5=8D=93?= <2284808383@qq.com> Date: Sun, 7 Apr 2024 17:36:32 +0800 Subject: [PATCH] password --- package-lock.json | 2 +- src/pages/login/index.vue | 40 ++--------- src/pages/password/index.vue | 121 +++++++++++++-------------------- src/pages/students/student.vue | 2 +- vite.config.js | 2 +- 5 files changed, 56 insertions(+), 111 deletions(-) diff --git a/package-lock.json b/package-lock.json index bc6aac9..1cac93f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1605,7 +1605,7 @@ }, "node_modules/pinia-plugin-persistedstate": { "version": "3.2.1", - "resolved": "https://registry.npmmirror.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz", "integrity": "sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ==", "peerDependencies": { "pinia": "^2.0.0" diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 81cfd46..e29b870 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -74,12 +74,8 @@ const rules = reactive({ message: "必须填写", }, { - min: 10, - message: "输入不正确", - }, - { - max: 10, - message: "输入不正确", + pattern: /^\d{10}$/, // 正则表达式只允许10位数字 + message: "学号必须是10位数字", }, ], password: [ @@ -92,36 +88,17 @@ const rules = reactive({ message: "请输入 8 位密码", }, { - pattern: /[A-Z]+/, - message: "密码必须包含大写字母", + pattern: /^(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{8,}$/u, + message: "密码必须包含至少一个大写字母,并由字母和数字组成", }, ], }); -const onReset = () => { - // 清空表单数据 - formData.account = ""; - formData.password = ""; - MessagePlugin.success("重置成功"); -}; -// const onSubmit = () => { -// this.$refs.form.validateResult((valid,errors) => { -// console.log(valid); -// if (valid) { -// MessagePlugin.success("提交成功"); -// } else { -// MessagePlugin.error("提交失败"); -// console.log("Errors: ", errors); -// return false; -// } -// }); -// }; - const onSubmit = async () => { try { const validateResult = await this.$refs.form.validate(); if (validateResult.result) { - await reqUser(); + await reqUser(formData.account, formData.password); MessagePlugin.success("提交成功"); await router.push("/"); } else { @@ -135,18 +112,13 @@ const onSubmit = async () => { } }; -// const Login = async () => { -// await reqUser(); -// }; - onMounted(() => { reqUser(); }); function handleForgotPasswordClick() { - router.push("/password-reset") + router.push("/password-reset"); } - \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 7f06cc0..4aba0e9 100644 --- a/vite.config.js +++ b/vite.config.js @@ -11,7 +11,7 @@ export default defineConfig({ server: { proxy: { "/api": { - target: "http://192.168.1.10:8000", + target: "http://192.168.1.10:8080", changeOrigin: true, }, },