@ysgroup/ui 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { computed, reactive, ref, watch } from "vue";
|
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
6
|
modelValue: boolean;
|
|
7
|
+
authenticated: boolean;
|
|
7
8
|
role?: string;
|
|
8
9
|
username?: string;
|
|
9
10
|
passwordManagementUrl?: string;
|
|
@@ -18,8 +19,14 @@ const active = ref("security");
|
|
|
18
19
|
const form = reactive({ current: "", next: "", confirm: "" });
|
|
19
20
|
const error = ref("");
|
|
20
21
|
const submitting = ref(false);
|
|
22
|
+
const PASSWORD_REQUIREMENT = "密码须至少包含 8 个字符,并同时包含大写字母、小写字母和数字。";
|
|
21
23
|
|
|
22
24
|
const canChangePassword = computed(() => props.role !== "Root" && props.username?.trim().toLowerCase() !== "root");
|
|
25
|
+
const visible = computed(() => props.modelValue && props.authenticated);
|
|
26
|
+
|
|
27
|
+
function isStrongPassword(password: string): boolean {
|
|
28
|
+
return password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /\d/.test(password);
|
|
29
|
+
}
|
|
23
30
|
|
|
24
31
|
function reset() {
|
|
25
32
|
form.current = "";
|
|
@@ -30,12 +37,16 @@ function reset() {
|
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
watch(
|
|
33
|
-
() => props.
|
|
34
|
-
(
|
|
35
|
-
if (!
|
|
40
|
+
() => props.authenticated,
|
|
41
|
+
(authenticated) => {
|
|
42
|
+
if (!authenticated && props.modelValue) emit("update:modelValue", false);
|
|
36
43
|
},
|
|
37
44
|
);
|
|
38
45
|
|
|
46
|
+
watch(visible, (open) => {
|
|
47
|
+
if (!open) reset();
|
|
48
|
+
});
|
|
49
|
+
|
|
39
50
|
function close() {
|
|
40
51
|
if (submitting.value) return;
|
|
41
52
|
emit("update:modelValue", false);
|
|
@@ -47,6 +58,10 @@ async function submit() {
|
|
|
47
58
|
error.value = "请完整填写密码信息";
|
|
48
59
|
return;
|
|
49
60
|
}
|
|
61
|
+
if (!isStrongPassword(form.next)) {
|
|
62
|
+
error.value = PASSWORD_REQUIREMENT;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
50
65
|
if (form.next !== form.confirm) {
|
|
51
66
|
error.value = "两次新密码不一致";
|
|
52
67
|
return;
|
|
@@ -70,14 +85,14 @@ defineExpose({
|
|
|
70
85
|
|
|
71
86
|
<template>
|
|
72
87
|
<el-dialog
|
|
73
|
-
:model-value="
|
|
88
|
+
:model-value="visible"
|
|
74
89
|
title="设置中心"
|
|
75
90
|
width="560px"
|
|
76
91
|
destroy-on-close
|
|
77
92
|
:close-on-click-modal="!submitting"
|
|
78
93
|
:close-on-press-escape="!submitting"
|
|
79
94
|
:show-close="!submitting"
|
|
80
|
-
@update:model-value="emit('update:modelValue', $event)"
|
|
95
|
+
@update:model-value="emit('update:modelValue', $event && authenticated)"
|
|
81
96
|
>
|
|
82
97
|
<el-tabs v-model="active" tab-position="left" class="ys-settings">
|
|
83
98
|
<el-tab-pane label="账号安全" name="security">
|
|
@@ -98,6 +113,7 @@ defineExpose({
|
|
|
98
113
|
<template v-else-if="canChangePassword">
|
|
99
114
|
<h3 class="ys-settings__title">修改登录密码</h3>
|
|
100
115
|
<el-alert title="修改成功后,当前账号的所有登录会话都会退出,请使用新密码重新登录。" type="info" :closable="false" show-icon class="ys-settings__notice" />
|
|
116
|
+
<el-alert :title="PASSWORD_REQUIREMENT" type="info" :closable="false" show-icon class="ys-settings__notice" />
|
|
101
117
|
<el-form label-width="110px" @submit.prevent="submit">
|
|
102
118
|
<el-form-item label="当前密码" required>
|
|
103
119
|
<el-input v-model="form.current" type="password" show-password autocomplete="current-password" />
|