增加首页导航
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
makeStyles,
|
||||
Button,
|
||||
@@ -76,6 +77,7 @@ const useStyles = makeStyles({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: tokens.spacingHorizontalS,
|
||||
cursor: 'pointer',
|
||||
},
|
||||
icon: {
|
||||
height: '32px',
|
||||
@@ -170,6 +172,7 @@ const AdminDashboard: React.FC<AdminDashboardProps> = ({
|
||||
isDarkMode = false,
|
||||
onToggleTheme
|
||||
}) => {
|
||||
const navigate = useNavigate();
|
||||
const styles = useStyles();
|
||||
const [activeTab, setActiveTab] = React.useState<TabValue>('systemSettings');
|
||||
const [postReviewSubTab, setPostReviewSubTab] = React.useState<TabValue>('pending');
|
||||
@@ -665,7 +668,7 @@ const AdminDashboard: React.FC<AdminDashboardProps> = ({
|
||||
<div className={styles.root}>
|
||||
{/* 顶栏 - 采用 MainLayout 的 Header 样式 */}
|
||||
<header className={styles.header}>
|
||||
<Text size={500} weight="semibold" className={styles.title}>
|
||||
<Text size={500} weight="semibold" className={styles.title} onClick={() => navigate('/')} title="返回首页">
|
||||
<img src={icon} alt="logo" className={styles.icon} />
|
||||
{`${SITE_TITLE} | 管理面板`}
|
||||
</Text>
|
||||
|
||||
@@ -53,10 +53,10 @@ const StatusDisplay: React.FC = () => {
|
||||
const fetchStatus = async () => {
|
||||
try {
|
||||
// Check API online status
|
||||
const teapotResponse = await fetch(`${API_CONFIG.BASE_URL}/test`);
|
||||
if (teapotResponse.status === 200) {
|
||||
const TestAPIResponse = await fetch(`${API_CONFIG.BASE_URL}/test`);
|
||||
if (TestAPIResponse.status === 200) {
|
||||
setIsApiOnline(true);
|
||||
} else if (teapotResponse.status === 503) {
|
||||
} else if (TestAPIResponse.status === 503) {
|
||||
setIsApiOnline(false);
|
||||
if (location.pathname !== '/init') {
|
||||
navigate('/init');
|
||||
@@ -88,7 +88,7 @@ const StatusDisplay: React.FC = () => {
|
||||
};
|
||||
|
||||
fetchStatus();
|
||||
const interval = setInterval(fetchStatus, 30000); // Refresh every 30 seconds
|
||||
const interval = setInterval(fetchStatus, 60000); // Refresh every 30 seconds
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [navigate, location.pathname]);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { makeStyles, Text, tokens, Button } from '@fluentui/react-components';
|
||||
import { WeatherSunny24Regular, WeatherMoon24Regular, Code24Regular } from '@fluentui/react-icons';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import icon from '/icon.png';
|
||||
import { SITE_TITLE, EnableCodeIcon, RepoUrl } from '../../config';
|
||||
@@ -19,6 +20,12 @@ const useStyles = makeStyles({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: tokens.spacingHorizontalS,
|
||||
cursor: 'pointer',
|
||||
textDecoration: 'none',
|
||||
color: 'inherit',
|
||||
'&:hover': {
|
||||
opacity: 0.8,
|
||||
},
|
||||
},
|
||||
icon: {
|
||||
height: '32px',
|
||||
@@ -43,10 +50,15 @@ interface HeaderProps {
|
||||
|
||||
const Header = ({ isDarkMode, onToggleTheme, onToggleSidebar }: HeaderProps) => {
|
||||
const styles = useStyles();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleTitleClick = () => {
|
||||
navigate('/');
|
||||
};
|
||||
|
||||
return (
|
||||
<header className={styles.header}>
|
||||
<Text size={500} weight="semibold" className={styles.title}>
|
||||
<Text size={500} weight="semibold" className={styles.title} onClick={handleTitleClick}>
|
||||
<img src={icon} alt="logo" className={styles.icon} />
|
||||
{SITE_TITLE}
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user