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
cd124373
authored
Jul 15, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support custom model now (close #276)
parent
b1cb2602
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
2 deletions
+37
-2
web/src/pages/Channel/EditChannel.js
+37
-2
No files found.
web/src/pages/Channel/EditChannel.js
View file @
cd124373
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Form
,
Header
,
Message
,
Segment
}
from
'semantic-ui-react'
;
import
{
Button
,
Form
,
Header
,
Input
,
Message
,
Segment
}
from
'semantic-ui-react'
;
import
{
useParams
}
from
'react-router-dom'
;
import
{
useParams
}
from
'react-router-dom'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
,
verifyJSON
}
from
'../../helpers'
;
import
{
API
,
showError
,
showInfo
,
showSuccess
,
verifyJSON
}
from
'../../helpers'
;
import
{
CHANNEL_OPTIONS
}
from
'../../constants'
;
import
{
CHANNEL_OPTIONS
}
from
'../../constants'
;
...
@@ -31,6 +31,7 @@ const EditChannel = () => {
...
@@ -31,6 +31,7 @@ const EditChannel = () => {
const
[
groupOptions
,
setGroupOptions
]
=
useState
([]);
const
[
groupOptions
,
setGroupOptions
]
=
useState
([]);
const
[
basicModels
,
setBasicModels
]
=
useState
([]);
const
[
basicModels
,
setBasicModels
]
=
useState
([]);
const
[
fullModels
,
setFullModels
]
=
useState
([]);
const
[
fullModels
,
setFullModels
]
=
useState
([]);
const
[
customModel
,
setCustomModel
]
=
useState
(
''
);
const
handleInputChange
=
(
e
,
{
name
,
value
})
=>
{
const
handleInputChange
=
(
e
,
{
name
,
value
})
=>
{
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
setInputs
((
inputs
)
=>
({
...
inputs
,
[
name
]:
value
}));
};
};
...
@@ -43,6 +44,19 @@ const EditChannel = () => {
...
@@ -43,6 +44,19 @@ const EditChannel = () => {
data
.
models
=
[];
data
.
models
=
[];
}
else
{
}
else
{
data
.
models
=
data
.
models
.
split
(
','
);
data
.
models
=
data
.
models
.
split
(
','
);
setTimeout
(()
=>
{
let
localModelOptions
=
[...
modelOptions
];
data
.
models
.
forEach
((
model
)
=>
{
if
(
!
localModelOptions
.
find
((
option
)
=>
option
.
key
===
model
))
{
localModelOptions
.
push
({
key
:
model
,
text
:
model
,
value
:
model
});
}
});
setModelOptions
(
localModelOptions
);
},
1000
);
}
}
if
(
data
.
group
===
''
)
{
if
(
data
.
group
===
''
)
{
data
.
groups
=
[];
data
.
groups
=
[];
...
@@ -263,6 +277,27 @@ const EditChannel = () => {
...
@@ -263,6 +277,27 @@ const EditChannel = () => {
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
[]
});
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
[]
});
}}
>
清除所有模型
<
/Button
>
}}
>
清除所有模型
<
/Button
>
<
Input
action
=
{
<
Button
type
=
{
'button'
}
onClick
=
{()
=>
{
let
localModels
=
[...
inputs
.
models
];
localModels
.
push
(
customModel
);
let
localModelOptions
=
[...
modelOptions
];
localModelOptions
.
push
({
key
:
customModel
,
text
:
customModel
,
value
:
customModel
,
});
setModelOptions
(
localModelOptions
);
handleInputChange
(
null
,
{
name
:
'models'
,
value
:
localModels
});
}}
>
填入
<
/Button
>
}
placeholder
=
'输入自定义模型名称'
value
=
{
customModel
}
onChange
=
{(
e
,
{
value
})
=>
{
setCustomModel
(
value
);
}}
/
>
<
/div
>
<
/div
>
<
Form
.
Field
>
<
Form
.
Field
>
<
Form
.
TextArea
<
Form
.
TextArea
...
@@ -309,7 +344,7 @@ const EditChannel = () => {
...
@@ -309,7 +344,7 @@ const EditChannel = () => {
/
>
/
>
)
)
}
}
<
Button
positive
onClick
=
{
submit
}
>
提交
<
/Button
>
<
Button
type
=
{
isEdit
?
"button"
:
"submit"
}
positive
onClick
=
{
submit
}
>
提交
<
/Button
>
<
/Form
>
<
/Form
>
<
/Segment
>
<
/Segment
>
<
/
>
<
/
>
...
...
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