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