diff --git a/app/secret/page.tsx b/app/secret/page.tsx index a848d24..6556001 100644 --- a/app/secret/page.tsx +++ b/app/secret/page.tsx @@ -24,7 +24,7 @@ function SecretHomePage() { return (
{/* Glass Navbar */} - + {/* Search Form - Separate from navbar */}
([]); + const [sortBy, setSortBy] = useState('default'); + const [isAddModalOpen, setIsAddModalOpen] = useState(false); + const [isRestoreDefaultsDialogOpen, setIsRestoreDefaultsDialogOpen] = useState(false); + const [editingSource, setEditingSource] = useState(null); + + useEffect(() => { + const settings = settingsStore.getSettings(); + setAdultSources(settings.adultSources || []); + setSortBy(settings.sortBy); + }, []); + + const handleSourcesChange = (newSources: VideoSource[]) => { + setAdultSources(newSources); + const currentSettings = settingsStore.getSettings(); + settingsStore.saveSettings({ + ...currentSettings, + adultSources: newSources, + }); + }; + + const handleAddSource = (source: VideoSource) => { + const exists = adultSources.some(s => s.id === source.id); + const updated = exists + ? adultSources.map(s => s.id === source.id ? source : s) + : [...adultSources, source]; + handleSourcesChange(updated); + setEditingSource(null); + }; + + const handleEditSource = (source: VideoSource) => { + setEditingSource(source); + setIsAddModalOpen(true); + }; + + const handleRestoreDefaults = () => { + const defaults = getDefaultAdultSources(); + handleSourcesChange(defaults); + setIsRestoreDefaultsDialogOpen(false); + }; + + return { + adultSources, + sortBy, + isAddModalOpen, + isRestoreDefaultsDialogOpen, + setIsAddModalOpen, + setIsRestoreDefaultsDialogOpen, + setEditingSource, + handleSourcesChange, + handleAddSource, + handleRestoreDefaults, + editingSource, + handleEditSource, + }; +} diff --git a/app/secret/settings/page.tsx b/app/secret/settings/page.tsx new file mode 100644 index 0000000..040e637 --- /dev/null +++ b/app/secret/settings/page.tsx @@ -0,0 +1,85 @@ +'use client'; + +import { AddSourceModal } from '@/components/settings/AddSourceModal'; +import { ConfirmDialog } from '@/components/ui/ConfirmDialog'; +import { AdultSourceSettings } from '@/components/settings/AdultSourceSettings'; +import { SettingsHeader } from '@/components/settings/SettingsHeader'; +import { useSecretSettingsPage } from './hooks/useSecretSettingsPage'; +import Link from 'next/link'; + +export default function SecretSettingsPage() { + const { + adultSources, + isAddModalOpen, + isRestoreDefaultsDialogOpen, + setIsAddModalOpen, + setIsRestoreDefaultsDialogOpen, + handleSourcesChange, + handleAddSource, + handleRestoreDefaults, + editingSource, + handleEditSource, + setEditingSource, + } = useSecretSettingsPage(); + + return ( +
+
+ {/* Custom Header for Secret Settings */} +
+
+
+ + + + + +
+

成人源设置

+

管理成人内容来源

+
+
+
+
+ + {/* Adult Source Management */} + setIsRestoreDefaultsDialogOpen(true)} + onAddSource={() => { + setEditingSource(null); + setIsAddModalOpen(true); + }} + onEditSource={handleEditSource} + /> +
+ + {/* Modals */} + { + setIsAddModalOpen(false); + setEditingSource(null); + }} + onAdd={handleAddSource} + existingIds={adultSources.map(s => s.id)} + initialValues={editingSource} + /> + + setIsRestoreDefaultsDialogOpen(false)} + /> +
+ ); +} diff --git a/app/settings/hooks/useSettingsPage.ts b/app/settings/hooks/useSettingsPage.ts index 6067cc7..f640788 100644 --- a/app/settings/hooks/useSettingsPage.ts +++ b/app/settings/hooks/useSettingsPage.ts @@ -32,7 +32,9 @@ export function useSettingsPage() { const handleSourcesChange = (newSources: VideoSource[]) => { setSources(newSources); + const currentSettings = settingsStore.getSettings(); settingsStore.saveSettings({ + ...currentSettings, sources: newSources, sortBy, searchHistory: true, @@ -58,7 +60,9 @@ export function useSettingsPage() { const handleSortChange = (newSort: SortOption) => { setSortBy(newSort); + const currentSettings = settingsStore.getSettings(); settingsStore.saveSettings({ + ...currentSettings, sources, sortBy: newSort, searchHistory: true, @@ -70,7 +74,9 @@ export function useSettingsPage() { const handlePasswordToggle = (enabled: boolean) => { setPasswordAccess(enabled); + const currentSettings = settingsStore.getSettings(); settingsStore.saveSettings({ + ...currentSettings, sources, sortBy, searchHistory: true, @@ -83,7 +89,9 @@ export function useSettingsPage() { const handleAddPassword = (password: string) => { const updated = [...accessPasswords, password]; setAccessPasswords(updated); + const currentSettings = settingsStore.getSettings(); settingsStore.saveSettings({ + ...currentSettings, sources, sortBy, searchHistory: true, @@ -96,7 +104,9 @@ export function useSettingsPage() { const handleRemovePassword = (password: string) => { const updated = accessPasswords.filter(p => p !== password); setAccessPasswords(updated); + const currentSettings = settingsStore.getSettings(); settingsStore.saveSettings({ + ...currentSettings, sources, sortBy, searchHistory: true, diff --git a/components/layout/Navbar.tsx b/components/layout/Navbar.tsx index 0a478d4..009240a 100644 --- a/components/layout/Navbar.tsx +++ b/components/layout/Navbar.tsx @@ -5,9 +5,12 @@ import { Icons } from '@/components/ui/Icon'; interface NavbarProps { onReset: () => void; + isSecretMode?: boolean; } -export function Navbar({ onReset }: NavbarProps) { +export function Navbar({ onReset, isSecretMode = false }: NavbarProps) { + const settingsHref = isSecretMode ? '/secret/settings' : '/settings'; + return (