Browse Source

修复mac判断问题

TEST-s
weige 2 months ago
parent
commit
397f9c9d55
  1. 16
      src/components/WorkflowCanvas.tsx

16
src/components/WorkflowCanvas.tsx

@ -321,9 +321,6 @@ const getQuickAddSource = (node: Node, edges: Edge[]): { handleId: string; handl
return outputHandle && handleType ? { handleId: outputHandle, handleType } : null; return outputHandle && handleType ? { handleId: outputHandle, handleType } : null;
}; };
// Detect if running on macOS for platform-specific trackpad behavior
const isMacOS = typeof navigator !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
// Detect if a wheel event is from a mouse (vs trackpad) // Detect if a wheel event is from a mouse (vs trackpad)
const isMouseWheel = (event: WheelEvent): boolean => { const isMouseWheel = (event: WheelEvent): boolean => {
// Mouse scroll wheel typically uses deltaMode 1 (lines) or has large discrete deltas // Mouse scroll wheel typically uses deltaMode 1 (lines) or has large discrete deltas
@ -448,6 +445,11 @@ export function WorkflowCanvas() {
const [isSplitting, setIsSplitting] = useState(false); const [isSplitting, setIsSplitting] = useState(false);
const [isBuildingWorkflow, setIsBuildingWorkflow] = useState(false); const [isBuildingWorkflow, setIsBuildingWorkflow] = useState(false);
const [showNewProjectSetup, setShowNewProjectSetup] = useState(false); const [showNewProjectSetup, setShowNewProjectSetup] = useState(false);
const [isMacOSClient, setIsMacOSClient] = useState(false);
useEffect(() => {
setIsMacOSClient(/Mac|iPod|iPhone|iPad/.test(navigator.platform));
}, []);
useEffect(() => { useEffect(() => {
let cancelled = false; let cancelled = false;
@ -1884,7 +1886,7 @@ export function WorkflowCanvas() {
} }
// On macOS, differentiate trackpad from mouse // On macOS, differentiate trackpad from mouse
if (isMacOS) { if (isMacOSClient) {
if (isMouseWheel(event)) { if (isMouseWheel(event)) {
// Mouse wheel → zoom if settings allow // Mouse wheel → zoom if settings allow
if (shouldZoom) { if (shouldZoom) {
@ -1925,7 +1927,7 @@ export function WorkflowCanvas() {
return () => { return () => {
wrapper.removeEventListener('wheel', handleWheelNonPassive); wrapper.removeEventListener('wheel', handleWheelNonPassive);
}; };
}, [isModalOpen, zoomIn, zoomOut, getViewport, setViewport, canvasNavigationSettings]); }, [isMacOSClient, isModalOpen, zoomIn, zoomOut, getViewport, setViewport, canvasNavigationSettings]);
// Keyboard shortcuts for copy/paste and stacking selected nodes // Keyboard shortcuts for copy/paste and stacking selected nodes
const handleKeyDown = useCallback((event: KeyboardEvent) => { const handleKeyDown = useCallback((event: KeyboardEvent) => {
@ -2552,7 +2554,7 @@ export function WorkflowCanvas() {
? false ? false
: canvasNavigationSettings.panMode === "always" : canvasNavigationSettings.panMode === "always"
? false ? false
: isMacOS && !isModalOpen : isMacOSClient && !isModalOpen
} }
selectionKeyCode={ selectionKeyCode={
isModalOpen ? null isModalOpen ? null
@ -2569,7 +2571,7 @@ export function WorkflowCanvas() {
? true ? true
: canvasNavigationSettings.panMode === "middleMouse" : canvasNavigationSettings.panMode === "middleMouse"
? [2] ? [2]
: !isMacOS : !isMacOSClient
} }
selectNodesOnDrag={false} selectNodesOnDrag={false}
nodeDragThreshold={5} nodeDragThreshold={5}

Loading…
Cancel
Save