mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-11 16:39:15 +08:00
feat: conditionally render settings tab based on session view
This commit is contained in:
parent
e02f826707
commit
e6e43dbcca
@ -46,6 +46,7 @@ const HomeTabs: FC<Props> = ({
|
|||||||
|
|
||||||
const { chat } = useRuntime()
|
const { chat } = useRuntime()
|
||||||
const { activeTopicOrSession } = chat
|
const { activeTopicOrSession } = chat
|
||||||
|
const isSessionView = activeTopicOrSession === 'session'
|
||||||
|
|
||||||
const [tab, setTab] = useState<Tab>(position === 'left' ? _tab || 'assistants' : 'topic')
|
const [tab, setTab] = useState<Tab>(position === 'left' ? _tab || 'assistants' : 'topic')
|
||||||
const borderStyle = '0.5px solid var(--color-border)'
|
const borderStyle = '0.5px solid var(--color-border)'
|
||||||
@ -59,6 +60,7 @@ const HomeTabs: FC<Props> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const showTab = position === 'left' && topicPosition === 'left'
|
const showTab = position === 'left' && topicPosition === 'left'
|
||||||
|
const canShowSettingsTab = !isSessionView
|
||||||
|
|
||||||
const onCreateAssistant = async () => {
|
const onCreateAssistant = async () => {
|
||||||
const assistant = await AddAssistantPopup.show()
|
const assistant = await AddAssistantPopup.show()
|
||||||
@ -113,9 +115,11 @@ const HomeTabs: FC<Props> = ({
|
|||||||
<TabItem active={tab === 'topic'} onClick={() => setTab('topic')}>
|
<TabItem active={tab === 'topic'} onClick={() => setTab('topic')}>
|
||||||
{activeTopicOrSession === 'topic' ? t('common.topics') : t('agent.session.label_other')}
|
{activeTopicOrSession === 'topic' ? t('common.topics') : t('agent.session.label_other')}
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem active={tab === 'settings'} onClick={() => setTab('settings')}>
|
{canShowSettingsTab && (
|
||||||
{t('settings.title')}
|
<TabItem active={tab === 'settings'} onClick={() => setTab('settings')}>
|
||||||
</TabItem>
|
{t('settings.title')}
|
||||||
|
</TabItem>
|
||||||
|
)}
|
||||||
</CustomTabs>
|
</CustomTabs>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -124,9 +128,11 @@ const HomeTabs: FC<Props> = ({
|
|||||||
<TabItem active={tab === 'topic'} onClick={() => setTab('topic')}>
|
<TabItem active={tab === 'topic'} onClick={() => setTab('topic')}>
|
||||||
{activeTopicOrSession === 'topic' ? t('common.topics') : t('agent.session.label_other')}
|
{activeTopicOrSession === 'topic' ? t('common.topics') : t('agent.session.label_other')}
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem active={tab === 'settings'} onClick={() => setTab('settings')}>
|
{canShowSettingsTab && (
|
||||||
{t('settings.title')}
|
<TabItem active={tab === 'settings'} onClick={() => setTab('settings')}>
|
||||||
</TabItem>
|
{t('settings.title')}
|
||||||
|
</TabItem>
|
||||||
|
)}
|
||||||
</CustomTabs>
|
</CustomTabs>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -147,7 +153,7 @@ const HomeTabs: FC<Props> = ({
|
|||||||
position={position}
|
position={position}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{tab === 'settings' && <Settings assistant={activeAssistant} />}
|
{tab === 'settings' && canShowSettingsTab && <Settings assistant={activeAssistant} />}
|
||||||
</TabContent>
|
</TabContent>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user