leanote使用本地帐户时,去掉待同步的小红点

切换开发者工具,以下图,点击左上角的箭头图标,选取元素,直接选择小红点。 css

 

而后会看到小红点来自于resources/app/public/themes/default.css文件中2092行:node

.item-dirty:after,.item-err:after,.nb-dirty:after,.nb-new:after {
    content: "";
    width: 7px;
    height: 7px;
    background: #FF6363;
    border-radius: 50%;
    position: absolute
}

开发工具可动态选择样式是否生效,点击复选框中的勾便可。 
而后整个leanote项目中grep 'item-dirty',找到调用的地方。jquery

固然这里直接修改default.css文件去掉background: #FF6363;也能达到不显示小红点的效果。可是实际上还在,只是看不见而已。 
搜索结果发现是在resources/app/public/js/app/note.jsNote.setNoteDirty函数和Note._renderNotes函数。setNoteDirty函数在建立笔记的时候调用,_renderNotes函数在笔记列表发生变化时或者初次加载时调用。安全

Note.setNoteDirty = function(noteId, isDirty) {
    console.trace('setNoteDirty');
    var $leftNoteNav = $(tt('#noteItemList [noteId="?"]', noteId));
    if (!isDirty) {
        $leftNoteNav.removeClass('item-err');
    }
    this.setNoteCache({ NoteId: noteId, IsDirty: isDirty }, false);
    isDirty ? $leftNoteNav.addClass('item-dirty') : $leftNoteNav.removeClass('item-dirty');
    }
};
Note._renderNotes= function(...) {
    if (note.IsDirty || note.IsNew) {
        classes += " item-dirty";
    }
...
}

那么修改就是判断当前如果本地帐户,就不添加item-dirty样式了。正好该js文件中有个UserInfo.isLocal变量能够判断当前用户是否本地:app

if (note.IsDirty || note.IsNew) {
    console.log("UserInfo.IsLocal:"+UserInfo.IsLocal);
    if(!UserInfo.IsLocal) { //非本地帐户帐户才显示dirty图标(红色小圆点)added by wangyong 20171107
    classes += " item-dirty";
    }
}

这里提醒一下,查看源码过程当中发现isDirty这个布尔值决定了是否显示小红点,可是修改的时候不要直接去改isDirty这个布尔值,源代码可能基于这个值作了其余数据上的冲突、hash检测等等事情。咱们仅在css样式层面修改就很安全。函数

一样的方式能够去掉笔记本上的小红点。笔记本的小红点样式为nb-dirty nb-new,调用的地方在resources/app/public/js/jquery.ztree.all-3.5.js中,该js中没有现成的UserInfo可用,所以直接注释掉了如下代码……工具

if (node.IsDirty) {
    classes += "nb-dirty "
}
if (node.IsNew) {
    classes += "nb-new ";
}

我也是瞎折腾。。。开发工具