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
56ffbd57
authored
Oct 10, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: legal setting
parent
b7725d7a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
24 deletions
+71
-24
.dockerignore
+2
-0
.gitignore
+2
-0
controller/misc.go
+5
-8
model/option.go
+0
-2
setting/system_setting/legal.go
+21
-0
web/src/components/settings/OtherSetting.jsx
+41
-14
No files found.
.dockerignore
View file @
56ffbd57
...
@@ -6,3 +6,4 @@
...
@@ -6,3 +6,4 @@
Makefile
Makefile
docs
docs
.eslintcache
.eslintcache
.gocache
\ No newline at end of file
.gitignore
View file @
56ffbd57
...
@@ -13,6 +13,7 @@ new-api
...
@@ -13,6 +13,7 @@ new-api
.DS_Store
.DS_Store
tiktoken_cache
tiktoken_cache
.eslintcache
.eslintcache
.gocache
electron/node_modules
electron/node_modules
electron/dist
electron/dist
\ No newline at end of file
controller/misc.go
View file @
56ffbd57
...
@@ -43,6 +43,7 @@ func GetStatus(c *gin.Context) {
...
@@ -43,6 +43,7 @@ func GetStatus(c *gin.Context) {
defer
common
.
OptionMapRWMutex
.
RUnlock
()
defer
common
.
OptionMapRWMutex
.
RUnlock
()
passkeySetting
:=
system_setting
.
GetPasskeySettings
()
passkeySetting
:=
system_setting
.
GetPasskeySettings
()
legalSetting
:=
system_setting
.
GetLegalSettings
()
data
:=
gin
.
H
{
data
:=
gin
.
H
{
"version"
:
common
.
Version
,
"version"
:
common
.
Version
,
...
@@ -108,8 +109,8 @@ func GetStatus(c *gin.Context) {
...
@@ -108,8 +109,8 @@ func GetStatus(c *gin.Context) {
"passkey_user_verification"
:
passkeySetting
.
UserVerification
,
"passkey_user_verification"
:
passkeySetting
.
UserVerification
,
"passkey_attachment"
:
passkeySetting
.
AttachmentPreference
,
"passkey_attachment"
:
passkeySetting
.
AttachmentPreference
,
"setup"
:
constant
.
Setup
,
"setup"
:
constant
.
Setup
,
"user_agreement_enabled"
:
common
.
OptionMap
[
"UserAgreement"
]
!=
""
,
"user_agreement_enabled"
:
legalSetting
.
UserAgreement
!=
""
,
"privacy_policy_enabled"
:
common
.
OptionMap
[
"PrivacyPolicy"
]
!=
""
,
"privacy_policy_enabled"
:
legalSetting
.
PrivacyPolicy
!=
""
,
}
}
// 根据启用状态注入可选内容
// 根据启用状态注入可选内容
...
@@ -154,23 +155,19 @@ func GetAbout(c *gin.Context) {
...
@@ -154,23 +155,19 @@ func GetAbout(c *gin.Context) {
}
}
func
GetUserAgreement
(
c
*
gin
.
Context
)
{
func
GetUserAgreement
(
c
*
gin
.
Context
)
{
common
.
OptionMapRWMutex
.
RLock
()
defer
common
.
OptionMapRWMutex
.
RUnlock
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
true
,
"success"
:
true
,
"message"
:
""
,
"message"
:
""
,
"data"
:
common
.
OptionMap
[
"UserAgreement"
]
,
"data"
:
system_setting
.
GetLegalSettings
()
.
UserAgreement
,
})
})
return
return
}
}
func
GetPrivacyPolicy
(
c
*
gin
.
Context
)
{
func
GetPrivacyPolicy
(
c
*
gin
.
Context
)
{
common
.
OptionMapRWMutex
.
RLock
()
defer
common
.
OptionMapRWMutex
.
RUnlock
()
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
true
,
"success"
:
true
,
"message"
:
""
,
"message"
:
""
,
"data"
:
common
.
OptionMap
[
"PrivacyPolicy"
]
,
"data"
:
system_setting
.
GetLegalSettings
()
.
PrivacyPolicy
,
})
})
return
return
}
}
...
...
model/option.go
View file @
56ffbd57
...
@@ -61,8 +61,6 @@ func InitOptionMap() {
...
@@ -61,8 +61,6 @@ func InitOptionMap() {
common
.
OptionMap
[
"SMTPToken"
]
=
""
common
.
OptionMap
[
"SMTPToken"
]
=
""
common
.
OptionMap
[
"SMTPSSLEnabled"
]
=
strconv
.
FormatBool
(
common
.
SMTPSSLEnabled
)
common
.
OptionMap
[
"SMTPSSLEnabled"
]
=
strconv
.
FormatBool
(
common
.
SMTPSSLEnabled
)
common
.
OptionMap
[
"Notice"
]
=
""
common
.
OptionMap
[
"Notice"
]
=
""
common
.
OptionMap
[
"UserAgreement"
]
=
""
common
.
OptionMap
[
"PrivacyPolicy"
]
=
""
common
.
OptionMap
[
"About"
]
=
""
common
.
OptionMap
[
"About"
]
=
""
common
.
OptionMap
[
"HomePageContent"
]
=
""
common
.
OptionMap
[
"HomePageContent"
]
=
""
common
.
OptionMap
[
"Footer"
]
=
common
.
Footer
common
.
OptionMap
[
"Footer"
]
=
common
.
Footer
...
...
setting/system_setting/legal.go
0 → 100644
View file @
56ffbd57
package
system_setting
import
"one-api/setting/config"
type
LegalSettings
struct
{
UserAgreement
string
`json:"user_agreement"`
PrivacyPolicy
string
`json:"privacy_policy"`
}
var
defaultLegalSettings
=
LegalSettings
{
UserAgreement
:
""
,
PrivacyPolicy
:
""
,
}
func
init
()
{
config
.
GlobalConfig
.
Register
(
"legal"
,
&
defaultLegalSettings
)
}
func
GetLegalSettings
()
*
LegalSettings
{
return
&
defaultLegalSettings
}
web/src/components/settings/OtherSetting.jsx
View file @
56ffbd57
...
@@ -34,12 +34,15 @@ import { useTranslation } from 'react-i18next';
...
@@ -34,12 +34,15 @@ import { useTranslation } from 'react-i18next';
import
{
StatusContext
}
from
'../../context/Status'
;
import
{
StatusContext
}
from
'../../context/Status'
;
import
Text
from
'@douyinfe/semi-ui/lib/es/typography/text'
;
import
Text
from
'@douyinfe/semi-ui/lib/es/typography/text'
;
const
LEGAL_USER_AGREEMENT_KEY
=
'legal.user_agreement'
;
const
LEGAL_PRIVACY_POLICY_KEY
=
'legal.privacy_policy'
;
const
OtherSetting
=
()
=>
{
const
OtherSetting
=
()
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
let
[
inputs
,
setInputs
]
=
useState
({
let
[
inputs
,
setInputs
]
=
useState
({
Notice
:
''
,
Notice
:
''
,
UserAgreement
:
''
,
[
LEGAL_USER_AGREEMENT_KEY
]
:
''
,
PrivacyPolicy
:
''
,
[
LEGAL_PRIVACY_POLICY_KEY
]
:
''
,
SystemName
:
''
,
SystemName
:
''
,
Logo
:
''
,
Logo
:
''
,
Footer
:
''
,
Footer
:
''
,
...
@@ -71,8 +74,8 @@ const OtherSetting = () => {
...
@@ -71,8 +74,8 @@ const OtherSetting = () => {
const
[
loadingInput
,
setLoadingInput
]
=
useState
({
const
[
loadingInput
,
setLoadingInput
]
=
useState
({
Notice
:
false
,
Notice
:
false
,
UserAgreement
:
false
,
[
LEGAL_USER_AGREEMENT_KEY
]
:
false
,
PrivacyPolicy
:
false
,
[
LEGAL_PRIVACY_POLICY_KEY
]
:
false
,
SystemName
:
false
,
SystemName
:
false
,
Logo
:
false
,
Logo
:
false
,
HomePageContent
:
false
,
HomePageContent
:
false
,
...
@@ -103,27 +106,45 @@ const OtherSetting = () => {
...
@@ -103,27 +106,45 @@ const OtherSetting = () => {
// 通用设置 - UserAgreement
// 通用设置 - UserAgreement
const
submitUserAgreement
=
async
()
=>
{
const
submitUserAgreement
=
async
()
=>
{
try
{
try
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
UserAgreement
:
true
}));
setLoadingInput
((
loadingInput
)
=>
({
await
updateOption
(
'UserAgreement'
,
inputs
.
UserAgreement
);
...
loadingInput
,
[
LEGAL_USER_AGREEMENT_KEY
]:
true
,
}));
await
updateOption
(
LEGAL_USER_AGREEMENT_KEY
,
inputs
[
LEGAL_USER_AGREEMENT_KEY
],
);
showSuccess
(
t
(
'用户协议已更新'
));
showSuccess
(
t
(
'用户协议已更新'
));
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
t
(
'用户协议更新失败'
),
error
);
console
.
error
(
t
(
'用户协议更新失败'
),
error
);
showError
(
t
(
'用户协议更新失败'
));
showError
(
t
(
'用户协议更新失败'
));
}
finally
{
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
UserAgreement
:
false
}));
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
[
LEGAL_USER_AGREEMENT_KEY
]:
false
,
}));
}
}
};
};
// 通用设置 - PrivacyPolicy
// 通用设置 - PrivacyPolicy
const
submitPrivacyPolicy
=
async
()
=>
{
const
submitPrivacyPolicy
=
async
()
=>
{
try
{
try
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
PrivacyPolicy
:
true
}));
setLoadingInput
((
loadingInput
)
=>
({
await
updateOption
(
'PrivacyPolicy'
,
inputs
.
PrivacyPolicy
);
...
loadingInput
,
[
LEGAL_PRIVACY_POLICY_KEY
]:
true
,
}));
await
updateOption
(
LEGAL_PRIVACY_POLICY_KEY
,
inputs
[
LEGAL_PRIVACY_POLICY_KEY
],
);
showSuccess
(
t
(
'隐私政策已更新'
));
showSuccess
(
t
(
'隐私政策已更新'
));
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
t
(
'隐私政策更新失败'
),
error
);
console
.
error
(
t
(
'隐私政策更新失败'
),
error
);
showError
(
t
(
'隐私政策更新失败'
));
showError
(
t
(
'隐私政策更新失败'
));
}
finally
{
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
PrivacyPolicy
:
false
}));
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
[
LEGAL_PRIVACY_POLICY_KEY
]:
false
,
}));
}
}
};
};
// 个性化设置
// 个性化设置
...
@@ -359,13 +380,16 @@ const OtherSetting = () => {
...
@@ -359,13 +380,16 @@ const OtherSetting = () => {
placeholder=
{
t
(
placeholder=
{
t
(
'在此输入用户协议内容,支持 Markdown & HTML 代码'
,
'在此输入用户协议内容,支持 Markdown & HTML 代码'
,
)
}
)
}
field=
{
'UserAgreement'
}
field=
{
LEGAL_USER_AGREEMENT_KEY
}
onChange=
{
handleInputChange
}
onChange=
{
handleInputChange
}
style=
{
{
fontFamily
:
'JetBrains Mono, Consolas'
}
}
style=
{
{
fontFamily
:
'JetBrains Mono, Consolas'
}
}
autosize=
{
{
minRows
:
6
,
maxRows
:
12
}
}
autosize=
{
{
minRows
:
6
,
maxRows
:
12
}
}
helpText=
{
t
(
'填写用户协议内容后,用户注册时将被要求勾选已阅读用户协议'
)
}
helpText=
{
t
(
'填写用户协议内容后,用户注册时将被要求勾选已阅读用户协议'
)
}
/>
/>
<
Button
onClick=
{
submitUserAgreement
}
loading=
{
loadingInput
[
'UserAgreement'
]
}
>
<
Button
onClick=
{
submitUserAgreement
}
loading=
{
loadingInput
[
LEGAL_USER_AGREEMENT_KEY
]
}
>
{
t
(
'设置用户协议'
)
}
{
t
(
'设置用户协议'
)
}
</
Button
>
</
Button
>
<
Form
.
TextArea
<
Form
.
TextArea
...
@@ -373,13 +397,16 @@ const OtherSetting = () => {
...
@@ -373,13 +397,16 @@ const OtherSetting = () => {
placeholder=
{
t
(
placeholder=
{
t
(
'在此输入隐私政策内容,支持 Markdown & HTML 代码'
,
'在此输入隐私政策内容,支持 Markdown & HTML 代码'
,
)
}
)
}
field=
{
'PrivacyPolicy'
}
field=
{
LEGAL_PRIVACY_POLICY_KEY
}
onChange=
{
handleInputChange
}
onChange=
{
handleInputChange
}
style=
{
{
fontFamily
:
'JetBrains Mono, Consolas'
}
}
style=
{
{
fontFamily
:
'JetBrains Mono, Consolas'
}
}
autosize=
{
{
minRows
:
6
,
maxRows
:
12
}
}
autosize=
{
{
minRows
:
6
,
maxRows
:
12
}
}
helpText=
{
t
(
'填写隐私政策内容后,用户注册时将被要求勾选已阅读隐私政策'
)
}
helpText=
{
t
(
'填写隐私政策内容后,用户注册时将被要求勾选已阅读隐私政策'
)
}
/>
/>
<
Button
onClick=
{
submitPrivacyPolicy
}
loading=
{
loadingInput
[
'PrivacyPolicy'
]
}
>
<
Button
onClick=
{
submitPrivacyPolicy
}
loading=
{
loadingInput
[
LEGAL_PRIVACY_POLICY_KEY
]
}
>
{
t
(
'设置隐私政策'
)
}
{
t
(
'设置隐私政策'
)
}
</
Button
>
</
Button
>
</
Form
.
Section
>
</
Form
.
Section
>
...
...
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