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