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
cee6f9c3
authored
Mar 14, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 允许开关mj回调
parent
643622eb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
9 deletions
+30
-9
constant/midjourney.go
+2
-0
model/option.go
+4
-0
service/midjourney.go
+3
-1
web/src/components/OperationSetting.js
+21
-8
No files found.
constant/midjourney.go
View file @
cee6f9c3
package
constant
var
MjNotifyEnabled
=
false
const
(
MjErrorUnknown
=
5
MjRequestError
=
4
...
...
model/option.go
View file @
cee6f9c3
...
...
@@ -2,6 +2,7 @@ package model
import
(
"one-api/common"
"one-api/constant"
"strconv"
"strings"
"time"
...
...
@@ -88,6 +89,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"DataExportInterval"
]
=
strconv
.
Itoa
(
common
.
DataExportInterval
)
common
.
OptionMap
[
"DataExportDefaultTime"
]
=
common
.
DataExportDefaultTime
common
.
OptionMap
[
"DefaultCollapseSidebar"
]
=
strconv
.
FormatBool
(
common
.
DefaultCollapseSidebar
)
common
.
OptionMap
[
"MjNotifyEnabled"
]
=
strconv
.
FormatBool
(
constant
.
MjNotifyEnabled
)
common
.
OptionMapRWMutex
.
Unlock
()
loadOptionsFromDatabase
()
...
...
@@ -181,6 +183,8 @@ func updateOptionMap(key string, value string) (err error) {
common
.
DataExportEnabled
=
boolValue
case
"DefaultCollapseSidebar"
:
common
.
DefaultCollapseSidebar
=
boolValue
case
"MjNotifyEnabled"
:
constant
.
MjNotifyEnabled
=
boolValue
}
}
switch
key
{
...
...
service/midjourney.go
View file @
cee6f9c3
...
...
@@ -163,7 +163,9 @@ func DoMidjourneyHttpRequest(c *gin.Context, timeout time.Duration, fullRequestU
return
MidjourneyErrorWithStatusCodeWrapper
(
constant
.
MjErrorUnknown
,
"read_request_body_failed"
,
http
.
StatusInternalServerError
),
nullBytes
,
err
}
delete
(
mapResult
,
"accountFilter"
)
delete
(
mapResult
,
"notifyHook"
)
if
!
constant
.
MjNotifyEnabled
{
delete
(
mapResult
,
"notifyHook"
)
}
//req, err := http.NewRequest(c.Request.Method, fullRequestURL, requestBody)
// make new request with mapResult
reqBody
,
err
:=
json
.
Marshal
(
mapResult
)
...
...
web/src/components/OperationSetting.js
View file @
cee6f9c3
...
...
@@ -23,6 +23,7 @@ const OperationSetting = () => {
LogConsumeEnabled
:
''
,
DisplayInCurrencyEnabled
:
''
,
DisplayTokenStatEnabled
:
''
,
MjNotifyEnabled
:
''
,
DrawingEnabled
:
''
,
DataExportEnabled
:
''
,
DataExportDefaultTime
:
'hour'
,
...
...
@@ -229,7 +230,6 @@ const OperationSetting = () => {
/>
<
/Form.Group
>
<
Form
.
Group
inline
>
<
Form
.
Checkbox
checked
=
{
inputs
.
DisplayInCurrencyEnabled
===
'true'
}
label
=
'以货币形式显示额度'
...
...
@@ -243,12 +243,6 @@ const OperationSetting = () => {
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Checkbox
checked
=
{
inputs
.
DrawingEnabled
===
'true'
}
label
=
'启用绘图功能'
name
=
'DrawingEnabled'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Checkbox
checked
=
{
inputs
.
DefaultCollapseSidebar
===
'true'
}
label
=
'默认折叠侧边栏'
name
=
'DefaultCollapseSidebar'
...
...
@@ -257,7 +251,26 @@ const OperationSetting = () => {
<
/Form.Group
>
<
Form
.
Button
onClick
=
{()
=>
{
submitConfig
(
'general'
).
then
();
}}
>
保存通用设置
<
/Form.Button><Divider/
>
}}
>
保存通用设置
<
/Form.Button
>
<
Divider
/>
<
Header
as
=
'h3'
>
绘图设置
<
/Header
>
<
Form
.
Group
inline
>
<
Form
.
Checkbox
checked
=
{
inputs
.
DrawingEnabled
===
'true'
}
label
=
'启用绘图功能'
name
=
'DrawingEnabled'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Checkbox
checked
=
{
inputs
.
MjNotifyEnabled
===
'true'
}
label
=
'允许回调(会泄露服务器ip地址)'
name
=
'MjNotifyEnabled'
onChange
=
{
handleInputChange
}
/
>
<
/Form.Group
>
<
Divider
/>
<
Header
as
=
'h3'
>
日志设置
<
/Header
>
...
...
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