소스 검색

Talk about Golden Retriever

Artur Paikin 6 년 전
부모
커밋
54321c38c2
2개의 변경된 파일21개의 추가작업 그리고 10개의 파일을 삭제
  1. 17 10
      examples/bundled/index.js
  2. 4 0
      examples/bundled/sw.js

+ 17 - 10
examples/bundled/index.js

@@ -38,6 +38,11 @@ const uppy = Uppy({
   .use(Url, { target: Dashboard, serverUrl: 'http://localhost:3020' })
   .use(Webcam, { target: Dashboard })
   .use(Tus, { endpoint: TUS_ENDPOINT })
+
+  // You can optinally enable the Golden Retriever plugin — it will
+  // restore files after a browser crash / accidental closed window
+  // see more at https://uppy.io/docs/golden-retriever/
+  //
   // .use(GoldenRetriever, {serviceWorker: true})
 
 uppy.on('complete', (result) => {
@@ -50,15 +55,17 @@ uppy.on('complete', (result) => {
   console.log('failed files:', result.failed)
 })
 
+// uncomment if you enable Golden Retriever
+//
 /* eslint-disable compat/compat */
-if ('serviceWorker' in navigator) {
-  navigator.serviceWorker
-    .register('/sw.js')
-    .then((registration) => {
-      console.log('ServiceWorker registration successful with scope: ', registration.scope)
-    })
-    .catch((error) => {
-      console.log('Registration failed with ' + error)
-    })
-}
+// if ('serviceWorker' in navigator) {
+//   navigator.serviceWorker
+//     .register('/sw.js')
+//     .then((registration) => {
+//       console.log('ServiceWorker registration successful with scope: ', registration.scope)
+//     })
+//     .catch((error) => {
+//       console.log('Registration failed with ' + error)
+//     })
+// }
 /* eslint-enable */

+ 4 - 0
examples/bundled/sw.js

@@ -1,3 +1,7 @@
+// This service worker is needed for Golden Retriever plugin,
+// only include if you’ve enabled it
+// https://uppy.io/docs/golden-retriever/
+
 /* globals clients */
 
 const fileCache = Object.create(null)