2026-08-17 18:37:21 +08:00
|
|
|
import { useEffect, useState } from 'react';
|
2026-08-17 19:50:50 +08:00
|
|
|
import { useNavigate, useLocation } from 'react-router-dom';
|
2026-08-17 18:37:21 +08:00
|
|
|
import Icon from './Icons';
|
2026-08-17 19:50:50 +08:00
|
|
|
import { PAGE_ORDER, usePageIndex } from '../utils/pageNav';
|
|
|
|
|
import { Avatar, AvatarImage, AvatarFallback } from '@appica/ui-react/avatar'
|
2026-08-17 18:37:21 +08:00
|
|
|
|
|
|
|
|
/* =========================================================
|
2026-08-17 19:50:50 +08:00
|
|
|
共享页眉 —— 所有大屏页面统一(由 ScreenLayout 注入)
|
|
|
|
|
状态文案按当前页面自动识别;左右键循环 + 可点击按钮切换
|
2026-08-17 18:37:21 +08:00
|
|
|
========================================================= */
|
|
|
|
|
|
2026-08-17 19:50:50 +08:00
|
|
|
const STATUS_BY_PATH = {
|
|
|
|
|
'/': '数据实时',
|
|
|
|
|
'/twin': '3D 实时',
|
|
|
|
|
'/screen': '媒体播放',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function PageHeader() {
|
2026-08-17 18:37:21 +08:00
|
|
|
const navigate = useNavigate();
|
2026-08-17 19:50:50 +08:00
|
|
|
const location = useLocation();
|
2026-08-17 18:37:21 +08:00
|
|
|
const [now, setNow] = useState(new Date());
|
2026-08-17 19:50:50 +08:00
|
|
|
const pageIdx = usePageIndex();
|
2026-08-17 18:37:21 +08:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const iv = setInterval(() => setNow(new Date()), 1000);
|
|
|
|
|
return () => clearInterval(iv);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const dateStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
|
|
|
|
const week = ['日', '一', '二', '三', '四', '五', '六'][now.getDay()];
|
|
|
|
|
const timeStr = now.toLocaleTimeString('zh-CN', { hour12: false });
|
2026-08-17 19:50:50 +08:00
|
|
|
const status = STATUS_BY_PATH[location.pathname] || '在线';
|
|
|
|
|
|
|
|
|
|
// 循环中的相邻页面(左/右)
|
|
|
|
|
const n = PAGE_ORDER.length;
|
|
|
|
|
const left = pageIdx >= 0 ? PAGE_ORDER[(pageIdx - 1 + n) % n] : null;
|
|
|
|
|
const right = pageIdx >= 0 ? PAGE_ORDER[(pageIdx + 1) % n] : null;
|
2026-08-17 18:37:21 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<header className="bd-header">
|
|
|
|
|
<div className="bd-header-left">
|
2026-08-17 19:50:50 +08:00
|
|
|
{/* <span className="bd-logo">
|
|
|
|
|
<Image src="/logo.png" alt="Logo" />
|
|
|
|
|
</span> */}
|
|
|
|
|
<Avatar size="lg">
|
|
|
|
|
<AvatarImage src="/public/logo.png" alt="" />
|
|
|
|
|
</Avatar>
|
2026-08-17 18:37:21 +08:00
|
|
|
<div className="bd-header-titles">
|
|
|
|
|
<h1 className="bd-header-title">昆明市大学生创业园 <span className="bd-header-title-accent">· OPC 智能园区数字运营中心</span></h1>
|
2026-08-17 19:50:50 +08:00
|
|
|
<div className="bd-header-sub">云南省首家政府主办大学生创业孵化园区 · <span className="bd-header-content—highlights">空间+孵化+融资+政策+资源+AI赋能+综合服务</span> 七位一体</div>
|
2026-08-17 18:37:21 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bd-header-right">
|
2026-08-17 19:50:50 +08:00
|
|
|
<div className="bd-nav-keys" title="左右方向键或点击切换页面">
|
|
|
|
|
{left && (
|
|
|
|
|
<button className="bd-nav-key" onClick={() => navigate(left.path)}>
|
|
|
|
|
<Icon name="chevron-left" size={13} />
|
|
|
|
|
{left.label}
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
<span className="bd-nav-dot">·</span>
|
|
|
|
|
{right && (
|
|
|
|
|
<button className="bd-nav-key" onClick={() => navigate(right.path)}>
|
|
|
|
|
{right.label}
|
|
|
|
|
<Icon name="chevron-right" size={13} />
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-08-17 18:37:21 +08:00
|
|
|
<div className="bd-live">
|
|
|
|
|
<span className="bd-live-dot" />
|
|
|
|
|
{status}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bd-clock">
|
|
|
|
|
<div className="bd-clock-time">{timeStr}</div>
|
|
|
|
|
<div className="bd-clock-date">{dateStr} 周{week}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
);
|
|
|
|
|
}
|