增加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
+9
View File
@@ -4,10 +4,15 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { TOKEN_CONFIG } from '@/lib/refresh-token';
import { isTVModeEnabled } from '@/lib/tv-mode';
export async function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
if (!isTVModeEnabled() && isTVModePath(pathname)) {
return new NextResponse('Not Found', { status: 404 });
}
// 跳过不需要认证的路径
if (shouldSkipAuth(pathname)) {
return NextResponse.next();
@@ -171,6 +176,10 @@ function shouldSkipAuth(pathname: string): boolean {
return skipPaths.some((path) => pathname.startsWith(path));
}
function isTVModePath(pathname: string): boolean {
return pathname === '/tv' || pathname.startsWith('/tv/') || pathname.startsWith('/api/tv-remote/');
}
// 配置middleware匹配规则
export const config = {
matcher: [