From f8ebcc740746e8ed0e9cffefc11d10fc235e9516 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 10 Nov 2021 16:49:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=85=A8=E5=B1=80=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/App.tsx | 3 ++- web/src/utils/dom-helper.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/src/App.tsx b/web/src/App.tsx index cf275c97..c7265c27 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -7,7 +7,7 @@ import { ConfigProvider as AntdProvider } from 'antd'; import { parseColorScheme } from './utils/color-scheme-helper'; import { Helmet } from 'react-helmet'; import { useRecordMeasure } from './utils/measure-helper'; -import { getPopupContainer } from './utils/dom-helper'; +import { getPopupContainer, preventDefault } from './utils/dom-helper'; import { LoadingSpinner } from './components/LoadingSpinner'; const MainRoute = Loadable(() => import('./routes/Main')); @@ -47,6 +47,7 @@ const AppContainer: React.FC = React.memo((props) => { }, extraSchemeName )} + onContextMenu={preventDefault} > {props.children} diff --git a/web/src/utils/dom-helper.ts b/web/src/utils/dom-helper.ts index 5eb816ad..a82ffb83 100644 --- a/web/src/utils/dom-helper.ts +++ b/web/src/utils/dom-helper.ts @@ -17,3 +17,10 @@ export function getPopupContainer() { export function stopPropagation(e: React.BaseSyntheticEvent) { e.stopPropagation(); } + +/** + * 一个快捷方案用于直接在组件中执行 preventDefault + */ +export function preventDefault(e: React.BaseSyntheticEvent) { + e.preventDefault(); +}