Commit 9ec8efa5 authored by 罗超's avatar 罗超

Merge branch 'master' of http://gitlab.oytour.com/viitto/madara

# Conflicts:
#	src/renderer/components/msssage/index.vue
parents 93156bb9 0bc25050
This diff is collapsed.
...@@ -129,6 +129,7 @@ export default { ...@@ -129,6 +129,7 @@ export default {
if(!localStorage.currentAts){ if(!localStorage.currentAts){
localStorage.currentAts='{}' localStorage.currentAts='{}'
} }
localStorage.selfNam=userData.emName
if (this.usermodel.remeber) { if (this.usermodel.remeber) {
this.usermodel.userpic = userData.Icon; this.usermodel.userpic = userData.Icon;
this.usermodel.username = userData.emName; this.usermodel.username = userData.emName;
......
...@@ -406,28 +406,26 @@ export default { ...@@ -406,28 +406,26 @@ export default {
let accids=[] let accids=[]
ats.forEach(x=>{ ats.forEach(x=>{
if(x=='@全体成员(all)'){ if(x=='@全体成员(all)'){
accids.push({ accids.push('-1')
account:'-1',
alias:'@全体成员(all)'
})
} else { } else {
this.members.forEach(y=>{ this.members.forEach(y=>{
if(x==`@${y.alias}`){ if(x==`@${y.alias}`){
accids.push({ accids.push(`${y.account}`)
account:y.account,
alias:'@'+y.alias
})
} }
}) })
} }
}) })
let apns={
accounts:accids,
content:`${localStorage.selfNam}在群里@了你`,
forcePush:true
}
this.$store.dispatch("sendMsg", { this.$store.dispatch("sendMsg", {
type: "at", type: "at",
scene: this.scene, scene: this.scene,
to: this.to, to: this.to,
text: this.msgToSent, text: this.msgToSent,
content: accids, apns
callbackTeam:this.callBackTeam
}); });
}else{ }else{
console.log('in start...........',new Date()) console.log('in start...........',new Date())
......
...@@ -512,14 +512,15 @@ export default { ...@@ -512,14 +512,15 @@ export default {
// 文本消息 // 文本消息
item.showText = util.escape(item.text); item.showText = util.escape(item.text);
let ats = item.showText.replace(/ /ig, " ").match(/@[^\s@$]+/g) let ats = item.showText.replace(/ /ig, " ").match(/@[^\s@$]+/g)
if(ats && item.scene=='team' && item.custom){ if(ats && item.scene=='team' && item.apns && item.apns.accounts && item.apns.accounts.length>0){
let atUser=JSON.parse(item.custom) //let atUser=item.apns
console.log(item)
ats.forEach(at=>{ ats.forEach(at=>{
let isExsit=atUser.find(x=>{ // let isExsit=atUser.find(x=>{
return x.alias==at // return x.alias==at
}) // })
if(isExsit) // if(isExsit)
item.showText=item.showText.replace(at,`<p class='at-user'>${at}</p>`) item.showText=item.showText.replace(at,`<p class='at-user'>${at}</p>`)
}) })
} }
if (/\[[^\]]+\]/.test(item.showText)) { if (/\[[^\]]+\]/.test(item.showText)) {
......
...@@ -78,58 +78,13 @@ ...@@ -78,58 +78,13 @@
</div> </div>
</li> </li>
</template> </template>
<template v-for="(session, index) in sessionlist">
<li
:class="{'active':currentSession.id==session.id}"
style="background:rgb(238,238,238)"
v-if="session.top && (sessionKey=='' || session.name.indexOf(sessionKey)!=-1)"
:key="index"
@contextmenu.prevent='showMenu(session,$event)'
@click="enterChat(session)"
>
<el-badge
:value="session.unread"
:max="99"
class="item"
:hidden="session.unread==0"
:is-dot="session.isMute && session.unread>0"
>
<div
class="headinfo"
:class="{'notice':!session.avatar,'blue':session.groupType==0,'green':session.groupType==1,'user':session.groupType==-1}"
>
<img :src="session.avatar" v-if="session.avatar">
<i class="iconfont icontaolun" v-else-if="session.groupType == 0"></i>
<i class="iconfont iconqunzu" v-else-if="session.groupType == 1"></i>
<i class="iconfont iconyonghutouxiang" v-else></i>
</div>
</el-badge>
<div class="baseinfo">
<div class="userbase">
<div class="name">{{session.name}}</div>
<div class="time">{{session.updateTimeShow}}</div>
</div>
<div class="msgbase">
<div class="last">
<span class="at-me" v-if="session.atId">[有人@我]</span>
<template v-if="session.isMute && session.unread>0 && !session.historiMsg">
<span>[{{session.unread}}]</span>
</template>
<span v-if="!session.historiMsg">{{session.lastMsgShow}}</span>
<span v-if="session.historiMsg && currentSession.id !== session.id" style="color: red">[草稿]</span>{{session.historiMsg}}
</div>
<div class="no-tip" v-if="session.isMute">
<i class="iconfont iconmiandarao-kai"></i>
</div>
</div>
</div>
</li>
</template>
<template v-for="(session, index) in sessionlist"> <template v-for="(session, index) in sessionlist">
<!-- && session.lastMsgShow!== '[未知消息类型]' --> <!-- && session.lastMsgShow!== '[未知消息类型]' -->
<li <li
:class="{'active':currentSession.id==session.id}" :class="{'active':currentSession.id==session.id}"
v-if="!session.top && (sessionKey=='' || session.name.indexOf(sessionKey)!=-1) && session.name!== ''" v-if="(sessionKey=='' || session.name.indexOf(sessionKey)!=-1) && session.name!== ''"
:style="{background: session.top ? 'rgb(238,238,238)' : ''}"
:key="index" :key="index"
@contextmenu.prevent='showMenu(session,$event)' @contextmenu.prevent='showMenu(session,$event)'
@click="enterChat(session)" @click="enterChat(session)"
...@@ -158,7 +113,7 @@ ...@@ -158,7 +113,7 @@
</div> </div>
<div class="msgbase"> <div class="msgbase">
<div class="last"> <div class="last">
<span class="at-me" v-if="session.atId">[有人@我]</span> <span class="at-me" v-if="session.atId && session.unread>0">[有人@我]</span>
<template v-if="session.isMute && session.unread>0 && !session.historiMsg"> <template v-if="session.isMute && session.unread>0 && !session.historiMsg">
<span>[{{session.unread}}]</span> <span>[{{session.unread}}]</span>
</template> </template>
...@@ -235,7 +190,8 @@ export default { ...@@ -235,7 +190,8 @@ export default {
atIds:null, atIds:null,
forwardMsgInfo:{}, forwardMsgInfo:{},
sessionlistArr: [], sessionlistArr: [],
initSessionList:[] initSessionList:[],
localAts:{}
}; };
}, },
updated() { updated() {
...@@ -383,33 +339,38 @@ export default { ...@@ -383,33 +339,38 @@ export default {
} }
}, },
clearAtMe(){ clearAtMe(){
let teamInfo = null;
if (this.currentSession.scene === "team") { if (this.currentSession.scene === "team") {
teamInfo = this.$store.state.teamlist.find(team => { this.$store.state.teamlist.forEach(team => {
return team.teamId === this.currentSession.to; if(team.teamId === this.currentSession.to){
delete team.atId
}
}); });
this.localAts=JSON.parse(localStorage.currentAts)
if(this.localAts[this.currentSession.to])
delete this.localAts[this.currentSession.to]
localStorage.currentAts=JSON.stringify(this.localAts)
} }
if(teamInfo && teamInfo.custom){ // if(teamInfo && teamInfo.custom){
let custom=JSON.parse(teamInfo.custom) // let custom=JSON.parse(teamInfo.custom)
if(custom.ats){ // if(custom.ats){
custom.ats=custom.ats.filter(x=>{ // custom.ats=custom.ats.filter(x=>{
if(x.account==this.$store.state.userUID) // if(x.account==this.$store.state.userUID)
return // return
return x // return x
}) // })
this.$store.dispatch("delegateTeamFunction", { // this.$store.dispatch("delegateTeamFunction", {
functionName: 'updateTeam', // functionName: 'updateTeam',
options: { // options: {
teamId: teamInfo.teamId, // teamId: teamInfo.teamId,
custom: JSON.stringify(custom), // custom: JSON.stringify(custom),
done: (error, team) => { // done: (error, team) => {
// console.log('serverCustom Error:',error) // // console.log('serverCustom Error:',error)
} // }
} // }
}) // })
} // }
} // }
}, },
openNotice(){ openNotice(){
this.$store.dispatch("resetCurrSession") this.$store.dispatch("resetCurrSession")
...@@ -496,6 +457,7 @@ export default { ...@@ -496,6 +457,7 @@ export default {
}, },
mounted() { mounted() {
this.audio_base=this.$electron.remote.getGlobal("AUDIO_PATH")+'audio/' this.audio_base=this.$electron.remote.getGlobal("AUDIO_PATH")+'audio/'
this.localAts=JSON.parse(localStorage.currentAts)
if (window.localStorage.top) { if (window.localStorage.top) {
this.TOPSESSION = JSON.parse(window.localStorage.top); this.TOPSESSION = JSON.parse(window.localStorage.top);
} }
...@@ -543,17 +505,18 @@ export default { ...@@ -543,17 +505,18 @@ export default {
this.MsgBus.$on("create-session", function(obj) { this.MsgBus.$on("create-session", function(obj) {
that.createSession(obj) that.createSession(obj)
}); });
this.MsgBus.$on('reload-ats',function(){
this.localAts=JSON.parse(localStorage.currentAts)
})
// //
setTimeout(() => { setTimeout(() => {
this.initSessionList=this.sessionlist.filter(x=>{ this.initSessionList=this.sessionlist.filter(x=>{
console.log(x.lastMsg) if(x.scene=='team' && x.unread>0 && x.unread<100 && !this.localAts[x.to]){
if(x.scene=='team' && x.unread>0 && x.unread<100){
return x return x
}else{ }else{
return false return false
} }
}) })
console.log(this.initSessionList)
if(this.initSessionList.length>0){ if(this.initSessionList.length>0){
this.getAts() this.getAts()
} }
...@@ -622,23 +585,35 @@ export default { ...@@ -622,23 +585,35 @@ export default {
? this.myGroupIcon ? this.myGroupIcon
: this.myAdvancedIcon); : this.myAdvancedIcon);
item.isMute = teamInfo.usermute ? teamInfo.usermute : false; item.isMute = teamInfo.usermute ? teamInfo.usermute : false;
try { // try {
if(teamInfo.custom){ // if(teamInfo.custom){
let custom=JSON.parse(teamInfo.custom) // let custom=JSON.parse(teamInfo.custom)
if(custom.ats){ // if(custom.ats){
let atme =custom.ats.find(x=>{ // let atme =custom.ats.find(x=>{
return x.account==this.$store.state.userUID // return x.account==this.$store.state.userUID
}) // })
if(atme && this.currentSession.id!=item.id){ // if(atme && this.currentSession.id!=item.id){
item.atId=atme.id // item.atId=atme.id
}else if(atme && this.currentSession.id==item.id){ // }else if(atme && this.currentSession.id==item.id){
setTimeout(() => { // setTimeout(() => {
this.clearAtMe() // this.clearAtMe()
}, 1000); // }, 1000);
} // }
// }
// }
// } catch (error) {}
if(item.lastMsg.apns && item.lastMsg.apns.accounts && (item.lastMsg.apns.accounts.indexOf(localStorage.imAccount) != -1 || item.lastMsg.apns.accounts[0] == -1)){
item.atId=item.lastMsg.idServer
}else{
if(teamInfo.atId){
item.atId=teamInfo.atId
}else{
item.atId=null
if(this.localAts[item.to]){
item.atId=this.localAts[item.to]
} }
} }
} catch (error) {} }
} else { } else {
return; return;
item.groupType = "normal"; item.groupType = "normal";
...@@ -751,6 +726,7 @@ export default { ...@@ -751,6 +726,7 @@ export default {
this.newMsgList = unreadList; this.newMsgList = unreadList;
sessionlist.sort((a, b) => b.top - a.top)
return sessionlist; return sessionlist;
} }
// netState(){ // netState(){
......
...@@ -233,7 +233,6 @@ export function sendMsg({ state, commit }, obj) { ...@@ -233,7 +233,6 @@ export function sendMsg({ state, commit }, obj) {
done: onSendMsgDone, done: onSendMsgDone,
needMsgReceipt: obj.needMsgReceipt || false needMsgReceipt: obj.needMsgReceipt || false
}) })
console.log('start sdk.........')
util.getDate() util.getDate()
break break
case 'at': case 'at':
...@@ -241,13 +240,11 @@ export function sendMsg({ state, commit }, obj) { ...@@ -241,13 +240,11 @@ export function sendMsg({ state, commit }, obj) {
scene: obj.scene, scene: obj.scene,
to: obj.to, to: obj.to,
text: obj.text, text: obj.text,
done: function(err, msg) { apns: obj.apns,
obj.callbackTeam(obj.content, msg.idServer) done: onSendMsgDone,
onMsg(msg) needMsgReceipt: obj.needMsgReceipt || false
},
needMsgReceipt: obj.needMsgReceipt || false,
custom: JSON.stringify(obj.content)
}) })
util.getDate()
break break
case 'custom': case 'custom':
nim.sendCustomMsg({ nim.sendCustomMsg({
...@@ -482,7 +479,7 @@ export function getHistoryMsgs({ state, commit }, obj) { ...@@ -482,7 +479,7 @@ export function getHistoryMsgs({ state, commit }, obj) {
msgs: msgs, msgs: msgs,
to: to to: to
}) })
} else { } else {
commit('updateCurrSessionMsgs', { commit('updateCurrSessionMsgs', {
type: 'concat', type: 'concat',
msgs: msgs msgs: msgs
......
This diff is collapsed.
...@@ -260,12 +260,25 @@ export default { ...@@ -260,12 +260,25 @@ export default {
// 装入未读消息 // 装入未读消息
unreadListHis(state, obj) { unreadListHis(state, obj) {
let currentAts = JSON.parse(localStorage.currentAts) let currentAts = JSON.parse(localStorage.currentAts)
let tempteamlist = store.state.teamlist
let teamObj = []
obj.msgs.forEach(x => { obj.msgs.forEach(x => {
if (x.apns && x.apns.accounts && x.apns.accounts.indexOf(localStorage.imAccount) != -1) {
if (x.apns && x.apns.accounts && (x.apns.accounts.indexOf(localStorage.imAccount) != -1 || x.apns.accounts[0] == -1)) {
console.log(x.apns)
currentAts[obj.to] = x.idServer currentAts[obj.to] = x.idServer
localStorage.setItem("currentAts", JSON.stringify(currentAts) || {});
tempteamlist.forEach(t => {
if (t.teamId == obj.to) {
t.atId = x.idServer
}
teamObj.push(t)
})
} }
}) })
localStorage.currentAts = JSON.stringify(currentAts) || {} if (teamObj.length > 0) {
store.commit('updateTeamList', teamObj)
}
}, },
// clearMsgs(state, obj) { // clearMsgs(state, obj) {
// state.msgs = [] // state.msgs = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment