From a25f079fc061cae54216760c5c3e670a5532f029 Mon Sep 17 00:00:00 2001 From: wonderlandpark Date: Mon, 17 May 2021 15:19:50 +0900 Subject: [PATCH] chore: improved pwa --- next.config.js | 7 ++-- pages/_app.tsx | 8 +++- pages/_document.tsx | 71 ++++++++++++++++++++++++++------ public/android-icon-512x512.png | Bin 0 -> 19449 bytes public/apple-icon-256x256.png | Bin 0 -> 8561 bytes public/apple-icon-512x512.png | Bin 0 -> 19449 bytes public/manifest.json | 10 ++++- utils/Constants.ts | 5 +++ utils/Tools.ts | 6 ++- 9 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 public/android-icon-512x512.png create mode 100644 public/apple-icon-256x256.png create mode 100644 public/apple-icon-512x512.png diff --git a/next.config.js b/next.config.js index b76e73e..ffa0116 100644 --- a/next.config.js +++ b/next.config.js @@ -3,9 +3,9 @@ const { withSentryConfig } = require('@sentry/nextjs') const withPWA = require('next-pwa') const VERSION = require('./package.json').version -module.exports = withSentryConfig(withPWA({ +const NextConfig = { pwa: { - dest: 'public' + register: false }, env: { NEXT_PUBLIC_RELEASE_VERSION: VERSION, @@ -17,4 +17,5 @@ module.exports = withSentryConfig(withPWA({ experimental: { scrollRestoration: true } -}), {}) \ No newline at end of file +} +module.exports = withSentryConfig(withPWA(NextConfig)) \ No newline at end of file diff --git a/pages/_app.tsx b/pages/_app.tsx index 87ef62c..ce87006 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -8,7 +8,7 @@ import NProgress from 'nprogress' import Logger from '@utils/Logger' import { handlePWA, parseCookie, systemTheme } from '@utils/Tools' -import { shortcutKeyMap } from '@utils/Constants' +import { shortcutKeyMap, TITLE } from '@utils/Constants' import { Theme } from '@types' const Footer = dynamic(() => import('@components/Footer')) @@ -52,12 +52,16 @@ const KoreanbotsApp = ({ Component, pageProps, err, cookie }: KoreanbotsProps): } else setTheme(localStorage.theme) setStandalone(handlePWA()) + + if('serviceWorker' in navigator) { + navigator.serviceWorker.register("/sw.js") + } else Logger.warn('[SW] Load Failed') }, []) return
- 한국 디스코드봇 리스트 + {TITLE}
diff --git a/pages/_document.tsx b/pages/_document.tsx index d924aba..666a4a8 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -1,3 +1,4 @@ +import { DESCRIPTION, THEME_COLOR, TITLE } from '@utils/Constants' import Document, { DocumentContext, Html, Head, Main, NextScript } from 'next/document' class MyDocument extends Document { @@ -8,21 +9,62 @@ class MyDocument extends Document { } render() { return ( - + + {/* META */} - - + + + - + - + + {/* Android */} + + + + {/* iOS */} + + + + + {/* Windows */} + + + + + + {/* Pinned Sites */} + + + + + {/* Tap highlighting */} + + + {/* UC Mobile Browser */} + + + + + + + + + {/* LINK */} + + - + + + + + {/* iOS */} @@ -32,14 +74,17 @@ class MyDocument extends Document { + + + + + {/* Android */} - - - - - - - + + {/* Others */} + + + {/* SCRIPT */}