wip: create course generate
This commit is contained in:
16
composables/useDownload.ts
Normal file
16
composables/useDownload.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export const useDownload = (url: string, filename: string) => {
|
||||
const download = () => {
|
||||
fetch(url)
|
||||
.then((response) => response.blob())
|
||||
.then((blob) => {
|
||||
const url = window.URL.createObjectURL(new Blob([blob]))
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', filename)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.parentNode?.removeChild(link)
|
||||
})
|
||||
}
|
||||
return { download }
|
||||
}
|
||||
Reference in New Issue
Block a user