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
58f235af
authored
Jun 08, 2025
by
Calcium-Ion
Committed by
GitHub
Jun 08, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1176 from RedwindA/feat/tagMode-channelModelList
feat: 标签聚合模式编辑渠道时复用渠道模型列表
parents
e0ff3b6f
b197dfb9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
1 deletions
+67
-1
controller/channel.go
+41
-0
router/api-router.go
+1
-0
web/src/pages/Channel/EditTagModal.js
+25
-1
No files found.
controller/channel.go
View file @
58f235af
...
@@ -623,3 +623,44 @@ func BatchSetChannelTag(c *gin.Context) {
...
@@ -623,3 +623,44 @@ func BatchSetChannelTag(c *gin.Context) {
})
})
return
return
}
}
func
GetTagModels
(
c
*
gin
.
Context
)
{
tag
:=
c
.
Query
(
"tag"
)
if
tag
==
""
{
c
.
JSON
(
http
.
StatusBadRequest
,
gin
.
H
{
"success"
:
false
,
"message"
:
"tag不能为空"
,
})
return
}
channels
,
err
:=
model
.
GetChannelsByTag
(
tag
,
false
)
// Assuming false for idSort is fine here
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"success"
:
false
,
"message"
:
err
.
Error
(),
})
return
}
var
longestModels
string
maxLength
:=
0
// Find the longest models string among all channels with the given tag
for
_
,
channel
:=
range
channels
{
if
channel
.
Models
!=
""
{
currentModels
:=
strings
.
Split
(
channel
.
Models
,
","
)
if
len
(
currentModels
)
>
maxLength
{
maxLength
=
len
(
currentModels
)
longestModels
=
channel
.
Models
}
}
}
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
true
,
"message"
:
""
,
"data"
:
longestModels
,
})
return
}
router/api-router.go
View file @
58f235af
...
@@ -105,6 +105,7 @@ func SetApiRouter(router *gin.Engine) {
...
@@ -105,6 +105,7 @@ func SetApiRouter(router *gin.Engine) {
channelRoute
.
GET
(
"/fetch_models/:id"
,
controller
.
FetchUpstreamModels
)
channelRoute
.
GET
(
"/fetch_models/:id"
,
controller
.
FetchUpstreamModels
)
channelRoute
.
POST
(
"/fetch_models"
,
controller
.
FetchModels
)
channelRoute
.
POST
(
"/fetch_models"
,
controller
.
FetchModels
)
channelRoute
.
POST
(
"/batch/tag"
,
controller
.
BatchSetChannelTag
)
channelRoute
.
POST
(
"/batch/tag"
,
controller
.
BatchSetChannelTag
)
channelRoute
.
GET
(
"/tag/models"
,
controller
.
GetTagModels
)
}
}
tokenRoute
:=
apiRouter
.
Group
(
"/token"
)
tokenRoute
:=
apiRouter
.
Group
(
"/token"
)
tokenRoute
.
Use
(
middleware
.
UserAuth
())
tokenRoute
.
Use
(
middleware
.
UserAuth
())
...
...
web/src/pages/Channel/EditTagModal.js
View file @
58f235af
...
@@ -194,6 +194,24 @@ const EditTagModal = (props) => {
...
@@ -194,6 +194,24 @@ const EditTagModal = (props) => {
},
[
originModelOptions
,
inputs
.
models
]);
},
[
originModelOptions
,
inputs
.
models
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
fetchTagModels
=
async
()
=>
{
if
(
!
tag
)
return
;
setLoading
(
true
);
try
{
const
res
=
await
API
.
get
(
`/api/channel/tag/models?tag=
${
tag
}
`
);
if
(
res
?.
data
?.
success
)
{
const
models
=
res
.
data
.
data
?
res
.
data
.
data
.
split
(
','
)
:
[];
setInputs
((
inputs
)
=>
({
...
inputs
,
models
:
models
}));
}
else
{
showError
(
res
.
data
.
message
);
}
}
catch
(
error
)
{
showError
(
error
.
message
);
}
finally
{
setLoading
(
false
);
}
};
setInputs
({
setInputs
({
...
originInputs
,
...
originInputs
,
tag
:
tag
,
tag
:
tag
,
...
@@ -201,7 +219,8 @@ const EditTagModal = (props) => {
...
@@ -201,7 +219,8 @@ const EditTagModal = (props) => {
});
});
fetchModels
().
then
();
fetchModels
().
then
();
fetchGroups
().
then
();
fetchGroups
().
then
();
},
[
visible
]);
fetchTagModels
().
then
();
// Call the new function
},
[
visible
,
tag
]);
// Add tag to dependency array
const
addCustomModels
=
()
=>
{
const
addCustomModels
=
()
=>
{
if
(
customModel
.
trim
()
===
''
)
return
;
if
(
customModel
.
trim
()
===
''
)
return
;
...
@@ -347,6 +366,11 @@ const EditTagModal = (props) => {
...
@@ -347,6 +366,11 @@ const EditTagModal = (props) => {
<
div
className
=
"space-y-4"
>
<
div
className
=
"space-y-4"
>
<
div
>
<
div
>
<
Text
strong
className
=
"block mb-2"
>
{
t
(
'模型'
)}
<
/Text
>
<
Text
strong
className
=
"block mb-2"
>
{
t
(
'模型'
)}
<
/Text
>
<
Banner
type
=
"info"
description
=
{
t
(
'当前模型列表为该标签下所有渠道模型列表最长的一个,并非所有渠道的并集,请注意可能导致某些渠道模型丢失。'
)}
className
=
"!rounded-lg mb-4"
/>
<
Select
<
Select
placeholder
=
{
t
(
'请选择该渠道所支持的模型,留空则不更改'
)}
placeholder
=
{
t
(
'请选择该渠道所支持的模型,留空则不更改'
)}
name
=
'models'
name
=
'models'
...
...
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