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
076e6602
authored
May 13, 2024
by
Calcium-Ion
Committed by
GitHub
May 13, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #242 from iszcz/new512
渠道批量添加模型
parents
5cf33f35
b8407404
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
12 deletions
+29
-12
web/src/pages/Channel/EditChannel.js
+29
-12
No files found.
web/src/pages/Channel/EditChannel.js
View file @
076e6602
...
...
@@ -99,6 +99,7 @@ const EditChannel = (props) => {
'mj_blend'
,
'mj_upscale'
,
'mj_describe'
,
'mj_uploads'
,
];
break
;
case
5
:
...
...
@@ -118,6 +119,7 @@ const EditChannel = (props) => {
'mj_high_variation'
,
'mj_low_variation'
,
'mj_pan'
,
'mj_uploads'
,
];
break
;
default
:
...
...
@@ -296,24 +298,39 @@ const EditChannel = (props) => {
}
};
const
addCustomModel
=
()
=>
{
const
addCustomModel
s
=
()
=>
{
if
(
customModel
.
trim
()
===
''
)
return
;
if
(
inputs
.
models
.
includes
(
customModel
))
return
showError
(
'该模型已存在!'
);
// 使用逗号分隔字符串,然后去除每个模型名称前后的空格
const
modelArray
=
customModel
.
split
(
','
).
map
(
model
=>
model
.
trim
());
let
localModels
=
[...
inputs
.
models
];
localModels
.
push
(
customModel
);
let
localModelOptions
=
[];
localModelOptions
.
push
({
key
:
customModel
,
text
:
customModel
,
value
:
customModel
,
});
setModelOptions
((
modelOptions
)
=>
{
return
[...
modelOptions
,
...
localModelOptions
];
let
localModelOptions
=
[...
modelOptions
];
let
hasError
=
false
;
modelArray
.
forEach
(
model
=>
{
// 检查模型是否已存在,且模型名称非空
if
(
model
&&
!
localModels
.
includes
(
model
))
{
localModels
.
push
(
model
);
// 添加到模型列表
localModelOptions
.
push
({
// 添加到下拉选项
key
:
model
,
text
:
model
,
value
:
model
,
});
}
else
if
(
model
)
{
showError
(
'某些模型已存在!'
);
hasError
=
true
;
}
});
if
(
hasError
)
return
;
// 如果有错误则终止操作
// 更新状态值
setModelOptions
(
localModelOptions
);
setCustomModel
(
''
);
handleInputChange
(
'models'
,
localModels
);
};
return
(
<>
<
SideSheet
...
...
@@ -540,7 +557,7 @@ const EditChannel = (props) => {
<
/Space
>
<
Input
addonAfter
=
{
<
Button
type
=
'primary'
onClick
=
{
addCustomModel
}
>
<
Button
type
=
'primary'
onClick
=
{
addCustomModel
s
}
>
填入
<
/Button
>
}
...
...
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