mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-28 03:27:54 +08:00
更新验证器:为必填项和数字输入添加国际化支持,提升用户体验
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
import type { ValidationRule } from 'vuetify/types/services/validation'
|
import type { ValidationRule } from 'vuetify/types/services/validation'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
// 必输校验
|
// 必输校验
|
||||||
export const requiredValidator: ValidationRule = (value: any) => !!value || '此项为必填项'
|
export const requiredValidator: ValidationRule = (value: any) => {
|
||||||
|
const { t } = useI18n()
|
||||||
|
return !!value || t('validators.required')
|
||||||
|
}
|
||||||
|
|
||||||
// 数字校验
|
// 数字校验
|
||||||
export const numberValidator: ValidationRule = (value: any) => !isNaN(value) || '请输入数字'
|
export const numberValidator: ValidationRule = (value: any) => {
|
||||||
|
const { t } = useI18n()
|
||||||
|
return !isNaN(value) || t('validators.number')
|
||||||
|
}
|
||||||
|
|||||||
@@ -2320,4 +2320,8 @@ export default {
|
|||||||
byFileSize: 'By File Size',
|
byFileSize: 'By File Size',
|
||||||
keepLatestOnly: 'Keep Latest Only',
|
keepLatestOnly: 'Keep Latest Only',
|
||||||
},
|
},
|
||||||
|
validators: {
|
||||||
|
required: 'This field is required',
|
||||||
|
number: 'Please enter a number',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2296,4 +2296,8 @@ export default {
|
|||||||
byFileSize: '按文件大小',
|
byFileSize: '按文件大小',
|
||||||
keepLatestOnly: '仅保留最新',
|
keepLatestOnly: '仅保留最新',
|
||||||
},
|
},
|
||||||
|
validators: {
|
||||||
|
required: '此项为必填项',
|
||||||
|
number: '请输入数字',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2298,4 +2298,8 @@ export default {
|
|||||||
byFileSize: '按文件大小',
|
byFileSize: '按文件大小',
|
||||||
keepLatestOnly: '僅保留最新',
|
keepLatestOnly: '僅保留最新',
|
||||||
},
|
},
|
||||||
|
validators: {
|
||||||
|
required: '此項為必填項',
|
||||||
|
number: '請輸入數字',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user