mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 04:15:52 +00:00
- split settings.tsx (1,781 lines) into modular components - extract hooks into separate files (context-hooks, use-*-config) - create sections: websearch, proxy, globalenv with subcomponents - add tab-navigation and section-skeleton components - add settings-context.ts for state management
24 lines
629 B
TypeScript
24 lines
629 B
TypeScript
/**
|
|
* Settings Tab URL Sync Hook
|
|
*/
|
|
|
|
import { useCallback } from 'react';
|
|
import { useSearchParams } from 'react-router-dom';
|
|
import type { SettingsTab } from '../types';
|
|
|
|
export function useSettingsTab() {
|
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
const tabParam = searchParams.get('tab');
|
|
const activeTab: SettingsTab =
|
|
tabParam === 'globalenv' ? 'globalenv' : tabParam === 'proxy' ? 'proxy' : 'websearch';
|
|
|
|
const setActiveTab = useCallback(
|
|
(tab: SettingsTab) => {
|
|
setSearchParams({ tab }, { replace: true });
|
|
},
|
|
[setSearchParams]
|
|
);
|
|
|
|
return { activeTab, setActiveTab };
|
|
}
|