ExportJSON.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div class="export-json-dialog">
  3. <div class="preview">
  4. <pre>{{ json }}</pre>
  5. </div>
  6. <div class="btns">
  7. <Button class="btn export" type="primary" @click="exportJSON()">{{ lang.ssExportJSON }}</Button>
  8. <Button class="btn close" @click="emit('close')">{{ lang.ssClose }}</Button>
  9. </div>
  10. </div>
  11. </template>
  12. <script lang="ts" setup>
  13. import { computed } from 'vue'
  14. import { storeToRefs } from 'pinia'
  15. import { useSlidesStore } from '@/store'
  16. import useExport from '@/hooks/useExport'
  17. import { lang } from '@/main'
  18. import Button from '@/components/Button.vue'
  19. const emit = defineEmits<{
  20. (event: 'close'): void
  21. }>()
  22. const { slides, viewportRatio, title, viewportSize, theme } = storeToRefs(useSlidesStore())
  23. const { exportJSON } = useExport()
  24. const json = computed(() => {
  25. return {
  26. title: title.value,
  27. width: viewportSize.value,
  28. height: viewportSize.value * viewportRatio.value,
  29. theme: theme.value,
  30. slides: slides.value,
  31. }
  32. })
  33. </script>
  34. <style lang="scss" scoped>
  35. .export-json-dialog {
  36. height: 100%;
  37. display: flex;
  38. justify-content: center;
  39. align-items: center;
  40. flex-direction: column;
  41. position: relative;
  42. overflow: hidden;
  43. }
  44. .preview {
  45. width: 100%;
  46. height: calc(100% - 80px);
  47. background-color: #f9f9f9;
  48. color: #0451a5;
  49. overflow: auto;
  50. }
  51. pre {
  52. font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  53. }
  54. .btns {
  55. width: 300px;
  56. height: 80px;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. .export {
  61. flex: 1;
  62. }
  63. .close {
  64. width: 100px;
  65. margin-left: 10px;
  66. }
  67. }
  68. ::-webkit-scrollbar {
  69. width: 10px;
  70. height: 10px;
  71. background-color: transparent;
  72. }
  73. ::-webkit-scrollbar-thumb {
  74. background-color: #e1e1e1;
  75. border-radius: 5px;
  76. }
  77. </style>