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
6f4b547f
authored
Sep 03, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: press enter to submit custom model name
parent
fa0fedff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
web/src/pages/Channel/EditChannel.js
+29
-21
No files found.
web/src/pages/Channel/EditChannel.js
View file @
6f4b547f
...
...
@@ -14,13 +14,13 @@ function type2secretPrompt(type) {
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
switch
(
type
)
{
case
15
:
return
"按照如下格式输入:APIKey|SecretKey"
return
'按照如下格式输入:APIKey|SecretKey'
;
case
18
:
return
"按照如下格式输入:APPID|APISecret|APIKey"
return
'按照如下格式输入:APPID|APISecret|APIKey'
;
case
22
:
return
"按照如下格式输入:APIKey-AppId,例如:fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041"
return
'按照如下格式输入:APIKey-AppId,例如:fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041'
;
default
:
return
"请输入渠道对应的鉴权密钥"
return
'请输入渠道对应的鉴权密钥'
;
}
}
...
...
@@ -207,6 +207,24 @@ const EditChannel = () => {
}
};
const
addCustomModel
=
()
=>
{
if
(
customModel
.
trim
()
===
''
)
return
;
if
(
inputs
.
models
.
includes
(
customModel
))
return
;
let
localModels
=
[...
inputs
.
models
];
localModels
.
push
(
customModel
);
let
localModelOptions
=
[];
localModelOptions
.
push
({
key
:
customModel
,
text
:
customModel
,
value
:
customModel
});
setModelOptions
(
modelOptions
=>
{
return
[...
modelOptions
,
...
localModelOptions
];
});
setCustomModel
(
''
);
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
localModels
});
};
return
(
<>
<
Segment
loading
=
{
loading
}
>
...
...
@@ -350,29 +368,19 @@ const EditChannel = () => {
}}
>
清除所有模型
<
/Button
>
<
Input
action
=
{
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
if
(
customModel
.
trim
()
===
''
)
return
;
if
(
inputs
.
models
.
includes
(
customModel
))
return
;
let
localModels
=
[...
inputs
.
models
];
localModels
.
push
(
customModel
);
let
localModelOptions
=
[];
localModelOptions
.
push
({
key
:
customModel
,
text
:
customModel
,
value
:
customModel
});
setModelOptions
(
modelOptions
=>
{
return
[...
modelOptions
,
...
localModelOptions
];
});
setCustomModel
(
''
);
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
localModels
});
}}
>
填入
<
/Button
>
<
Button
type
=
{
'button'
}
onClick
=
{
addCustomModel
}
>
填入
<
/Button
>
}
placeholder
=
'输入自定义模型名称'
value
=
{
customModel
}
onChange
=
{(
e
,
{
value
})
=>
{
setCustomModel
(
value
);
}}
onKeyDown
=
{(
e
)
=>
{
if
(
e
.
key
===
'Enter'
)
{
addCustomModel
();
e
.
preventDefault
();
}
}}
/
>
<
/div
>
<
Form
.
Field
>
...
...
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