From 8d0d08725d9bed14f6aea3cb17923ee24f4cac40 Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Sun, 26 Mar 2023 16:56:05 +0800 Subject: [PATCH 01/30] feat: add Dockerfile for docker deployment support --- Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e60534f92 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:18 + +WORKDIR /app + +ENV OPENAI_API_KEY="" +ENV CODE="" + +COPY . ./ + +RUN yarn && yarn build + +EXPOSE 3000 + +CMD ["yarn","start"] From 2645540721a457b8772730e65ff16c86da45108f Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 13:49:26 +0800 Subject: [PATCH 02/30] perf: build in stages to reduce container size --- Dockerfile | 40 +++++++++++++++++++++++++++++++++++----- next.config.js | 4 ++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index e60534f92..314d6c365 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,44 @@ -FROM node:18 +FROM node:18-alpine AS base +FROM base AS deps + +RUN apk add --no-cache libc6-compat + +WORKDIR /app + +COPY package.json yarn.lock* package-lock.json* ./ + +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + else echo "Lockfile not found." && exit 1; \ + fi + +FROM base AS builder + +RUN apk update && apk add --no-cache git + +ENV OPENAI_API_KEY="" +ENV CODE="" +ARG DOCKER=true + +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +RUN yarn build + +FROM base AS runner WORKDIR /app ENV OPENAI_API_KEY="" ENV CODE="" -COPY . ./ - -RUN yarn && yarn build +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/.next/server ./.next/server EXPOSE 3000 -CMD ["yarn","start"] +CMD ["node","server.js"] diff --git a/next.config.js b/next.config.js index eea258d3b..fc164db9c 100644 --- a/next.config.js +++ b/next.config.js @@ -14,4 +14,8 @@ const nextConfig = { } }; +if (process.env.DOCKER) { + nextConfig.output = 'standalone' +} + module.exports = nextConfig; From e880df6db92471dc7fe53ab61fad5155043405ec Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 13:59:23 +0800 Subject: [PATCH 03/30] docs: add instructions for docker deployment --- README.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index de57e4bbc..d7ca656dc 100644 --- a/README.md +++ b/README.md @@ -125,16 +125,30 @@ Please ask ChatGPT with prompt: how to deploy nextjs project with pm2 and yarn on my ubuntu server, the build command is `yarn build`, the start command is `yarn start`, the project must start with env var named `OPENAI_API_KEY`, the port is 3000, use ngnix ``` -### Docker Deployment -请直接询问 ChatGPT,使用下列 Prompt: +### 容器部署 Docker Deployment + +1. 首先拉取镜像 +```shell +docker pull aprilnea/chatgpt-next-web ``` -如何使用 docker 部署 nextjs 项目到 ubuntu 服务器上,项目编译命令为 yarn build,启动命令为 yarn start,启动时需要设置环境变量为 OPENAI_API_KEY,端口为 3000,使用 ngnix 做反向代理 +2. 运行 +```shell +docker run -d -p 3000:3000 -e OPEN_API_KEY="" -e CODE="" aprilnea/chatgpt-next-web +``` +请在适当位置替换你的 `OPEN_API-KEY` 和 `CODE` + + +1. First, pull the image +```shell +docker pull aprilnea/chatgpt-next-web ``` -Please ask ChatGPT with prompt: -``` -how to deploy nextjs project with docker on my ubuntu server, the build command is `yarn build`, the start command is `yarn start`, the project must start with env var named `OPENAI_API_KEY`, the port is 3000, use ngnix +2. Run the container +```shell +docker run -d -p 3000:3000 -e OPEN_API_KEY="" -e CODE="" aprilnea/chatgpt-next-web ``` +Please replace `OPEN_API_KEY` and `CODE` with your own credentials at the appropriate locations. + ## 截图 Screenshots From cd73c3a7cb062e59bfee60f421be8a3a508bf286 Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 15:01:35 +0800 Subject: [PATCH 04/30] fix: taskbar color follow(#54) --- app/components/home.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/components/home.tsx b/app/components/home.tsx index 1c665f872..fd38ee8c3 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -358,12 +358,20 @@ function useSwitchTheme() { const config = useChatStore((state) => state.config); useEffect(() => { + const metaDescription = document.querySelector('meta[name="theme-color"]'); + document.body.classList.remove("light"); document.body.classList.remove("dark"); if (config.theme === "dark") { document.body.classList.add("dark"); + if (metaDescription){ + metaDescription.setAttribute('content', "#151515"); + } } else if (config.theme === "light") { document.body.classList.add("light"); + if (metaDescription){ + metaDescription.setAttribute('content', "#fafafa"); + } } }, [config.theme]); } From 6446692db04b612ab243d19c88c09c3cbee52c29 Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 15:02:12 +0800 Subject: [PATCH 05/30] feat: support safari appleWebApp --- app/layout.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/layout.tsx b/app/layout.tsx index 095d3a184..eea0c9a63 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -13,6 +13,11 @@ const COMMIT_ID = process 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() { From 785372ad73b6691717fb699125bd62fbdc5f078b Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 15:47:46 +0800 Subject: [PATCH 06/30] fix: fix the different colors on mobile --- app/components/home.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index fd38ee8c3..bcb71984a 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -356,6 +356,7 @@ export function Chat(props: { showSideBar?: () => void }) { function useSwitchTheme() { const config = useChatStore((state) => state.config); + const screenWidth = window.innerWidth; useEffect(() => { const metaDescription = document.querySelector('meta[name="theme-color"]'); @@ -364,16 +365,24 @@ function useSwitchTheme() { document.body.classList.remove("dark"); if (config.theme === "dark") { document.body.classList.add("dark"); - if (metaDescription){ - metaDescription.setAttribute('content', "#151515"); + if (metaDescription) { + if (screenWidth < 600) { + metaDescription.setAttribute('content', "#1a262a"); + } else { + metaDescription.setAttribute('content', "#151515"); + } } } else if (config.theme === "light") { document.body.classList.add("light"); - if (metaDescription){ - metaDescription.setAttribute('content', "#fafafa"); + if (metaDescription) { + if (screenWidth < 600) { + metaDescription.setAttribute('content', "#e7f8ff"); + } else { + metaDescription.setAttribute('content', "#fafafa"); + } } } - }, [config.theme]); + }, [config.theme,screenWidth]); } function exportMessages(messages: Message[], topic: string) { From dd80c4563ddc4b40232fb823405ddd1f31c8f4de Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 17:04:11 +0800 Subject: [PATCH 07/30] feat: adding iOS Webapp support - fix media query about background-color - Use colors from CSS files instead of fixed values --- app/components/home.tsx | 24 ++++++------------------ app/styles/globals.scss | 9 ++++++++- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index bcb71984a..a2ef17b7f 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -356,33 +356,21 @@ export function Chat(props: { showSideBar?: () => void }) { function useSwitchTheme() { const config = useChatStore((state) => state.config); - const screenWidth = window.innerWidth; useEffect(() => { - const metaDescription = document.querySelector('meta[name="theme-color"]'); - document.body.classList.remove("light"); document.body.classList.remove("dark"); + if (config.theme === "dark") { document.body.classList.add("dark"); - if (metaDescription) { - if (screenWidth < 600) { - metaDescription.setAttribute('content', "#1a262a"); - } else { - metaDescription.setAttribute('content', "#151515"); - } - } } else if (config.theme === "light") { document.body.classList.add("light"); - if (metaDescription) { - if (screenWidth < 600) { - metaDescription.setAttribute('content', "#e7f8ff"); - } else { - metaDescription.setAttribute('content', "#fafafa"); - } - } } - }, [config.theme,screenWidth]); + + const themeColor = getComputedStyle(document.body).getPropertyValue("--theme-color").trim(); + const metaDescription = document.querySelector('meta[name="theme-color"]'); + metaDescription?.setAttribute('content', themeColor); + }, [config.theme]); } function exportMessages(messages: Message[], topic: string) { diff --git a/app/styles/globals.scss b/app/styles/globals.scss index e7d352260..96b6a5018 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 { From bdf17fafff02733c76b8977b2c19bb87db0864d1 Mon Sep 17 00:00:00 2001 From: "jianjian.ma" Date: Mon, 27 Mar 2023 17:41:44 +0800 Subject: [PATCH 08/30] feat: add PWA support --- app/layout.tsx | 1 + public/serviceWorker.js | 35 +++++++++++++++++++++++++++++++++++ public/site.webmanifest | 22 +++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 public/serviceWorker.js diff --git a/app/layout.tsx b/app/layout.tsx index 095d3a184..3a6315f7f 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -50,6 +50,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/public/serviceWorker.js b/public/serviceWorker.js new file mode 100644 index 000000000..dff7af9a5 --- /dev/null +++ b/public/serviceWorker.js @@ -0,0 +1,35 @@ +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); + }) + ); +}); + +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 45dc8a206..117f33b86 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 From a81e7394f0668316b9e20a964f761b7804d1f831 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Mon, 27 Mar 2023 17:45:36 +0800 Subject: [PATCH 09/30] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f20debd0b..0c7284bd9 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) From 689b7bab2692a9fe0271d1392819ba9b7ff59239 Mon Sep 17 00:00:00 2001 From: "jianjian.ma" Date: Mon, 27 Mar 2023 17:53:32 +0800 Subject: [PATCH 10/30] feat: add PWA support --- .eslintignore | 1 + app/layout.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..089752554 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +public/serviceWorker.js \ No newline at end of file diff --git a/app/layout.tsx b/app/layout.tsx index 3a6315f7f..f42e10443 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -50,7 +50,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} From 5593c067c4a576f35ff11e40c2c0e98352a74db5 Mon Sep 17 00:00:00 2001 From: "jianjian.ma" Date: Mon, 27 Mar 2023 18:02:35 +0800 Subject: [PATCH 11/30] feat: add PWA support --- app/layout.tsx | 2 +- public/serviceWorker.js | 13 +------------ public/serviceWorkerRegister.js | 9 +++++++++ 3 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 public/serviceWorkerRegister.js diff --git a/app/layout.tsx b/app/layout.tsx index f42e10443..e4df377cf 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -50,7 +50,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/public/serviceWorker.js b/public/serviceWorker.js index dff7af9a5..585633fcb 100644 --- a/public/serviceWorker.js +++ b/public/serviceWorker.js @@ -9,7 +9,6 @@ self.addEventListener('install', function (event) { caches.open(CHATGPT_NEXT_WEB_CACHE) .then(function (cache) { return cache.addAll([ - '/', ]); }) ); @@ -22,14 +21,4 @@ self.addEventListener('fetch', function (event) { return response || fetch(event.request); }) ); -}); - -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 +}); \ No newline at end of file diff --git a/public/serviceWorkerRegister.js b/public/serviceWorkerRegister.js new file mode 100644 index 000000000..8405f21aa --- /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 From fb06fb8c38f8578597e28c861824ad5e0004c34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BC=8F=E6=99=93?= Date: Mon, 27 Mar 2023 16:58:53 +0800 Subject: [PATCH 12/30] fix: resolve hydration error --- app/api/chat-stream/route.ts | 1 - app/components/home.tsx | 12 +++++++++++- app/components/settings.tsx | 2 +- app/components/userRole.tsx | 0 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 app/components/userRole.tsx diff --git a/app/api/chat-stream/route.ts b/app/api/chat-stream/route.ts index 8803a4252..ad40c6be1 100644 --- a/app/api/chat-stream/route.ts +++ b/app/api/chat-stream/route.ts @@ -1,4 +1,3 @@ -import type { ChatRequest } from "../chat/typing"; import { createParser } from "eventsource-parser"; import { NextRequest } from "next/server"; diff --git a/app/components/home.tsx b/app/components/home.tsx index 1265149a1..ffe813e0d 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -465,6 +465,16 @@ function showMemoryPrompt(session: ChatSession) { }); } +const useHasHydrated = () => { + const [hasHydrated, setHasHydrated] = useState(false); + + useEffect(() => { + setHasHydrated(true); + }, []); + + return hasHydrated; +}; + export function Home() { const [createNewSession, currentIndex, removeSession] = useChatStore( (state) => [ @@ -473,7 +483,7 @@ export function Home() { state.removeSession, ] ); - const loading = !useChatStore?.persist?.hasHydrated(); + const loading = !useHasHydrated(); const [showSideBar, setShowSideBar] = useState(true); // setting diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 56165daa2..eb9bc6d49 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -354,7 +354,7 @@ export function Settings(props: { closeSettings: () => void }) { updateConfig( diff --git a/app/components/userRole.tsx b/app/components/userRole.tsx new file mode 100644 index 000000000..e69de29bb From efaf6590ef5ef46174b7e9a90d63b4b8bf806b78 Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Mon, 27 Mar 2023 18:31:04 +0800 Subject: [PATCH 13/30] fix(#65): fix unknown git commit id --- app/layout.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index 095d3a184..db8deacc3 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -5,10 +5,15 @@ import "./styles/prism.scss"; import process from "child_process"; import { ACCESS_CODES } from "./api/access"; -const COMMIT_ID = process - .execSync("git rev-parse --short HEAD") - .toString() - .trim(); +let COMMIT_ID: string | undefined; +try { + COMMIT_ID = process + .execSync("git rev-parse --short HEAD") + .toString() + .trim(); +} catch (e) { + console.error("No git or not from git repo.") +} export const metadata = { title: "ChatGPT Next Web", @@ -17,7 +22,7 @@ export const metadata = { function Meta() { const metas = { - version: COMMIT_ID, + version: COMMIT_ID ?? "unknown", access: ACCESS_CODES.size > 0 ? "enabled" : "disabled", }; From 9570691d5b9eec83b4d6bb66716409039054d68e Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Mon, 27 Mar 2023 21:52:50 +0800 Subject: [PATCH 14/30] Delete userRole.tsx --- app/components/userRole.tsx | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/components/userRole.tsx diff --git a/app/components/userRole.tsx b/app/components/userRole.tsx deleted file mode 100644 index e69de29bb..000000000 From 0463b350d843af268d6738987d3a8a4e8f4db030 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Mon, 27 Mar 2023 22:44:09 +0800 Subject: [PATCH 15/30] feat: #24 docker publish actions --- .github/workflows/docker.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..5b2520eb9 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,33 @@ +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: yidadaa/chatgpt-next-web + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From cc1a1d4f3ca95398d5b50f1cac299ef5d39dbe52 Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Mon, 27 Mar 2023 14:34:46 +0000 Subject: [PATCH 16/30] feat: #27 add docker image publish actions --- README.md | 22 +++------------------- package.json | 1 + 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index ae68cb32e..00c0fd763 100644 --- a/README.md +++ b/README.md @@ -131,28 +131,11 @@ how to deploy nextjs project with pm2 and yarn on my ubuntu server, the build co ### 容器部署 Docker Deployment -1. 首先拉取镜像 -```shell -docker pull aprilnea/chatgpt-next-web -``` -2. 运行 ```shell +docker pull yidadaa/chatgpt-next-web + docker run -d -p 3000:3000 -e OPEN_API_KEY="" -e CODE="" aprilnea/chatgpt-next-web ``` -请在适当位置替换你的 `OPEN_API-KEY` 和 `CODE` - - -1. First, pull the image -```shell -docker pull aprilnea/chatgpt-next-web -``` - -2. Run the container -```shell -docker run -d -p 3000:3000 -e OPEN_API_KEY="" -e CODE="" aprilnea/chatgpt-next-web -``` -Please replace `OPEN_API_KEY` and `CODE` with your own credentials at the appropriate locations. - ## 截图 Screenshots @@ -178,6 +161,7 @@ If you would like to contribute your API key, you can email it to the author and [@ClarenceDan](https://github.com/ClarenceDan) ### 贡献者 Contributor + [@AprilNEA](https://github.com/AprilNEA) ## LICENSE diff --git a/package.json b/package.json index df74cb960..b7d1d6995 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "chatgpt-next-web", "version": "1.1", "private": false, + "license": "Anti 996", "scripts": { "dev": "next dev", "build": "next build", From 77a3fdea5fc7d719866a44376b778a388b26b39b Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Mon, 27 Mar 2023 23:02:39 +0800 Subject: [PATCH 17/30] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 00c0fd763..3394a4953 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,8 @@ If you would like to contribute your API key, you can email it to the author and ### 贡献者 Contributor [@AprilNEA](https://github.com/AprilNEA) +[@iSource](https://github.com/iSource) +[@iFwu](https://github.com/iFwu) ## LICENSE From c93a46a02f0201bf1e8eff319e4a7fbbca1c29db Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Tue, 28 Mar 2023 02:15:52 +0800 Subject: [PATCH 18/30] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3394a4953..ca08c2c61 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ how to deploy nextjs project with pm2 and yarn on my ubuntu server, the build co ```shell docker pull yidadaa/chatgpt-next-web -docker run -d -p 3000:3000 -e OPEN_API_KEY="" -e CODE="" aprilnea/chatgpt-next-web +docker run -d -p 3000:3000 -e OPENAI_API_KEY="" -e CODE="" yidadaa/chatgpt-next-web ``` ## 截图 Screenshots From 55f37248f7dc7be70a30daa39f902e3dfc7adf17 Mon Sep 17 00:00:00 2001 From: iSource Date: Tue, 28 Mar 2023 10:50:50 +0800 Subject: [PATCH 19/30] fix: code copy button position --- app/styles/markdown.scss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/styles/markdown.scss b/app/styles/markdown.scss index d90555a50..ec2052c48 100644 --- a/app/styles/markdown.scss +++ b/app/styles/markdown.scss @@ -839,7 +839,7 @@ .markdown-body .highlight pre, .markdown-body pre { - padding: 16px; + padding: 16px 16px 8px 16px; overflow: auto; font-size: 85%; line-height: 1.45; @@ -849,11 +849,11 @@ .markdown-body pre code, .markdown-body pre tt { - display: inline; - max-width: auto; + display: inline-block; + max-width: 100%; padding: 0; margin: 0; - overflow: visible; + overflow-x: scroll; line-height: inherit; word-wrap: normal; background-color: transparent; From 306f0850e925bd75201085341eb6700dac8a4ca2 Mon Sep 17 00:00:00 2001 From: iSource Date: Tue, 28 Mar 2023 11:25:47 +0800 Subject: [PATCH 20/30] feat: add robots.txt --- public/robots.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 public/robots.txt diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 000000000..d4fc2a4b6 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Disallow: / +User-agent: vitals.vercel-insights.com +Allow: / \ No newline at end of file From 684a3c41efb1ec4f975aec365ed8e9bffbb4159c Mon Sep 17 00:00:00 2001 From: AprilNEA Date: Tue, 28 Mar 2023 11:51:36 +0800 Subject: [PATCH 21/30] fix: fix #82, close sidebar after new session --- app/components/home.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 2526f2325..8396438af 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -561,7 +561,10 @@ export function Home() { } text={Locale.Home.NewChat} - onClick={createNewSession} + onClick={()=>{ + createNewSession(); + setShowSideBar(false); + }} /> From d822f333c2e7291b21217e7fa3933adbd773aa47 Mon Sep 17 00:00:00 2001 From: xiaotianxt Date: Tue, 28 Mar 2023 00:22:33 +0800 Subject: [PATCH 22/30] feat(SubmitKey): add MetaEnter option Add another option for MacOS user who prefer Cmd+Enter or Linux user who prefer Meta+Enter. --- app/components/home.tsx | 1 + app/store/app.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/app/components/home.tsx b/app/components/home.tsx index 8396438af..9c7e45f1d 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -131,6 +131,7 @@ function useSubmitHandler() { (config.submitKey === SubmitKey.AltEnter && e.altKey) || (config.submitKey === SubmitKey.CtrlEnter && e.ctrlKey) || (config.submitKey === SubmitKey.ShiftEnter && e.shiftKey) || + (config.submitKey === SubmitKey.MetaEnter && e.metaKey) || (config.submitKey === SubmitKey.Enter && !e.altKey && !e.ctrlKey && diff --git a/app/store/app.ts b/app/store/app.ts index 703078adc..d7ff2ff71 100644 --- a/app/store/app.ts +++ b/app/store/app.ts @@ -21,6 +21,7 @@ export enum SubmitKey { CtrlEnter = "Ctrl + Enter", ShiftEnter = "Shift + Enter", AltEnter = "Alt + Enter", + MetaEnter = "Meta + Enter", } export enum Theme { From a2807c9815d88febad341e23b55f553e73234c27 Mon Sep 17 00:00:00 2001 From: xiaotianxt Date: Tue, 28 Mar 2023 01:26:49 +0800 Subject: [PATCH 23/30] fix(scroll): scroll after click submit button The behavior of SubmitKey and SubmitButton should be the same --- app/components/home.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 9c7e45f1d..74434eb02 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -204,9 +204,21 @@ export function Chat(props: { showSideBar?: () => void }) { // for auto-scroll const latestMessageRef = useRef(null); + const inputPanelRef = useRef(null); // wont scroll while hovering messages const [autoScroll, setAutoScroll] = useState(false); + useEffect(() => { + const handleMouseDown = (e: MouseEvent) => { + // check if click on input panel + setAutoScroll( + !!inputPanelRef.current && + inputPanelRef.current.contains(e.target as HTMLElement) + ); + }; + document.addEventListener("mousedown", handleMouseDown); + return () => document.removeEventListener("mousedown", handleMouseDown); + }); // preview messages const messages = (session.messages as RenderMessage[]) @@ -369,7 +381,7 @@ export function Chat(props: { showSideBar?: () => void }) { -
+