mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 02:09:03 +08:00
fix(SessionSettingsPopup): inline ModalContent component for better readability
fix: Error: Cannot create components during render
This commit is contained in:
parent
4ae30db53a
commit
2e694a87f8
@ -65,39 +65,6 @@ const SessionSettingPopupContainer: React.FC<SessionSettingPopupParams> = ({ tab
|
|||||||
] as const satisfies { key: AgentSettingPopupTab; label: string }[]
|
] as const satisfies { key: AgentSettingPopupTab; label: string }[]
|
||||||
).filter(Boolean)
|
).filter(Boolean)
|
||||||
|
|
||||||
const ModalContent = () => {
|
|
||||||
if (isLoading) {
|
|
||||||
// TODO: use skeleton for better ux
|
|
||||||
return <Spinner />
|
|
||||||
}
|
|
||||||
if (error) {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Alert color="danger" title={t('agent.get.error.failed')} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="flex w-full flex-1">
|
|
||||||
<LeftMenu>
|
|
||||||
<StyledMenu
|
|
||||||
defaultSelectedKeys={[tab || 'essential'] satisfies AgentSettingPopupTab[]}
|
|
||||||
mode="vertical"
|
|
||||||
selectedKeys={[menu]}
|
|
||||||
items={items}
|
|
||||||
onSelect={({ key }) => setMenu(key as AgentSettingPopupTab)}
|
|
||||||
/>
|
|
||||||
</LeftMenu>
|
|
||||||
<Settings>
|
|
||||||
{menu === 'essential' && <SessionEssentialSettings session={session} update={updateSession} />}
|
|
||||||
{menu === 'prompt' && <PromptSettings agentBase={session} update={updateSession} />}
|
|
||||||
{menu === 'tooling' && <ToolingSettings agentBase={session} update={updateSession} />}
|
|
||||||
{menu === 'advanced' && <AdvancedSettings agentBase={session} update={updateSession} />}
|
|
||||||
</Settings>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledModal
|
<StyledModal
|
||||||
open={open}
|
open={open}
|
||||||
@ -125,7 +92,31 @@ const SessionSettingPopupContainer: React.FC<SessionSettingPopupParams> = ({ tab
|
|||||||
}}
|
}}
|
||||||
width="min(800px, 70vw)"
|
width="min(800px, 70vw)"
|
||||||
centered>
|
centered>
|
||||||
<ModalContent />
|
{isLoading && <Spinner />}
|
||||||
|
{!isLoading && error && (
|
||||||
|
<div>
|
||||||
|
<Alert color="danger" title={t('agent.get.error.failed')} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!isLoading && !error && (
|
||||||
|
<div className="flex w-full flex-1">
|
||||||
|
<LeftMenu>
|
||||||
|
<StyledMenu
|
||||||
|
defaultSelectedKeys={[tab || 'essential'] satisfies AgentSettingPopupTab[]}
|
||||||
|
mode="vertical"
|
||||||
|
selectedKeys={[menu]}
|
||||||
|
items={items}
|
||||||
|
onSelect={({ key }) => setMenu(key as AgentSettingPopupTab)}
|
||||||
|
/>
|
||||||
|
</LeftMenu>
|
||||||
|
<Settings>
|
||||||
|
{menu === 'essential' && <SessionEssentialSettings session={session} update={updateSession} />}
|
||||||
|
{menu === 'prompt' && <PromptSettings agentBase={session} update={updateSession} />}
|
||||||
|
{menu === 'tooling' && <ToolingSettings agentBase={session} update={updateSession} />}
|
||||||
|
{menu === 'advanced' && <AdvancedSettings agentBase={session} update={updateSession} />}
|
||||||
|
</Settings>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</StyledModal>
|
</StyledModal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user