From ad7817d21b47532212e2efbc0689baead32680fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=91=E9=A3=9E=E6=89=AC?= <15678871232@qq.com>
Date: Wed, 15 Jun 2022 02:01:14 +0000
Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E8=A7=84=E5=88=99=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=E5=B0=81=E8=A3=85,ts=20=E6=94=B9js,=E5=8E=BB=E6=8E=89?=
=?UTF-8?q?i18n=EF=BC=8C=E9=9B=86=E6=88=90=E5=88=B0=E8=8B=A5=E4=BE=9D?=
=?UTF-8?q?=E3=80=82=20https://blog.csdn.net/qq=5F36647038/article/details?=
=?UTF-8?q?/119142295?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/components/Password/CheckList.vue | 127 ++++++++++++++++++
ruoyi-ui/src/components/Password/index.js | 6 +
ruoyi-ui/src/components/Password/index.vue | 91 +++++++++++++
ruoyi-ui/src/components/Password/utils.js | 63 +++++++++
ruoyi-ui/src/views/system/user/index.vue | 51 +++++--
.../views/system/user/profile/resetPwd.vue | 29 +++-
6 files changed, 354 insertions(+), 13 deletions(-)
create mode 100644 ruoyi-ui/src/components/Password/CheckList.vue
create mode 100644 ruoyi-ui/src/components/Password/index.js
create mode 100644 ruoyi-ui/src/components/Password/index.vue
create mode 100644 ruoyi-ui/src/components/Password/utils.js
diff --git a/ruoyi-ui/src/components/Password/CheckList.vue b/ruoyi-ui/src/components/Password/CheckList.vue
new file mode 100644
index 00000000..07545878
--- /dev/null
+++ b/ruoyi-ui/src/components/Password/CheckList.vue
@@ -0,0 +1,127 @@
+
+
+
{{ title }}
+
+
+
+
+
+
+
+
+
+
{{ label }}
+
+
+
+
+
+
+
+
+
diff --git a/ruoyi-ui/src/components/Password/index.js b/ruoyi-ui/src/components/Password/index.js
new file mode 100644
index 00000000..b9cd50c6
--- /dev/null
+++ b/ruoyi-ui/src/components/Password/index.js
@@ -0,0 +1,6 @@
+import Password from "./index.vue";
+import {usePassword} from "./utils";
+
+export {usePassword};
+
+export default Password;
diff --git a/ruoyi-ui/src/components/Password/index.vue b/ruoyi-ui/src/components/Password/index.vue
new file mode 100644
index 00000000..aea3c34d
--- /dev/null
+++ b/ruoyi-ui/src/components/Password/index.vue
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ruoyi-ui/src/components/Password/utils.js b/ruoyi-ui/src/components/Password/utils.js
new file mode 100644
index 00000000..102f2590
--- /dev/null
+++ b/ruoyi-ui/src/components/Password/utils.js
@@ -0,0 +1,63 @@
+export const usePassword = (options) => {
+ const defaultRules = [
+ {
+ key: "length",
+ label: "长度在6到20个字符",
+ regExp: /^.{10,20}$/
+ },
+ {
+ key: "lowercase",
+ label: "使用小写字母",
+ regExp: /[a-z]+/
+ },
+ {
+ key: "capital",
+ label: "用大写字母",
+ regExp: /[A-Z]+/
+ },
+ {
+ key: "number",
+ label: "使用数字",
+ regExp: /\d{1,}/
+ }
+ ];
+ const ruleItems = options
+ ? options.reduce((res, item) => {
+ if (typeof item === "string") {
+ const rule = defaultRules.find(i => item === i.key);
+ if (rule) {
+ res.push(rule);
+ } else {
+ throw new Error("无效的规则");
+ }
+ } else {
+ res.push(item);
+ }
+ return res;
+ }, [])
+ : [...defaultRules];
+ // 返回默认的匹配规则map 和 校验结果mapList
+ return {
+ checkList: ruleItems.map(({key, label}) => ({key, label})),
+ validate: (value) => {
+ // 过滤出符合正则的rule[], map返回key[]
+ const validList = ruleItems
+ .filter(({regExp, validator}) => {
+ if (validator) {
+ return validator(value);
+ } else if (regExp) {
+ return regExp.test(value);
+ } else {
+ return false;
+ }
+ })
+ .map(({key}) => {
+ return key;
+ });
+ return {
+ validList,
+ valid: validList.length === ruleItems.length
+ };
+ }
+ };
+};
diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue
index fc8e3850..de6b9c70 100644
--- a/ruoyi-ui/src/views/system/user/index.vue
+++ b/ruoyi-ui/src/views/system/user/index.vue
@@ -238,7 +238,13 @@
-
+
+
@@ -342,16 +348,18 @@
\ No newline at end of file
+
+
diff --git a/ruoyi-ui/src/views/system/user/profile/resetPwd.vue b/ruoyi-ui/src/views/system/user/profile/resetPwd.vue
index 06715e5c..70c76af9 100644
--- a/ruoyi-ui/src/views/system/user/profile/resetPwd.vue
+++ b/ruoyi-ui/src/views/system/user/profile/resetPwd.vue
@@ -4,7 +4,13 @@
-
+
+
@@ -18,8 +24,14 @@