eslint fix

This commit is contained in:
mtvpls
2026-01-23 16:41:49 +08:00
parent a167763324
commit 6eaed34b14
107 changed files with 311 additions and 318 deletions
+4 -4
View File
@@ -1,10 +1,10 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getStorage } from '@/lib/db';
import { getConfig } from '@/lib/config';
import { EmailService } from '@/lib/email.service';
import type { AdminConfig } from '@/lib/admin.types';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getStorage } from '@/lib/db';
import { EmailService } from '@/lib/email.service';
export const runtime = 'nodejs';
+1
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
+1 -1
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
@@ -37,7 +38,6 @@ export async function POST(request: NextRequest) {
// 追加和覆盖:合并Sources数组
if (data.Sources && Array.isArray(data.Sources)) {
const existingSources = adminConfig.EmbyConfig?.Sources || [];
const existingKeys = new Set(existingSources.map(s => s.key));
// 覆盖已存在的,追加新的
const mergedSources = [...existingSources];
+1 -1
View File
@@ -87,7 +87,7 @@ export async function POST(request: NextRequest) {
}
// 验证扫描间隔
let scanInterval = parseInt(ScanInterval) || 0;
const scanInterval = parseInt(ScanInterval) || 0;
if (scanInterval > 0 && scanInterval < 60) {
return NextResponse.json(
{ error: '定时扫描间隔最低为 60 分钟' },
-4
View File
@@ -2,7 +2,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
export const runtime = 'nodejs';
@@ -24,9 +23,6 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// 获取配置
const adminConfig = await getConfig();
// 判定操作者角色
let operatorRole: 'owner' | 'admin' | 'user' = 'user';
if (authInfo.username === process.env.USERNAME) {
+1
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
+2 -41
View File
@@ -2,11 +2,11 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import {
orchestrateDataSources,
VideoContext,
} from '@/lib/ai-orchestrator';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
@@ -35,7 +35,7 @@ async function streamOpenAIChat(
temperature: number;
maxTokens: number;
},
enableStreaming: boolean = true
enableStreaming = true
): Promise<ReadableStream | Response> {
const response = await fetch(`${config.baseURL}/chat/completions`, {
method: 'POST',
@@ -61,45 +61,6 @@ async function streamOpenAIChat(
return enableStreaming ? response.body! : response;
}
/**
* Claude API流式聊天请求
*/
async function streamClaudeChat(
messages: ChatMessage[],
systemPrompt: string,
config: {
apiKey: string;
model: string;
temperature: number;
maxTokens: number;
}
): Promise<ReadableStream> {
const response = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': config.apiKey,
'anthropic-version': '2023-06-01',
},
body: JSON.stringify({
model: config.model,
max_tokens: config.maxTokens,
temperature: config.temperature,
system: systemPrompt,
messages: messages,
stream: true,
}),
});
if (!response.ok) {
throw new Error(
`Claude API error: ${response.status} ${response.statusText}`
);
}
return response.body!;
}
/**
* 转换流为SSE格式
*/
@@ -123,7 +123,7 @@ export async function POST(request: NextRequest) {
}
// 检查用户名是否已存在(优先使用新版本)
let userExists = await db.checkUserExistV2(username);
const userExists = await db.checkUserExistV2(username);
if (userExists) {
return NextResponse.json(
{ error: '用户名已存在' },
+1 -9
View File
@@ -4,7 +4,6 @@ import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
import { OpenListClient } from '@/lib/openlist.client';
import {
getCachedMetaInfo,
MetaInfo,
@@ -260,13 +259,6 @@ async function handleOpenListProxy(request: NextRequest) {
);
}
const rootPath = openListConfig.RootPath || '/';
const client = new OpenListClient(
openListConfig.URL,
openListConfig.Username,
openListConfig.Password
);
// 读取 metainfo (从数据库或缓存)
let metaInfo: MetaInfo | null = getCachedMetaInfo();
@@ -296,7 +288,7 @@ async function handleOpenListProxy(request: NextRequest) {
if (wd) {
const results = Object.entries(metaInfo.folders)
.filter(
([key, info]) =>
([_key, info]) =>
info.folderName.toLowerCase().includes(wd.toLowerCase()) ||
info.title.toLowerCase().includes(wd.toLowerCase())
)
+2 -2
View File
@@ -4,12 +4,12 @@ import { NextRequest, NextResponse } from 'next/server';
import { getConfig, refineConfig } from '@/lib/config';
import { db, getStorage } from '@/lib/db';
import { EmailService } from '@/lib/email.service';
import { FavoriteUpdate,getBatchFavoriteUpdateEmailTemplate } from '@/lib/email.templates';
import { fetchVideoDetail } from '@/lib/fetchVideoDetail';
import { refreshLiveChannels } from '@/lib/live';
import { startOpenListRefresh } from '@/lib/openlist-refresh';
import { SearchResult } from '@/lib/types';
import { EmailService } from '@/lib/email.service';
import { getBatchFavoriteUpdateEmailTemplate, FavoriteUpdate } from '@/lib/email.templates';
export const runtime = 'nodejs';
-1
View File
@@ -3,7 +3,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
import { DanmakuFilterConfig } from '@/lib/types';
+2 -1
View File
@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import * as cheerio from 'cheerio';
import { NextRequest, NextResponse } from 'next/server';
import { fetchDoubanWithVerification } from '@/lib/douban-anti-crawler';
export const runtime = 'nodejs';
+2 -1
View File
@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import * as cheerio from 'cheerio';
import { NextRequest, NextResponse } from 'next/server';
import { fetchDoubanData } from '@/lib/douban';
import { fetchDoubanWithVerification } from '@/lib/douban-anti-crawler';
+1 -1
View File
@@ -2,8 +2,8 @@
import { NextRequest, NextResponse } from 'next/server';
import { embyManager } from '@/lib/emby-manager';
import { getCachedEmbyList, setCachedEmbyList } from '@/lib/emby-cache';
import { embyManager } from '@/lib/emby-manager';
export const runtime = 'nodejs';
+1 -1
View File
@@ -2,8 +2,8 @@
import { NextRequest, NextResponse } from 'next/server';
import { embyManager } from '@/lib/emby-manager';
import { getCachedEmbyViews, setCachedEmbyViews } from '@/lib/emby-cache';
import { embyManager } from '@/lib/emby-manager';
export const runtime = 'nodejs';
-1
View File
@@ -3,7 +3,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
import { Favorite } from '@/lib/types';
+1 -1
View File
@@ -1,5 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { nanoid } from 'nanoid';
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getStorage } from '@/lib/db';
@@ -3,11 +3,12 @@
* 路径格式: /api/offline-download/local/[source]/[videoId]/[episodeIndex]/[file]
*/
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import * as fs from 'fs';
import { NextRequest, NextResponse } from 'next/server';
import * as path from 'path';
import { getAuthInfoFromCookie } from '@/lib/auth';
// 检查是否启用离线下载功能
const OFFLINE_DOWNLOAD_ENABLED = process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true';
const OFFLINE_DOWNLOAD_DIR = process.env.OFFLINE_DOWNLOAD_DIR || '/data';
+3 -2
View File
@@ -2,11 +2,12 @@
* 本地下载视频播放代理 API
*/
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import * as fs from 'fs';
import { NextRequest, NextResponse } from 'next/server';
import * as path from 'path';
import { getAuthInfoFromCookie } from '@/lib/auth';
// 检查是否启用离线下载功能
const OFFLINE_DOWNLOAD_ENABLED = process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true';
const OFFLINE_DOWNLOAD_DIR = process.env.OFFLINE_DOWNLOAD_DIR || '/data';
+3 -2
View File
@@ -2,11 +2,12 @@
* 离线下载任务管理 API
*/
import * as fs from 'fs';
import { NextRequest, NextResponse } from 'next/server';
import * as path from 'path';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { OfflineDownloader, OfflineDownloadTask } from '@/lib/offline-downloader';
import * as fs from 'fs';
import * as path from 'path';
// 检查是否启用离线下载功能
const OFFLINE_DOWNLOAD_ENABLED = process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true';
-1
View File
@@ -6,7 +6,6 @@ import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
import {
getCachedMetaInfo,
invalidateMetaInfoCache,
MetaInfo,
setCachedMetaInfo,
-1
View File
@@ -3,7 +3,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
import { PlayRecord } from '@/lib/types';
-1
View File
@@ -3,7 +3,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
export const runtime = 'nodejs';
-1
View File
@@ -3,7 +3,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { db } from '@/lib/db';
import { SkipConfig } from '@/lib/types';
+1
View File
@@ -3,6 +3,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
import { getThemeCSS } from '@/styles/themes';
export const runtime = 'nodejs';
+4 -3
View File
@@ -1,11 +1,12 @@
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
import {
searchTMDBMulti,
getTMDBImageUrl,
getTMDBMovieDetails,
getTMDBTVDetails,
getTMDBImageUrl,
searchTMDBMulti,
} from '@/lib/tmdb.client';
import { getConfig } from '@/lib/config';
// 服务器端缓存(内存)
const searchCache = new Map<
+4 -3
View File
@@ -1,11 +1,12 @@
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
import {
searchTMDBMulti,
getTMDBImageUrl,
getTMDBMovieRecommendations,
getTMDBTVRecommendations,
getTMDBImageUrl,
searchTMDBMulti,
} from '@/lib/tmdb.client';
import { getConfig } from '@/lib/config';
// 服务器端缓存(1天)
const searchCache = new Map<string, { data: any; timestamp: number }>();
+2 -2
View File
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
import { HttpsProxyAgent } from 'https-proxy-agent';
import { NextRequest, NextResponse } from 'next/server';
import nodeFetch from 'node-fetch';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getNextApiKey } from '@/lib/tmdb.client';
import { HttpsProxyAgent } from 'https-proxy-agent';
import nodeFetch from 'node-fetch';
export const runtime = 'nodejs';
+2 -2
View File
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
import { HttpsProxyAgent } from 'https-proxy-agent';
import { NextRequest, NextResponse } from 'next/server';
import nodeFetch from 'node-fetch';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { HttpsProxyAgent } from 'https-proxy-agent';
import nodeFetch from 'node-fetch';
import { getNextApiKey } from '@/lib/tmdb.client';
export const runtime = 'nodejs';
+2 -2
View File
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
import { HttpsProxyAgent } from 'https-proxy-agent';
import { NextRequest, NextResponse } from 'next/server';
import nodeFetch from 'node-fetch';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getNextApiKey } from '@/lib/tmdb.client';
import { HttpsProxyAgent } from 'https-proxy-agent';
import nodeFetch from 'node-fetch';
export const runtime = 'nodejs';
+2 -1
View File
@@ -1,9 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { NextResponse } from 'next/server';
import { getTMDBTrendingContent, getTMDBVideos } from '@/lib/tmdb.client';
import { getConfig } from '@/lib/config';
import { fetchDoubanData } from '@/lib/douban';
import { getTMDBTrendingContent, getTMDBVideos } from '@/lib/tmdb.client';
// 缓存配置 - 服务器内存缓存3小时
const CACHE_DURATION = 3 * 60 * 60 * 1000; // 3小时
+2 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from 'next/server';
import { getTMDBUpcomingContent } from '@/lib/tmdb.client';
import { getConfig } from '@/lib/config';
import { getTMDBUpcomingContent } from '@/lib/tmdb.client';
// 内存缓存对象
interface CacheItem {
+1
View File
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
export const dynamic = 'force-dynamic'; // 禁用缓存
+1 -1
View File
@@ -1,5 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import crypto from 'crypto';
import { NextRequest, NextResponse } from 'next/server';
function getAntiCode(oldAntiCode: string, streamName: string): string {
const paramsT = 100;