summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-04-11 23:11:01 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-04-11 23:11:01 +0800
commit69d890e2772426c414308c5bec09bd477af59668 (patch)
treee8324522e2166f50b4a3bc64e9f09b8c88809612
parent185f569baed1da69a73e14044a7bd07f7be6a6bf (diff)
made it pwa
-rw-r--r--website/index.html2
-rw-r--r--website/index.js9
-rw-r--r--website/manifest.json15
-rw-r--r--website/sw.js18
4 files changed, 44 insertions, 0 deletions
diff --git a/website/index.html b/website/index.html
index c02b9bc..7a7400b 100644
--- a/website/index.html
+++ b/website/index.html
@@ -6,6 +6,7 @@
<script src="/main.js" defer></script>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="favicon.png" type="image/png">
+ <link rel="manifest" href="manifest.json">
<title>Apple converter</title>
</head>
<body>
@@ -15,5 +16,6 @@
</div>
<button data-tilt data-tilt-full-page-listening data-tilt-max="100" id="copyBtn">copy</button>
<script defer type="text/javascript" src="vanilla-tilt.min.js"></script>
+ <script src="index.js"></script>
</body>
</html> \ No newline at end of file
diff --git a/website/index.js b/website/index.js
new file mode 100644
index 0000000..0652897
--- /dev/null
+++ b/website/index.js
@@ -0,0 +1,9 @@
+if("serviceWorker" in navigator){
+ navigator.serviceWorker.register("sw.js").then(registration=>{
+ console.log("SW Registered!");
+ }).catch(error=>{
+ console.log("SW Registration Failed");
+ });
+}else{
+ console.log("Not supported");
+} \ No newline at end of file
diff --git a/website/manifest.json b/website/manifest.json
new file mode 100644
index 0000000..f1ad673
--- /dev/null
+++ b/website/manifest.json
@@ -0,0 +1,15 @@
+{
+ "name": "Apple Converter",
+ "short_name": "ac",
+ "start_url": ".",
+ "theme_color": "#1E2021",
+ "background_color": "#000",
+ "display": "standalone",
+ "icons":[
+ {
+ "src":"favicon.png",
+ "sizes": "300x300",
+ "type": "image/png"
+ }
+ ]
+} \ No newline at end of file
diff --git a/website/sw.js b/website/sw.js
new file mode 100644
index 0000000..03f2913
--- /dev/null
+++ b/website/sw.js
@@ -0,0 +1,18 @@
+// Cached core static resources
+self.addEventListener("install",e=>{
+ e.waitUntil(
+ caches.open("static").then(cache=>{
+ return cache.addAll(["./",'./favicon.png', './index.html', './main.js', './vanilla-tilt.min.js', './style.css']);
+ })
+ );
+ });
+
+ // Fatch resources
+ self.addEventListener("fetch",e=>{
+ e.respondWith(
+ caches.match(e.request).then(response=>{
+ return response||fetch(e.request);
+ })
+ );
+ });
+ \ No newline at end of file