import { renderAsync } from "docx-preview"
function getDocxContent(url: string) {
try {
previewRef.value.open()
fetch(url)
.then(response => response.blob())
.then(blob => {
renderAsync(blob, previewContentRef.value)
})
} catch (err) {
previewRef.value.close()
console.error(err)
}
}
function createElementA(url: string) {
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
fun(name: string, id: string){
const url = `${ import.meta.env.VITE_API_PREFIX } /attachment/download / ${ id }?Authorization = ${ localStorage.token } `
if (name.includes("pdf")) {
fetch(url)
.then(response => response.blob())
.then(blob => {
const url = URL.createObjectURL(blob)
window.open(url, "_blank")
})
} else if (name.includes("doc")) {
getDocxContent(url)
}
}