HeadBar.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import { Link } from "react-router-dom";
  2. import { Layout, Col, Row, Space } from "antd";
  3. import { useIntl } from "react-intl";
  4. import type { MenuProps } from "antd";
  5. import { Menu } from "antd";
  6. import img_banner from "../../assets/library/images/wikipali_logo_library.svg";
  7. import UiLangSelect from "../general/UiLangSelect";
  8. import SignInAvatar from "../auth/SignInAvatar";
  9. import ToStudio from "../auth/ToStudio";
  10. const { Header } = Layout;
  11. const onClick: MenuProps["onClick"] = (e) => {
  12. console.log("click ", e);
  13. };
  14. type IWidgetHeadBar = {
  15. selectedKeys?: string;
  16. };
  17. const Widget = ({ selectedKeys = "" }: IWidgetHeadBar) => {
  18. //Library head bar
  19. const intl = useIntl(); //i18n
  20. // TODO
  21. const items: MenuProps["items"] = [
  22. {
  23. label: (
  24. <Link to="/community/list">
  25. {intl.formatMessage({
  26. id: "columns.library.community.title",
  27. })}
  28. </Link>
  29. ),
  30. key: "community",
  31. },
  32. {
  33. label: (
  34. <Link to="/palicanon/list">
  35. {intl.formatMessage({
  36. id: "columns.library.palicanon.title",
  37. })}
  38. </Link>
  39. ),
  40. key: "palicanon",
  41. },
  42. {
  43. label: (
  44. <Link to="/course/list">
  45. {intl.formatMessage({ id: "columns.library.course.title" })}
  46. </Link>
  47. ),
  48. key: "course",
  49. },
  50. {
  51. label: (
  52. <Link to="/dict/recent">
  53. {intl.formatMessage({ id: "columns.library.dict.title" })}
  54. </Link>
  55. ),
  56. key: "dict",
  57. },
  58. {
  59. label: (
  60. <Link to="/anthology/list">
  61. {intl.formatMessage({
  62. id: "columns.library.anthology.title",
  63. })}
  64. </Link>
  65. ),
  66. key: "anthology",
  67. },
  68. {
  69. label: (
  70. <a
  71. href="https://asset-hk.wikipali.org/help/zh-Hans"
  72. target="_blank"
  73. rel="noreferrer"
  74. >
  75. {intl.formatMessage({ id: "columns.library.help.title" })}
  76. </a>
  77. ),
  78. key: "help",
  79. },
  80. {
  81. label: (
  82. <Space>
  83. {intl.formatMessage({ id: "columns.library.more.title" })}
  84. </Space>
  85. ),
  86. key: "more",
  87. children: [
  88. {
  89. label: (
  90. <a
  91. href="https://asset-hk.wikipali.org/handbook/zh-Hans"
  92. target="_blank"
  93. rel="noreferrer"
  94. >
  95. {intl.formatMessage({
  96. id: "columns.library.palihandbook.title",
  97. })}
  98. </a>
  99. ),
  100. key: "palihandbook",
  101. },
  102. {
  103. label: (
  104. <Link to="/calendar">
  105. {intl.formatMessage({
  106. id: "columns.library.calendar.title",
  107. })}
  108. </Link>
  109. ),
  110. key: "calendar",
  111. },
  112. {
  113. label: (
  114. <Link to="/convertor">
  115. {intl.formatMessage({
  116. id: "columns.library.convertor.title",
  117. })}
  118. </Link>
  119. ),
  120. key: "convertor",
  121. },
  122. {
  123. label: (
  124. <Link to="/statistics">
  125. {intl.formatMessage({
  126. id: "columns.library.statistics.title",
  127. })}
  128. </Link>
  129. ),
  130. key: "statistics",
  131. },
  132. ],
  133. },
  134. ];
  135. return (
  136. <Header className="header">
  137. <Row justify="space-between">
  138. <Col flex="100px">
  139. <Link to="/">
  140. <img
  141. alt="code"
  142. style={{ height: "3em" }}
  143. src={img_banner}
  144. />
  145. </Link>
  146. </Col>
  147. <Col span={8}>
  148. <Menu
  149. onClick={onClick}
  150. selectedKeys={[selectedKeys]}
  151. mode="horizontal"
  152. theme="dark"
  153. items={items}
  154. />
  155. </Col>
  156. <Col span={4}>
  157. <Space>
  158. <ToStudio />
  159. <SignInAvatar />
  160. <UiLangSelect />
  161. </Space>
  162. </Col>
  163. </Row>
  164. </Header>
  165. );
  166. };
  167. export default Widget;