refactor(deps): migrate to nuxt v4

This commit is contained in:
2026-02-10 00:31:04 +08:00
parent f1b9cea060
commit 880b85f75d
88 changed files with 80 additions and 60 deletions

View File

@@ -0,0 +1,20 @@
export const useBlobUrlFromB64 = (dataurl: string): string => {
// data:image/jpeg;base64,/9j/...
const arr = dataurl.split(',')
if (arr.length < 2) {
throw new Error('dataurl is not a valid base64 image')
}
const mimeMatches = arr[0].match(/:(.*?);/)
if (mimeMatches === null) {
throw new Error('dataurl is not a valid base64 image')
}
const mime = mimeMatches[1] //image/png
const b64data = atob(arr[1])
let length = b64data.length
const u8arr = new Uint8Array(length)
while (length--) {
u8arr[length] = b64data.charCodeAt(length)
}
const blob = new Blob([u8arr], { type: mime })
return URL.createObjectURL(blob)
}