Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
26c6087d
authored
Jun 17, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat(GroupRatioSettings): enhance JSON validation for group ratios
parent
c6a9df67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
web/src/pages/Setting/Operation/GroupRatioSettings.js
+21
-2
No files found.
web/src/pages/Setting/Operation/GroupRatioSettings.js
View file @
26c6087d
...
...
@@ -180,8 +180,27 @@ export default function GroupRatioSettings(props) {
stopValidateWithError
rules
=
{[
{
validator
:
(
rule
,
value
)
=>
verifyJSON
(
value
),
message
:
t
(
'不是合法的 JSON 字符串'
),
validator
:
(
rule
,
value
)
=>
{
if
(
!
value
||
value
.
trim
()
===
''
)
{
return
true
;
// Allow empty values
}
// First check if it's valid JSON
try
{
const
parsed
=
JSON
.
parse
(
value
);
// Check if it's an array
if
(
!
Array
.
isArray
(
parsed
))
{
return
false
;
}
// Check if every element is a string
return
parsed
.
every
(
item
=>
typeof
item
===
'string'
);
}
catch
(
error
)
{
return
false
;
}
},
message
:
t
(
'必须是有效的 JSON 字符串数组,例如:["g1","g2"]'
),
},
]}
onChange
=
{(
value
)
=>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment