feat(side config): add SITE_TITLE,SITE_DESCRIPTION and SITE_LOGO_URL as environment variable

This commit is contained in:
chenxc
2024-07-15 13:53:32 +08:00
parent a7894a77d0
commit 92a00c5cca
7 changed files with 40 additions and 29 deletions

View File

@@ -63,8 +63,10 @@ ANTHROPIC_URL=
WHITE_WEBDEV_ENDPOINTS= WHITE_WEBDEV_ENDPOINTS=
### custom sidebar title.(optional) ### custom sidebar title.(optional)
SIDEBAR_TITLE= SITE_TITLE=
### custom sidebar subtitle.(optional) ### custom sidebar subtitle.(optional)
SIDEBAR_SUBTITLE= SITE_DESCRIPTION=
## custom sidebar logo url.(optional)
SITE_LOGO_URL=

View File

@@ -25,7 +25,7 @@ jobs:
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v4
with: with:
images: 195658/chatgpt-next-web images: yidadaa/chatgpt-next-web
tags: | tags: |
type=raw,value=latest type=raw,value=latest
type=ref,event=tag type=ref,event=tag

View File

@@ -40,6 +40,7 @@ import { EXPORT_MESSAGE_CLASS_NAME } from "../constant";
import { getClientConfig } from "../config/client"; import { getClientConfig } from "../config/client";
import { type ClientApi, getClientApi } from "../client/api"; import { type ClientApi, getClientApi } from "../client/api";
import { getMessageTextContent } from "../utils"; import { getMessageTextContent } from "../utils";
import { getServerSideConfig } from "@/app/config/server";
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, { const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
loading: () => <LoadingIcon />, loading: () => <LoadingIcon />,
@@ -515,7 +516,7 @@ export function ImagePreviewer(props: {
dom.innerHTML = dom.innerHTML; // Refresh the content of the preview by resetting its HTML for fix a bug glitching dom.innerHTML = dom.innerHTML; // Refresh the content of the preview by resetting its HTML for fix a bug glitching
} }
}; };
const { siteTitle, siteDescription } = getServerSideConfig();
return ( return (
<div className={styles["image-previewer"]}> <div className={styles["image-previewer"]}>
<PreviewActions <PreviewActions
@@ -539,10 +540,8 @@ export function ImagePreviewer(props: {
</div> </div>
<div> <div>
<div className={styles["main-title"]}>NextChat</div> <div className={styles["main-title"]}>{siteTitle}</div>
<div className={styles["sub-title"]}> <div className={styles["sub-title"]}>{siteDescription}</div>
github.com/Yidadaa/ChatGPT-Next-Web
</div>
<div className={styles["icons"]}> <div className={styles["icons"]}>
<ExportAvatar avatar={config.avatar} /> <ExportAvatar avatar={config.avatar} />
<span className={styles["icon-space"]}>&</span> <span className={styles["icon-space"]}>&</span>

View File

@@ -140,7 +140,7 @@ export function SideBar(props: { className?: string }) {
() => isIOS() && isMobileScreen, () => isIOS() && isMobileScreen,
[isMobileScreen], [isMobileScreen],
); );
const serverConfig = getServerSideConfig(); const { siteTitle, siteDescription, siteLogURL } = getServerSideConfig();
useHotKey(); useHotKey();
return ( return (
@@ -155,13 +155,15 @@ export function SideBar(props: { className?: string }) {
> >
<div className={styles["sidebar-header"]} data-tauri-drag-region> <div className={styles["sidebar-header"]} data-tauri-drag-region>
<div className={styles["sidebar-title"]} data-tauri-drag-region> <div className={styles["sidebar-title"]} data-tauri-drag-region>
{serverConfig.sidebarTitle} {siteTitle}
</div>
<div className={styles["sidebar-sub-title"]}>
{serverConfig.sidebarSubTitle}
</div> </div>
<div className={styles["sidebar-sub-title"]}>{siteDescription}</div>
<div className={styles["sidebar-logo"] + " no-dark"}> <div className={styles["sidebar-logo"] + " no-dark"}>
<ChatGptIcon /> {!!siteLogURL ? (
<img src={"https://unsplash.it/40/43?random"}></img>
) : (
<ChatGptIcon />
)}
</div> </div>
</div> </div>

View File

@@ -56,10 +56,11 @@ declare global {
// custom template for preprocessing user input // custom template for preprocessing user input
DEFAULT_INPUT_TEMPLATE?: string; DEFAULT_INPUT_TEMPLATE?: string;
// custom sidebar title // custom site title
SIDEBAR_TITLE?: string; SITE_TITLE?: string;
// custom sidebar sub-title // custom site description
SIDEBAR_SUB_TITLE?: string; SITE_DESCRIPTION?: string;
SITE_LOGO_URL?: string;
} }
} }
} }
@@ -129,10 +130,11 @@ export const getServerSideConfig = () => {
const allowedWebDevEndpoints = ( const allowedWebDevEndpoints = (
process.env.WHITE_WEBDEV_ENDPOINTS ?? "" process.env.WHITE_WEBDEV_ENDPOINTS ?? ""
).split(","); ).split(",");
// custom title // custom site
const sidebarTitle = process.env.SIDEBAR_TITLE ?? "NextChat"; const siteTitle = process.env.SITE_TITLE ?? "NextChat";
const sidebarSubTitle = const siteDescription =
process.env.SIDEBAR_SUB_TITLE ?? "Build your own AI assistant."; process.env.SITE_DESCRIPTION ?? "Build your own AI assistant.";
const siteLogURL = process.env.SITE_LOGO_URL ?? "";
return { return {
baseUrl: process.env.BASE_URL, baseUrl: process.env.BASE_URL,
apiKey: getApiKey(process.env.OPENAI_API_KEY), apiKey: getApiKey(process.env.OPENAI_API_KEY),
@@ -181,7 +183,8 @@ export const getServerSideConfig = () => {
customModels, customModels,
defaultModel, defaultModel,
allowedWebDevEndpoints, allowedWebDevEndpoints,
sidebarTitle, siteTitle,
sidebarSubTitle, siteDescription,
siteLogURL,
}; };
}; };

View File

@@ -10,10 +10,10 @@ import { GoogleTagManager } from "@next/third-parties/google";
const serverConfig = getServerSideConfig(); const serverConfig = getServerSideConfig();
export const metadata: Metadata = { export const metadata: Metadata = {
title: "NextChat", title: serverConfig.siteTitle,
description: "Your personal ChatGPT Chat Bot.", description: "Your personal ChatGPT Chat Bot.",
appleWebApp: { appleWebApp: {
title: "NextChat", title: serverConfig.siteTitle,
statusBarStyle: "default", statusBarStyle: "default",
}, },
}; };
@@ -37,7 +37,10 @@ export default function RootLayout({
<html lang="en"> <html lang="en">
<head> <head>
<meta name="config" content={JSON.stringify(getClientConfig())} /> <meta name="config" content={JSON.stringify(getClientConfig())} />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link rel="manifest" href="/site.webmanifest"></link> <link rel="manifest" href="/site.webmanifest"></link>
<script src="/serviceWorkerRegister.js" defer></script> <script src="/serviceWorkerRegister.js" defer></script>
</head> </head>

View File

@@ -11,9 +11,11 @@ import Locale from "../locales";
import { use } from "react"; import { use } from "react";
import { useAppConfig } from "."; import { useAppConfig } from ".";
import { ClientApi } from "../client/api"; import { ClientApi } from "../client/api";
import { getServerSideConfig } from "@/app/config/server";
const ONE_MINUTE = 60 * 1000; const ONE_MINUTE = 60 * 1000;
const isApp = !!getClientConfig()?.isApp; const isApp = !!getClientConfig()?.isApp;
const serverConfig = getServerSideConfig();
function formatVersionDate(t: string) { function formatVersionDate(t: string) {
const d = new Date(+t); const d = new Date(+t);
@@ -106,7 +108,7 @@ export const useUpdateStore = createPersistStore(
if (version === remoteId) { if (version === remoteId) {
// Show a notification using Tauri // Show a notification using Tauri
window.__TAURI__?.notification.sendNotification({ window.__TAURI__?.notification.sendNotification({
title: "NextChat", title: `${serverConfig.siteTitle}`,
body: `${Locale.Settings.Update.IsLatest}`, body: `${Locale.Settings.Update.IsLatest}`,
icon: `${ChatGptIcon.src}`, icon: `${ChatGptIcon.src}`,
sound: "Default", sound: "Default",
@@ -116,7 +118,7 @@ export const useUpdateStore = createPersistStore(
Locale.Settings.Update.FoundUpdate(`${remoteId}`); Locale.Settings.Update.FoundUpdate(`${remoteId}`);
// Show a notification for the new version using Tauri // Show a notification for the new version using Tauri
window.__TAURI__?.notification.sendNotification({ window.__TAURI__?.notification.sendNotification({
title: "NextChat", title: `${serverConfig.siteTitle}`,
body: updateMessage, body: updateMessage,
icon: `${ChatGptIcon.src}`, icon: `${ChatGptIcon.src}`,
sound: "Default", sound: "Default",