diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..0897525 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +public/serviceWorker.js \ No newline at end of file diff --git a/README.md b/README.md index f20debd..0c7284b 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,9 @@ If you would like to contribute your API key, you can email it to the author and [@mushan0x0](https://github.com/mushan0x0) [@ClarenceDan](https://github.com/ClarenceDan) +### 贡献者 Contributor +[@AprilNEA](https://github.com/AprilNEA) + ## LICENSE - [Anti 996 License](https://github.com/kattgu7/Anti-996-License/blob/master/LICENSE_CN_EN) diff --git a/app/components/home.tsx b/app/components/home.tsx index 1265149..166da96 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -399,11 +399,16 @@ function useSwitchTheme() { useEffect(() => { document.body.classList.remove("light"); document.body.classList.remove("dark"); + if (config.theme === "dark") { document.body.classList.add("dark"); } else if (config.theme === "light") { document.body.classList.add("light"); } + + const themeColor = getComputedStyle(document.body).getPropertyValue("--theme-color").trim(); + const metaDescription = document.querySelector('meta[name="theme-color"]'); + metaDescription?.setAttribute('content', themeColor); }, [config.theme]); } diff --git a/app/layout.tsx b/app/layout.tsx index db8deac..3653191 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -18,6 +18,11 @@ try { export const metadata = { title: "ChatGPT Next Web", description: "Your personal ChatGPT Chat Bot.", + appleWebApp: { + title: "ChatGPT Next Web", + statusBarStyle: "black-translucent", + }, + themeColor: "#fafafa" }; function Meta() { @@ -55,6 +60,7 @@ export default function RootLayout({ href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;700;900&display=swap" rel="stylesheet" > + {children} diff --git a/app/styles/globals.scss b/app/styles/globals.scss index 46f074d..b4b25b5 100644 --- a/app/styles/globals.scss +++ b/app/styles/globals.scss @@ -7,6 +7,7 @@ --second: rgb(231, 248, 255); --hover-color: #f3f3f3; --bar-color: rgba(0, 0, 0, 0.1); + --theme-color: var(--gray); /* shadow */ --shadow: 50px 50px 100px 10px rgb(0, 0, 0, 0.1); @@ -28,6 +29,8 @@ --bar-color: rgba(255, 255, 255, 0.1); --border-in-light: 1px solid rgba(255, 255, 255, 0.192); + + --theme-color: var(--gray); } .light { @@ -84,7 +87,11 @@ body { align-items: center; user-select: none; font-family: "Noto Sans SC", "SF Pro SC", "SF Pro Text", "SF Pro Icons", - "PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif; + "PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif; + + @media only screen and (max-width: 600px) { + background-color: var(--second); + } } ::-webkit-scrollbar { diff --git a/public/serviceWorker.js b/public/serviceWorker.js new file mode 100644 index 0000000..585633f --- /dev/null +++ b/public/serviceWorker.js @@ -0,0 +1,24 @@ +const CHATGPT_NEXT_WEB_CACHE = "chatgpt-next-web-cache"; + +self.addEventListener('activate', function (event) { + console.log('ServiceWorker activated.'); +}); + +self.addEventListener('install', function (event) { + event.waitUntil( + caches.open(CHATGPT_NEXT_WEB_CACHE) + .then(function (cache) { + return cache.addAll([ + ]); + }) + ); +}); + +self.addEventListener('fetch', function (event) { + event.respondWith( + caches.match(event.request) + .then(function (response) { + return response || fetch(event.request); + }) + ); +}); \ No newline at end of file diff --git a/public/serviceWorkerRegister.js b/public/serviceWorkerRegister.js new file mode 100644 index 0000000..8405f21 --- /dev/null +++ b/public/serviceWorkerRegister.js @@ -0,0 +1,9 @@ +if ('serviceWorker' in navigator) { + window.addEventListener('load', function () { + navigator.serviceWorker.register('/serviceWorker.js').then(function (registration) { + console.log('ServiceWorker registration successful with scope: ', registration.scope); + }, function (err) { + console.error('ServiceWorker registration failed: ', err); + }); + }); +} \ No newline at end of file diff --git a/public/site.webmanifest b/public/site.webmanifest index 45dc8a2..117f33b 100644 --- a/public/site.webmanifest +++ b/public/site.webmanifest @@ -1 +1,21 @@ -{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file +{ + "name": "ChatGPT Next Web", + "short_name": "ChatGPT", + "icons": [ + { + "src": "/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "start_url": "/", + "theme_color": "#ffffff", + "background_color": "#ffffff", + "display": "standalone" + } + \ No newline at end of file