mirror of https://github.com/msgbyte/tailchat
fix:网页面板下,右侧pin的面板拖拽事件丢失问题
parent
23b1a851a9
commit
2421475d27
@ -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);
|
||||
});
|
||||
return updateStatus ;
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
|
||||
export interface DragState {
|
||||
/**
|
||||
* 拖拽
|
||||
*/
|
||||
isDraging:boolean
|
||||
|
||||
}
|
||||
|
||||
const initialState: DragState = {
|
||||
isDraging: false,
|
||||
};
|
||||
|
||||
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;
|
||||
Loading…
Reference in New Issue