workflow(sfc-playground): fix download

This commit is contained in:
Evan You 2021-03-28 23:48:01 -04:00
parent 9613969ffc
commit ce5e0b67a9

View File

@ -28,30 +28,12 @@
</template>
<script setup lang="ts">
import { exportFiles } from './store'
import { saveAs } from 'file-saver'
import { downloadProject } from './download/download'
function copyLink() {
navigator.clipboard.writeText(location.href)
alert('Sharable URL has been copied to clipboard.')
}
async function downloadProject() {
const { default: JSZip } = await import('jszip')
const zip = new JSZip()
// basic structure
// project src
const src = zip.folder('src')!
const files = exportFiles()
for (const file in files) {
src.file(file, files[file])
}
const blob = await zip.generateAsync({ type: 'blob' })
saveAs(blob, 'vue-project.zip')
}
</script>
<style>