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
4ba55580
authored
Jun 19, 2025
by
Calcium-Ion
Committed by
GitHub
Jun 19, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1262 from wans10/main
fix: 修复渠道界面模型选择下拉框模型重复显示
parents
4d5e79c9
e4a7f0c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
12 deletions
+21
-12
web/src/pages/Channel/EditChannel.js
+21
-12
No files found.
web/src/pages/Channel/EditChannel.js
View file @
4ba55580
...
...
@@ -298,18 +298,27 @@ const EditChannel = (props) => {
}
};
useEffect
(()
=>
{
let
localModelOptions
=
[...
originModelOptions
];
inputs
.
models
.
forEach
((
model
)
=>
{
if
(
!
localModelOptions
.
find
((
option
)
=>
option
.
label
===
model
))
{
localModelOptions
.
push
({
label
:
model
,
value
:
model
,
});
}
});
setModelOptions
(
localModelOptions
);
},
[
originModelOptions
,
inputs
.
models
]);
useEffect
(()
=>
{
// 使用 Map 来避免重复,以 value 为键
const
modelMap
=
new
Map
();
// 先添加原始模型选项
originModelOptions
.
forEach
(
option
=>
{
modelMap
.
set
(
option
.
value
,
option
);
});
// 再添加当前选中的模型(如果不存在)
inputs
.
models
.
forEach
(
model
=>
{
if
(
!
modelMap
.
has
(
model
))
{
modelMap
.
set
(
model
,
{
label
:
model
,
value
:
model
,
});
}
});
setModelOptions
(
Array
.
from
(
modelMap
.
values
()));
},
[
originModelOptions
,
inputs
.
models
]);
useEffect
(()
=>
{
fetchModels
().
then
();
...
...
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