Skip to content

Commit

Permalink
修改一些细节
Browse files Browse the repository at this point in the history
  • Loading branch information
slince-zero committed May 9, 2024
1 parent 841d34f commit 97663aa
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/context/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,6 @@ export default function ImgContextProvider({
return result
}

function blobToDataURL(blob: any) {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onloadend = function () {
resolve(reader.result)
}
reader.onerror = reject
reader.readAsDataURL(blob)
})
}

// 生成AI图片
function handleGenerateAIImage() {
try {
Expand All @@ -269,9 +258,8 @@ export default function ImgContextProvider({
inputs: aiValue,
}
query(data).then((res) => {
blobToDataURL(res).then((url) => {
setAiResult(url)
})
const url = URL.createObjectURL(res)
setAiResult(url)
setLoadingAIImage(false)
})
} catch (e) {
Expand All @@ -290,6 +278,8 @@ export default function ImgContextProvider({
})
}



return (
<ImgContext.Provider
value={{
Expand Down

0 comments on commit 97663aa

Please sign in to comment.