|
@@ -74,7 +74,8 @@
|
|
:label="t('room.form.nickname')"
|
|
:label="t('room.form.nickname')"
|
|
name="leaderName"
|
|
name="leaderName"
|
|
:rules="[
|
|
:rules="[
|
|
- { required: true, message: t('room.form.nicknameRequired') }
|
|
|
|
|
|
+ { required: true, message: t('room.form.nicknameRequired') },
|
|
|
|
+ { validator: handleNickRegex }
|
|
]"
|
|
]"
|
|
>
|
|
>
|
|
<a-input
|
|
<a-input
|
|
@@ -116,8 +117,7 @@ import type { FormInstance } from 'ant-design-vue'
|
|
import { useI18n } from '@/hook/useI18n'
|
|
import { useI18n } from '@/hook/useI18n'
|
|
import { useLocale } from '@/locales/useLocale'
|
|
import { useLocale } from '@/locales/useLocale'
|
|
|
|
|
|
-const roomStore = useRoomStore()
|
|
|
|
-const { t } = useI18n()
|
|
|
|
|
|
+
|
|
|
|
|
|
// const titleValidator = ref({
|
|
// const titleValidator = ref({
|
|
// validator: (_, value) =>
|
|
// validator: (_, value) =>
|
|
@@ -132,7 +132,9 @@ export default defineComponent({
|
|
props,
|
|
props,
|
|
setup(props) {
|
|
setup(props) {
|
|
const visible = ref(true)
|
|
const visible = ref(true)
|
|
|
|
+ const roomStore = useRoomStore()
|
|
const { getLocale } = useLocale()
|
|
const { getLocale } = useLocale()
|
|
|
|
+ const { t } = useI18n()
|
|
const returnLocale = computed(() => {
|
|
const returnLocale = computed(() => {
|
|
if (unref(getLocale).includes('zh')) {
|
|
if (unref(getLocale).includes('zh')) {
|
|
return 'zh'
|
|
return 'zh'
|
|
@@ -163,7 +165,21 @@ export default defineComponent({
|
|
// }))
|
|
// }))
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
+ const handleNickRegex = async (_: any, value: string) => {
|
|
|
|
+ console.log('value', value)
|
|
|
|
+ const regex = new RegExp(
|
|
|
|
+ '^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_]){1,15}$'
|
|
|
|
+ )
|
|
|
|
+ if (value?.length && !regex.test(value)) {
|
|
|
|
+ return Promise.reject(
|
|
|
|
+ t('room.nickNameRegrexError')
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ return Promise.resolve('')
|
|
|
|
+ }
|
|
|
|
+
|
|
return {
|
|
return {
|
|
|
|
+ handleNickRegex,
|
|
returnLocale,
|
|
returnLocale,
|
|
t,
|
|
t,
|
|
visible,
|
|
visible,
|