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,13 +512,14 @@ export default { ...@@ -512,13 +512,14 @@ 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>`)
}) })
} }
......
...@@ -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
} }
if(teamInfo && teamInfo.custom){ });
let custom=JSON.parse(teamInfo.custom) this.localAts=JSON.parse(localStorage.currentAts)
if(custom.ats){ if(this.localAts[this.currentSession.to])
custom.ats=custom.ats.filter(x=>{ delete this.localAts[this.currentSession.to]
if(x.account==this.$store.state.userUID) localStorage.currentAts=JSON.stringify(this.localAts)
return }
return x // if(teamInfo && teamInfo.custom){
}) // let custom=JSON.parse(teamInfo.custom)
// if(custom.ats){
// custom.ats=custom.ats.filter(x=>{
// if(x.account==this.$store.state.userUID)
// return
// 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({
......
...@@ -7,16 +7,16 @@ export function onTeams(teams) { ...@@ -7,16 +7,16 @@ export function onTeams(teams) {
} }
teams = teams.filter(item => !!item) teams = teams.filter(item => !!item)
let teamIds = [] let teamIds = []
teams.forEach(team=>{ teams.forEach(team => {
teamIds.push(team.teamId) teamIds.push(team.teamId)
if (team.validToCurrentUser === undefined) { if (team.validToCurrentUser === undefined) {
team.validToCurrentUser = true team.validToCurrentUser = true
} }
if (team.avatar && team.avatar.indexOf('nim.nosdn.127') >0 && team.avatar.indexOf('?imageView')===-1) { if (team.avatar && team.avatar.indexOf('nim.nosdn.127') > 0 && team.avatar.indexOf('?imageView') === -1) {
team.avatar = team.avatar + '?imageView&thumbnail=300y300' team.avatar = team.avatar + '?imageView&thumbnail=300y300'
} }
}) })
getNotifyForNewTeamMsg(store,teamIds) getNotifyForNewTeamMsg(store, teamIds)
store.commit('updateTeamList', teams) store.commit('updateTeamList', teams)
} }
...@@ -35,7 +35,7 @@ export function onCreateTeam(team) { ...@@ -35,7 +35,7 @@ export function onCreateTeam(team) {
}) })
} }
export function onSynCreateTeam(team){ export function onSynCreateTeam(team) {
onTeams(team) onTeams(team)
} }
...@@ -46,10 +46,11 @@ export function onDismissTeam(obj) { ...@@ -46,10 +46,11 @@ export function onDismissTeam(obj) {
} }
export function onUpdateTeam(team) { export function onUpdateTeam(team) {
console.log('team update..........')
onTeams(team) onTeams(team)
} }
export function onTeamNotificationMsg({state, commit}, msg) { export function onTeamNotificationMsg({ state, commit }, msg) {
if (msg.attach.type === 'updateTeam' && msg.attach.team) { if (msg.attach.type === 'updateTeam' && msg.attach.team) {
store.commit('updateTeamInfo', msg.attach.team) store.commit('updateTeamInfo', msg.attach.team)
} }
...@@ -62,7 +63,7 @@ export function onTeamNotificationMsg({state, commit}, msg) { ...@@ -62,7 +63,7 @@ export function onTeamNotificationMsg({state, commit}, msg) {
} }
export function onAddTeamMembers(obj) { export function onAddTeamMembers(obj) {
obj.accounts.forEach(account=>{ obj.accounts.forEach(account => {
// 自己被拉入群时更新群列表 // 自己被拉入群时更新群列表
if (account === store.state.userUID) { if (account === store.state.userUID) {
let team = [obj.team] let team = [obj.team]
...@@ -120,7 +121,7 @@ export function onTeamMsgReceipt(obj) { ...@@ -120,7 +121,7 @@ export function onTeamMsgReceipt(obj) {
} }
// 进入可配置的群信息设置页,进入前改变state中的配置信息,进入页面后读取配置信息更新视图 // 进入可配置的群信息设置页,进入前改变state中的配置信息,进入页面后读取配置信息更新视图
export function enterSettingPage({commit}, obj) { export function enterSettingPage({ commit }, obj) {
commit('updateTeamSettingConfig', obj) commit('updateTeamSettingConfig', obj)
// setTimeout(() => { // setTimeout(() => {
// location.href = `#/teamsetting` // location.href = `#/teamsetting`
...@@ -129,16 +130,16 @@ export function enterSettingPage({commit}, obj) { ...@@ -129,16 +130,16 @@ export function enterSettingPage({commit}, obj) {
/* /*
* 代理nim sdk中对群组的操作方法 * 代理nim sdk中对群组的操作方法
* @functionName nim sdk中的方法名 * @functionName nim sdk中的方法名
* @options 传递给sdk方法的参数 * @options 传递给sdk方法的参数
*/ */
export function delegateTeamFunction({state}, {functionName, options}) { export function delegateTeamFunction({ state }, { functionName, options }) {
const nim = state.nim const nim = state.nim
if (functionName && nim[functionName] && typeof nim[functionName] === 'function') { if (functionName && nim[functionName] && typeof nim[functionName] === 'function') {
nim[functionName](options) nim[functionName](options)
} else { } else {
throw(`There is not property of '${functionName}' in nim or '${functionName}' is not a function`) throw (`There is not property of '${functionName}' in nim or '${functionName}' is not a function`)
} }
} }
...@@ -168,26 +169,26 @@ export function getTeamMembers({ state }, teamId) { ...@@ -168,26 +169,26 @@ export function getTeamMembers({ state }, teamId) {
}) })
} }
export function getNotifyForNewTeamMsg({state,commit},teamIds) { export function getNotifyForNewTeamMsg({ state, commit }, teamIds) {
const nim = state.nim const nim = state.nim
nim.notifyForNewTeamMsg({ nim.notifyForNewTeamMsg({
teamIds: teamIds, teamIds: teamIds,
done: (err, obj) => { done: (err, obj) => {
commit('updateTeamUserMute',obj) commit('updateTeamUserMute', obj)
} }
}) })
} }
export function checkTeamMsgReceipt({state}, msgs) { export function checkTeamMsgReceipt({ state }, msgs) {
var result = /team-(\d+)/.exec(state.currSessionId) var result = /team-(\d+)/.exec(state.currSessionId)
if (!result) { if (!result) {
return null return null
} }
var teamId = result[1] var teamId = result[1]
var needToPeceiptList= getMsgNeedToReceipt(state, teamId, msgs) var needToPeceiptList = getMsgNeedToReceipt(state, teamId, msgs)
if (needToPeceiptList && needToPeceiptList.length>0) { if (needToPeceiptList && needToPeceiptList.length > 0) {
nim.sendTeamMsgReceipt({ nim.sendTeamMsgReceipt({
teamMsgReceipts: needToPeceiptList, teamMsgReceipts: needToPeceiptList,
done: (err, obj, content) => { done: (err, obj, content) => {
...@@ -225,8 +226,8 @@ export function getTeamMsgReads({ state }, needQuery) { ...@@ -225,8 +226,8 @@ export function getTeamMsgReads({ state }, needQuery) {
done: (error, obj, content) => { done: (error, obj, content) => {
if (error) { if (error) {
//console.log('获取群组消息已读' + error) //console.log('获取群组消息已读' + error)
let a=0; let a = 0;
}else { } else {
//('获取群组消息已读:', content) //('获取群组消息已读:', content)
store.commit('updateTeamMsgReads', content) store.commit('updateTeamMsgReads', content)
} }
......
...@@ -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