You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2 KiB

  1. import { List, NavBar, SpinLoading, Toast } from 'antd-mobile';
  2. import { UnorderedListOutline, SetOutline, UploadOutline, LoopOutline } from 'antd-mobile-icons';
  3. import { useNavigate } from 'react-router-dom';
  4. import { useAppDispatch, useAppSelector } from '../utils/hooks';
  5. import { syncBaseData } from '../store/features/baseData';
  6. export default function Mine2() {
  7. const navigate = useNavigate();
  8. const dispatch = useAppDispatch();
  9. const baseState = useAppSelector((state) => state.baseData);
  10. const onSync = async () => {
  11. const res = await dispatch(syncBaseData()).unwrap();
  12. if (!res.success) {
  13. Toast.show(res.message);
  14. }
  15. };
  16. return (
  17. <div>
  18. <NavBar className="bg-white" back={null}>
  19. </NavBar>
  20. <div className="home-page-content overflow-x-hidden overflow-y-auto pt-3">
  21. <List>
  22. <List.Item prefix={<UnorderedListOutline />} onClick={() => navigate('/measure/records')}>
  23. </List.Item>
  24. <List.Item prefix={<UploadOutline />} onClick={() => navigate('/measure/upload')}>
  25. </List.Item>
  26. <List.Item prefix={<SetOutline />} onClick={() => navigate('/profile/setting')}>
  27. </List.Item>
  28. <List.Item prefix={<LoopOutline />} onClick={onSync}>
  29. <div className="flex justify-between">
  30. <span></span>
  31. {baseState.syncBaseProgress.finish ? (
  32. <div>
  33. {baseState.syncBaseProgress.error ? (
  34. <span className="text-xs text-[red]">{baseState.syncBaseProgress.msg}</span>
  35. ) : (
  36. <span className="text-xs text-[green]">
  37. {baseState.syncBaseProgress.progress >= 90 ? '同步完成' : ''}
  38. </span>
  39. )}
  40. </div>
  41. ) : (
  42. <div className="flex items-center gap-2">
  43. <span className="text-xs">{`${baseState.syncBaseProgress.progress}%`}</span>
  44. <SpinLoading style={{ '--size': '16px' }} />
  45. </div>
  46. )}
  47. </div>
  48. </List.Item>
  49. </List>
  50. </div>
  51. </div>
  52. );
  53. }