增加tv mode开关

This commit is contained in:
mtvpls
2026-06-01 02:05:05 +08:00
parent 3099cf9bfa
commit a682998930
11 changed files with 83 additions and 15 deletions
+2
View File
@@ -36,6 +36,7 @@ export async function GET(request: NextRequest) {
SiteName: process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTVPlus',
StorageType: 'localstorage',
Version: CURRENT_VERSION,
TVModeEnabled: process.env.ENABLE_TV_MODE !== 'false',
WatchRoom: watchRoomConfig,
EnableOfflineDownload: process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true',
DanmakuAutoLoadDefault: true,
@@ -48,6 +49,7 @@ export async function GET(request: NextRequest) {
SiteName: config.SiteConfig.SiteName,
StorageType: storageType,
Version: CURRENT_VERSION,
TVModeEnabled: process.env.ENABLE_TV_MODE !== 'false',
WatchRoom: watchRoomConfig,
EnableOfflineDownload: process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true',
EnableRegistration: config.SiteConfig.EnableRegistration || false,
+5
View File
@@ -1,12 +1,17 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { isTVModeEnabled } from '@/lib/tv-mode';
const { listTVRemoteDevices } = require('@/lib/tv-remote-hub');
export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
if (!isTVModeEnabled()) {
return NextResponse.json({ error: 'TV 模式未启用' }, { status: 404 });
}
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo?.username) {
return NextResponse.json({ error: '未登录' }, { status: 401 });
+5
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { isTVModeEnabled } from '@/lib/tv-mode';
import type { TVRemoteKeyCommand } from '@/lib/tv-remote-types';
const { sendTVRemoteCommand } = require('@/lib/tv-remote-hub');
@@ -8,6 +9,10 @@ const { sendTVRemoteCommand } = require('@/lib/tv-remote-hub');
export const runtime = 'nodejs';
export async function POST(request: NextRequest) {
if (!isTVModeEnabled()) {
return NextResponse.json({ error: 'TV 模式未启用' }, { status: 404 });
}
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo?.username) {
return NextResponse.json({ error: '未登录' }, { status: 401 });
+5
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { isTVModeEnabled } from '@/lib/tv-mode';
import type { TVRemoteTextCommand } from '@/lib/tv-remote-types';
const { sendTVRemoteCommand } = require('@/lib/tv-remote-hub');
@@ -8,6 +9,10 @@ const { sendTVRemoteCommand } = require('@/lib/tv-remote-hub');
export const runtime = 'nodejs';
export async function POST(request: NextRequest) {
if (!isTVModeEnabled()) {
return NextResponse.json({ error: 'TV 模式未启用' }, { status: 404 });
}
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo?.username) {
return NextResponse.json({ error: '未登录' }, { status: 401 });
+1
View File
@@ -255,6 +255,7 @@ export default async function RootLayout({
BANGUMI_DATA_SOURCE: bangumiDataSource,
BANGUMI_API_BASE_URL: bangumiApiBaseUrl,
BANGUMI_IMAGE_BASE_URL: bangumiImageBaseUrl,
ENABLE_TV_MODE: process.env.ENABLE_TV_MODE !== 'false',
ENABLE_TVBOX_SUBSCRIBE: process.env.ENABLE_TVBOX_SUBSCRIBE === 'true',
ENABLE_OFFLINE_DOWNLOAD:
process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true',
+6
View File
@@ -1,12 +1,18 @@
import { ReactNode } from 'react';
import { notFound } from 'next/navigation';
import TVRemoteReceiver from '@/components/tv/TVRemoteReceiver';
import { isTVModeEnabled } from '@/lib/tv-mode';
export const metadata = {
title: 'TV - MoonTV Plus',
};
export default function Layout({ children }: { children: ReactNode }) {
if (!isTVModeEnabled()) {
notFound();
}
return (
<>
{children}