-
Notifications
You must be signed in to change notification settings - Fork 349
fix:网页面板下,右侧pin的面板拖拽事件丢失问题 || fix: Under the web page panel, the panel drag event on the right pin is lost #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useAppSelector ,useAppDispatch} from './useAppSelector'; | ||
import {dragActions} from '../slices/drag' | ||
import { useMemoizedFn } from '../..'; | ||
|
||
/** | ||
* 返回面板拖拽状态 | ||
*/ | ||
export function useDragstatus():boolean { | ||
return useAppSelector((state) => state.drag.isDraging ?? []); | ||
} | ||
|
||
export function updateDragStatus(){ | ||
const dispatch = useAppDispatch(); | ||
const setStatus = useMemoizedFn( | ||
(status:boolean) => { | ||
dispatch(dragActions.setDragStatus(status))} | ||
); | ||
|
||
/** | ||
* 更新 | ||
*/ | ||
const updateStatus= useMemoizedFn((status: boolean) => { | ||
setStatus(status); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can direct call |
||
}); | ||
return updateStatus ; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
|
||
export interface DragState { | ||
/** | ||
* 拖拽 | ||
*/ | ||
isDraging:boolean | ||
|
||
} | ||
|
||
const initialState: DragState = { | ||
isDraging: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its should be |
||
}; | ||
|
||
const globalSlice = createSlice({ | ||
name: 'global', | ||
initialState, | ||
reducers: { | ||
setDragStatus( | ||
state, | ||
action: PayloadAction<DragState['isDraging']> | ||
) { | ||
state.isDraging = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const dragActions = globalSlice.actions; | ||
export const dragReducer = globalSlice.reducer; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its looks like should not create a new slice and should merge into |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
import { t } from 'tailchat-shared'; | ||
import React, { useEffect, useMemo, useRef, useState } from 'react'; | ||
import { t , useDragstatus } from 'tailchat-shared'; | ||
import { withKeepAliveOverlay } from './KeepAliveOverlay'; | ||
import { Loading } from './Loading'; | ||
|
||
|
||
|
||
interface WebviewProps { | ||
className?: string; | ||
style?: React.CSSProperties; | ||
|
@@ -15,25 +17,27 @@ interface WebviewProps { | |
export const Webview: React.FC<WebviewProps> = (props) => { | ||
const ref = useRef<HTMLIFrameElement>(null); | ||
const [spinning, setSpinning] = useState(true); | ||
|
||
const status = useDragstatus() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An important problem is component This code will restrict this component must be render under redux context. My suggestion is change pin logic, and overlay a translucent div on both sides of the drag bar. To make sure drag event not send into iframe |
||
useEffect(() => { | ||
const callback = () => { | ||
setSpinning(false); | ||
}; | ||
ref.current?.addEventListener('load', callback); | ||
|
||
return () => { | ||
ref.current?.removeEventListener('load', callback); | ||
}; | ||
}, []); | ||
const pointerEvents =useMemo(()=>{ | ||
return status ? 'none' : 'auto' | ||
},[status]) | ||
|
||
return ( | ||
<Loading | ||
spinning={spinning} | ||
className="w-full h-full" | ||
tip={t('加载网页中...')} | ||
> | ||
<iframe ref={ref} className="w-full h-full" src={props.url} /> | ||
<iframe ref={ref} style={{pointerEvents}} className="w-full h-full" src={props.url} /> | ||
</Loading> | ||
); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why your code not auto format? did you skip github hooks manual?