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
b8407404
authored
May 05, 2024
by
iszcz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
渠道批量添加模型
parent
699e29e2
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 @
b8407404
...
...
@@ -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