mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 02:55:54 +08:00
fix: window size changed causes result regeneration (#1908)
This commit is contained in:
parent
a938e1f184
commit
891218615e
@ -374,7 +374,13 @@ const TextGeneration: FC<IMainProps> = ({
|
||||
}
|
||||
}, [siteInfo?.title, canReplaceLogo])
|
||||
|
||||
const [isShowResSidebar, { setTrue: showResSidebar, setFalse: hideResSidebar }] = useBoolean(false)
|
||||
const [isShowResSidebar, { setTrue: doShowResSidebar, setFalse: hideResSidebar }] = useBoolean(false)
|
||||
const showResSidebar = () => {
|
||||
// fix: useClickAway hideResSidebar will close sidebar
|
||||
setTimeout(() => {
|
||||
doShowResSidebar()
|
||||
}, 0)
|
||||
}
|
||||
const resRef = useRef<HTMLDivElement>(null)
|
||||
useClickAway(() => {
|
||||
hideResSidebar()
|
||||
@ -406,6 +412,16 @@ const TextGeneration: FC<IMainProps> = ({
|
||||
return (showTaskList.map(task => renderRes(task)))
|
||||
}
|
||||
|
||||
const resWrapClassNames = (() => {
|
||||
if (isPC)
|
||||
return 'grow h-full'
|
||||
|
||||
if (!isShowResSidebar)
|
||||
return 'none'
|
||||
|
||||
return cn('fixed z-50 inset-0', isTablet ? 'pl-[128px]' : 'pl-6')
|
||||
})()
|
||||
|
||||
const renderResWrap = (
|
||||
<div
|
||||
ref={resRef}
|
||||
@ -578,22 +594,14 @@ const TextGeneration: FC<IMainProps> = ({
|
||||
</div>
|
||||
|
||||
{/* Result */}
|
||||
{isPC && (
|
||||
<div className='grow h-full'>
|
||||
{renderResWrap}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(!isPC && isShowResSidebar) && (
|
||||
<div
|
||||
className={cn('fixed z-50 inset-0', isTablet ? 'pl-[128px]' : 'pl-6')}
|
||||
className={resWrapClassNames}
|
||||
style={{
|
||||
background: 'rgba(35, 56, 118, 0.2)',
|
||||
background: (!isPC && isShowResSidebar) ? 'rgba(35, 56, 118, 0.2)' : 'none',
|
||||
}}
|
||||
>
|
||||
{renderResWrap}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user