mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	hotfix cache upload image
This commit is contained in:
		@@ -15,6 +15,10 @@ self.addEventListener("install", function (event) {
 | 
			
		||||
  );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function jsonify(data) {
 | 
			
		||||
  return Response(JSON.stringify(data), { headers: { 'content-type': 'application/json' } })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function upload(request, url) {
 | 
			
		||||
  const formData = await request.formData()
 | 
			
		||||
  const file = formData.getAll('file')[0]
 | 
			
		||||
@@ -33,13 +37,13 @@ async function upload(request, url) {
 | 
			
		||||
      'server': 'ServiceWorker',
 | 
			
		||||
    }
 | 
			
		||||
  }))
 | 
			
		||||
  return Response.json({ code: 0, data: fileUrl })
 | 
			
		||||
  return jsonify({ code: 0, data: fileUrl })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function remove(request, url) {
 | 
			
		||||
  const cache = await caches.open(CHATGPT_NEXT_WEB_FILE_CACHE)
 | 
			
		||||
  const res = await cache.delete(request.url)
 | 
			
		||||
  return Response.json({ code: 0 })
 | 
			
		||||
  return jsonify({ code: 0 })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
self.addEventListener("fetch", (e) => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user