ThumbnailChildPage.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="thumbnail-child-page" @click="handleClick" :class="{ 'active': slideIndexStore === props.slideIndex || 0 }">
  3. <div class="child-page-icon">
  4. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  5. <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
  6. <line x1="9" y1="9" x2="15" y2="9"></line>
  7. <line x1="9" y1="15" x2="15" y2="15"></line>
  8. </svg>
  9. </div>
  10. <div class="child-page-label">{{ lang.ssChildPageLabel }}</div>
  11. <div class="child-page-label">{{ lang.ssPendingCount }}({{ pendingCount }} / {{ props.toolsArray?.length || 0 }})</div>
  12. </div>
  13. </template>
  14. <script lang="ts" setup>
  15. import { computed } from 'vue'
  16. import { lang } from '@/main'
  17. import { useMainStore, useSlidesStore } from '@/store'
  18. import { storeToRefs } from 'pinia'
  19. const props = defineProps<{
  20. toolsArray?: any[]
  21. slideIndex?: number
  22. }>()
  23. const mainStore = useMainStore()
  24. const { setChildPageState } = mainStore
  25. const slidesStore = useSlidesStore()
  26. const { currentSlide, slideIndex: slideIndexStore } = storeToRefs(slidesStore)
  27. // 切换页面
  28. const changeSlideIndex = (index: number) => {
  29. mainStore.setActiveElementIdList([])
  30. if (slideIndexStore.value === index) return
  31. slidesStore.updateSlideIndex(index)
  32. }
  33. const handleClick = () => {
  34. if (slideIndexStore.value === props.slideIndex) return
  35. console.log(props.slideIndex)
  36. changeSlideIndex(props.slideIndex || 0)
  37. setChildPageState(false, [], props.slideIndex || 0)
  38. setTimeout(() => {
  39. setChildPageState(true, props.toolsArray || [], props.slideIndex || 0)
  40. }, 500)
  41. }
  42. // 计算待处理任务数量
  43. const pendingCount = computed(() => {
  44. return props.toolsArray?.filter(item => item.isSet === true).length || 0
  45. })
  46. </script>
  47. <style lang="scss" scoped>
  48. .thumbnail-child-page {
  49. display: flex;
  50. flex-direction: column;
  51. align-items: center;
  52. justify-content: center;
  53. padding: 5px;
  54. width: 100px;
  55. height: 75px;
  56. background-color: #fffbeb;
  57. border: 2px dashed #f59e0b;
  58. border-radius: 8px;
  59. cursor: pointer;
  60. transition: all 0.2s;
  61. &.active {
  62. border-style: solid;
  63. }
  64. &:hover {
  65. background-color: #fef3c7;
  66. border-style: solid;
  67. }
  68. .child-page-icon {
  69. width: 24px;
  70. height: 24px;
  71. color: #f59e0b;
  72. margin-bottom: 4px;
  73. }
  74. .child-page-label {
  75. font-size: 10px;
  76. color: #d97706;
  77. text-align: center;
  78. white-space: nowrap;
  79. overflow: hidden;
  80. text-overflow: ellipsis;
  81. max-width: 100%;
  82. }
  83. }
  84. </style>