mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-03-07 18:07:31 +08:00
using compressImage when serviceWorker register error
This commit is contained in:
parent
a765237441
commit
052004d70e
@ -106,6 +106,10 @@ export function base64Image2Blob(base64Data: string, contentType: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function uploadImage(file: File): Promise<string> {
|
export function uploadImage(file: File): Promise<string> {
|
||||||
|
if (!window._SW_ENABLED) {
|
||||||
|
// if serviceWorker register error, using compressImage
|
||||||
|
return compressImage(file, 256 * 1024);
|
||||||
|
}
|
||||||
const body = new FormData();
|
const body = new FormData();
|
||||||
body.append("file", file);
|
body.append("file", file);
|
||||||
return fetch(UPLOAD_URL, {
|
return fetch(UPLOAD_URL, {
|
||||||
|
@ -15,6 +15,7 @@ if ('serviceWorker' in navigator) {
|
|||||||
registration.update().then(res => {
|
registration.update().then(res => {
|
||||||
console.log('ServiceWorker registration update: ', res);
|
console.log('ServiceWorker registration update: ', res);
|
||||||
});
|
});
|
||||||
|
window._SW_ENABLED = true
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
console.error('ServiceWorker registration failed: ', err);
|
console.error('ServiceWorker registration failed: ', err);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user