From 28797a83cca48f9b13b4adee77a4aec25bdb661e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=AD=90=E9=BB=98?= <925456043@qq.com> Date: Mon, 22 Jun 2026 18:18:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=97=A7=E7=89=88=E6=9C=AC=20chrome=20-=20?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=99=BE=E5=BA=A6=E7=BB=9F=E8=AE=A1=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easyflow-ui-admin/app/index.html | 9 ---- easyflow-ui-admin/app/src/main.ts | 15 +++---- easyflow-ui-admin/app/src/polyfills.ts | 62 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 easyflow-ui-admin/app/src/polyfills.ts diff --git a/easyflow-ui-admin/app/index.html b/easyflow-ui-admin/app/index.html index b642016d..d3bb5f51 100644 --- a/easyflow-ui-admin/app/index.html +++ b/easyflow-ui-admin/app/index.html @@ -13,15 +13,6 @@ /> <%= VITE_APP_TITLE %> -
diff --git a/easyflow-ui-admin/app/src/main.ts b/easyflow-ui-admin/app/src/main.ts index 36fe0c5e..c76aa39e 100644 --- a/easyflow-ui-admin/app/src/main.ts +++ b/easyflow-ui-admin/app/src/main.ts @@ -1,14 +1,9 @@ -import { - initPreferences, - preferences, - updatePreferences, -} from '@easyflow/preferences'; -import { unmountGlobalLoading } from '@easyflow/utils'; +import './polyfills'; -import { - normalizeBrandAssetPreferences, - overridesPreferences, -} from './preferences'; +import {initPreferences, preferences, updatePreferences,} from '@easyflow/preferences'; +import {unmountGlobalLoading} from '@easyflow/utils'; + +import {normalizeBrandAssetPreferences, overridesPreferences,} from './preferences'; /** * 应用初始化完成之后再进行页面加载渲染 diff --git a/easyflow-ui-admin/app/src/polyfills.ts b/easyflow-ui-admin/app/src/polyfills.ts new file mode 100644 index 00000000..786d12aa --- /dev/null +++ b/easyflow-ui-admin/app/src/polyfills.ts @@ -0,0 +1,62 @@ +const objectConstructor = Object as ObjectConstructor & { + hasOwn?: (object: unknown, property: PropertyKey) => boolean; +}; + +if (typeof objectConstructor.hasOwn !== 'function') { + Object.defineProperty(Object, 'hasOwn', { + configurable: true, + value(object: unknown, property: PropertyKey) { + if (object === null || object === undefined) { + throw new TypeError('Cannot convert undefined or null to object'); + } + return Object.prototype.hasOwnProperty.call(Object(object), property); + }, + writable: true, + }); +} + +const arrayPrototype = Array.prototype as unknown[] & { + toReversed?: () => unknown[]; + toSorted?: (compareFn?: (left: unknown, right: unknown) => number) => unknown[]; + toSpliced?: ( + start: number, + deleteCount?: number, + ...items: unknown[] + ) => unknown[]; +}; + +if (typeof arrayPrototype.toReversed !== 'function') { + Object.defineProperty(Array.prototype, 'toReversed', { + configurable: true, + value() { + return Array.prototype.slice.call(this).reverse(); + }, + writable: true, + }); +} + +if (typeof arrayPrototype.toSorted !== 'function') { + Object.defineProperty(Array.prototype, 'toSorted', { + configurable: true, + value(compareFn?: (left: unknown, right: unknown) => number) { + return Array.prototype.slice.call(this).sort(compareFn); + }, + writable: true, + }); +} + +if (typeof arrayPrototype.toSpliced !== 'function') { + Object.defineProperty(Array.prototype, 'toSpliced', { + configurable: true, + value(start: number, deleteCount?: number, ...items: unknown[]) { + const copy = Array.prototype.slice.call(this); + if (arguments.length === 1) { + copy.splice(start); + } else { + copy.splice(start, deleteCount as number, ...items); + } + return copy; + }, + writable: true, + }); +}