// src/libs/modernizr-wrapper.js
export function loadModernizr() {
    return new Promise((resolve) => {
        // 保存原始的require和define函数
        const originalRequire = window.requirejs || window.require;
        const originalDefine = window.define;

        // 临时替换全局函数
        window.require = undefined;
        window.define = undefined;

        const script = document.createElement('script');
        script.src = '/src/assets/js/modernizr.2.5.3.min.js';
        script.onload = () => {
            // 恢复原始函数
            if (originalRequire) window.require = originalRequire;
            if (originalDefine) window.define = originalDefine;

            // 确保Modernizr已加载
            const check = () => {
                if (window.Modernizr) {
                    resolve(window.Modernizr);
                } else {
                    setTimeout(check, 50);
                }
            };
            check();
        };
        document.head.appendChild(script);
    });
}