(()=>{

    const
       竖屏 = 0.4,
       横屏 = 0.7,
       强制缩放 = 1.0,
       网页宽度 = 700,
       meta = document.querySelector('meta[name=viewport]'),
       ori = screen.orientation.type,
       ua = navigator.userAgent;

    function changeScale(x) {
       meta.setAttribute(
         'content',
         `width=device-width,initial-scale=${x},maximum-scale=10.0,user-scalable=1`);
    };

    function autoChangeScale() {
        if (ori.indexOf('landscape')==0) {
            changeScale(横屏);
        } else {
            if (ua.indexOf('Mobile')<0) {
                changeScale(竖屏);
            } else if (window.innerWidth<网页宽度) {
                changeScale(强制缩放);
            }
        }
    }

    // 刚打开
    autoChangeScale();

    // 用户改变
    screen.orientation.onchange = autoChangeScale;

})();