Files
OneOS1.2/src/common/oneosWebLegacy/legacyGlobals.ts

39 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import * as antd from 'antd';
import {
formatMoney,
formatMoneyYuan,
formatMoneyWithUnit,
formatNumber,
formatInteger,
} from '../format-number.js';
declare global {
interface Window {
React: typeof React;
ReactDOM: typeof ReactDOM;
antd: typeof antd;
__oneosFormatNumber: typeof formatNumber;
__oneosFormatMoney: typeof formatMoney;
__oneosFormatMoneyYuan: typeof formatMoneyYuan;
__oneosFormatMoneyWithUnit: typeof formatMoneyWithUnit;
__oneosFormatInteger: typeof formatInteger;
}
}
export function ensureOneosWebLegacyGlobals(): void {
if (typeof window === 'undefined') return;
window.React = React;
window.ReactDOM = ReactDOM;
window.antd = antd;
window.__oneosFormatNumber = formatNumber;
window.__oneosFormatMoney = formatMoney;
window.__oneosFormatMoneyYuan = formatMoneyYuan;
window.__oneosFormatMoneyWithUnit = formatMoneyWithUnit;
window.__oneosFormatInteger = formatInteger;
}
// Legacy jsx 可能在模块顶层使用 React.createElement须在页面 import 之前完成注入。
ensureOneosWebLegacyGlobals();