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); + } +}