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 @@ +
+ + Keybase PGP + +

萌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 += `Update Commit Latest Update`; + + if ("serviceWorker" in navigator) { + navigator.serviceWorker + .register("./sw.js", { + scope: "/", + }) + .then(function (registration) { + console.log( + "ServiceWorker registration successful with scope: ", + registration.scope + ); + }) + .catch(function (err) { + console.warn("ServiceWorker registration failed: ", err); + }); + let refreshing = false; + navigator.serviceWorker.addEventListener("controllerchange", () => { + if (refreshing) { + return; + } + refreshing = true; + window.location.reload(); + }); + } }); diff --git a/src/public/78361641.png b/src/public/78361641.png deleted file mode 100644 index 5f49a51..0000000 Binary files a/src/public/78361641.png and /dev/null differ diff --git a/src/styles/contents.css b/src/styles/contents.css index 234c740..fe7e9c1 100644 --- a/src/styles/contents.css +++ b/src/styles/contents.css @@ -3,6 +3,11 @@ contents { position: absolute; top: 75vh; + right: 0vh; + left: 0vh; + + margin: 0vh 5vw; + justify-content: center; align-items: flex-start; flex-direction: column; @@ -48,7 +53,7 @@ group#friend > card > a > img { group#footer { display: block; - margin: 0vh 2.5vw; + margin: 2rem 0.5rem; align-self: flex-start; color: var(--font-color-lighter); font-size: calc(var(--font-size-description) - 0.4rem); @@ -63,3 +68,10 @@ group#footer > * { filter: invert(100%); } } + + +@media screen and (max-width: 480px) { + contents { + margin: 0 2vw; + } +} \ No newline at end of file diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts index 11f02fe..17afc9a 100644 --- a/src/vite-env.d.ts +++ b/src/vite-env.d.ts @@ -1 +1,3 @@ /// +declare const __APP_VERSION: string; +declare const __APP_BUILD_TIME: string; diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..90573cd --- /dev/null +++ b/vercel.json @@ -0,0 +1,43 @@ +{ + "routes": [ + { + "src": "/(.*)", + "headers": { + "Cache-Control": "s-maxage=1209600, max-age=86400, public", + "Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload", + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", + "Access-Control-Allow-Headers": "Accept, Authorization, Cache-Control, Content-Type, DNT, If-Modified-Since, Keep-Alive, Origin, User-Agent, X-Requested-With, Token, x-access-token" + }, + "continue": true + }, + { + "src": "/goto/github", + "status": 302, + "headers": { + "Location": "https://github.com/186526" + } + }, + { + "src": "/goto/telegram", + "status": 302, + "headers": { + "Location": "https://t.me/real186526" + } + }, + { + "src": "/goto/blog", + "status": 302, + "headers": { + "Location": "https://blog.186526.xyz" + } + }, + { + "src": "/goto/email", + "status": 302, + "headers": { + "Location": "mailto:admin@186526.xyz" + } + } + ] +} \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 2630a56..b0e1a95 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,7 +4,8 @@ import child_process from "child_process" */ const config = { define: { - '__APP_VERSION': child_process.execSync('git rev-parse --short HEAD'), + '__APP_VERSION': child_process.execSync('git rev-parse --short HEAD').toString().replaceAll("\n",""), + '__APP_BUILD_TIME': Math.floor(Date.now() / 1000), } } export default config \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 6ce9aa3..27295b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -223,3 +223,8 @@ vite@^2.9.5: rollup "^2.59.0" optionalDependencies: fsevents "~2.3.2" + +workbox-cdn@4.2.0: + version "4.2.0" + resolved "https://registry.npmmirror.com/workbox-cdn/-/workbox-cdn-4.2.0.tgz#1bab3a0ab8d4d1edd00c7d30721790d669aa5bb7" + integrity sha512-tX7a5svvRqbUCnvfuM4izwDYO3T+LtpTpPoJx6HMaN/OSA+yqJH321Dbqg8SOUvzJjyRfFRQiriCX1csdqdFyg==