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

index.tsx 1.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * @Author: 赵伟
  3. * @Date: 2024-04-16 13:58:08
  4. * @Description: 主动学习实验详情
  5. */
  6. import PageTitle from '@/components/PageTitle';
  7. import { getActiveLearnInfoReq } from '@/services/activeLearn';
  8. import { safeInvoke } from '@/utils/functional';
  9. import { to } from '@/utils/promise';
  10. import { useParams } from '@umijs/max';
  11. import { useEffect, useState } from 'react';
  12. import ActiveLearnBasic from '../components/ActiveLearnBasic';
  13. import { ActiveLearnData } from '../types';
  14. import styles from './index.less';
  15. function ActiveLearnInfo() {
  16. const params = useParams();
  17. const id = safeInvoke(Number)(params.id);
  18. const [info, setInfo] = useState<ActiveLearnData | undefined>(undefined);
  19. useEffect(() => {
  20. if (id) {
  21. getActiveLearnInfo();
  22. }
  23. }, []);
  24. // 获取详情
  25. const getActiveLearnInfo = async () => {
  26. const [res] = await to(getActiveLearnInfoReq({ id: id }));
  27. if (res && res.data) {
  28. setInfo(res.data);
  29. }
  30. };
  31. return (
  32. <div className={styles['auto-ml-info']}>
  33. <PageTitle title="实验详情"></PageTitle>
  34. <div className={styles['auto-ml-info__content']}>
  35. <ActiveLearnBasic info={info} />
  36. </div>
  37. </div>
  38. );
  39. }
  40. export default ActiveLearnInfo;