|
@@ -7,36 +7,19 @@ const WindowsTranslateApi = 'https://jiasm.zfire.top/translate'
|
|
|
|
|
|
// 数据过滤校验
|
|
|
function isNumberRegex(str) {
|
|
|
- const pureNumberRegex = /^\d+$/
|
|
|
- const floatNumberRegex = /^\d*\.\d+$/
|
|
|
- const timeRegexHHMM = /^([01]\d|2[0-3]):([0-5]\d)$/
|
|
|
- const timeRegexHHMMSS = /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/
|
|
|
- const timeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
|
|
|
- const pureLetterRegex = /^[A-Za-z]+$/
|
|
|
- const letterAndDigitRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$/
|
|
|
- const letterAndPunctuationRegex = /^(?=.*[A-Za-z])(?=.*[\p{P}\p{S}])[\p{L}\p{P}\p{S}]+$/u
|
|
|
- const digitAndPunctuationRegex = /^(?=.*\d)(?=.*[\p{P}\p{S}])[\d\p{P}\p{S}]+$/u
|
|
|
- if (pureNumberRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else if (floatNumberRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else if (timeRegexHHMM.test(str)) {
|
|
|
- return true
|
|
|
- } else if (timeRegexHHMMSS.test(str)) {
|
|
|
- return true
|
|
|
- } else if (pureLetterRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else if (letterAndDigitRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else if (letterAndPunctuationRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else if (digitAndPunctuationRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else if (timeRegex.test(str)) {
|
|
|
- return true
|
|
|
- } else {
|
|
|
- return !!window.Vue_Translation_Of_Text_Old_Data[str]
|
|
|
- }
|
|
|
+ const regexPatterns = [
|
|
|
+ /^\d+$/, // 纯数字
|
|
|
+ /^\d*\.\d+$/, // 浮点数
|
|
|
+ /^([01]\d|2[0-3]):([0-5]\d)$/, // 时间 (HH:MM)
|
|
|
+ /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/, // 时间 (HH:MM:SS)
|
|
|
+ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/, // 完整时间戳
|
|
|
+ /^[A-Za-z]+$/, // 纯字母
|
|
|
+ /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$/, // 字母和数字
|
|
|
+ /^(?=.*[A-Za-z])(?=.*[\p{P}\p{S}])[\p{L}\p{P}\p{S}]+$/u, // 字母和标点符号
|
|
|
+ /^(?=.*\d)(?=.*[\p{P}\p{S}])[\d\p{P}\p{S}]+$/u, // 数字和标点符号
|
|
|
+ /^[\p{P}\s\dA-Za-z]+$/u // 字母、数字和标点符号
|
|
|
+ ]
|
|
|
+ return regexPatterns.some(pattern => pattern.test(str)) || !!window.Vue_Translation_Of_Text_Old_Data[str]
|
|
|
}
|
|
|
|
|
|
// 文本转译请求
|