skeleton-index-modal.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import {
  2. Cell,
  3. CellGroup,
  4. Skeleton,
  5. SkeletonAvatar,
  6. SkeletonParagraph
  7. } from 'vant';
  8. import { defineComponent, onMounted, reactive, watch } from 'vue';
  9. import styles from './index.module.less';
  10. export default defineComponent({
  11. name: 'skeleton-modal',
  12. props: {
  13. show: {
  14. type: Boolean,
  15. default: false
  16. },
  17. showCount: {
  18. type: Array,
  19. default: () => [1, 2, 3, 4, 5]
  20. }
  21. },
  22. setup(props, { slots }) {
  23. const forms = reactive({
  24. loading: false
  25. });
  26. onMounted(() => {
  27. forms.loading = props.show;
  28. });
  29. watch(
  30. () => props.show,
  31. () => {
  32. forms.loading = props.show;
  33. }
  34. );
  35. return () => (
  36. <Skeleton loading={forms.loading} style="flex-wrap: wrap">
  37. {{
  38. template: () => (
  39. <div
  40. style={{
  41. height: `calc(100vh - var(--header-height))`,
  42. overflow: 'hidden',
  43. width: '100%'
  44. }}>
  45. {props.showCount.map(() => (
  46. <CellGroup inset class={styles.lessonCellGroup}>
  47. <Cell center class={styles.timeCell}>
  48. {{
  49. title: () => <SkeletonParagraph rowWidth={'40%'} />,
  50. value: () => <SkeletonParagraph rowWidth={'40%'} />
  51. }}
  52. </Cell>
  53. <Cell center border={false} valueClass={styles.skeletonClass}>
  54. {{
  55. icon: () => <SkeletonAvatar class={styles.iconStudent} />,
  56. title: () => (
  57. <div class={styles.userInfo}>
  58. <SkeletonParagraph
  59. class={styles.name}
  60. rowWidth={'40%'}
  61. />
  62. <SkeletonParagraph
  63. class={styles.subject}
  64. rowWidth={'50%'}
  65. />
  66. </div>
  67. ),
  68. value: () => (
  69. <SkeletonParagraph
  70. class={styles.people}
  71. rowWidth={'40%'}
  72. />
  73. )
  74. }}
  75. </Cell>
  76. <Cell center class={styles.musicCell}>
  77. {{
  78. title: () => (
  79. <SkeletonParagraph
  80. class={styles.musicInfo}
  81. rowWidth={'40%'}
  82. style={{ marginTop: '10px' }}
  83. />
  84. ),
  85. label: () => (
  86. <SkeletonParagraph
  87. class={styles.rowGroup}
  88. rowWidth={'80%'}
  89. />
  90. )
  91. }}
  92. </Cell>
  93. </CellGroup>
  94. ))}
  95. </div>
  96. ),
  97. default: () => slots.default && slots.default()
  98. }}
  99. </Skeleton>
  100. );
  101. }
  102. });