LeftSider.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { Link } from "react-router-dom";
  2. import { useIntl } from "react-intl";
  3. import { useParams } from "react-router-dom";
  4. import type { MenuProps } from 'antd';
  5. import { Affix , Layout} from "antd";
  6. import { Menu } from 'antd';
  7. import { AppstoreOutlined, HomeOutlined, TeamOutlined } from '@ant-design/icons';
  8. const { Sider } = Layout;
  9. const onClick: MenuProps['onClick'] = e => {
  10. console.log('click ', e);
  11. };
  12. type IWidgetHeadBar ={
  13. selectedKeys?: string
  14. }
  15. const Widget = ({selectedKeys = ''}: IWidgetHeadBar) => {
  16. //Library head bar
  17. const intl = useIntl();//i18n
  18. const { studioname } = useParams();
  19. // TODO
  20. const linkPalicanon = "/studio/"+studioname+"/palicanon";
  21. const linkRecent = "/studio/"+studioname+"/recent";
  22. const linkChannel = "/studio/"+studioname+"/channel";
  23. const linkGroup = "/studio/"+studioname+"/group";
  24. const linkUserdict = "/studio/"+studioname+"/dict";
  25. const linkTerm = "/studio/"+studioname+"/term";
  26. const linkArticle = "/studio/"+studioname+"/article";
  27. const linkAnthology = "/studio/"+studioname+"/anthology";
  28. const linkAnalysis = "/studio/"+studioname+"/analysis";
  29. const items: MenuProps['items'] = [
  30. {
  31. label: "常用",
  32. key: 'basic',
  33. icon: <HomeOutlined />,
  34. children:[
  35. {
  36. label: (<Link to = {linkPalicanon}>{intl.formatMessage({ id: "columns.studio.palicanon.title" })}</Link>),
  37. key: 'palicanon',
  38. },
  39. {
  40. label: (<Link to = {linkRecent}>{intl.formatMessage({ id: "columns.studio.recent.title" })}</Link>),
  41. key: 'recent',
  42. },
  43. {
  44. label: (<Link to = {linkChannel}>{intl.formatMessage({ id: "columns.studio.channel.title" })}</Link>),
  45. key: 'channel',
  46. },
  47. {
  48. label: (<Link to = {linkAnalysis}>{intl.formatMessage({ id: "columns.studio.analysis.title" })}</Link>),
  49. key: 'analysis',
  50. },
  51. ]
  52. },
  53. {
  54. label: "高级",
  55. key: 'advance',
  56. icon: <AppstoreOutlined/>,
  57. children:[
  58. {
  59. label: (<Link to = {linkUserdict}>{intl.formatMessage({ id: "columns.studio.userdict.title" })}</Link>),
  60. key: 'userdict',
  61. },
  62. {
  63. label: (<Link to = {linkTerm}>{intl.formatMessage({ id: "columns.studio.term.title" })}</Link>),
  64. key: 'term',
  65. },
  66. {
  67. label: (<Link to = {linkArticle}>{intl.formatMessage({ id: "columns.studio.article.title" })}</Link>),
  68. key: 'article',
  69. },
  70. {
  71. label: (<Link to = {linkAnthology}>{intl.formatMessage({ id: "columns.studio.anthology.title" })}</Link>),
  72. key: 'anthology',
  73. },
  74. ],
  75. },
  76. {
  77. label: "协作",
  78. key: 'collaboration',
  79. icon:<TeamOutlined />,
  80. children:[
  81. {
  82. label: (<Link to = {linkGroup}>{intl.formatMessage({ id: "columns.studio.group.title" })}</Link>),
  83. key: 'group',
  84. },
  85. ]
  86. },
  87. ]
  88. return (
  89. <Affix offsetTop={0} >
  90. <Sider
  91. width={200}
  92. breakpoint="lg"
  93. className="site-layout-background">
  94. <Menu
  95. theme="dark"
  96. onClick={onClick}
  97. defaultSelectedKeys={[selectedKeys]}
  98. defaultOpenKeys={['basic','advance','collaboration']}
  99. mode="inline"
  100. items={items}
  101. />
  102. </Sider>
  103. </Affix>
  104. );
  105. };
  106. export default Widget;