feat: 补充导出JSON文件信息(#293)

This commit is contained in:
zxc 2024-11-02 14:35:13 +08:00
parent 8a8210356e
commit 537363ec67
2 changed files with 19 additions and 3 deletions

View File

@ -67,7 +67,13 @@ export default () => {
// 导出JSON文件
const exportJSON = () => {
const blob = new Blob([JSON.stringify(slides.value)], { type: '' })
const json = {
title: title.value,
width: viewportSize.value,
height: viewportSize.value * viewportRatio.value,
slides: slides.value,
}
const blob = new Blob([JSON.stringify(json)], { type: '' })
saveAs(blob, `${title.value}.json`)
}

View File

@ -1,7 +1,7 @@
<template>
<div class="export-json-dialog">
<div class="preview">
<pre>{{slides}}</pre>
<pre>{{ json }}</pre>
</div>
<div class="btns">
@ -12,6 +12,7 @@
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { storeToRefs } from 'pinia'
import { useSlidesStore } from '@/store'
import useExport from '@/hooks/useExport'
@ -21,8 +22,17 @@ const emit = defineEmits<{
(event: 'close'): void
}>()
const { slides } = storeToRefs(useSlidesStore())
const { slides, viewportRatio, title, viewportSize } = storeToRefs(useSlidesStore())
const { exportJSON } = useExport()
const json = computed(() => {
return {
title: title.value,
width: viewportSize.value,
height: viewportSize.value * viewportRatio.value,
slides: slides.value,
}
})
</script>
<style lang="scss" scoped>