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
d11134d9
authored
May 12, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: now supports custom smtp port
parent
b14b4005
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
38 deletions
+58
-38
common/constants.go
+1
-0
common/email.go
+1
-1
model/option.go
+4
-0
web/src/components/SystemSetting.js
+29
-14
web/src/pages/Channel/AddChannel.js
+4
-4
web/src/pages/Channel/EditChannel.js
+4
-4
web/src/pages/Redemption/EditRedemption.js
+4
-4
web/src/pages/Token/EditToken.js
+4
-4
web/src/pages/User/EditUser.js
+7
-7
No files found.
common/constants.go
View file @
d11134d9
...
...
@@ -34,6 +34,7 @@ var TurnstileCheckEnabled = false
var
RegisterEnabled
=
true
var
SMTPServer
=
""
var
SMTPPort
=
587
var
SMTPAccount
=
""
var
SMTPToken
=
""
...
...
common/email.go
View file @
d11134d9
...
...
@@ -8,7 +8,7 @@ func SendEmail(subject string, receiver string, content string) error {
m
.
SetHeader
(
"To"
,
receiver
)
m
.
SetHeader
(
"Subject"
,
subject
)
m
.
SetBody
(
"text/html"
,
content
)
d
:=
gomail
.
NewDialer
(
SMTPServer
,
587
,
SMTPAccount
,
SMTPToken
)
d
:=
gomail
.
NewDialer
(
SMTPServer
,
SMTPPort
,
SMTPAccount
,
SMTPToken
)
err
:=
d
.
DialAndSend
(
m
)
return
err
}
model/option.go
View file @
d11134d9
...
...
@@ -33,6 +33,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"TurnstileCheckEnabled"
]
=
strconv
.
FormatBool
(
common
.
TurnstileCheckEnabled
)
common
.
OptionMap
[
"RegisterEnabled"
]
=
strconv
.
FormatBool
(
common
.
RegisterEnabled
)
common
.
OptionMap
[
"SMTPServer"
]
=
""
common
.
OptionMap
[
"SMTPPort"
]
=
strconv
.
Itoa
(
common
.
SMTPPort
)
common
.
OptionMap
[
"SMTPAccount"
]
=
""
common
.
OptionMap
[
"SMTPToken"
]
=
""
common
.
OptionMap
[
"Notice"
]
=
""
...
...
@@ -112,6 +113,9 @@ func updateOptionMap(key string, value string) (err error) {
switch
key
{
case
"SMTPServer"
:
common
.
SMTPServer
=
value
case
"SMTPPort"
:
intValue
,
_
:=
strconv
.
Atoi
(
value
)
common
.
SMTPPort
=
intValue
case
"SMTPAccount"
:
common
.
SMTPAccount
=
value
case
"SMTPToken"
:
...
...
web/src/components/SystemSetting.js
View file @
d11134d9
...
...
@@ -12,6 +12,7 @@ const SystemSetting = () => {
GitHubClientSecret
:
''
,
Notice
:
''
,
SMTPServer
:
''
,
SMTPPort
:
''
,
SMTPAccount
:
''
,
SMTPToken
:
''
,
ServerAddress
:
''
,
...
...
@@ -129,6 +130,12 @@ const SystemSetting = () => {
await
updateOption
(
'SMTPAccount'
,
inputs
.
SMTPAccount
);
}
if
(
originInputs
[
'SMTPPort'
]
!==
inputs
.
SMTPPort
&&
inputs
.
SMTPPort
!==
''
)
{
await
updateOption
(
'SMTPPort'
,
inputs
.
SMTPPort
);
}
if
(
originInputs
[
'SMTPToken'
]
!==
inputs
.
SMTPToken
&&
inputs
.
SMTPToken
!==
''
)
{
...
...
@@ -258,7 +265,7 @@ const SystemSetting = () => {
label
=
'新用户初始配额'
name
=
'QuotaForNewUser'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
QuotaForNewUser
}
type
=
'number'
min
=
'0'
...
...
@@ -268,7 +275,7 @@ const SystemSetting = () => {
label
=
'充值链接'
name
=
'TopUpLink'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
TopUpLink
}
type
=
'link'
placeholder
=
'例如发卡网站的购买链接'
...
...
@@ -280,7 +287,7 @@ const SystemSetting = () => {
name
=
'ModelRatio'
onChange
=
{
handleInputChange
}
style
=
{{
minHeight
:
250
,
fontFamily
:
'JetBrains Mono, Consolas'
}}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
ModelRatio
}
placeholder
=
'为一个 JSON 文本,键为模型名称,值为倍率'
/>
...
...
@@ -291,20 +298,28 @@ const SystemSetting = () => {
配置
SMTP
<
Header
.
Subheader
>
用以支持系统的邮件发送
<
/Header.Subheader
>
<
/Header
>
<
Form
.
Group
widths
=
{
3
}
>
<
Form
.
Group
widths
=
{
4
}
>
<
Form
.
Input
label
=
'SMTP 服务器地址'
name
=
'SMTPServer'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
SMTPServer
}
placeholder
=
'例如:smtp.qq.com'
/>
<
Form
.
Input
label
=
'SMTP 端口'
name
=
'SMTPPort'
onChange
=
{
handleInputChange
}
autoComplete
=
'new-password'
value
=
{
inputs
.
SMTPPort
}
placeholder
=
'默认: 587'
/>
<
Form
.
Input
label
=
'SMTP 账户'
name
=
'SMTPAccount'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
SMTPAccount
}
placeholder
=
'通常是邮箱地址'
/>
...
...
@@ -313,7 +328,7 @@ const SystemSetting = () => {
name
=
'SMTPToken'
onChange
=
{
handleInputChange
}
type
=
'password'
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
SMTPToken
}
placeholder
=
'敏感信息不会发送到前端显示'
/>
...
...
@@ -340,7 +355,7 @@ const SystemSetting = () => {
label
=
'GitHub Client ID'
name
=
'GitHubClientId'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
GitHubClientId
}
placeholder
=
'输入你注册的 GitHub OAuth APP 的 ID'
/>
...
...
@@ -349,7 +364,7 @@ const SystemSetting = () => {
name
=
'GitHubClientSecret'
onChange
=
{
handleInputChange
}
type
=
'password'
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
GitHubClientSecret
}
placeholder
=
'敏感信息不会发送到前端显示'
/>
...
...
@@ -377,7 +392,7 @@ const SystemSetting = () => {
name
=
'WeChatServerAddress'
placeholder
=
'例如:https://yourdomain.com'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
WeChatServerAddress
}
/
>
<
Form
.
Input
...
...
@@ -385,7 +400,7 @@ const SystemSetting = () => {
name
=
'WeChatServerToken'
type
=
'password'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
WeChatServerToken
}
placeholder
=
'敏感信息不会发送到前端显示'
/>
...
...
@@ -393,7 +408,7 @@ const SystemSetting = () => {
label
=
'微信公众号二维码图片链接'
name
=
'WeChatAccountQRCodeImageURL'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
WeChatAccountQRCodeImageURL
}
placeholder
=
'输入一个图片链接'
/>
...
...
@@ -417,7 +432,7 @@ const SystemSetting = () => {
label
=
'Turnstile Site Key'
name
=
'TurnstileSiteKey'
onChange
=
{
handleInputChange
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
TurnstileSiteKey
}
placeholder
=
'输入你注册的 Turnstile Site Key'
/>
...
...
@@ -426,7 +441,7 @@ const SystemSetting = () => {
name
=
'TurnstileSecretKey'
onChange
=
{
handleInputChange
}
type
=
'password'
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
value
=
{
inputs
.
TurnstileSecretKey
}
placeholder
=
'敏感信息不会发送到前端显示'
/>
...
...
web/src/pages/Channel/AddChannel.js
View file @
d11134d9
...
...
@@ -36,7 +36,7 @@ const AddChannel = () => {
<>
<
Segment
>
<
Header
as
=
'h3'
>
创建新的渠道
<
/Header
>
<
Form
autoComplete
=
'
off
'
>
<
Form
autoComplete
=
'
new-password
'
>
<
Form
.
Field
>
<
Form
.
Select
label
=
'类型'
...
...
@@ -55,7 +55,7 @@ const AddChannel = () => {
placeholder
=
{
'请输入自定义渠道的 Base URL,例如:https://openai.justsong.cn'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
base_url
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
)
...
...
@@ -67,7 +67,7 @@ const AddChannel = () => {
placeholder
=
{
'请输入名称'
}
onChange
=
{
handleInputChange
}
value
=
{
name
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
required
/>
<
/Form.Field
>
...
...
@@ -79,7 +79,7 @@ const AddChannel = () => {
onChange
=
{
handleInputChange
}
value
=
{
key
}
// type='password'
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
required
/>
<
/Form.Field
>
...
...
web/src/pages/Channel/EditChannel.js
View file @
d11134d9
...
...
@@ -50,7 +50,7 @@ const EditChannel = () => {
<>
<
Segment
loading
=
{
loading
}
>
<
Header
as
=
'h3'
>
更新渠道信息
<
/Header
>
<
Form
autoComplete
=
'
off
'
>
<
Form
autoComplete
=
'
new-password
'
>
<
Form
.
Field
>
<
Form
.
Select
label
=
'类型'
...
...
@@ -69,7 +69,7 @@ const EditChannel = () => {
placeholder
=
{
'请输入新的自定义渠道的 Base URL,例如:https://openai.justsong.cn'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
base_url
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
)
...
...
@@ -81,7 +81,7 @@ const EditChannel = () => {
placeholder
=
{
'请输入新的名称'
}
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
name
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
<
Form
.
Field
>
...
...
@@ -92,7 +92,7 @@ const EditChannel = () => {
onChange
=
{
handleInputChange
}
value
=
{
inputs
.
key
}
// type='password'
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
<
Button
onClick
=
{
submit
}
>
提交
<
/Button
>
...
...
web/src/pages/Redemption/EditRedemption.js
View file @
d11134d9
...
...
@@ -73,7 +73,7 @@ const EditRedemption = () => {
<>
<
Segment
loading
=
{
loading
}
>
<
Header
as
=
'h3'
>
{
isEdit
?
'更新兑换码信息'
:
'创建新的兑换码'
}
<
/Header
>
<
Form
autoComplete
=
'
off
'
>
<
Form
autoComplete
=
'
new-password
'
>
<
Form
.
Field
>
<
Form
.
Input
label
=
'名称'
...
...
@@ -81,7 +81,7 @@ const EditRedemption = () => {
placeholder
=
{
'请输入名称'
}
onChange
=
{
handleInputChange
}
value
=
{
name
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
required
=
{
!
isEdit
}
/
>
<
/Form.Field
>
...
...
@@ -92,7 +92,7 @@ const EditRedemption = () => {
placeholder
=
{
'请输入单个兑换码中包含的额度'
}
onChange
=
{
handleInputChange
}
value
=
{
quota
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
type
=
'number'
/>
<
/Form.Field
>
...
...
@@ -105,7 +105,7 @@ const EditRedemption = () => {
placeholder
=
{
'请输入生成数量'
}
onChange
=
{
handleInputChange
}
value
=
{
count
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
type
=
'number'
/>
<
/Form.Field
>
...
...
web/src/pages/Token/EditToken.js
View file @
d11134d9
...
...
@@ -95,7 +95,7 @@ const EditToken = () => {
<>
<
Segment
loading
=
{
loading
}
>
<
Header
as
=
'h3'
>
{
isEdit
?
'更新令牌信息'
:
'创建新的令牌'
}
<
/Header
>
<
Form
autoComplete
=
'
off
'
>
<
Form
autoComplete
=
'
new-password
'
>
<
Form
.
Field
>
<
Form
.
Input
label
=
'名称'
...
...
@@ -103,7 +103,7 @@ const EditToken = () => {
placeholder
=
{
'请输入名称'
}
onChange
=
{
handleInputChange
}
value
=
{
name
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
required
=
{
!
isEdit
}
/
>
<
/Form.Field
>
...
...
@@ -116,7 +116,7 @@ const EditToken = () => {
placeholder
=
{
'请输入额度'
}
onChange
=
{
handleInputChange
}
value
=
{
remain_quota
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
type
=
'number'
disabled
=
{
unlimited_quota
}
/
>
...
...
@@ -133,7 +133,7 @@ const EditToken = () => {
placeholder
=
{
'请输入过期时间,格式为 yyyy-MM-dd HH:mm:ss,-1 表示无限制'
}
onChange
=
{
handleInputChange
}
value
=
{
expired_time
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
type
=
'datetime-local'
/>
<
/Form.Field
>
...
...
web/src/pages/User/EditUser.js
View file @
d11134d9
...
...
@@ -60,7 +60,7 @@ const EditUser = () => {
<>
<
Segment
loading
=
{
loading
}
>
<
Header
as
=
'h3'
>
更新用户信息
<
/Header
>
<
Form
autoComplete
=
'
off
'
>
<
Form
autoComplete
=
'
new-password
'
>
<
Form
.
Field
>
<
Form
.
Input
label
=
'用户名'
...
...
@@ -68,7 +68,7 @@ const EditUser = () => {
placeholder
=
{
'请输入新的用户名'
}
onChange
=
{
handleInputChange
}
value
=
{
username
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
<
Form
.
Field
>
...
...
@@ -79,7 +79,7 @@ const EditUser = () => {
placeholder
=
{
'请输入新的密码'
}
onChange
=
{
handleInputChange
}
value
=
{
password
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
<
Form
.
Field
>
...
...
@@ -89,7 +89,7 @@ const EditUser = () => {
placeholder
=
{
'请输入新的显示名称'
}
onChange
=
{
handleInputChange
}
value
=
{
display_name
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
/>
<
/Form.Field
>
<
Form
.
Field
>
...
...
@@ -97,7 +97,7 @@ const EditUser = () => {
label
=
'已绑定的 GitHub 账户'
name
=
'github_id'
value
=
{
github_id
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
placeholder
=
'此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改'
readOnly
/>
...
...
@@ -107,7 +107,7 @@ const EditUser = () => {
label
=
'已绑定的微信账户'
name
=
'wechat_id'
value
=
{
wechat_id
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
placeholder
=
'此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改'
readOnly
/>
...
...
@@ -117,7 +117,7 @@ const EditUser = () => {
label
=
'已绑定的邮箱账户'
name
=
'email'
value
=
{
email
}
autoComplete
=
'
off
'
autoComplete
=
'
new-password
'
placeholder
=
'此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改'
readOnly
/>
...
...
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