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
17ebd73f
authored
May 01, 2024
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: able to set AccountFilter
parent
38377e10
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
6 deletions
+19
-6
constant/midjourney.go
+1
-0
model/option.go
+3
-0
service/midjourney.go
+8
-6
web/src/components/OperationSetting.js
+7
-0
No files found.
constant/midjourney.go
View file @
17ebd73f
package
constant
package
constant
var
MjNotifyEnabled
=
false
var
MjNotifyEnabled
=
false
var
MjAccountFilterEnabled
=
false
var
MjModeClearEnabled
=
false
var
MjModeClearEnabled
=
false
var
MjForwardUrlEnabled
=
true
var
MjForwardUrlEnabled
=
true
...
...
model/option.go
View file @
17ebd73f
...
@@ -92,6 +92,7 @@ func InitOptionMap() {
...
@@ -92,6 +92,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"DataExportDefaultTime"
]
=
common
.
DataExportDefaultTime
common
.
OptionMap
[
"DataExportDefaultTime"
]
=
common
.
DataExportDefaultTime
common
.
OptionMap
[
"DefaultCollapseSidebar"
]
=
strconv
.
FormatBool
(
common
.
DefaultCollapseSidebar
)
common
.
OptionMap
[
"DefaultCollapseSidebar"
]
=
strconv
.
FormatBool
(
common
.
DefaultCollapseSidebar
)
common
.
OptionMap
[
"MjNotifyEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjNotifyEnabled
)
common
.
OptionMap
[
"MjNotifyEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjNotifyEnabled
)
common
.
OptionMap
[
"MjAccountFilterEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjAccountFilterEnabled
)
common
.
OptionMap
[
"MjModeClearEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjModeClearEnabled
)
common
.
OptionMap
[
"MjModeClearEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjModeClearEnabled
)
common
.
OptionMap
[
"MjForwardUrlEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjForwardUrlEnabled
)
common
.
OptionMap
[
"MjForwardUrlEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjForwardUrlEnabled
)
common
.
OptionMap
[
"CheckSensitiveEnabled"
]
=
strconv
.
FormatBool
(
constant
.
CheckSensitiveEnabled
)
common
.
OptionMap
[
"CheckSensitiveEnabled"
]
=
strconv
.
FormatBool
(
constant
.
CheckSensitiveEnabled
)
...
@@ -197,6 +198,8 @@ func updateOptionMap(key string, value string) (err error) {
...
@@ -197,6 +198,8 @@ func updateOptionMap(key string, value string) (err error) {
common
.
DefaultCollapseSidebar
=
boolValue
common
.
DefaultCollapseSidebar
=
boolValue
case
"MjNotifyEnabled"
:
case
"MjNotifyEnabled"
:
constant
.
MjNotifyEnabled
=
boolValue
constant
.
MjNotifyEnabled
=
boolValue
case
"MjAccountFilterEnabled"
:
constant
.
MjAccountFilterEnabled
=
boolValue
case
"MjModeClearEnabled"
:
case
"MjModeClearEnabled"
:
constant
.
MjModeClearEnabled
=
boolValue
constant
.
MjModeClearEnabled
=
boolValue
case
"MjForwardUrlEnabled"
:
case
"MjForwardUrlEnabled"
:
...
...
service/midjourney.go
View file @
17ebd73f
...
@@ -165,7 +165,9 @@ func DoMidjourneyHttpRequest(c *gin.Context, timeout time.Duration, fullRequestU
...
@@ -165,7 +165,9 @@ func DoMidjourneyHttpRequest(c *gin.Context, timeout time.Duration, fullRequestU
if
err
!=
nil
{
if
err
!=
nil
{
return
MidjourneyErrorWithStatusCodeWrapper
(
constant
.
MjErrorUnknown
,
"read_request_body_failed"
,
http
.
StatusInternalServerError
),
nullBytes
,
err
return
MidjourneyErrorWithStatusCodeWrapper
(
constant
.
MjErrorUnknown
,
"read_request_body_failed"
,
http
.
StatusInternalServerError
),
nullBytes
,
err
}
}
delete
(
mapResult
,
"accountFilter"
)
if
!
constant
.
MjAccountFilterEnabled
{
delete
(
mapResult
,
"accountFilter"
)
}
if
!
constant
.
MjNotifyEnabled
{
if
!
constant
.
MjNotifyEnabled
{
delete
(
mapResult
,
"notifyHook"
)
delete
(
mapResult
,
"notifyHook"
)
}
}
...
@@ -174,11 +176,11 @@ func DoMidjourneyHttpRequest(c *gin.Context, timeout time.Duration, fullRequestU
...
@@ -174,11 +176,11 @@ func DoMidjourneyHttpRequest(c *gin.Context, timeout time.Duration, fullRequestU
}
}
if
constant
.
MjModeClearEnabled
{
if
constant
.
MjModeClearEnabled
{
if
prompt
,
ok
:=
mapResult
[
"prompt"
]
.
(
string
);
ok
{
if
prompt
,
ok
:=
mapResult
[
"prompt"
]
.
(
string
);
ok
{
prompt
=
strings
.
Replace
(
prompt
,
"--fast"
,
""
,
-
1
)
prompt
=
strings
.
Replace
(
prompt
,
"--fast"
,
""
,
-
1
)
prompt
=
strings
.
Replace
(
prompt
,
"--relax"
,
""
,
-
1
)
prompt
=
strings
.
Replace
(
prompt
,
"--relax"
,
""
,
-
1
)
prompt
=
strings
.
Replace
(
prompt
,
"--turbo"
,
""
,
-
1
)
prompt
=
strings
.
Replace
(
prompt
,
"--turbo"
,
""
,
-
1
)
mapResult
[
"prompt"
]
=
prompt
mapResult
[
"prompt"
]
=
prompt
}
}
}
}
reqBody
,
err
:=
json
.
Marshal
(
mapResult
)
reqBody
,
err
:=
json
.
Marshal
(
mapResult
)
...
...
web/src/components/OperationSetting.js
View file @
17ebd73f
...
@@ -38,6 +38,7 @@ const OperationSetting = () => {
...
@@ -38,6 +38,7 @@ const OperationSetting = () => {
StopOnSensitiveEnabled
:
''
,
StopOnSensitiveEnabled
:
''
,
SensitiveWords
:
''
,
SensitiveWords
:
''
,
MjNotifyEnabled
:
''
,
MjNotifyEnabled
:
''
,
MjAccountFilterEnabled
:
''
,
MjModeClearEnabled
:
''
,
MjModeClearEnabled
:
''
,
MjForwardUrlEnabled
:
''
,
MjForwardUrlEnabled
:
''
,
DrawingEnabled
:
''
,
DrawingEnabled
:
''
,
...
@@ -324,6 +325,12 @@ const OperationSetting = () => {
...
@@ -324,6 +325,12 @@ const OperationSetting = () => {
onChange
=
{
handleInputChange
}
onChange
=
{
handleInputChange
}
/
>
/
>
<
Form
.
Checkbox
<
Form
.
Checkbox
checked
=
{
inputs
.
MjAccountFilterEnabled
===
'true'
}
label
=
'允许AccountFilter参数'
name
=
'MjAccountFilterEnabled'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Checkbox
checked
=
{
inputs
.
MjForwardUrlEnabled
===
'true'
}
checked
=
{
inputs
.
MjForwardUrlEnabled
===
'true'
}
label
=
'开启之后将上游地址替换为服务器地址'
label
=
'开启之后将上游地址替换为服务器地址'
name
=
'MjForwardUrlEnabled'
name
=
'MjForwardUrlEnabled'
...
...
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