Roamedit-DIY功能-明天今天昨天

sheen 2021-7-9 1130

/**
 * @title 时间跳转
 * @author 邦邦 && sheen
 * @note 在文档中出现明天,今天,昨天这三个词时,点击会跳转对应的当日
 */
pluginManager.register("future",{
    after_nodeView_parseOriText(nodeView,parsing){
        const sj = nodeView.data.created
        const daytime = 24*60*60   
        const sj01 = Number(sj + daytime),sj02 = Number(sj - daytime);
        const mt = timekit.format("yyyy-MM-dd",sj01)
        const zt = timekit.format("yyyy-MM-dd",sj02)
        const jt = timekit.format("yyyy-MM-dd",sj)
        if(/(明天|昨天|今天)(?![^\[\]]*]]|[^\[\]]*])/g.test(nodeView.data.ori)){
nodeView.setOriText(nodeView.data.ori
            .replaceAll(/明天(?![^\[\]]*]]|[^\[\]]*])/g,"[明天]"+ '(' + mt + ')')
            .replaceAll(/昨天(?![^\[\]]*]]|[^\[\]]*])/g,"[昨天]"+ '(' + zt + ')')
            .replaceAll(/今天(?![^\[\]]*]]|[^\[\]]*])/g,"[今天]"+ '(' + jt + ')'))
            plugin.inodeModel.save(nodeView.data),nodeView.reparse();
        }
    }
}
)


使用过程若遇到问题,除了在帖子和B站会回复,其他平台一律不回复相关的

快速回复
最新回复 (3)
  • xushaolin 2021-7-9
    0 2
                .replaceAll(/今天(?![^\[\]]*]]|[^\[\]]*])/g,"[昨天]"+ '(' + zt + ')')
                .replaceAll(/昨天(?![^\[\]]*]]|[^\[\]]*])/g,"[今天]"+ '(' + jt + ')');

    好像有问题

    需要改成:
                .replaceAll(/昨天(?![^\[\]]*]]|[^\[\]]*])/g,"[昨天]"+ '(' + zt + ')')
                .replaceAll(/今天(?![^\[\]]*]]|[^\[\]]*])/g,"[今天]"+ '(' + jt + ')');
  • sheen 2021-7-9
    0 3
    xushaolin .replaceAll(/今天(?![^\[\]]*]]|[^\[\]]*])/g,"[昨天]"+ '(' + zt + ')') ...
    谢谢,已修改
  • Innis 2021-7-9
    1 4
    这个酷!非常有用!爱了❤️
返回