rt-sim-training-client/src/utils/chatFomat.js

34 lines
649 B
JavaScript
Raw Normal View History

2019-07-26 13:32:43 +08:00
var ChatFomat = {
2019-08-02 14:31:29 +08:00
roleConfig: {
'Admin': '管理员',
'Instructor': '教员',
'Dispatcher': '行调',
'Attendant': '车站',
'Audience': '观众',
'Driver': '列车'
},
formatTime(time) {
return /\d{2}:\d{2}:\d{2}/.exec(time)[0] || time;
},
formatName(member) {
let name = `${member.nickName}`;
if (member.id) {
name = `${this.roleConfig[member.role] || ''}${name}`;
}
return name;
},
formatSay(nor) {
let who = '';
if (nor.group) {
if (nor.targetMember) {
who = `@${nor.targetMember.nickName}`;
} else {
who = '@ALL';
}
}
return `${who} ${nor.value}`;
}
2019-07-26 13:32:43 +08:00
};
export default ChatFomat;