<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>招聘官网</title><script src=/sf-webproxy/api/vpn-config></script><script src=/sf-webproxy/resource/web_proxy.js?v=1.4.3.605></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html, body {
            overflow: hidden;
        }

        #iframeCon {
            width: 100vw;
            height: 100vh;
            border: none;
            overflow: hidden;
        }
    </style>
</head>
<body>
<iframe id="iframeCon" src="">

</iframe>
</body>
<script type="text/javascript">
    // 请求
    function ajax(method, url, data, success, error) {
        const xhr = new XMLHttpRequest();
        xhr.open(method, url, true);
        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    success(JSON.parse(xhr.responseText));
                } else {
                    error();
                    console.error(xhr.statusText);
                }
            }
        };
        xhr.send(data);
    }

    const UA = window.navigator.userAgent.toLowerCase();
    const isAndroid = UA && /(android|openharmony|harmonyos)/i.test(UA);
    const isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA);
    const defaultUrl = {
        link: 'https://www.dayee.com',
        title: '大易官网',
    };

    ajax(
        'POST',
        `${location.origin}/wecruit/common/getSLD`,
        `sld=${location.host}`,
        function (res) {
            const {data, state} = res;

            if (state === '200' && data) {
                const {linkData, linkDataMobile} = data;

                if (isAndroid || isIos) {   //终端为移动端
                    let href = '';

                    if (linkDataMobile !== undefined && linkDataMobile.link) {
                        href = linkDataMobile.link;
                    } else if (linkData !== undefined && linkData.link) {
                        href = linkData.link;
                    } else {
                        href = defaultUrl.link;
                    }

                    if (href.indexOf('sp.wintalent.cn') !== -1 && href.indexOf('flag=clearCache') !== -1) {
                        href += `&v=${new Date().getTime()}`
                    }

                    proxyLoc(window.location).href = href;
                } else {   //终端为PC端
                    const {title, link, icon} = linkData || defaultUrl;

                    document.title = title;
                    document.getElementById('iframeCon').setAttribute('src', link);

                    // 根据配置设置favicon.ico
                    if (icon) {
                        let iconLink = document.querySelector("link[rel*='icon']") || document.createElement('link');
                        iconLink.type = 'image/x-icon';
                        iconLink.rel = 'shortcut icon';
                        proxyLoc(iconLink).href = icon;
                        document.getElementsByTagName('head')[0].appendChild(iconLink);
                    }
                }
            } else {
                proxyLoc(window.location).href = defaultUrl.link;
            }
        },
        function () {
            proxyLoc(window.location).href = defaultUrl.link;
        },
    );
</script>
</html>

