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
4d5e79c9
authored
Jun 19, 2025
by
Calcium-Ion
Committed by
GitHub
Jun 19, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1257 from QuantumNous/pay_custom
feat: 自定义充值方式
parents
1ea674f3
ef6c390a
Expand all
Hide 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 @
4d5e79c9
...
...
@@ -76,6 +76,7 @@ func GetStatus(c *gin.Context) {
"demo_site_enabled"
:
operation_setting
.
DemoSiteEnabled
,
"self_use_mode_enabled"
:
operation_setting
.
SelfUseModeEnabled
,
"default_use_auto_group"
:
setting
.
DefaultUseAutoGroup
,
"pay_methods"
:
setting
.
PayMethods
,
// 面板启用开关
"api_info_enabled"
:
cs
.
ApiInfoEnabled
,
...
...
model/option.go
View file @
4d5e79c9
...
...
@@ -79,6 +79,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"Chats"
]
=
setting
.
Chats2JsonString
()
common
.
OptionMap
[
"AutoGroups"
]
=
setting
.
AutoGroups2JsonString
()
common
.
OptionMap
[
"DefaultUseAutoGroup"
]
=
strconv
.
FormatBool
(
setting
.
DefaultUseAutoGroup
)
common
.
OptionMap
[
"PayMethods"
]
=
setting
.
PayMethods2JsonString
()
common
.
OptionMap
[
"GitHubClientId"
]
=
""
common
.
OptionMap
[
"GitHubClientSecret"
]
=
""
common
.
OptionMap
[
"TelegramBotToken"
]
=
""
...
...
@@ -388,6 +389,8 @@ func updateOptionMap(key string, value string) (err error) {
operation_setting
.
AutomaticDisableKeywordsFromString
(
value
)
case
"StreamCacheQueueLength"
:
setting
.
StreamCacheQueueLength
,
_
=
strconv
.
Atoi
(
value
)
case
"PayMethods"
:
err
=
setting
.
UpdatePayMethodsByJsonString
(
value
)
}
return
err
}
...
...
setting/payment.go
View file @
4d5e79c9
package
setting
import
"encoding/json"
var
PayAddress
=
""
var
CustomCallbackAddress
=
""
var
EpayId
=
""
var
EpayKey
=
""
var
Price
=
7.3
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 @
4d5e79c9
...
...
@@ -17,7 +17,7 @@ import {
removeTrailingSlash
,
showError
,
showSuccess
,
verifyJSON
verifyJSON
,
}
from
'../../helpers'
;
import
axios
from
'axios'
;
...
...
@@ -73,6 +73,7 @@ const SystemSetting = () => {
LinuxDOOAuthEnabled
:
''
,
LinuxDOClientId
:
''
,
LinuxDOClientSecret
:
''
,
PayMethods
:
''
,
});
const
[
originInputs
,
setOriginInputs
]
=
useState
({});
...
...
@@ -230,6 +231,12 @@ const SystemSetting = () => {
return
;
}
}
if
(
originInputs
[
'PayMethods'
]
!==
inputs
.
PayMethods
)
{
if
(
!
verifyJSON
(
inputs
.
PayMethods
))
{
showError
(
'充值方式设置不是合法的 JSON 字符串'
);
return
;
}
}
const
options
=
[
{
key
:
'PayAddress'
,
value
:
removeTrailingSlash
(
inputs
.
PayAddress
)
},
...
...
@@ -256,6 +263,9 @@ const SystemSetting = () => {
if
(
originInputs
[
'TopupGroupRatio'
]
!==
inputs
.
TopupGroupRatio
)
{
options
.
push
({
key
:
'TopupGroupRatio'
,
value
:
inputs
.
TopupGroupRatio
});
}
if
(
originInputs
[
'PayMethods'
]
!==
inputs
.
PayMethods
)
{
options
.
push
({
key
:
'PayMethods'
,
value
:
inputs
.
PayMethods
});
}
await
updateOptions
(
options
);
};
...
...
@@ -658,6 +668,12 @@ const SystemSetting = () => {
placeholder
=
'为一个 JSON 文本,键为组名称,值为倍率'
autosize
/>
<
Form
.
TextArea
field
=
'PayMethods'
label
=
'充值方式设置'
placeholder
=
'为一个 JSON 文本'
autosize
/>
<
Button
onClick
=
{
submitPayAddress
}
>
更新支付设置
<
/Button
>
<
/Form.Section
>
<
/Card
>
...
...
web/src/helpers/data.js
View file @
4d5e79c9
...
...
@@ -9,6 +9,7 @@ export function setStatusData(data) {
localStorage
.
setItem
(
'enable_task'
,
data
.
enable_task
);
localStorage
.
setItem
(
'enable_data_export'
,
data
.
enable_data_export
);
localStorage
.
setItem
(
'chats'
,
JSON
.
stringify
(
data
.
chats
));
localStorage
.
setItem
(
'pay_methods'
,
JSON
.
stringify
(
data
.
pay_methods
));
localStorage
.
setItem
(
'data_export_default_time'
,
data
.
data_export_default_time
,
...
...
web/src/pages/TopUp/index.js
View file @
4d5e79c9
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