美文网首页
ComfyUI搜索功能实现中文搜索修改

ComfyUI搜索功能实现中文搜索修改

作者: 师娘哪里去了 | 来源:发表于2023-12-12 14:08 被阅读0次

    显示效果,在中文插件的支持下,可以实现中文搜索。


    image.png

    修改文件web/lib/litegraph.css,在文件最后添加样式内容

    .node-zh-cn-name {
        background-color: rgb(128, 213, 247);
        color: #000;
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 2px 5px;
        cursor: pointer;
    }
    .node-zh-cn-name:hover {
        outline: 2px solid dodgerblue;
    }
    .node-zh-cn-name p {
        margin: 0;
    }
    .node-zh-cn-name span {
        text-align: center;
        border-radius: 5px;
        background-color: dodgerblue;
        color: #fff;
        padding: 2px;
        position: relative;
        min-width: 20px;
        overflow: hidden;
    }
    

    修改web/lib/litegraph.core.js

    搜索 var filtered = keys.filter( inner_test_filter ); 在下一行添加

    filtered=filtered.map(function(e){
                            if(/.*[\u4e00-\u9fa5]+.*$/.test(LiteGraph.registered_node_types[e]['title'])) {
                                return [e,LiteGraph.registered_node_types[e]['title']];
                            }else{
                                return e;
                            }
                         });
    

    修改前

    image.png
    修改后
    image.png
    搜索 inner_test_filter 在函数里
    if ((!options.show_all_if_empty || str) && type.toLowerCase().indexOf(str) === -1 )
    

    修改为

    if ((!options.show_all_if_empty || str) && (type.toLowerCase().indexOf(str) === -1 && ctor.title.indexOf(str) === -1 ))
    

    修改前


    image.png

    修改后


    image.png

    搜索 addResult 在函数里修改,将

    help.innerText = type;
    help.dataset["type"] = escape(type);
    

    替换为

    var tag = document.createElement("div");
    tag.className = "node-zh-cn-name";
    if(type instanceof Array){
      tag.innerHTML='<p>'+type[0]+'</p><span>'+type[1]+'</span>'
      help.appendChild(tag)
      help.dataset["type"] = escape(type[0]);
    }else{
      tag.innerHTML='<p>'+type+'</p>'
      help.appendChild(tag)
      help.dataset["type"] = escape(type);
    }
    

    修改前

    image.png
    修改后
    image.png
    最后刷新一下页面就可以了,不需要重启comfyUI 作者:枫叶下的熊 https://www.bilibili.com/read/cv28295184/ 出处:bilibili

    相关文章

      网友评论

          本文标题:ComfyUI搜索功能实现中文搜索修改

          本文链接:https://www.haomeiwen.com/subject/wbuvgdtx.html