refactor: username validation rules for signup form (#5740)

#### What type of PR is this?

/area ui
/kind improvement
/milestone 2.15.x

#### What this PR does / why we need it:

优化注册表单的用户名校验规则,改为最低要求 4 个字符,并完善规则提示。

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/5733

#### Does this PR introduce a user-facing change?

```release-note
优化注册表单的用户名校验规则
```
pull/5746/head
Ryan Wang 2024-04-18 17:44:06 +08:00 committed by GitHub
parent b05ed5814c
commit 90e3c2c017
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted, reactive, computed, type ComputedRef } from "vue"; import { computed, type ComputedRef, onMounted, reactive, ref } from "vue";
import { submitForm } from "@formkit/core"; import { submitForm } from "@formkit/core";
import { Toast, VButton } from "@halo-dev/components"; import { Toast, VButton } from "@halo-dev/components";
import { apiClient } from "@/utils/api-client"; import { apiClient } from "@/utils/api-client";
@ -170,7 +170,7 @@ const sendVerifyCodeButtonText = computed(() => {
type="text" type="text"
:validation="[ :validation="[
['required'], ['required'],
['length:0,63'], ['length', '4', '63'],
[ [
'matches', 'matches',
/^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/, /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/,

View File

@ -915,7 +915,7 @@ core:
fields: fields:
username: username:
label: Username label: Username
validation: Please enter a valid username. validation: Can only contain numbers, lowercase letters, periods (.), and hyphens (-), and cannot start or end with a period (.) or hyphen (-).
display_name: display_name:
label: Display name label: Display name
email: email:
@ -1113,7 +1113,7 @@ core:
fields: fields:
username: username:
label: Username label: Username
validation: Please enter a valid username. validation: Can only contain numbers, lowercase letters, periods (.), and hyphens (-), and cannot start or end with a period (.) or hyphen (-).
display_name: display_name:
label: Display name label: Display name
email: email:

View File

@ -871,7 +871,7 @@ core:
fields: fields:
username: username:
label: 用户名 label: 用户名
validation: 请输入有效的用户名 validation: 只能包含数字、小写字母、. 和 - 符号,且不能以 . 和 - 符号开头和结尾
display_name: display_name:
label: 显示名称 label: 显示名称
email: email:
@ -1061,7 +1061,7 @@ core:
fields: fields:
username: username:
label: 用户名 label: 用户名
validation: 请输入有效的用户名 validation: 只能包含数字、小写字母、. 和 - 符号,且不能以 . 和 - 符号开头和结尾
display_name: display_name:
label: 显示名称 label: 显示名称
email: email:

View File

@ -859,7 +859,7 @@ core:
fields: fields:
username: username:
label: 用戶名 label: 用戶名
validation: 請輸入有效的用戶名 validation: 只能包含數字、小寫字母、. 和 - 符號,且不能以 . 和 - 符號開頭和結尾。
display_name: display_name:
label: 顯示名稱 label: 顯示名稱
email: email:
@ -1049,7 +1049,7 @@ core:
fields: fields:
username: username:
label: 用戶名 label: 用戶名
validation: 請輸入有效的用戶名 validation: 只能包含數字、小寫字母、. 和 - 符號,且不能以 . 和 - 符號開頭和結尾。
display_name: display_name:
label: 顯示名稱 label: 顯示名稱
email: email: