function ellipsis(str, len) { return str.length > len ? str.slice(0, len) + '...' : str; } // 消息类型对应的标签主题色:0=系统消息(蓝),1=公告消息(橙),2=需求消息(绿) function tagTheme(type) { var map = { '0': 'primary', '1': 'warning', '2': 'success' }; return map[String(type)] || 'default'; } module.exports = { ellipsis: ellipsis, tagTheme: tagTheme }