@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
39 lines (27 loc) • 913 B
text/typescript
import { usePathname } from 'next/navigation';
import { ProfileTabs, SettingsTabs, SidebarTabKey } from '@/store/global/initialState';
/**
* Returns the active tab key (chat/market/settings/...)
*/
export const useActiveTabKey = () => {
const pathname = usePathname();
return pathname.split('/').find(Boolean)! as SidebarTabKey;
};
/**
* Returns the active setting page key (common/sync/agent/...)
*/
export const useActiveSettingsKey = () => {
const pathname = usePathname();
const tabs = pathname.split('/').at(-1);
if (tabs === 'settings') return SettingsTabs.Common;
return tabs as SettingsTabs;
};
/**
* Returns the active profile page key (profile/security/stats/...)
*/
export const useActiveProfileKey = () => {
const pathname = usePathname();
const tabs = pathname.split('/').at(-1);
if (tabs === 'profile') return ProfileTabs.Profile;
return tabs as ProfileTabs;
};