ExportSpecificFile.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div class="export-pptist-dialog">
  3. <div class="configs">
  4. <div class="row">
  5. <div class="title">导出范围:</div>
  6. <RadioGroup
  7. class="config-item"
  8. v-model:value="rangeType"
  9. >
  10. <RadioButton style="width: 33.33%;" value="all">全部</RadioButton>
  11. <RadioButton style="width: 33.33%;" value="current">当前页</RadioButton>
  12. <RadioButton style="width: 33.33%;" value="custom">自定义</RadioButton>
  13. </RadioGroup>
  14. </div>
  15. <div class="row" v-if="rangeType === 'custom'">
  16. <div class="title" :data-range="`(${range[0]} ~ ${range[1]})`">自定义范围:</div>
  17. <Slider
  18. class="config-item"
  19. range
  20. :min="1"
  21. :max="slides.length"
  22. :step="1"
  23. v-model:value="range"
  24. />
  25. </div>
  26. <div class="tip">
  27. 提示:.pptist 是本应用的特有文件后缀,支持将该类型的文件导入回应用中。
  28. </div>
  29. </div>
  30. <div class="btns">
  31. <Button class="btn export" type="primary" @click="exportSpecificFile(selectedSlides)">导出 .pptist 文件</Button>
  32. <Button class="btn close" @click="emit('close')">关闭</Button>
  33. </div>
  34. </div>
  35. </template>
  36. <script lang="ts" setup>
  37. import { computed, ref } from 'vue'
  38. import { storeToRefs } from 'pinia'
  39. import { useSlidesStore } from '@/store'
  40. import useExport from '@/hooks/useExport'
  41. import Slider from '@/components/Slider.vue'
  42. import Button from '@/components/Button.vue'
  43. import RadioButton from '@/components/RadioButton.vue'
  44. import RadioGroup from '@/components/RadioGroup.vue'
  45. const emit = defineEmits<{
  46. (event: 'close'): void
  47. }>()
  48. const { slides, currentSlide } = storeToRefs(useSlidesStore())
  49. const { exportSpecificFile } = useExport()
  50. const rangeType = ref<'all' | 'current' | 'custom'>('all')
  51. const range = ref<[number, number]>([1, slides.value.length])
  52. const selectedSlides = computed(() => {
  53. if (rangeType.value === 'all') return slides.value
  54. if (rangeType.value === 'current') return [currentSlide.value]
  55. return slides.value.filter((item, index) => {
  56. const [min, max] = range.value
  57. return index >= min - 1 && index <= max - 1
  58. })
  59. })
  60. </script>
  61. <style lang="scss" scoped>
  62. .export-pptist-dialog {
  63. height: 100%;
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. flex-direction: column;
  68. position: relative;
  69. overflow: hidden;
  70. }
  71. .configs {
  72. width: 350px;
  73. height: calc(100% - 100px);
  74. display: flex;
  75. flex-direction: column;
  76. justify-content: center;
  77. .row {
  78. display: flex;
  79. justify-content: center;
  80. align-items: center;
  81. margin-bottom: 25px;
  82. }
  83. .title {
  84. width: 100px;
  85. position: relative;
  86. &::after {
  87. content: attr(data-range);
  88. position: absolute;
  89. top: 20px;
  90. left: 0;
  91. }
  92. }
  93. .config-item {
  94. flex: 1;
  95. }
  96. .tip {
  97. font-size: 12px;
  98. color: #aaa;
  99. line-height: 1.8;
  100. margin-top: 25px;
  101. }
  102. }
  103. .btns {
  104. width: 300px;
  105. height: 100px;
  106. display: flex;
  107. justify-content: center;
  108. align-items: center;
  109. .export {
  110. flex: 1;
  111. }
  112. .close {
  113. width: 100px;
  114. margin-left: 10px;
  115. }
  116. }
  117. </style>