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
354e1df3
authored
Apr 03, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/main'
parents
f18a83c1
975a12a8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
46 deletions
+75
-46
controller/misc.go
+15
-5
relay/channel/claude/relay-claude.go
+2
-0
web/.prettierrc.mjs
+1
-2
web/src/helpers/render.js
+27
-29
web/src/pages/Setting/index.js
+30
-10
No files found.
controller/misc.go
View file @
354e1df3
...
...
@@ -120,18 +120,28 @@ func SendEmailVerification(c *gin.Context) {
})
return
}
if
common
.
EmailDomainRestrictionEnabled
{
if
config
.
EmailDomainRestrictionEnabled
{
parts
:=
strings
.
Split
(
email
,
"@"
)
localPart
:=
parts
[
0
]
domainPart
:=
parts
[
1
]
containsSpecialSymbols
:=
strings
.
Contains
(
localPart
,
"+"
)
||
strings
.
Count
(
localPart
,
"."
)
>
1
allowed
:=
false
for
_
,
domain
:=
range
co
mmon
.
EmailDomainWhitelist
{
if
strings
.
HasSuffix
(
email
,
"@"
+
domain
)
{
for
_
,
domain
:=
range
co
nfig
.
EmailDomainWhitelist
{
if
domainPart
==
domain
{
allowed
=
true
break
}
}
if
!
allowed
{
if
allowed
&&
!
containsSpecialSymbols
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
true
,
"message"
:
"Your email address is allowed."
,
})
}
else
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
"
管理员启用了邮箱域名白名单,您的邮箱地址的域名不在白名单中
"
,
"message"
:
"
The administrator has enabled the email domain name whitelist, and your email address is not allowed due to special symbols or it's not in the whitelist.
"
,
})
return
}
...
...
relay/channel/claude/relay-claude.go
View file @
354e1df3
...
...
@@ -34,6 +34,7 @@ func requestOpenAI2ClaudeComplete(textRequest dto.GeneralOpenAIRequest) *ClaudeR
StopSequences
:
nil
,
Temperature
:
textRequest
.
Temperature
,
TopP
:
textRequest
.
TopP
,
TopK
:
textRequest
.
TopK
,
Stream
:
textRequest
.
Stream
,
}
if
claudeRequest
.
MaxTokensToSample
==
0
{
...
...
@@ -63,6 +64,7 @@ func requestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*ClaudeR
StopSequences
:
nil
,
Temperature
:
textRequest
.
Temperature
,
TopP
:
textRequest
.
TopP
,
TopK
:
textRequest
.
TopK
,
Stream
:
textRequest
.
Stream
,
}
if
claudeRequest
.
MaxTokens
==
0
{
...
...
web/.prettierrc.mjs
→
web/.prettierrc.mjs
View file @
354e1df3
module.exports = require("@so1ve/prettier-config");
\ No newline at end of file
module.exports = require("@so1ve/prettier-config");
web/src/helpers/render.js
View file @
354e1df3
...
...
@@ -8,39 +8,37 @@ export function renderText(text, limit) {
return
text
;
}
/**
* Render group tags based on the input group string
* @param {string} group - The input group string
* @returns {JSX.Element} - The rendered group tags
*/
export
function
renderGroup
(
group
)
{
if
(
group
===
''
)
{
return
<
Tag
size
=
'large'
>
default
<
/Tag>
;
return
<
Tag
size
=
'large'
key
=
'default'
>
default
<
/Tag>
;
}
let
groups
=
group
.
split
(
','
);
groups
.
sort
();
const
tagColors
=
{
'vip'
:
'yellow'
,
'pro'
:
'yellow'
,
'svip'
:
'red'
,
'premium'
:
'red'
};
const
groups
=
group
.
split
(
','
).
sort
();
return
(
<>
{
groups
.
map
((
group
)
=>
{
if
(
group
===
'vip'
||
group
===
'pro'
)
{
return
(
<
Tag
size
=
'large'
color
=
'yellow'
>
{
group
}
<
/Tag
>
);
}
else
if
(
group
===
'svip'
||
group
===
'premium'
)
{
return
(
<
Tag
size
=
'large'
color
=
'red'
>
{
group
}
<
/Tag
>
);
}
if
(
group
===
'default'
)
{
return
<
Tag
size
=
'large'
>
{
group
}
<
/Tag>
;
}
else
{
return
(
<
Tag
size
=
'large'
color
=
{
stringToColor
(
group
)}
>
{
group
}
<
/Tag
>
);
}
})}
<
/
>
<
span
key
=
{
group
}
>
{
groups
.
map
((
group
)
=>
(
<
Tag
size
=
'large'
color
=
{
tagColors
[
group
]
||
stringToColor
(
group
)}
key
=
{
group
}
>
{
group
}
<
/Tag
>
))}
<
/span
>
);
}
...
...
web/src/pages/Setting/index.js
View file @
354e1df3
import
React
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Layout
,
TabPane
,
Tabs
}
from
'@douyinfe/semi-ui'
;
import
{
useNavigate
,
useLocation
}
from
'react-router-dom'
;
import
SystemSetting
from
'../../components/SystemSetting'
;
import
{
isRoot
}
from
'../../helpers'
;
import
OtherSetting
from
'../../components/OtherSetting'
;
import
PersonalSetting
from
'../../components/PersonalSetting'
;
import
OperationSetting
from
'../../components/OperationSetting'
;
import
{
Layout
,
TabPane
,
Tabs
}
from
'@douyinfe/semi-ui'
;
const
Setting
=
()
=>
{
const
navigate
=
useNavigate
();
const
location
=
useLocation
();
const
[
tabActiveKey
,
setTabActiveKey
]
=
useState
(
'1'
);
let
panes
=
[
{
tab
:
'个人设置'
,
content
:
<
PersonalSetting
/>
,
itemKey
:
'
1
'
,
itemKey
:
'
personal
'
,
},
];
...
...
@@ -19,28 +23,44 @@ const Setting = () => {
panes
.
push
({
tab
:
'运营设置'
,
content
:
<
OperationSetting
/>
,
itemKey
:
'
2
'
,
itemKey
:
'
operation
'
,
});
panes
.
push
({
tab
:
'系统设置'
,
content
:
<
SystemSetting
/>
,
itemKey
:
'
3
'
,
itemKey
:
'
system
'
,
});
panes
.
push
({
tab
:
'其他设置'
,
content
:
<
OtherSetting
/>
,
itemKey
:
'
4
'
,
itemKey
:
'
other
'
,
});
}
const
onChangeTab
=
(
key
)
=>
{
setTabActiveKey
(
key
);
navigate
(
`?tab=
${
key
}
`
);
};
useEffect
(()
=>
{
const
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
tab
=
searchParams
.
get
(
'tab'
);
if
(
tab
)
{
setTabActiveKey
(
tab
);
}
else
{
onChangeTab
(
'personal'
);
}
},
[
location
.
search
]);
return
(
<
div
>
<
Layout
>
<
Layout
.
Content
>
<
Tabs
type
=
'line'
defaultActiveKey
=
'1'
>
<
Tabs
type
=
'line'
activeKey
=
{
tabActiveKey
}
onChange
=
{(
key
)
=>
onChangeTab
(
key
)}
>
{
panes
.
map
((
pane
)
=>
(
<
TabPane
itemKey
=
{
pane
.
itemKey
}
tab
=
{
pane
.
tab
}
key
=
{
pane
.
itemKey
}
>
{
pane
.
content
}
{
tabActiveKey
===
pane
.
itemKey
&&
pane
.
content
}
<
/TabPane
>
))}
<
/Tabs
>
...
...
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