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
ef6c390a
authored
Jun 18, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 充值方式设置
parent
175ea56f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
1 deletions
+59
-1
controller/misc.go
+1
-0
model/option.go
+3
-0
setting/payment.go
+37
-0
web/src/components/settings/SystemSetting.js
+17
-1
web/src/helpers/data.js
+1
-0
web/src/pages/TopUp/index.js
+0
-0
No files found.
controller/misc.go
View file @
ef6c390a
...
@@ -76,6 +76,7 @@ func GetStatus(c *gin.Context) {
...
@@ -76,6 +76,7 @@ func GetStatus(c *gin.Context) {
"demo_site_enabled"
:
operation_setting
.
DemoSiteEnabled
,
"demo_site_enabled"
:
operation_setting
.
DemoSiteEnabled
,
"self_use_mode_enabled"
:
operation_setting
.
SelfUseModeEnabled
,
"self_use_mode_enabled"
:
operation_setting
.
SelfUseModeEnabled
,
"default_use_auto_group"
:
setting
.
DefaultUseAutoGroup
,
"default_use_auto_group"
:
setting
.
DefaultUseAutoGroup
,
"pay_methods"
:
setting
.
PayMethods
,
// 面板启用开关
// 面板启用开关
"api_info_enabled"
:
cs
.
ApiInfoEnabled
,
"api_info_enabled"
:
cs
.
ApiInfoEnabled
,
...
...
model/option.go
View file @
ef6c390a
...
@@ -79,6 +79,7 @@ func InitOptionMap() {
...
@@ -79,6 +79,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"Chats"
]
=
setting
.
Chats2JsonString
()
common
.
OptionMap
[
"Chats"
]
=
setting
.
Chats2JsonString
()
common
.
OptionMap
[
"AutoGroups"
]
=
setting
.
AutoGroups2JsonString
()
common
.
OptionMap
[
"AutoGroups"
]
=
setting
.
AutoGroups2JsonString
()
common
.
OptionMap
[
"DefaultUseAutoGroup"
]
=
strconv
.
FormatBool
(
setting
.
DefaultUseAutoGroup
)
common
.
OptionMap
[
"DefaultUseAutoGroup"
]
=
strconv
.
FormatBool
(
setting
.
DefaultUseAutoGroup
)
common
.
OptionMap
[
"PayMethods"
]
=
setting
.
PayMethods2JsonString
()
common
.
OptionMap
[
"GitHubClientId"
]
=
""
common
.
OptionMap
[
"GitHubClientId"
]
=
""
common
.
OptionMap
[
"GitHubClientSecret"
]
=
""
common
.
OptionMap
[
"GitHubClientSecret"
]
=
""
common
.
OptionMap
[
"TelegramBotToken"
]
=
""
common
.
OptionMap
[
"TelegramBotToken"
]
=
""
...
@@ -388,6 +389,8 @@ func updateOptionMap(key string, value string) (err error) {
...
@@ -388,6 +389,8 @@ func updateOptionMap(key string, value string) (err error) {
operation_setting
.
AutomaticDisableKeywordsFromString
(
value
)
operation_setting
.
AutomaticDisableKeywordsFromString
(
value
)
case
"StreamCacheQueueLength"
:
case
"StreamCacheQueueLength"
:
setting
.
StreamCacheQueueLength
,
_
=
strconv
.
Atoi
(
value
)
setting
.
StreamCacheQueueLength
,
_
=
strconv
.
Atoi
(
value
)
case
"PayMethods"
:
err
=
setting
.
UpdatePayMethodsByJsonString
(
value
)
}
}
return
err
return
err
}
}
...
...
setting/payment.go
View file @
ef6c390a
package
setting
package
setting
import
"encoding/json"
var
PayAddress
=
""
var
PayAddress
=
""
var
CustomCallbackAddress
=
""
var
CustomCallbackAddress
=
""
var
EpayId
=
""
var
EpayId
=
""
var
EpayKey
=
""
var
EpayKey
=
""
var
Price
=
7.3
var
Price
=
7.3
var
MinTopUp
=
1
var
MinTopUp
=
1
var
PayMethods
=
[]
map
[
string
]
string
{
{
"name"
:
"支付宝"
,
"color"
:
"rgba(var(--semi-blue-5), 1)"
,
"type"
:
"zfb"
,
},
{
"name"
:
"微信"
,
"color"
:
"rgba(var(--semi-green-5), 1)"
,
"type"
:
"wx"
,
},
}
func
UpdatePayMethodsByJsonString
(
jsonString
string
)
error
{
PayMethods
=
make
([]
map
[
string
]
string
,
0
)
return
json
.
Unmarshal
([]
byte
(
jsonString
),
&
PayMethods
)
}
func
PayMethods2JsonString
()
string
{
jsonBytes
,
err
:=
json
.
Marshal
(
PayMethods
)
if
err
!=
nil
{
return
"[]"
}
return
string
(
jsonBytes
)
}
func
ContainsPayMethod
(
method
string
)
bool
{
for
_
,
payMethod
:=
range
PayMethods
{
if
payMethod
[
"type"
]
==
method
{
return
true
}
}
return
false
}
web/src/components/settings/SystemSetting.js
View file @
ef6c390a
...
@@ -17,7 +17,7 @@ import {
...
@@ -17,7 +17,7 @@ import {
removeTrailingSlash
,
removeTrailingSlash
,
showError
,
showError
,
showSuccess
,
showSuccess
,
verifyJSON
verifyJSON
,
}
from
'../../helpers'
;
}
from
'../../helpers'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
...
@@ -73,6 +73,7 @@ const SystemSetting = () => {
...
@@ -73,6 +73,7 @@ const SystemSetting = () => {
LinuxDOOAuthEnabled
:
''
,
LinuxDOOAuthEnabled
:
''
,
LinuxDOClientId
:
''
,
LinuxDOClientId
:
''
,
LinuxDOClientSecret
:
''
,
LinuxDOClientSecret
:
''
,
PayMethods
:
''
,
});
});
const
[
originInputs
,
setOriginInputs
]
=
useState
({});
const
[
originInputs
,
setOriginInputs
]
=
useState
({});
...
@@ -230,6 +231,12 @@ const SystemSetting = () => {
...
@@ -230,6 +231,12 @@ const SystemSetting = () => {
return
;
return
;
}
}
}
}
if
(
originInputs
[
'PayMethods'
]
!==
inputs
.
PayMethods
)
{
if
(
!
verifyJSON
(
inputs
.
PayMethods
))
{
showError
(
'充值方式设置不是合法的 JSON 字符串'
);
return
;
}
}
const
options
=
[
const
options
=
[
{
key
:
'PayAddress'
,
value
:
removeTrailingSlash
(
inputs
.
PayAddress
)
},
{
key
:
'PayAddress'
,
value
:
removeTrailingSlash
(
inputs
.
PayAddress
)
},
...
@@ -256,6 +263,9 @@ const SystemSetting = () => {
...
@@ -256,6 +263,9 @@ const SystemSetting = () => {
if
(
originInputs
[
'TopupGroupRatio'
]
!==
inputs
.
TopupGroupRatio
)
{
if
(
originInputs
[
'TopupGroupRatio'
]
!==
inputs
.
TopupGroupRatio
)
{
options
.
push
({
key
:
'TopupGroupRatio'
,
value
:
inputs
.
TopupGroupRatio
});
options
.
push
({
key
:
'TopupGroupRatio'
,
value
:
inputs
.
TopupGroupRatio
});
}
}
if
(
originInputs
[
'PayMethods'
]
!==
inputs
.
PayMethods
)
{
options
.
push
({
key
:
'PayMethods'
,
value
:
inputs
.
PayMethods
});
}
await
updateOptions
(
options
);
await
updateOptions
(
options
);
};
};
...
@@ -658,6 +668,12 @@ const SystemSetting = () => {
...
@@ -658,6 +668,12 @@ const SystemSetting = () => {
placeholder
=
'为一个 JSON 文本,键为组名称,值为倍率'
placeholder
=
'为一个 JSON 文本,键为组名称,值为倍率'
autosize
autosize
/>
/>
<
Form
.
TextArea
field
=
'PayMethods'
label
=
'充值方式设置'
placeholder
=
'为一个 JSON 文本'
autosize
/>
<
Button
onClick
=
{
submitPayAddress
}
>
更新支付设置
<
/Button
>
<
Button
onClick
=
{
submitPayAddress
}
>
更新支付设置
<
/Button
>
<
/Form.Section
>
<
/Form.Section
>
<
/Card
>
<
/Card
>
...
...
web/src/helpers/data.js
View file @
ef6c390a
...
@@ -9,6 +9,7 @@ export function setStatusData(data) {
...
@@ -9,6 +9,7 @@ export function setStatusData(data) {
localStorage
.
setItem
(
'enable_task'
,
data
.
enable_task
);
localStorage
.
setItem
(
'enable_task'
,
data
.
enable_task
);
localStorage
.
setItem
(
'enable_data_export'
,
data
.
enable_data_export
);
localStorage
.
setItem
(
'enable_data_export'
,
data
.
enable_data_export
);
localStorage
.
setItem
(
'chats'
,
JSON
.
stringify
(
data
.
chats
));
localStorage
.
setItem
(
'chats'
,
JSON
.
stringify
(
data
.
chats
));
localStorage
.
setItem
(
'pay_methods'
,
JSON
.
stringify
(
data
.
pay_methods
));
localStorage
.
setItem
(
localStorage
.
setItem
(
'data_export_default_time'
,
'data_export_default_time'
,
data
.
data_export_default_time
,
data
.
data_export_default_time
,
...
...
web/src/pages/TopUp/index.js
View file @
ef6c390a
This diff is collapsed.
Click to expand it.
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