From 8437b1bb55bf0bca6713cbebd75ea14ac73f57d1 Mon Sep 17 00:00:00 2001 From: zbf Date: Sun, 24 Apr 2022 10:16:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=A9=E5=B1=95=E6=9C=AA=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=AE=8C=E6=88=90=E5=AF=B9=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E9=83=A8=E5=88=86=E6=93=8D=E4=BD=9C=E6=8A=A5?= =?UTF-8?q?=E9=94=99=EF=BC=88#84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MdEditor/layouts/Modals/Clip.tsx | 5 +++++ MdEditor/layouts/Toolbar/composition.ts | 29 ++++++++++++++----------- MdEditor/utils/content-help.ts | 5 +++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/MdEditor/layouts/Modals/Clip.tsx b/MdEditor/layouts/Modals/Clip.tsx index 364f66b4..e237f5c7 100644 --- a/MdEditor/layouts/Modals/Clip.tsx +++ b/MdEditor/layouts/Modals/Clip.tsx @@ -63,6 +63,11 @@ export default defineComponent({ // 直接定义onchange,防止创建新的实例时遗留事件 (uploadRef.value as HTMLInputElement).onchange = () => { + if (!Cropper) { + // CATCH ERROR: 捕获全局错误 + return; + } + const fileList = (uploadRef.value as HTMLInputElement).files || []; // 切换模式 diff --git a/MdEditor/layouts/Toolbar/composition.ts b/MdEditor/layouts/Toolbar/composition.ts index 9935de4b..c5dad666 100644 --- a/MdEditor/layouts/Toolbar/composition.ts +++ b/MdEditor/layouts/Toolbar/composition.ts @@ -9,7 +9,13 @@ export const useSreenfull = (props: any) => { // 是否组件内部全屏标识 const screenfullMe = ref(false); + // 触发器 const fullScreenHandler = () => { + if (!screenfull) { + // CATCH ERROR: 捕获全局错误 + return; + } + if (screenfull.isEnabled) { screenfullMe.value = true; if (screenfull.isFullscreen) { @@ -22,11 +28,8 @@ export const useSreenfull = (props: any) => { } }; - const screenfullLoad = () => { - // 复制实例 - screenfull = window.screenfull; - - // 注册事件 + // 挂载监听事件 + const onScreenfullEvent = () => { if (screenfull && screenfull.isEnabled) { screenfull.on('change', () => { if (screenfullMe.value) { @@ -37,15 +40,15 @@ export const useSreenfull = (props: any) => { } }; + const screenfullLoad = () => { + // 复制实例 + screenfull = window.screenfull; + // 重新监听 + onScreenfullEvent(); + }; + onMounted(() => { - if (screenfull && screenfull.isEnabled) { - screenfull.on('change', () => { - if (screenfullMe.value) { - screenfullMe.value = false; - props.updateSetting(!props.setting.fullscreen, 'fullscreen'); - } - }); - } + onScreenfullEvent(); if (!previewOnly && props.screenfull === null) { const screenScript = document.createElement('script'); diff --git a/MdEditor/utils/content-help.ts b/MdEditor/utils/content-help.ts index a7ebd6b6..fba9e819 100644 --- a/MdEditor/utils/content-help.ts +++ b/MdEditor/utils/content-help.ts @@ -120,6 +120,11 @@ export const directive2flag = ( targetValue = `${pix} ${selectedText}`; deviationStart = pix.length + 1; } else if (direct === 'prettier') { + if (!window.prettier) { + // CATCH ERROR: 捕获全局错误 + return inputArea.value; + } + return window.prettier.format(inputArea.value, { parser: 'markdown', plugins: window.prettierPlugins