SOURCE

function handleStatusByAction(info=[], node) {
    if (!(info instanceof Array)) { info = [info] }
    // 获取字符串, 用于正则匹配, 进行逻辑处理
    const infoStr = info.toString();
    // 处理图片
    if (info.includes("img")) {
        const imgReg = /\w(\.gif|\.jpeg|\.png|\.jpg|\.bmp|\.svg)/i;
        const [url] = info.filter(param => imgReg.test(param));
        url && node.setImageUrl(url);
        url && node.setCursorUrl(url);
    }
    // 处理文本
    if (info.includes("text")) {
        // 16进制颜色
        const hexReg = /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/i;
        // rgb和rgba颜色
        const rgbaReg = /^[rR][gG][Bb][Aa]?[\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),){2}[\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),?[\s]*(0\.\d{1,2}|1|0)?[\)]{1}$/i;
        // 单词颜色需要带.color后缀
        const colorReg = /\w(\.color)/i;
        const [color] = info.filter(param => {
            if (hexReg.test(param)) { return hexReg.test(param) } 
            else if (rgbaReg.test(param)) { rgbaReg.test(param) } 
            else {
                return colorReg.test(param)
            }
        })
        color && node.setFontColor(color);
        color && node.setHoverFontColor(color);
    }
}
console 命令行工具 X clear

                    
>
console