HeadBar.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import { Link } from "react-router";
  2. import { Layout, Space } from "antd";
  3. import { FormattedMessage } 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. import ThemeSelect from "../general/ThemeSelect";
  11. import SearchButton from "../general/SearchButton";
  12. import { dashboardBasePath } from "../../utils";
  13. import NotificationIcon from "../notification/NotificationIcon";
  14. const { Header } = Layout;
  15. const onClick: MenuProps["onClick"] = (e) => {
  16. console.log("click ", e);
  17. };
  18. export const mainMenuItems: MenuProps["items"] = [
  19. {
  20. label: (
  21. <a href="/" rel="noreferrer">
  22. <FormattedMessage id="columns.library.home.title" />
  23. </a>
  24. ),
  25. key: "home",
  26. },
  27. {
  28. label: (
  29. <Link to="/community/list">
  30. <FormattedMessage id="columns.library.community.title" />
  31. </Link>
  32. ),
  33. key: "community",
  34. },
  35. {
  36. label: (
  37. <Link to="/palicanon/list">
  38. <FormattedMessage id="columns.library.palicanon.title" />
  39. </Link>
  40. ),
  41. key: "palicanon",
  42. },
  43. {
  44. label: (
  45. <Link to="/course/list">
  46. <FormattedMessage id="columns.library.course.title" />
  47. </Link>
  48. ),
  49. key: "course",
  50. },
  51. {
  52. label: (
  53. <Link to="/dict/recent">
  54. <FormattedMessage id="columns.library.dict.title" />
  55. </Link>
  56. ),
  57. key: "dict",
  58. },
  59. {
  60. label: (
  61. <Link to="/anthology/list">
  62. <FormattedMessage id="columns.library.anthology.title" />
  63. </Link>
  64. ),
  65. key: "anthology",
  66. },
  67. {
  68. label: (
  69. <a
  70. href={`${import.meta.env.VITE_REACT_APP_DOCUMENTS_SERVER}/help/zh-Hans/`}
  71. target="_blank"
  72. rel="noreferrer"
  73. >
  74. <FormattedMessage id="columns.library.help.title" />
  75. </a>
  76. ),
  77. key: "help",
  78. },
  79. {
  80. label: (
  81. <a
  82. href={
  83. dashboardBasePath() +
  84. `/anthology/0911697e-b8b2-43cf-afe3-f34a65e22bf0`
  85. }
  86. target="_blank"
  87. rel="noreferrer"
  88. >
  89. <FormattedMessage id="columns.library.palihandbook.title" />
  90. </a>
  91. ),
  92. key: "palihandbook",
  93. },
  94. {
  95. label: (
  96. <a
  97. href={`${window.location.origin}/app/calendar/index.html`}
  98. target={"_blank"}
  99. rel="noreferrer"
  100. >
  101. <FormattedMessage id="columns.library.calendar.title" />
  102. </a>
  103. ),
  104. key: "calendar",
  105. },
  106. {
  107. label: (
  108. <a
  109. href={`${window.location.origin}/app/tools/unicode.html`}
  110. target={"_blank"}
  111. rel="noreferrer"
  112. >
  113. <FormattedMessage id="columns.library.convertor.title" />
  114. </a>
  115. ),
  116. key: "convertor",
  117. },
  118. {
  119. label: (
  120. <a
  121. href={`${window.location.origin}/app/statistics/`}
  122. target={"_blank"}
  123. rel="noreferrer"
  124. >
  125. <FormattedMessage id="columns.library.statistics.title" />
  126. </a>
  127. ),
  128. key: "statistics",
  129. },
  130. {
  131. label: <Link to="/discussion/list">Discussion(alpha)</Link>,
  132. key: "discussion",
  133. },
  134. ];
  135. type IWidgetHeadBar = {
  136. selectedKeys?: string;
  137. };
  138. const HeadBarWidget = ({ selectedKeys = "" }: IWidgetHeadBar) => {
  139. //Library head bar
  140. return (
  141. <Header
  142. className="header"
  143. style={{
  144. lineHeight: "44px",
  145. height: 44,
  146. paddingLeft: 10,
  147. paddingRight: 10,
  148. }}
  149. >
  150. <div
  151. style={{
  152. display: "flex",
  153. width: "100%",
  154. justifyContent: "space-between",
  155. }}
  156. >
  157. <div style={{ width: 100 }}>
  158. <Link to="/">
  159. <img alt="code" style={{ height: "3em" }} src={img_banner} />
  160. </Link>
  161. </div>
  162. <div style={{ width: 500 }}>
  163. <Menu
  164. onClick={onClick}
  165. selectedKeys={[selectedKeys]}
  166. mode="horizontal"
  167. theme="dark"
  168. items={mainMenuItems}
  169. />
  170. </div>
  171. <Space>
  172. <Link to="/download/download">下载</Link>
  173. <SearchButton />
  174. <ToStudio />
  175. <SignInAvatar />
  176. <NotificationIcon />
  177. <UiLangSelect />
  178. <ThemeSelect />
  179. </Space>
  180. </div>
  181. </Header>
  182. );
  183. };
  184. export default HeadBarWidget;