From 9adb951c661d77de429def2a2040a267a14408d0 Mon Sep 17 00:00:00 2001 From: Troray Date: Fri, 2 Jan 2026 07:57:25 +0800 Subject: [PATCH 1/3] feature/site-meta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过环境命令设置站点名称、描述 --- README.md | 50 +++++++++++++++++++++++++++++- app/layout.tsx | 5 +-- components/layout/Navbar.tsx | 7 +++-- components/player/PlayerNavbar.tsx | 3 +- lib/config/site-config.ts | 39 +++++++++++++++++++++++ 5 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 lib/config/site-config.ts diff --git a/README.md b/README.md index f6dc10e..a81bd7f 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,49 @@ docker run -d -p 3000:3000 -e ACCESS_PASSWORD=your_secret_password --name kvideo - **无法在界面删除**:只能通过修改环境变量更改 - **与本地密码兼容**:两种密码都可以解锁应用 -## � 自动订阅源配置 +## 🎨 站点名称自定义配置 + +通过环境变量可以自定义站点名称、标题和描述,无需修改源代码。 + +### 可用环境变量: + +| 变量名 | 说明 | 默认值 | +|--------|------|--------| +| `NEXT_PUBLIC_SITE_TITLE` | 浏览器标签页标题 | `KVideo - 视频聚合平台` | +| `NEXT_PUBLIC_SITE_DESCRIPTION` | 站点描述 | `Multi-source video aggregation platform with beautiful Liquid Glass UI` | +| `NEXT_PUBLIC_SITE_NAME` | 站点头部名称 | `KVideo` | + +### 配置示例: + +**Vercel 部署:** +在 Vercel 项目设置中添加环境变量: + +- 变量名:`NEXT_PUBLIC_SITE_NAME` +- 变量值:`我的视频平台` + +**Cloudflare Pages 部署:** +在 Cloudflare Pages 项目设置中添加环境变量: +- 变量名:`NEXT_PUBLIC_SITE_NAME` +- 变量值:`我的视频平台` + +**Docker 部署:** +```bash +docker run -d -p 3000:3000 \ + -e NEXT_PUBLIC_SITE_NAME="我的视频平台" \ + -e NEXT_PUBLIC_SITE_TITLE="我的视频 - 聚合播放平台" \ + -e NEXT_PUBLIC_SITE_DESCRIPTION="专属视频聚合播放平台" \ + --name kvideo kuekhaoyang/kvideo:latest +``` + +**本地开发:** +在项目根目录创建 `.env.local` 文件: +```bash +NEXT_PUBLIC_SITE_NAME=我的视频平台 +NEXT_PUBLIC_SITE_TITLE=我的视频 - 聚合播放平台 +NEXT_PUBLIC_SITE_DESCRIPTION=专属视频聚合播放平台 +``` + +## 📦 自动订阅源配置 可以通过环境变量 `NEXT_PUBLIC_SUBSCRIPTION_SOURCES` 自动配置订阅源,应用启动时会自动加载并设置为自动更新。 @@ -141,6 +183,12 @@ docker run -d -p 3000:3000 -e NEXT_PUBLIC_SUBSCRIPTION_SOURCES='[{"name":"MySour - 变量名:`NEXT_PUBLIC_SUBSCRIPTION_SOURCES` - 变量值:`[{"name":"...","url":"..."}]` +**Cloudflare Pages 部署:** + +在 Cloudflare Pages 项目设置中添加环境变量: +- 变量名:`NEXT_PUBLIC_SUBSCRIPTION_SOURCES` +- 变量值:`[{"name":"...","url":"..."}]` + ## 📝 自定义源 JSON 格式 如果你想创建自己的订阅源或批量导入源,可以使用以下 JSON 格式。 diff --git a/app/layout.tsx b/app/layout.tsx index b2728f0..fa7b9df 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -5,6 +5,7 @@ import { ThemeProvider } from "@/components/ThemeProvider"; import { Analytics } from "@vercel/analytics/react"; import { ServiceWorkerRegister } from "@/components/ServiceWorkerRegister"; import { PasswordGate } from "@/components/PasswordGate"; +import { siteConfig } from "@/lib/config/site-config"; const geistSans = Geist({ @@ -18,8 +19,8 @@ const geistMono = Geist_Mono({ }); export const metadata: Metadata = { - title: "KVideo - 视频聚合平台", - description: "Multi-source video aggregation platform with beautiful Liquid Glass UI", + title: siteConfig.title, + description: siteConfig.description, icons: { icon: '/icon.png', }, diff --git a/components/layout/Navbar.tsx b/components/layout/Navbar.tsx index 009240a..b1e1c5d 100644 --- a/components/layout/Navbar.tsx +++ b/components/layout/Navbar.tsx @@ -2,6 +2,7 @@ import Link from 'next/link'; import Image from 'next/image'; import { ThemeSwitcher } from '@/components/ThemeSwitcher'; import { Icons } from '@/components/ui/Icon'; +import { siteConfig } from '@/lib/config/site-config'; interface NavbarProps { onReset: () => void; @@ -29,15 +30,15 @@ export function Navbar({ onReset, isSecretMode = false }: NavbarProps) {
KVideo
-

KVideo

-

视频聚合平台

+

{siteConfig.name}

+

{siteConfig.description}

diff --git a/components/player/PlayerNavbar.tsx b/components/player/PlayerNavbar.tsx index 7fe466c..7ed1c8f 100644 --- a/components/player/PlayerNavbar.tsx +++ b/components/player/PlayerNavbar.tsx @@ -4,6 +4,7 @@ import Image from 'next/image'; import { Button } from '@/components/ui/Button'; import { ThemeSwitcher } from '@/components/ThemeSwitcher'; import { Icons } from '@/components/ui/Icon'; +import { siteConfig } from '@/lib/config/site-config'; export function PlayerNavbar() { const router = useRouter(); @@ -20,7 +21,7 @@ export function PlayerNavbar() { > KVideo Date: Fri, 2 Jan 2026 09:37:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DREADME.md=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=9D=97=E8=AF=AD=E8=A8=80=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a81bd7f..2a2a60f 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ docker run -d -p 3000:3000 \ **本地开发:** 在项目根目录创建 `.env.local` 文件: -```bash +```env NEXT_PUBLIC_SITE_NAME=我的视频平台 NEXT_PUBLIC_SITE_TITLE=我的视频 - 聚合播放平台 NEXT_PUBLIC_SITE_DESCRIPTION=专属视频聚合播放平台 From 19e9c37d7105eb5465d8bf2f73f037ec366d692b Mon Sep 17 00:00:00 2001 From: Troray Date: Fri, 2 Jan 2026 09:38:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BA=86=E6=9C=AA?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84getSiteConfig()=E5=87=BD=E6=95=B0,?= =?UTF-8?q?=E9=99=A4=E4=BA=86=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84get?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E5=99=A8,=E4=B8=80=E4=BA=9B=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/config/site-config.ts | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/config/site-config.ts b/lib/config/site-config.ts index 6bde571..fe9cd4a 100644 --- a/lib/config/site-config.ts +++ b/lib/config/site-config.ts @@ -10,30 +10,12 @@ export interface SiteConfig { } /** - * Get site configuration from environment variables - * Falls back to default values if not set + * Site configuration object + * Uses environment variables with fallback to default values + * Note: NEXT_PUBLIC_ environment variables are statically embedded at build time */ -export function getSiteConfig(): SiteConfig { - return { - title: process.env.NEXT_PUBLIC_SITE_TITLE || "KVideo - 视频聚合平台", - description: process.env.NEXT_PUBLIC_SITE_DESCRIPTION || "Multi-source video aggregation platform with beautiful Liquid Glass UI", - name: process.env.NEXT_PUBLIC_SITE_NAME || "KVideo", - }; -} - -/** - * Get individual configuration values - */ -export const siteConfig = { - get title() { - return process.env.NEXT_PUBLIC_SITE_TITLE || "KVideo - 视频聚合平台"; - }, - - get description() { - return process.env.NEXT_PUBLIC_SITE_DESCRIPTION || "Multi-source video aggregation platform with beautiful Liquid Glass UI"; - }, - - get name() { - return process.env.NEXT_PUBLIC_SITE_NAME || "KVideo"; - }, +export const siteConfig: SiteConfig = { + title: process.env.NEXT_PUBLIC_SITE_TITLE || "KVideo - 视频聚合平台", + description: process.env.NEXT_PUBLIC_SITE_DESCRIPTION || "Multi-source video aggregation platform with beautiful Liquid Glass UI", + name: process.env.NEXT_PUBLIC_SITE_NAME || "KVideo", }; \ No newline at end of file