Skip to content

一分钟搭建影视站,支持Docker等部署方式

feat(source-manager): 略

bestZweid79e8e35548e
diff --git a/src/components/source-manager.tsx b/src/components/source-manager.tsx
index 66d4674..616c298 100644
--- a/src/components/source-manager.tsx
+++ b/src/components/source-manager.tsx
@@ -50,12 +50,17 @@ export function SourceManagerDrawer({ open, onClose }: { open: boolean; onClose:
className="h-4 w-4 accent-[#2563eb]"
checked={store.selectedKeys.includes(api.key)}
onChange={() => store.toggleSourceSelected(api.key)}
+ disabled={!!api.isAdult && store.yellowFilter}
+ title={api.isAdult && store.yellowFilter ? '成人内容过滤开启中,需先关闭过滤才能启用此源' : undefined}
aria-label={`选择 ${api.name}`}
/>
<div className="flex-1 min-w-0">
<div className="text-sm font-medium text-content truncate">
{api.name}
{api.isAdult && <span className="text-pink-400 text-xs ml-1">(18+)</span>}
+ {api.isAdult && store.yellowFilter && (
+ <span className="text-[10px] text-faint ml-1">过滤开启中,需关闭后才能启用</span>
+ )}
<span className="ml-1.5 text-[10px] px-1.5 py-0.5 rounded bg-chip text-faint align-middle">
部署者预置
</span>
@@ -87,12 +92,17 @@ export function SourceManagerDrawer({ open, onClose }: { open: boolean; onClose:
className="h-4 w-4 accent-[#2563eb]"
checked={store.selectedKeys.includes(api.key)}
onChange={() => store.toggleSourceSelected(api.key)}
+ disabled={!!api.isAdult && store.yellowFilter}
+ title={api.isAdult && store.yellowFilter ? '成人内容过滤开启中,需先关闭过滤才能启用此源' : undefined}
aria-label={`选择 ${api.name}`}
/>
<div className="flex-1 min-w-0">
<div className="text-sm font-medium text-content truncate">
{api.name}
{api.isAdult && <span className="text-pink-400 text-xs ml-1">(18+)</span>}
+ {api.isAdult && store.yellowFilter && (
+ <span className="text-[10px] text-faint ml-1">过滤开启中,需关闭后才能启用</span>
+ )}
</div>
<div className="text-xs text-faint truncate">{api.url}</div>
</div>
diff --git a/src/lib/cms-parser.ts b/src/lib/cms-parser.ts
index 565faee..41516db 100644
--- a/src/lib/cms-parser.ts
+++ b/src/lib/cms-parser.ts
@@ -139,9 +139,9 @@ export function parseDetailPageHtml(
/** 敏感分类过滤(成人内容过滤,关键词与旧版保持一致) */
const ADULT_KEYWORDS = [
- '伦理片', '福利', '里番动漫', '门事件', '萝莉少女', '制服诱惑', '国产传媒',
+ '伦理片', '福利', '倫理片','里番动漫', '门事件', '萝莉少女', '制服诱惑', '国产传媒',
'cosplay', '黑丝诱惑', '无码', '日本无码', '有码', '日本有码', 'SWAG',
- '网红主播', '色情片', '同性片', '福利视频', '福利片',
+ '网红主播', '色情片', '同性片', '福利视频', '无码高清', '有码高清', '91视频', '自拍偷拍', 'mini传媒', '福利片',
];
export function isAdultContent(typeName: string | undefined): boolean {
diff --git a/src/lib/store.ts b/src/lib/store.ts
index 5028dc7..20e715e 100644
--- a/src/lib/store.ts
+++ b/src/lib/store.ts
@@ -58,15 +58,20 @@ export const useAppStore = create<AppState>()(
addCustomApi: (api) => {
const list = get().customAPIs;
const entry: SourceConfig = { ...api, key: api.key || nextCustomKey(list) };
+ // 成人内容过滤开启时,成人源默认不勾选(用户可在关闭过滤后手动勾选)
+ const selectable = !(entry.isAdult && get().yellowFilter);
set({
customAPIs: [...list, entry],
- selectedKeys: [...get().selectedKeys, entry.key],
+ selectedKeys: selectable ? [...get().selectedKeys, entry.key] : get().selectedKeys,
});
},
updateCustomApi: (key, patch) => {
+ // 源被标记为成人内容且过滤开启时,同步取消勾选
+ const drop = patch.isAdult === true && get().yellowFilter;
set({
customAPIs: get().customAPIs.map((a) => (a.key === key ? { ...a, ...patch } : a)),
+ selectedKeys: drop ? get().selectedKeys.filter((k) => k !== key) : get().selectedKeys,
});
},
@@ -79,9 +84,14 @@ export const useAppStore = create<AppState>()(
toggleSourceSelected: (key) => {
const cur = get().selectedKeys;
- set({
- selectedKeys: cur.includes(key) ? cur.filter((k) => k !== key) : [...cur, key],
- });
+ if (cur.includes(key)) {
+ set({ selectedKeys: cur.filter((k) => k !== key) });
+ return;
+ }
+ // 成人内容过滤开启时不允许勾选成人源
+ const src = [...get().customAPIs, ...get().envSources].find((a) => a.key === key);
+ if (src?.isAdult && get().yellowFilter) return;
+ set({ selectedKeys: [...cur, key] });
},
setSelectedKeys: (keys) => set({ selectedKeys: keys }),
@@ -90,14 +100,34 @@ export const useAppStore = create<AppState>()(
// 预置源首次出现时自动勾选(开箱即搜);用户此后取消勾选不会被反复勾回
const seen = new Set(get().envKeysSeen);
const freshKeys = list.map((s) => s.key).filter((k) => !seen.has(k));
+ // 成人内容过滤开启时,成人预置源不自动勾选
+ const toSelect = freshKeys.filter((k) => {
+ const src = list.find((s) => s.key === k);
+ return !src?.isAdult || !get().yellowFilter;
+ });
set({
envSources: list,
envKeysSeen: [...get().envKeysSeen, ...freshKeys],
- selectedKeys: [...get().selectedKeys, ...freshKeys],
+ selectedKeys: [...get().selectedKeys, ...toSelect],
});
},
- updateSettings: (patch) => set(patch),
+ updateSettings: (patch) => {
+ // 打开成人内容过滤时,同步取消勾选所有成人源,避免两者并存
+ if (patch.yellowFilter === true) {
+ const adultKeys = new Set(
+ [...get().customAPIs, ...get().envSources]
+ .filter((s) => s.isAdult)
+ .map((s) => s.key)
+ );
+ set({
+ ...patch,
+ selectedKeys: get().selectedKeys.filter((k) => !adultKeys.has(k)),
+ });
+ return;
+ }
+ set(patch);
+ },
}),
{
name: 'libretv-settings',