From 6af4d8502d1665ff70d534cad97c6336564793d4 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Tue, 24 Sep 2024 16:20:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5?= =?UTF-8?q?=E5=91=8Asafari=E6=B5=8F=E8=A7=88=E5=99=A8js=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=A9=BA=E7=99=BD=E5=85=A8=E5=B1=80=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/pure/ms-rich-text/MsRichText.vue | 9 --------- frontend/src/main.ts | 4 ++++ frontend/src/utils/polyfill.ts | 5 +++++ 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 frontend/src/utils/polyfill.ts diff --git a/frontend/src/components/pure/ms-rich-text/MsRichText.vue b/frontend/src/components/pure/ms-rich-text/MsRichText.vue index 2ce7a8a5e0..d13def4143 100644 --- a/frontend/src/components/pure/ms-rich-text/MsRichText.vue +++ b/frontend/src/components/pure/ms-rich-text/MsRichText.vue @@ -502,15 +502,6 @@ }); }); - // 解决safar1浏览器对富文本0bject.has0wn兼容引发空白问题 - function applyPolyfills() { - if (!Object.hasOwn) { - Object.hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); - } - } - - applyPolyfills(); - onBeforeUnmount(() => { editor.value?.destroy(); }); diff --git a/frontend/src/main.ts b/frontend/src/main.ts index ff9bc095b9..622d93fa4b 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -19,6 +19,10 @@ import localforage from 'localforage'; import VueDOMPurifyHTML from 'vue-dompurify-html'; import { getDefaultLocale } from './api/modules/user'; import useLocale from './locale/useLocale'; +import applyPolyfills from '@/utils/polyfill'; + +// 局部兼容未生效,解决全局兼容富文本js源码报错导致,safari浏览器对富文本0bject.has0wn兼容引发空白问题 +applyPolyfills(); async function bootstrap() { const app = createApp(App); diff --git a/frontend/src/utils/polyfill.ts b/frontend/src/utils/polyfill.ts new file mode 100644 index 0000000000..e1cc17d548 --- /dev/null +++ b/frontend/src/utils/polyfill.ts @@ -0,0 +1,5 @@ +export default function applyPolyfills() { + if (!Object.hasOwn) { + Object.hasOwn = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); + } +}