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
aa0edd8d
authored
Jul 05, 2025
by
Calcium-Ion
Committed by
GitHub
Jul 05, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1321 from iszcz/main
支持Midjourney视频任务和图片编辑
parents
c17439a1
d4f2f4db
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
70 additions
and
1 deletions
+70
-1
constant/midjourney.go
+4
-0
dto/midjourney.go
+6
-0
i18n/zh-cn.json
+0
-0
model/midjourney.go
+2
-0
relay/constant/relay_mode.go
+6
-0
relay/relay-mj.go
+26
-0
router/relay-router.go
+2
-0
service/midjourney.go
+6
-1
setting/ratio_setting/model_ratio.go
+2
-0
web/src/components/table/MjLogsTable.js
+12
-0
web/src/pages/Channel/EditChannel.js
+2
-0
web/src/pages/Channel/EditTagModal.js
+2
-0
No files found.
constant/midjourney.go
View file @
aa0edd8d
...
...
@@ -22,6 +22,8 @@ const (
MjActionPan
=
"PAN"
MjActionSwapFace
=
"SWAP_FACE"
MjActionUpload
=
"UPLOAD"
MjActionVideo
=
"VIDEO"
MjActionEdits
=
"EDITS"
)
var
MidjourneyModel2Action
=
map
[
string
]
string
{
...
...
@@ -41,4 +43,6 @@ var MidjourneyModel2Action = map[string]string{
"mj_pan"
:
MjActionPan
,
"swap_face"
:
MjActionSwapFace
,
"mj_upload"
:
MjActionUpload
,
"mj_video"
:
MjActionVideo
,
"mj_edits"
:
MjActionEdits
,
}
dto/midjourney.go
View file @
aa0edd8d
...
...
@@ -57,6 +57,8 @@ type MidjourneyDto struct {
StartTime
int64
`json:"startTime"`
FinishTime
int64
`json:"finishTime"`
ImageUrl
string
`json:"imageUrl"`
VideoUrl
string
`json:"videoUrl"`
VideoUrls
[]
ImgUrls
`json:"videoUrls"`
Status
string
`json:"status"`
Progress
string
`json:"progress"`
FailReason
string
`json:"failReason"`
...
...
@@ -65,6 +67,10 @@ type MidjourneyDto struct {
Properties
*
Properties
`json:"properties"`
}
type
ImgUrls
struct
{
Url
string
`json:"url"`
}
type
MidjourneyStatus
struct
{
Status
int
`json:"status"`
}
...
...
i18n/zh-cn.json
0 → 100644
View file @
aa0edd8d
This diff is collapsed.
Click to expand it.
model/midjourney.go
View file @
aa0edd8d
...
...
@@ -14,6 +14,8 @@ type Midjourney struct {
StartTime
int64
`json:"start_time" gorm:"index"`
FinishTime
int64
`json:"finish_time" gorm:"index"`
ImageUrl
string
`json:"image_url"`
VideoUrl
string
`json:"video_url"`
VideoUrls
string
`json:"video_urls"`
Status
string
`json:"status" gorm:"type:varchar(20);index"`
Progress
string
`json:"progress" gorm:"type:varchar(30);index"`
FailReason
string
`json:"fail_reason"`
...
...
relay/constant/relay_mode.go
View file @
aa0edd8d
...
...
@@ -29,6 +29,8 @@ const (
RelayModeMidjourneyShorten
RelayModeSwapFace
RelayModeMidjourneyUpload
RelayModeMidjourneyVideo
RelayModeMidjourneyEdits
RelayModeAudioSpeech
// tts
RelayModeAudioTranscription
// whisper
...
...
@@ -108,6 +110,10 @@ func Path2RelayModeMidjourney(path string) int {
relayMode
=
RelayModeMidjourneyUpload
}
else
if
strings
.
HasSuffix
(
path
,
"/mj/submit/imagine"
)
{
relayMode
=
RelayModeMidjourneyImagine
}
else
if
strings
.
HasSuffix
(
path
,
"/mj/submit/video"
)
{
relayMode
=
RelayModeMidjourneyVideo
}
else
if
strings
.
HasSuffix
(
path
,
"/mj/submit/edits"
)
{
relayMode
=
RelayModeMidjourneyEdits
}
else
if
strings
.
HasSuffix
(
path
,
"/mj/submit/blend"
)
{
relayMode
=
RelayModeMidjourneyBlend
}
else
if
strings
.
HasSuffix
(
path
,
"/mj/submit/describe"
)
{
...
...
relay/relay-mj.go
View file @
aa0edd8d
...
...
@@ -106,6 +106,9 @@ func RelayMidjourneyNotify(c *gin.Context) *dto.MidjourneyResponse {
midjourneyTask
.
StartTime
=
midjRequest
.
StartTime
midjourneyTask
.
FinishTime
=
midjRequest
.
FinishTime
midjourneyTask
.
ImageUrl
=
midjRequest
.
ImageUrl
midjourneyTask
.
VideoUrl
=
midjRequest
.
VideoUrl
videoUrlsStr
,
_
:=
json
.
Marshal
(
midjRequest
.
VideoUrls
)
midjourneyTask
.
VideoUrls
=
string
(
videoUrlsStr
)
midjourneyTask
.
Status
=
midjRequest
.
Status
midjourneyTask
.
FailReason
=
midjRequest
.
FailReason
err
=
midjourneyTask
.
Update
()
...
...
@@ -136,6 +139,9 @@ func coverMidjourneyTaskDto(c *gin.Context, originTask *model.Midjourney) (midjo
}
else
{
midjourneyTask
.
ImageUrl
=
originTask
.
ImageUrl
}
if
originTask
.
VideoUrl
!=
""
{
midjourneyTask
.
VideoUrl
=
originTask
.
VideoUrl
}
midjourneyTask
.
Status
=
originTask
.
Status
midjourneyTask
.
FailReason
=
originTask
.
FailReason
midjourneyTask
.
Action
=
originTask
.
Action
...
...
@@ -148,6 +154,13 @@ func coverMidjourneyTaskDto(c *gin.Context, originTask *model.Midjourney) (midjo
midjourneyTask
.
Buttons
=
buttons
}
}
if
originTask
.
VideoUrls
!=
""
{
var
videoUrls
[]
dto
.
ImgUrls
err
:=
json
.
Unmarshal
([]
byte
(
originTask
.
VideoUrls
),
&
videoUrls
)
if
err
==
nil
{
midjourneyTask
.
VideoUrls
=
videoUrls
}
}
if
originTask
.
Properties
!=
""
{
var
properties
dto
.
Properties
err
:=
json
.
Unmarshal
([]
byte
(
originTask
.
Properties
),
&
properties
)
...
...
@@ -370,6 +383,9 @@ func RelayMidjourneySubmit(c *gin.Context, relayMode int) *dto.MidjourneyRespons
}
relayMode
=
relayconstant
.
RelayModeMidjourneyChange
}
if
relayMode
==
relayconstant
.
RelayModeMidjourneyVideo
{
midjRequest
.
Action
=
constant
.
MjActionVideo
}
if
relayMode
==
relayconstant
.
RelayModeMidjourneyImagine
{
//绘画任务,此类任务可重复
if
midjRequest
.
Prompt
==
""
{
...
...
@@ -378,6 +394,8 @@ func RelayMidjourneySubmit(c *gin.Context, relayMode int) *dto.MidjourneyRespons
midjRequest
.
Action
=
constant
.
MjActionImagine
}
else
if
relayMode
==
relayconstant
.
RelayModeMidjourneyDescribe
{
//按图生文任务,此类任务可重复
midjRequest
.
Action
=
constant
.
MjActionDescribe
}
else
if
relayMode
==
relayconstant
.
RelayModeMidjourneyEdits
{
//编辑任务,此类任务可重复
midjRequest
.
Action
=
constant
.
MjActionEdits
}
else
if
relayMode
==
relayconstant
.
RelayModeMidjourneyShorten
{
//缩短任务,此类任务可重复,plus only
midjRequest
.
Action
=
constant
.
MjActionShorten
}
else
if
relayMode
==
relayconstant
.
RelayModeMidjourneyBlend
{
//绘画任务,此类任务可重复
...
...
@@ -412,6 +430,14 @@ func RelayMidjourneySubmit(c *gin.Context, relayMode int) *dto.MidjourneyRespons
//}
mjId
=
midjRequest
.
TaskId
midjRequest
.
Action
=
constant
.
MjActionModal
}
else
if
relayMode
==
relayconstant
.
RelayModeMidjourneyVideo
{
midjRequest
.
Action
=
constant
.
MjActionVideo
if
midjRequest
.
TaskId
==
""
{
return
service
.
MidjourneyErrorWrapper
(
constant
.
MjRequestError
,
"task_id_is_required"
)
}
else
if
midjRequest
.
Action
==
""
{
return
service
.
MidjourneyErrorWrapper
(
constant
.
MjRequestError
,
"action_is_required"
)
}
mjId
=
midjRequest
.
TaskId
}
originTask
:=
model
.
GetByMJId
(
userId
,
mjId
)
...
...
router/relay-router.go
View file @
aa0edd8d
...
...
@@ -103,6 +103,8 @@ func registerMjRouterGroup(relayMjRouter *gin.RouterGroup) {
relayMjRouter
.
POST
(
"/submit/simple-change"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
POST
(
"/submit/describe"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
POST
(
"/submit/blend"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
POST
(
"/submit/edits"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
POST
(
"/submit/video"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
POST
(
"/notify"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
GET
(
"/task/:id/fetch"
,
controller
.
RelayMidjourney
)
relayMjRouter
.
GET
(
"/task/:id/image-seed"
,
controller
.
RelayMidjourney
)
...
...
service/midjourney.go
View file @
aa0edd8d
...
...
@@ -3,7 +3,6 @@ package service
import
(
"context"
"encoding/json"
"github.com/gin-gonic/gin"
"io"
"log"
"net/http"
...
...
@@ -15,6 +14,8 @@ import (
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
func
CoverActionToModelName
(
mjAction
string
)
string
{
...
...
@@ -38,6 +39,10 @@ func GetMjRequestModel(relayMode int, midjRequest *dto.MidjourneyRequest) (strin
switch
relayMode
{
case
relayconstant
.
RelayModeMidjourneyImagine
:
action
=
constant
.
MjActionImagine
case
relayconstant
.
RelayModeMidjourneyVideo
:
action
=
constant
.
MjActionVideo
case
relayconstant
.
RelayModeMidjourneyEdits
:
action
=
constant
.
MjActionEdits
case
relayconstant
.
RelayModeMidjourneyDescribe
:
action
=
constant
.
MjActionDescribe
case
relayconstant
.
RelayModeMidjourneyBlend
:
...
...
setting/ratio_setting/model_ratio.go
View file @
aa0edd8d
...
...
@@ -231,7 +231,9 @@ var defaultModelPrice = map[string]float64{
"dall-e-3"
:
0.04
,
"imagen-3.0-generate-002"
:
0.03
,
"gpt-4-gizmo-*"
:
0.1
,
"mj_video"
:
0.8
,
"mj_imagine"
:
0.1
,
"mj_edits"
:
0.1
,
"mj_variation"
:
0.1
,
"mj_reroll"
:
0.1
,
"mj_blend"
:
0.1
,
...
...
web/src/components/table/MjLogsTable.js
View file @
aa0edd8d
...
...
@@ -195,6 +195,18 @@ const LogsTable = () => {
{
t
(
'放大'
)}
<
/Tag
>
);
case
'VIDEO'
:
return
(
<
Tag
color
=
'orange'
size
=
'large'
shape
=
'circle'
prefixIcon
=
{
<
Video
size
=
{
14
}
/>}
>
{
t
(
'视频'
)}
<
/Tag
>
);
case
'EDITS'
:
return
(
<
Tag
color
=
'orange'
size
=
'large'
shape
=
'circle'
prefixIcon
=
{
<
Video
size
=
{
14
}
/>}
>
{
t
(
'编辑'
)}
<
/Tag
>
);
case
'VARIATION'
:
return
(
<
Tag
color
=
'purple'
size
=
'large'
shape
=
'circle'
prefixIcon
=
{
<
Shuffle
size
=
{
14
}
/>}
>
...
...
web/src/pages/Channel/EditChannel.js
View file @
aa0edd8d
...
...
@@ -153,6 +153,8 @@ const EditChannel = (props) => {
localModels
=
[
'swap_face'
,
'mj_imagine'
,
'mj_video'
,
'mj_edits'
,
'mj_variation'
,
'mj_reroll'
,
'mj_blend'
,
...
...
web/src/pages/Channel/EditTagModal.js
View file @
aa0edd8d
...
...
@@ -77,6 +77,8 @@ const EditTagModal = (props) => {
localModels
=
[
'swap_face'
,
'mj_imagine'
,
'mj_video'
,
'mj_edits'
,
'mj_variation'
,
'mj_reroll'
,
'mj_blend'
,
...
...
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