xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

qrcode & console.log

qrcode & console.log

image

https://fs-api.lightyy.com/service/utils/qrcode?url=http://169.254.130.54:3000/#/chat

import Light from "light";

/**
 * 打印二维码
 */
function printQRCode(hashpath) {
    //93781 lighting工程不管是jsn项目还是纯h5项目都在控制台显示二维码
    let path = location.pathname;
    //110579:--onlyfor h5 时二维码打印h5的
    if (typeof weex !== "undefined" && Light.onlyFor !== 'h5') {
        //105231 二维码内容兼容多页工程
        path = (path === "/" || path === "/index.html") ? `/${Light.mainPage}.native.js` : path.replace(/\.html/ig, ".native.js");
    }
    //128463当无法联网的环境下时,不再去请求平台接口来显示二维码
    if(navigator.onLine){
        let urlToScan = `http://${location.host}${path}${location.search}#${hashpath}`;
        Light.ajax({
            url:`https://fs-api.lightyy.com/service/utils/qrcode?url=${encodeURIComponent(urlToScan)}`,
            type:"get",
            dataType:"json",
            success(data){
                console.log("LightView 扫码 URL: " + urlToScan);
                //91631 最新版本chrome浏览器的console无法打印二维码
                console.log("%c ", "padding:75px 80px 75px;background:url(" + data.data + ") no-repeat;background-size:150px");
            }
        })
    }
    
}

/**
 * 计算节点的数量
 * @param node
 * @returns {number}
 */
function countNodes(node) {
    let count = 1;
    if(node.hasChildNodes()) {
        let cnodes = node.childNodes;
        for(let i=0; i<cnodes.length; i++) {
            count = count + countNodes(cnodes.item(i))
        }
    }
    return count;
}
/**
 * 计算节点的层数
 * @param node
 * @returns {number}
 */
function countLevels(node) {
    if(node.hasChildNodes()) {
        let cnodes = node.childNodes;

        let levels = [];
        cnodes.forEach(function (n) {
            levels.push(  1 + countLevels(n))
        })
        return Math.max(...levels)
    }else{
        return 1;
    }
}

Light.filter("route", function (from, to, next) {
    try {
        next();
        printQRCode(to.fullPath);

        //93785 lighting工程在展示当前视图的dom节点数量和最深的节点层次
        setTimeout(function () {
            let count = countNodes(document.body);
            let level = countLevels(document.body);
            console.log(`当前视图的DOM节点总数为:${count},最深的DOM节点层次为:${level}`);//
        },1000)
    }catch (e) {
        console.log(e)
    }
});

//93779 lighting工程编译时如果是添加了-w选项则在控制台提示用户可以查看编译资源树及分析
console.log(`%c查看编译资源详情请点击链接:http://${location.host}/stats.html`,"font-size:15px;color:red;font-weight:bolder");



//////////////////
// WEBPACK FOOTER
// C:/Users/xiagq/.lighting-plugins/node_modules/lighting-plugin-type-vue/plugins/qrcode.js
// module id = 305
// module chunks = 0

base 64


flutter ios app

https://github.com/X-Wei/flutter_catalog



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2019-06-28 14:06  xgqfrms  阅读(181)  评论(3编辑  收藏  举报