From 0e8ea7003accf8f2bcb3cf3ac1e65f428db7b6b0 Mon Sep 17 00:00:00 2001 From: katelya Date: Fri, 5 Sep 2025 00:57:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20is=5Fadult=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BB=A5=E6=94=AF=E6=8C=81=E6=88=90=E4=BA=BA?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=A0=87=E8=AE=B0=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/page.tsx | 31 +++++++++++++++++++++++++++--- src/app/api/admin/source/route.ts | 4 +++- src/lib/config.ts | 32 +++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 0908c85..c89bf2a 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -70,6 +70,7 @@ interface DataSource { detail?: string; disabled?: boolean; from: 'config' | 'custom'; + is_adult?: boolean; // 添加成人内容标记字段 } // 可折叠标签组件 @@ -643,6 +644,7 @@ const VideoSourceConfig = ({ detail: '', disabled: false, from: 'config', + is_adult: false, // 默认不是成人内容 }); // dnd-kit 传感器 @@ -721,6 +723,7 @@ const VideoSourceConfig = ({ name: newSource.name, api: newSource.api, detail: newSource.detail, + is_adult: newSource.is_adult, // 传递成人内容标记 }) .then(() => { setNewSource({ @@ -730,6 +733,7 @@ const VideoSourceConfig = ({ detail: '', disabled: false, from: 'custom', + is_adult: false, // 重置为默认值 }); setShowAddForm(false); }) @@ -866,7 +870,8 @@ const VideoSourceConfig = ({ exportConfig.api_site[source.key] = { api: source.api, name: source.name, - ...(source.detail && { detail: source.detail }) + ...(source.detail && { detail: source.detail }), + ...(source.is_adult !== undefined && { is_adult: source.is_adult }) // 确保导出 is_adult 字段 }; } }); @@ -939,7 +944,7 @@ const VideoSourceConfig = ({ throw new Error(`${key}: 无效的配置对象`); } - const sourceObj = source as { api?: string; name?: string; detail?: string }; + const sourceObj = source as { api?: string; name?: string; detail?: string; is_adult?: boolean }; if (!sourceObj.api || !sourceObj.name) { throw new Error(`${key}: 缺少必要字段 api 或 name`); @@ -950,7 +955,8 @@ const VideoSourceConfig = ({ key: key, name: sourceObj.name, api: sourceObj.api, - detail: sourceObj.detail || '' + detail: sourceObj.detail || '', + is_adult: sourceObj.is_adult || false // 确保处理 is_adult 字段 }); successCount++; } catch (error) { @@ -1246,6 +1252,25 @@ const VideoSourceConfig = ({ } className='px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100' /> + + {/* 成人内容标记复选框 */} +
+ + setNewSource((prev) => ({ ...prev, is_adult: e.target.checked })) + } + className='w-4 h-4 text-red-600 bg-gray-100 border-gray-300 rounded focus:ring-red-500 dark:bg-gray-700 dark:border-gray-600' + /> + +