34 lines
649 B
JavaScript
34 lines
649 B
JavaScript
var ChatFomat = {
|
|
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}`;
|
|
}
|
|
};
|
|
|
|
export default ChatFomat;
|