mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	using compressImage when serviceWorker register error
This commit is contained in:
		@@ -106,6 +106,10 @@ export function base64Image2Blob(base64Data: string, contentType: 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();
 | 
			
		||||
  body.append("file", file);
 | 
			
		||||
  return fetch(UPLOAD_URL, {
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ if ('serviceWorker' in navigator) {
 | 
			
		||||
      registration.update().then(res => {
 | 
			
		||||
        console.log('ServiceWorker registration update: ', res);
 | 
			
		||||
      });
 | 
			
		||||
      window._SW_ENABLED = true
 | 
			
		||||
    }, function (err) {
 | 
			
		||||
      console.error('ServiceWorker registration failed: ', err);
 | 
			
		||||
    });
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user