BasicLayout.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // BasicLayout.tsx
  2. import React, { useState } from 'react';
  3. import { Layout, Row, Col, ConfigProvider, Image } from 'antd';
  4. import { TabBar } from 'antd-mobile';
  5. import logo from '../assets/imgs/logo-v3.jpg';
  6. import NavbarFloat from './NavbarFloat';
  7. import NavMenu from './NavMenu';
  8. import StatusBar, { StatusBarProps } from './StateBar';
  9. import AboutPage from '@/pages/demo/AboutPage';
  10. import HomePage from '@/pages/demo/HomePage';
  11. import RegisterPage from '@/pages/patient/register';
  12. import WorklistPage from '@/pages/patient/worklist';
  13. import HistorylistPage from '@/pages/patient/HistoryList';
  14. import ArchivelistPage from '@/pages/patient/ArchiveList';
  15. import BinPage from '@/pages/patient/Bin';
  16. import OutputlistPage from '@/pages/patient/OutputList';
  17. // import { Link } from 'react-router-dom';
  18. // import { MenuOutlined } from '@ant-design/icons';
  19. // const { Content, Footer } = Layout;
  20. interface BasicLayoutProps {
  21. children: React.ReactNode;
  22. }
  23. // //自定义breakpoint
  24. // const breakpoint = {
  25. // xs: 480, // 小屏幕设备(手机)
  26. // sm: 576, // 中小屏幕设备(平板)
  27. // md: 768, // 中等屏幕设备(小桌面显示器)
  28. // lg: 992, // 大屏幕设备(桌面显示器)
  29. // xl: 1200, // 超大屏幕设备(大桌面显示器)
  30. // xxl: 1600 // 超超大屏幕设备(超大桌面显示器)
  31. // };
  32. const BasicLayout: React.FC<BasicLayoutProps> = () => {
  33. const status: StatusBarProps = {
  34. diskStatus: 'available', // 可用状态
  35. batteryLevel: 0,
  36. wifiStrength: 0,
  37. heatCapacity: 0,
  38. };
  39. //使用key state更新整个basic layout ,用于加载新的内容组件
  40. const [currentKey, setCurrentKey] = useState('register');
  41. // key和内容组件的映射
  42. const contentMap = {
  43. sub2: <AboutPage />,
  44. process: <HomePage />,
  45. register: <RegisterPage />,
  46. worklist: <WorklistPage />,
  47. historylist: <HistorylistPage />,
  48. archivelist: <ArchivelistPage />,
  49. bin: <BinPage />,
  50. outputlist: <OutputlistPage />,
  51. };
  52. //感知菜单项点击
  53. const handleMenuClick = (key: string) => {
  54. setCurrentKey(key);
  55. };
  56. return (
  57. // ConfigProvider 用于自定义 Ant Design 的主题和 breakpoints
  58. <ConfigProvider
  59. theme={
  60. {
  61. // token: {
  62. // // 自定义屏幕尺寸断点,与要求匹配
  63. // screenXS: 576, // xs: <576px
  64. // screenSM: 768, // sm: ≥768px
  65. // screenMD: 992, // md: ≥992px
  66. // screenLG: 1200, // lg: ≥1200px
  67. // screenXL: 1400, // xl: ≥1400px
  68. // screenXXL: 1600, // xxl: ≥1600px
  69. // },
  70. }
  71. }
  72. >
  73. <Layout
  74. style={{ minHeight: '100vh', border: '1px solid #ccc' }}
  75. className="h-[100vh] xl:text-[48px] lg:text-[40px] md:text-[30px] sm:text-[20px] xs:text-[15px]"
  76. >
  77. {/* 第一行:品牌和状态区域 */}
  78. <Row className="xl:h-[9vh] text-[100%]">
  79. {/* 品牌区域 */}
  80. <Col xl={4} lg={4} md={5} sm={0} xs={0} className="h-full">
  81. <Image src={logo} alt="Logo" height={'100%'} />
  82. </Col>
  83. {/* 状态区域 */}
  84. <Col
  85. xl={20}
  86. lg={20}
  87. md={19}
  88. sm={0}
  89. xs={0}
  90. className="items-center
  91. justify-end xl:flex
  92. lg:flex
  93. md:flex
  94. sm:hidden
  95. xs:hidden
  96. h-full
  97. text-[100%]"
  98. >
  99. {/* text-[100%] 用于传导父元素的字体大小,最终影响图标大小 */}
  100. <StatusBar
  101. diskStatus={status.diskStatus}
  102. batteryLevel={status.batteryLevel}
  103. wifiStrength={status.wifiStrength}
  104. heatCapacity={status.heatCapacity}
  105. />
  106. </Col>
  107. </Row>
  108. {/* 第二行:导航区域(第1列)和内容区域(第2列) */}
  109. <Row
  110. style={{
  111. flex: 1,
  112. display: 'flex',
  113. border: '1px solid red',
  114. }}
  115. className="xxl:h-[90vh] xl:h-[90vh] lg:h-[90vh] md:h-[90vh] sm:h-[90vh] xs:h-[90vh]"
  116. >
  117. {/* 导航区域 */}
  118. <Col xl={4} lg={4} md={0} sm={0} xs={0} style={{ flex: 1 }}>
  119. <NavMenu onMenuClick={handleMenuClick} />
  120. </Col>
  121. {/* 内容区域 */}
  122. <Col
  123. xl={20}
  124. lg={20}
  125. xs={24}
  126. md={24}
  127. sm={24}
  128. style={{ flex: 1, border: '1px solid blue' }}
  129. className="h-full"
  130. >
  131. {/* {children} */}
  132. {contentMap[currentKey]}
  133. </Col>
  134. </Row>
  135. {/* Tabbar:固定在底部,仅在手机屏幕显示 */}
  136. <div className="sticky bottom-0 w-full bg-red xl:hidden">
  137. <TabBar className="xl:hidden lg:hidden md:hidden sm:block xs:block">
  138. <TabBar.Item
  139. className="text-red-500"
  140. title="患者管理"
  141. key="home"
  142. icon={<div>🏠</div>}
  143. />
  144. <TabBar.Item
  145. className="text-red-500"
  146. title="检查"
  147. key="profile"
  148. icon={<div>👤</div>}
  149. />
  150. <TabBar.Item
  151. className="text-red-500"
  152. title="急诊"
  153. key="emergency"
  154. icon={<div>⚙️</div>}
  155. />
  156. <TabBar.Item
  157. className="text-red-500"
  158. title="图像处理"
  159. key="image-handling"
  160. icon={<div>⚙️</div>}
  161. />
  162. <TabBar.Item
  163. className="text-red-500"
  164. title="打印"
  165. key="print"
  166. icon={<div>⚙️</div>}
  167. />
  168. </TabBar>
  169. </div>
  170. <NavbarFloat
  171. className="fixed hidden sm:hidden xs:hidden md:block lg:hidden xl:hidden"
  172. position="right"
  173. />
  174. </Layout>
  175. </ConfigProvider>
  176. );
  177. };
  178. export default BasicLayout;