diff --git a/index.html b/index.html index d8326ba..92d418e 100644 --- a/index.html +++ b/index.html @@ -22,11 +22,14 @@ + + +
@@ -92,6 +95,11 @@萌ICP备20218600号
diff --git a/package.json b/package.json index 8ea2110..eb30ee9 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "vite": "^2.9.5" }, "dependencies": { - "typed.js": "^2.0.12" + "typed.js": "^2.0.12", + "workbox-cdn": "4.2.0" } } diff --git a/public/avatar.webp b/public/avatar.webp new file mode 100644 index 0000000..c742d81 Binary files /dev/null and b/public/avatar.webp differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..e1e2cb7 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "It's me, 186526!", + "short_name": "186526.xyz", + "lang": "zh-CN", + "start_url": "/", + "display": "standalone", + "theme_color": "#2A2734", + "background_color": "#FBDBC4", + "icons": [ + { + "src": "./maskable.png", + "sizes": "1269x1269", + "type": "image/png", + "purpose": "any maskable" + }, + { + "src": "./avatar.webp", + "sizes": "512x512", + "type": "image/webp" + } + ] +} \ No newline at end of file diff --git a/public/maskable.png b/public/maskable.png new file mode 100644 index 0000000..8ece205 Binary files /dev/null and b/public/maskable.png differ diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..d5d22ae --- /dev/null +++ b/public/sw.js @@ -0,0 +1,49 @@ +importScripts( + 'workbox/workbox-sw.js', +); +self.addEventListener('install', (e) => { + self.skipWaiting(); +}); + +if (workbox) { + workbox.core.setCacheNameDetails({ + prefix: 'home-app', + suffix: '0.0.2', + precache: 'precache', + runtime: 'runtime', + }); + workbox.routing.registerRoute( + /\/assets/, + new workbox.strategies.CacheFirst({ + plugins: [ + new workbox.expiration.Plugin({ + maxAgeSeconds: 24 * 60 * 60, + }), + ], + cacheName: 'assets', + }), + ); + workbox.routing.registerRoute( + '/manifest.json', + new workbox.strategies.StaleWhileRevalidate({ + plugins: [ + new workbox.expiration.Plugin({ + maxAgeSeconds: 7 * 24 * 60 * 60, + }), + ], + cacheName: 'startpage_me', + }), + ); + workbox.routing.registerRoute( + '/', + new workbox.strategies.StaleWhileRevalidate({ + plugins: [ + new workbox.expiration.Plugin({ + maxAgeSeconds: 60 * 60 * 24, + }), + ], + cacheName: 'startpage_me', + }), + ); +} + diff --git a/public/workbox b/public/workbox new file mode 120000 index 0000000..92f2eaa --- /dev/null +++ b/public/workbox @@ -0,0 +1 @@ +../node_modules/workbox-cdn/workbox \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 8637108..0e1bb82 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,10 +1,13 @@ +const __APP_VERSION__ = "__APP_VERSION"; +const __APP_BUILD_TIME__ = __APP_BUILD_TIME; + import "./styles/base.css"; import "./styles/header.css"; import "./styles/contents.css"; import Typed from "typed.js"; -window.addEventListener("load", (event) => { +window.addEventListener("load", (_ev) => { new Typed(document.querySelector("description") ?? "description", { stringsElement: "#description-list", shuffle: true, @@ -20,4 +23,33 @@ window.addEventListener("load", (event) => { tooltip.innerText = Elem.getAttribute("alt") ?? ""; Elem.appendChild(tooltip); }); + + // @ts-expect-error + document.querySelector( + "#footer > div" + ).innerHTML += `