index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import React, { useContext, useEffect } from 'react';
  2. import { Card, Grid, Header, Segment } from 'semantic-ui-react';
  3. import { API, showError, showNotice, timestamp2string } from '../../helpers';
  4. import { StatusContext } from '../../context/Status';
  5. const Home = () => {
  6. const [statusState, statusDispatch] = useContext(StatusContext);
  7. const displayNotice = async () => {
  8. const res = await API.get('/api/notice');
  9. const { success, message, data } = res.data;
  10. if (success) {
  11. let oldNotice = localStorage.getItem('notice');
  12. if (data !== oldNotice && data !== '') {
  13. showNotice(data);
  14. localStorage.setItem('notice', data);
  15. }
  16. } else {
  17. showError(message);
  18. }
  19. };
  20. const getStartTimeString = () => {
  21. const timestamp = statusState?.status?.start_time;
  22. return timestamp2string(timestamp);
  23. };
  24. useEffect(() => {
  25. displayNotice().then();
  26. }, []);
  27. return (
  28. <>
  29. <Segment>
  30. <Header as='h3'>系统状况</Header>
  31. <Grid columns={2} stackable>
  32. <Grid.Column>
  33. <Card fluid>
  34. <Card.Content>
  35. <Card.Header>系统信息</Card.Header>
  36. <Card.Meta>系统信息总览</Card.Meta>
  37. <Card.Description>
  38. <p>名称:{statusState?.status?.system_name}</p>
  39. <p>版本:{statusState?.status?.version}</p>
  40. <p>
  41. 源码:
  42. <a
  43. href='https://github.com/songquanpeng/message-pusher'
  44. target='_blank'
  45. >
  46. https://github.com/songquanpeng/message-pusher
  47. </a>
  48. </p>
  49. <p>启动时间:{getStartTimeString()}</p>
  50. <p>自从上次启动已发送消息数目:{statusState?.status?.message_count}</p>
  51. <p>自从上次启动新注册用户数目:{statusState?.status?.user_count}</p>
  52. </Card.Description>
  53. </Card.Content>
  54. </Card>
  55. </Grid.Column>
  56. <Grid.Column>
  57. <Card fluid>
  58. <Card.Content>
  59. <Card.Header>系统配置</Card.Header>
  60. <Card.Meta>系统配置总览</Card.Meta>
  61. <Card.Description>
  62. <p>
  63. 邮箱验证:
  64. {statusState?.status?.email_verification === true
  65. ? '已启用'
  66. : '未启用'}
  67. </p>
  68. <p>
  69. GitHub 身份验证:
  70. {statusState?.status?.github_oauth === true
  71. ? '已启用'
  72. : '未启用'}
  73. </p>
  74. <p>
  75. 微信身份验证:
  76. {statusState?.status?.wechat_login === true
  77. ? '已启用'
  78. : '未启用'}
  79. </p>
  80. <p>
  81. Turnstile 用户校验:
  82. {statusState?.status?.turnstile_check === true
  83. ? '已启用'
  84. : '未启用'}
  85. </p>
  86. <p>
  87. 全局消息持久化:
  88. {statusState?.status?.message_persistence === true
  89. ? '已启用'
  90. : '未启用'}
  91. </p>
  92. <p>
  93. 全局消息渲染:
  94. {statusState?.status?.message_render === true
  95. ? '已启用'
  96. : '未启用'}
  97. </p>
  98. </Card.Description>
  99. </Card.Content>
  100. </Card>
  101. </Grid.Column>
  102. </Grid>
  103. </Segment>
  104. </>
  105. );
  106. };
  107. export default Home;