mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-31 00:10:22 +08:00
fix: hide scrollbars on capturing (#7867)
This commit is contained in:
parent
84b4ae0634
commit
8ab4682519
@ -49,3 +49,11 @@ pre:not(.shiki)::-webkit-scrollbar-thumb {
|
||||
--color-scrollbar-thumb: var(--color-scrollbar-thumb-light);
|
||||
--color-scrollbar-thumb-hover: var(--color-scrollbar-thumb-light-hover);
|
||||
}
|
||||
|
||||
/* 用于截图时隐藏滚动条
|
||||
* FIXME: 临时方案,因为 html-to-image 没有正确处理伪元素。
|
||||
*/
|
||||
.hide-scrollbar,
|
||||
.hide-scrollbar * {
|
||||
scrollbar-width: none !important;
|
||||
}
|
||||
|
||||
@ -68,6 +68,9 @@ export const captureScrollableDiv = async (divRef: React.RefObject<HTMLDivElemen
|
||||
|
||||
const originalScrollTop = div.scrollTop
|
||||
|
||||
// Hide scrollbars during capture
|
||||
div.classList.add('hide-scrollbar')
|
||||
|
||||
// Modify styles to show full content
|
||||
div.style.height = 'auto'
|
||||
div.style.maxHeight = 'none'
|
||||
@ -134,6 +137,9 @@ export const captureScrollableDiv = async (divRef: React.RefObject<HTMLDivElemen
|
||||
} catch (error) {
|
||||
console.error('Error capturing scrollable div:', error)
|
||||
throw error
|
||||
} finally {
|
||||
// Remove scrollbar hiding class
|
||||
divRef.current?.classList.remove('hide-scrollbar')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user