mirror of
https://github.com/pionxzh/chatgpt-exporter.git
synced 2026-09-21 13:37:42 -05:00
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { useSyncExternalStore } from 'preact/compat'
|
||||
|
||||
export function useWindowSize<T>(selector: () => T) {
|
||||
export function useWindowResize<T>(selector: () => T) {
|
||||
return useSyncExternalStore(subscribe, selector)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { exportToPng } from '../exporter/image'
|
||||
import { exportToJson } from '../exporter/json'
|
||||
import { exportToMarkdown } from '../exporter/markdown'
|
||||
import { exportToText } from '../exporter/text'
|
||||
import { useWindowSize } from '../hooks/useWindowSize'
|
||||
import { useWindowResize } from '../hooks/useWindowResize'
|
||||
import { getHistoryDisabled } from '../page'
|
||||
import { Divider } from './Divider'
|
||||
import { ExportDialog } from './ExportDialog'
|
||||
@@ -55,7 +55,7 @@ function MenuInner({ container }: { container: HTMLDivElement }) {
|
||||
const onClickHtml = useCallback(() => exportToHtml(format, metaList), [format, metaList])
|
||||
const onClickJSON = useCallback(() => exportToJson(format), [format])
|
||||
|
||||
const width = useWindowSize(() => window.innerWidth)
|
||||
const width = useWindowResize(() => window.innerWidth)
|
||||
const isMobile = width < 768
|
||||
const Portal = isMobile ? 'div' : HoverCard.Portal
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ export const MenuItem: FC<MenuItemProps> = ({ text, successText, disabled = fals
|
||||
const [succeed, setSucceed] = useState(false)
|
||||
|
||||
const handleClick = typeof onClick === 'function'
|
||||
? async () => {
|
||||
? async (e: Event) => {
|
||||
e.preventDefault()
|
||||
if (loading) return
|
||||
|
||||
try {
|
||||
setLoading(true)
|
||||
const result = await onClick()
|
||||
|
||||
Reference in New Issue
Block a user