Fix App logs page modal show different model icon. (#1224)

This commit is contained in:
Rhon Joe
2023-09-27 08:54:52 +08:00
committed by GitHub
parent fd9413874a
commit 8eae643911
9 changed files with 56 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
import { VAR_ITEM_TEMPLATE, getMaxVarNameLength, zhRegex, emojiRegex, MAX_VAR_KEY_LENGHT } from "@/config"
const otherAllowedRegex = new RegExp(`^[a-zA-Z0-9_]+$`)
import { MAX_VAR_KEY_LENGHT, VAR_ITEM_TEMPLATE, getMaxVarNameLength } from '@/config'
const otherAllowedRegex = /^[a-zA-Z0-9_]+$/
export const getNewVar = (key: string) => {
return {
@@ -10,19 +10,19 @@ export const getNewVar = (key: string) => {
}
const checkKey = (key: string, canBeEmpty?: boolean) => {
if (key.length === 0 && !canBeEmpty) {
if (key.length === 0 && !canBeEmpty)
return 'canNoBeEmpty'
}
if (canBeEmpty && key === '') {
if (canBeEmpty && key === '')
return true
}
if (key.length > MAX_VAR_KEY_LENGHT) {
if (key.length > MAX_VAR_KEY_LENGHT)
return 'tooLong'
}
if (otherAllowedRegex.test(key)) {
if (/[0-9]/.test(key[0])) {
if (/[0-9]/.test(key[0]))
return 'notStartWithNumber'
}
return true
}
return 'notValid'
@@ -33,9 +33,9 @@ export const checkKeys = (keys: string[], canBeEmpty?: boolean) => {
let errorKey = ''
let errorMessageKey = ''
keys.forEach((key) => {
if (!isValid) {
if (!isValid)
return
}
const res = checkKey(key, canBeEmpty)
if (res !== true) {
isValid = false
@@ -44,4 +44,4 @@ export const checkKeys = (keys: string[], canBeEmpty?: boolean) => {
}
})
return { isValid, errorKey, errorMessageKey }
}
}