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
5e220430
authored
Mar 02, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Add self-use mode and demo site mode indicators to HeaderBar
parent
8c0219eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
5 deletions
+52
-5
controller/misc.go
+1
-0
web/src/components/HeaderBar.js
+51
-5
No files found.
controller/misc.go
View file @
5e220430
...
...
@@ -67,6 +67,7 @@ func GetStatus(c *gin.Context) {
"mj_notify_enabled"
:
setting
.
MjNotifyEnabled
,
"chats"
:
setting
.
Chats
,
"demo_site_enabled"
:
setting
.
DemoSiteEnabled
,
"self_use_mode_enabled"
:
setting
.
SelfUseModeEnabled
,
},
})
return
...
...
web/src/components/HeaderBar.js
View file @
5e220430
...
...
@@ -21,15 +21,17 @@ import {
IconUser
,
IconLanguage
}
from
'@douyinfe/semi-icons'
;
import
{
Avatar
,
Button
,
Dropdown
,
Layout
,
Nav
,
Switch
}
from
'@douyinfe/semi-ui'
;
import
{
Avatar
,
Button
,
Dropdown
,
Layout
,
Nav
,
Switch
,
Tag
}
from
'@douyinfe/semi-ui'
;
import
{
stringToColor
}
from
'../helpers/render'
;
import
Text
from
'@douyinfe/semi-ui/lib/es/typography/text'
;
import
{
StyleContext
}
from
'../context/Style/index.js'
;
import
{
StatusContext
}
from
'../context/Status/index.js'
;
const
HeaderBar
=
()
=>
{
const
{
t
,
i18n
}
=
useTranslation
();
const
[
userState
,
userDispatch
]
=
useContext
(
UserContext
);
const
[
styleState
,
styleDispatch
]
=
useContext
(
StyleContext
);
const
[
statusState
,
statusDispatch
]
=
useContext
(
StatusContext
);
let
navigate
=
useNavigate
();
const
[
currentLang
,
setCurrentLang
]
=
useState
(
i18n
.
language
);
...
...
@@ -40,6 +42,10 @@ const HeaderBar = () => {
const
isNewYear
=
(
currentDate
.
getMonth
()
===
0
&&
currentDate
.
getDate
()
===
1
);
// Check if self-use mode is enabled
const
isSelfUseMode
=
statusState
?.
status
?.
self_use_mode_enabled
||
false
;
const
isDemoSiteMode
=
statusState
?.
status
?.
demo_site_enabled
||
false
;
let
buttons
=
[
{
text
:
t
(
'首页'
),
...
...
@@ -166,7 +172,7 @@ const HeaderBar = () => {
onSelect
=
{(
key
)
=>
{}}
header
=
{
styleState
.
isMobile
?{
logo
:
(
<>
<
div
style
=
{{
display
:
'flex'
,
alignItems
:
'center'
,
position
:
'relative'
}}
>
{
!
styleState
.
showSider
?
<
Button
icon
=
{
<
IconMenu
/>
}
theme
=
"light"
aria
-
label
=
{
t
(
'展开侧边栏'
)}
onClick
=
{
...
...
@@ -176,13 +182,52 @@ const HeaderBar = () => {
()
=>
styleDispatch
({
type
:
'SET_SIDER'
,
payload
:
false
})
}
/
>
}
<
/
>
{(
isSelfUseMode
||
isDemoSiteMode
)
&&
(
<
Tag
color
=
{
isSelfUseMode
?
'purple'
:
'blue'
}
style
=
{{
position
:
'absolute'
,
top
:
'-8px'
,
right
:
'-15px'
,
fontSize
:
'0.7rem'
,
padding
:
'0 4px'
,
height
:
'auto'
,
lineHeight
:
'1.2'
,
zIndex
:
1
,
pointerEvents
:
'none'
}}
>
{
isSelfUseMode
?
t
(
'自用模式'
)
:
t
(
'演示站点'
)}
<
/Tag
>
)}
<
/div
>
),
}:{
logo
:
(
<
img
src
=
{
logo
}
alt
=
'logo'
/>
),
text
:
systemName
,
text
:
(
<
div
style
=
{{
position
:
'relative'
,
display
:
'inline-block'
}}
>
{
systemName
}
{(
isSelfUseMode
||
isDemoSiteMode
)
&&
(
<
Tag
color
=
{
isSelfUseMode
?
'purple'
:
'blue'
}
style
=
{{
position
:
'absolute'
,
top
:
'-10px'
,
right
:
'-25px'
,
fontSize
:
'0.7rem'
,
padding
:
'0 4px'
,
whiteSpace
:
'nowrap'
,
zIndex
:
1
,
boxShadow
:
'0 0 3px rgba(255, 255, 255, 0.7)'
}}
>
{
isSelfUseMode
?
t
(
'自用模式'
)
:
t
(
'演示站点'
)}
<
/Tag
>
)}
<
/div
>
),
}}
items
=
{
buttons
}
footer
=
{
...
...
@@ -266,7 +311,8 @@ const HeaderBar = () => {
icon
=
{
<
IconUser
/>
}
/
>
{
!
styleState
.
isMobile
&&
(
// Hide register option in self-use mode
!
styleState
.
isMobile
&&
!
isSelfUseMode
&&
(
<
Nav
.
Item
itemKey
=
{
'register'
}
text
=
{
t
(
'注册'
)}
...
...
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