|
|
@ -1,60 +1,61 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div class="home-page"> |
|
|
<div class="home-page"> |
|
|
<div class="app-container" :class="{ fullscreen: isFullscreen }"> |
|
|
<div class="app-container" :class="{ fullscreen: isFullscreen }"> |
|
|
<div class="navi-bar"> |
|
|
<div class="navi-bar"> |
|
|
<div class="navi-bar-box"> |
|
|
<div class="navi-bar-box"> |
|
|
<div class="top"> |
|
|
<div class="top"> |
|
|
<div class="user-head-image"> |
|
|
<div class="user-head-image"> |
|
|
<head-image :name="$store.state.userStore.userInfo.nickName" :size="38" |
|
|
<head-image :name="$store.state.userStore.userInfo.nickName" :size="38" |
|
|
:url="$store.state.userStore.userInfo.headImageThumb" @click.native="showSettingDialog = true"> |
|
|
:url="$store.state.userStore.userInfo.headImageThumb" |
|
|
</head-image> |
|
|
@click.native="showSettingDialog = true"> |
|
|
</div> |
|
|
</head-image> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="menu"> |
|
|
<div class="menu"> |
|
|
<router-link class="link" v-bind:to="'/home/chat'"> |
|
|
<router-link class="link" v-bind:to="'/home/chat'"> |
|
|
<div class="menu-item"> |
|
|
<div class="menu-item"> |
|
|
<span class="icon iconfont icon-chat"></span> |
|
|
<span class="icon iconfont icon-chat"></span> |
|
|
<div v-show="unreadCount > 0" class="unread-text">{{ unreadCount }}</div> |
|
|
<div v-show="unreadCount > 0" class="unread-text">{{ unreadCount }}</div> |
|
|
</div> |
|
|
</div> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<router-link class="link" v-bind:to="'/home/friend'"> |
|
|
<router-link class="link" v-bind:to="'/home/friend'"> |
|
|
<div class="menu-item"> |
|
|
<div class="menu-item"> |
|
|
<span class="icon iconfont icon-friend"></span> |
|
|
<span class="icon iconfont icon-friend"></span> |
|
|
</div> |
|
|
</div> |
|
|
</router-link> |
|
|
</router-link> |
|
|
<router-link class="link" v-bind:to="'/home/group'"> |
|
|
<router-link class="link" v-bind:to="'/home/group'"> |
|
|
<div class="menu-item"> |
|
|
<div class="menu-item"> |
|
|
<span class="icon iconfont icon-group" style="font-size: 28px"></span> |
|
|
<span class="icon iconfont icon-group" style="font-size: 28px"></span> |
|
|
</div> |
|
|
</div> |
|
|
</router-link> |
|
|
</router-link> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
<div class="botoom"> |
|
|
<div class="botoom"> |
|
|
<div class="botoom-item" @click="isFullscreen = !isFullscreen"> |
|
|
<div class="botoom-item" @click="isFullscreen = !isFullscreen"> |
|
|
<i class="el-icon-full-screen"></i> |
|
|
<i class="el-icon-full-screen"></i> |
|
|
</div> |
|
|
</div> |
|
|
<div class="botoom-item" @click="showSetting"> |
|
|
<div class="botoom-item" @click="showSetting"> |
|
|
<span class="icon iconfont icon-setting" style="font-size: 20px"></span> |
|
|
<span class="icon iconfont icon-setting" style="font-size: 20px"></span> |
|
|
</div> |
|
|
</div> |
|
|
<div class="botoom-item" @click="onExit()" title="退出"> |
|
|
<div class="botoom-item" @click="onExit()" title="退出"> |
|
|
<span class="icon iconfont icon-exit"></span> |
|
|
<span class="icon iconfont icon-exit"></span> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="content-box"> |
|
|
<div class="content-box"> |
|
|
<router-view></router-view> |
|
|
<router-view></router-view> |
|
|
</div> |
|
|
</div> |
|
|
<setting :visible="showSettingDialog" @close="closeSetting()"></setting> |
|
|
<setting :visible="showSettingDialog" @close="closeSetting()"></setting> |
|
|
<user-info v-show="uiStore.userInfo.show" :pos="uiStore.userInfo.pos" :user="uiStore.userInfo.user" |
|
|
<user-info v-show="uiStore.userInfo.show" :pos="uiStore.userInfo.pos" :user="uiStore.userInfo.user" |
|
|
@close="$store.commit('closeUserInfoBox')"></user-info> |
|
|
@close="$store.commit('closeUserInfoBox')"></user-info> |
|
|
<full-image :visible="uiStore.fullImage.show" :url="uiStore.fullImage.url" |
|
|
<full-image :visible="uiStore.fullImage.show" :url="uiStore.fullImage.url" |
|
|
@close="$store.commit('closeFullImageBox')"></full-image> |
|
|
@close="$store.commit('closeFullImageBox')"></full-image> |
|
|
<rtc-private-video ref="rtcPrivateVideo"></rtc-private-video> |
|
|
<rtc-private-video ref="rtcPrivateVideo"></rtc-private-video> |
|
|
<rtc-group-video ref="rtcGroupVideo"></rtc-group-video> |
|
|
<rtc-group-video ref="rtcGroupVideo"></rtc-group-video> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
@ -67,443 +68,456 @@ import RtcPrivateAcceptor from '../components/rtc/RtcPrivateAcceptor.vue'; |
|
|
import RtcGroupVideo from '../components/rtc/RtcGroupVideo.vue'; |
|
|
import RtcGroupVideo from '../components/rtc/RtcGroupVideo.vue'; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
components: { |
|
|
components: { |
|
|
HeadImage, |
|
|
HeadImage, |
|
|
Setting, |
|
|
Setting, |
|
|
UserInfo, |
|
|
UserInfo, |
|
|
FullImage, |
|
|
FullImage, |
|
|
RtcPrivateVideo, |
|
|
RtcPrivateVideo, |
|
|
RtcPrivateAcceptor, |
|
|
RtcPrivateAcceptor, |
|
|
RtcGroupVideo |
|
|
RtcGroupVideo |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
showSettingDialog: false, |
|
|
showSettingDialog: false, |
|
|
lastPlayAudioTime: new Date().getTime() - 1000, |
|
|
lastPlayAudioTime: new Date().getTime() - 1000, |
|
|
isFullscreen: true |
|
|
isFullscreen: true |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
init() { |
|
|
init() { |
|
|
this.$eventBus.$on('openPrivateVideo', (rctInfo) => { |
|
|
this.$eventBus.$on('openPrivateVideo', (rctInfo) => { |
|
|
// 进入单人视频通话 |
|
|
// 进入单人视频通话 |
|
|
this.$refs.rtcPrivateVideo.open(rctInfo); |
|
|
this.$refs.rtcPrivateVideo.open(rctInfo); |
|
|
}); |
|
|
}); |
|
|
this.$eventBus.$on('openGroupVideo', (rctInfo) => { |
|
|
this.$eventBus.$on('openGroupVideo', (rctInfo) => { |
|
|
// 进入多人视频通话 |
|
|
// 进入多人视频通话 |
|
|
this.$refs.rtcGroupVideo.open(rctInfo); |
|
|
this.$refs.rtcGroupVideo.open(rctInfo); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.$store.dispatch("load").then(() => { |
|
|
this.$store.dispatch("load").then(() => { |
|
|
// ws初始化 |
|
|
// ws初始化 |
|
|
this.$wsApi.connect(process.env.VUE_APP_WS_URL, sessionStorage.getItem("accessToken")); |
|
|
this.$wsApi.connect(process.env.VUE_APP_WS_URL, sessionStorage.getItem("accessToken")); |
|
|
this.$wsApi.onConnect(() => { |
|
|
this.$wsApi.onConnect(() => { |
|
|
// 加载离线消息 |
|
|
// 加载离线消息 |
|
|
this.pullPrivateOfflineMessage(this.$store.state.chatStore.privateMsgMaxId); |
|
|
this.pullPrivateOfflineMessage(this.$store.state.chatStore.privateMsgMaxId); |
|
|
this.pullGroupOfflineMessage(this.$store.state.chatStore.groupMsgMaxId); |
|
|
this.pullGroupOfflineMessage(this.$store.state.chatStore.groupMsgMaxId); |
|
|
}); |
|
|
}); |
|
|
this.$wsApi.onMessage((cmd, msgInfo) => { |
|
|
this.$wsApi.onMessage((cmd, msgInfo) => { |
|
|
if (cmd == 2) { |
|
|
if (cmd == 2) { |
|
|
// 关闭ws |
|
|
// 关闭ws |
|
|
this.$wsApi.close(3000) |
|
|
this.$wsApi.close(3000) |
|
|
// 异地登录,强制下线 |
|
|
// 异地登录,强制下线 |
|
|
this.$alert("您已在其他地方登录,将被强制下线", "强制下线通知", { |
|
|
this.$alert("您已在其他地方登录,将被强制下线", "强制下线通知", { |
|
|
confirmButtonText: '确定', |
|
|
confirmButtonText: '确定', |
|
|
callback: action => { |
|
|
callback: action => { |
|
|
location.href = "/"; |
|
|
location.href = "/"; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} else if (cmd == 3) { |
|
|
} else if (cmd == 3) { |
|
|
// 插入私聊消息 |
|
|
// 插入私聊消息 |
|
|
this.handlePrivateMessage(msgInfo); |
|
|
this.handlePrivateMessage(msgInfo); |
|
|
} else if (cmd == 4) { |
|
|
} else if (cmd == 4) { |
|
|
// 插入群聊消息 |
|
|
// 插入群聊消息 |
|
|
this.handleGroupMessage(msgInfo); |
|
|
this.handleGroupMessage(msgInfo); |
|
|
} else if (cmd == 5) { |
|
|
} else if (cmd == 5) { |
|
|
// 处理系统消息 |
|
|
// 处理系统消息 |
|
|
this.handleSystemMessage(msgInfo); |
|
|
this.handleSystemMessage(msgInfo); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
this.$wsApi.onClose((e) => { |
|
|
this.$wsApi.onClose((e) => { |
|
|
console.log(e); |
|
|
console.log(e); |
|
|
if (e.code != 3000) { |
|
|
if (e.code != 3000) { |
|
|
// 断线重连 |
|
|
// 断线重连 |
|
|
this.$message.error("连接断开,正在尝试重新连接..."); |
|
|
this.$message.error("连接断开,正在尝试重新连接..."); |
|
|
this.$wsApi.reconnect(process.env.VUE_APP_WS_URL, sessionStorage.getItem( |
|
|
this.$wsApi.reconnect(process.env.VUE_APP_WS_URL, sessionStorage.getItem( |
|
|
"accessToken")); |
|
|
"accessToken")); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
console.log("初始化失败", e); |
|
|
console.log("初始化失败", e); |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
pullPrivateOfflineMessage(minId) { |
|
|
pullPrivateOfflineMessage(minId) { |
|
|
this.$store.commit("loadingPrivateMsg", true) |
|
|
this.$store.commit("loadingPrivateMsg", true) |
|
|
this.$http({ |
|
|
this.$http({ |
|
|
url: "/message/private/pullOfflineMessage?minId=" + minId, |
|
|
url: "/message/private/pullOfflineMessage?minId=" + minId, |
|
|
method: 'GET' |
|
|
method: 'GET' |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
this.$store.commit("loadingPrivateMsg", false) |
|
|
this.$store.commit("loadingPrivateMsg", false) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
pullGroupOfflineMessage(minId) { |
|
|
pullGroupOfflineMessage(minId) { |
|
|
this.$store.commit("loadingGroupMsg", true) |
|
|
this.$store.commit("loadingGroupMsg", true) |
|
|
this.$http({ |
|
|
this.$http({ |
|
|
url: "/message/group/pullOfflineMessage?minId=" + minId, |
|
|
url: "/message/group/pullOfflineMessage?minId=" + minId, |
|
|
method: 'GET' |
|
|
method: 'GET' |
|
|
}).catch(() => { |
|
|
}).catch(() => { |
|
|
this.$store.commit("loadingGroupMsg", false) |
|
|
this.$store.commit("loadingGroupMsg", false) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
handlePrivateMessage(msg) { |
|
|
handlePrivateMessage(msg) { |
|
|
// 消息加载标志 |
|
|
// 标记这条消息是不是自己发的 |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.LOADING) { |
|
|
msg.selfSend = msg.sendId == this.$store.state.userStore.userInfo.id; |
|
|
this.$store.commit("loadingPrivateMsg", JSON.parse(msg.content)) |
|
|
// 好友id |
|
|
return; |
|
|
let friendId = msg.selfSend ? msg.recvId : msg.sendId; |
|
|
} |
|
|
// 会话信息 |
|
|
// 消息已读处理,清空已读数量 |
|
|
let chatInfo = { |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.READED) { |
|
|
type: 'PRIVATE', |
|
|
this.$store.commit("resetUnreadCount", { |
|
|
targetId: friendId |
|
|
type: 'PRIVATE', |
|
|
} |
|
|
targetId: msg.recvId |
|
|
// 消息加载标志 |
|
|
}) |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.LOADING) { |
|
|
return; |
|
|
this.$store.commit("loadingPrivateMsg", JSON.parse(msg.content)) |
|
|
} |
|
|
return; |
|
|
// 消息回执处理,改消息状态为已读 |
|
|
} |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.RECEIPT) { |
|
|
// 消息已读处理,清空已读数量 |
|
|
this.$store.commit("readedMessage", { |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.READED) { |
|
|
friendId: msg.sendId |
|
|
this.$store.commit("resetUnreadCount", chatInfo) |
|
|
}) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// 消息回执处理,改消息状态为已读 |
|
|
// 标记这条消息是不是自己发的 |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.RECEIPT) { |
|
|
msg.selfSend = msg.sendId == this.$store.state.userStore.userInfo.id; |
|
|
this.$store.commit("readedMessage", { |
|
|
// 单人webrtc 信令 |
|
|
friendId: msg.sendId |
|
|
if (this.$msgType.isRtcPrivate(msg.type)) { |
|
|
}) |
|
|
this.$refs.rtcPrivateVideo.onRTCMessage(msg) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// 消息撤回 |
|
|
// 好友id |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.RECALL) { |
|
|
let friendId = msg.selfSend ? msg.recvId : msg.sendId; |
|
|
this.$store.commit("recallMessage", [msg, chatInfo]) |
|
|
this.loadFriendInfo(friendId).then((friend) => { |
|
|
return; |
|
|
this.insertPrivateMessage(friend, msg); |
|
|
} |
|
|
}) |
|
|
// 单人webrtc 信令 |
|
|
}, |
|
|
if (this.$msgType.isRtcPrivate(msg.type)) { |
|
|
insertPrivateMessage(friend, msg) { |
|
|
this.$refs.rtcPrivateVideo.onRTCMessage(msg) |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// 好友id |
|
|
|
|
|
this.loadFriendInfo(friendId).then((friend) => { |
|
|
|
|
|
this.insertPrivateMessage(friend, msg); |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
insertPrivateMessage(friend, msg) { |
|
|
|
|
|
|
|
|
let chatInfo = { |
|
|
let chatInfo = { |
|
|
type: 'PRIVATE', |
|
|
type: 'PRIVATE', |
|
|
targetId: friend.id, |
|
|
targetId: friend.id, |
|
|
showName: friend.nickName, |
|
|
showName: friend.nickName, |
|
|
headImage: friend.headImage |
|
|
headImage: friend.headImage |
|
|
}; |
|
|
}; |
|
|
// 打开会话 |
|
|
// 打开会话 |
|
|
this.$store.commit("openChat", chatInfo); |
|
|
this.$store.commit("openChat", chatInfo); |
|
|
// 插入消息 |
|
|
// 插入消息 |
|
|
this.$store.commit("insertMessage", [msg, chatInfo]); |
|
|
this.$store.commit("insertMessage", [msg, chatInfo]); |
|
|
// 播放提示音 |
|
|
// 播放提示音 |
|
|
if (!msg.selfSend && this.$msgType.isNormal(msg.type) && |
|
|
if (!msg.selfSend && this.$msgType.isNormal(msg.type) && |
|
|
msg.status != this.$enums.MESSAGE_STATUS.READED) { |
|
|
msg.status != this.$enums.MESSAGE_STATUS.READED) { |
|
|
this.playAudioTip(); |
|
|
this.playAudioTip(); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
handleGroupMessage(msg) { |
|
|
handleGroupMessage(msg) { |
|
|
// 消息加载标志 |
|
|
// 标记这条消息是不是自己发的 |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.LOADING) { |
|
|
msg.selfSend = msg.sendId == this.$store.state.userStore.userInfo.id; |
|
|
this.$store.commit("loadingGroupMsg", JSON.parse(msg.content)) |
|
|
let chatInfo = { |
|
|
return; |
|
|
type: 'GROUP', |
|
|
} |
|
|
targetId: msg.groupId |
|
|
// 消息已读处理 |
|
|
} |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.READED) { |
|
|
// 消息加载标志 |
|
|
// 我已读对方的消息,清空已读数量 |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.LOADING) { |
|
|
let chatInfo = { |
|
|
this.$store.commit("loadingGroupMsg", JSON.parse(msg.content)) |
|
|
type: 'GROUP', |
|
|
return; |
|
|
targetId: msg.groupId |
|
|
} |
|
|
} |
|
|
// 消息已读处理 |
|
|
this.$store.commit("resetUnreadCount", chatInfo) |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.READED) { |
|
|
return; |
|
|
// 我已读对方的消息,清空已读数量 |
|
|
} |
|
|
this.$store.commit("resetUnreadCount", chatInfo) |
|
|
// 消息回执处理 |
|
|
return; |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.RECEIPT) { |
|
|
} |
|
|
// 更新消息已读人数 |
|
|
// 消息回执处理 |
|
|
let msgInfo = { |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.RECEIPT) { |
|
|
id: msg.id, |
|
|
// 更新消息已读人数 |
|
|
groupId: msg.groupId, |
|
|
let msgInfo = { |
|
|
readedCount: msg.readedCount, |
|
|
id: msg.id, |
|
|
receiptOk: msg.receiptOk |
|
|
groupId: msg.groupId, |
|
|
}; |
|
|
readedCount: msg.readedCount, |
|
|
this.$store.commit("updateMessage", msgInfo) |
|
|
receiptOk: msg.receiptOk |
|
|
return; |
|
|
}; |
|
|
} |
|
|
this.$store.commit("updateMessage", [msgInfo, chatInfo]) |
|
|
// 标记这条消息是不是自己发的 |
|
|
return; |
|
|
msg.selfSend = msg.sendId == this.$store.state.userStore.userInfo.id; |
|
|
} |
|
|
// 群视频信令 |
|
|
// 消息撤回 |
|
|
if (this.$msgType.isRtcGroup(msg.type)) { |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.RECALL) { |
|
|
this.$nextTick(() => { |
|
|
this.$store.commit("recallMessage", [msg, chatInfo]) |
|
|
this.$refs.rtcGroupVideo.onRTCMessage(msg); |
|
|
return; |
|
|
}) |
|
|
} |
|
|
return; |
|
|
// 群视频信令 |
|
|
} |
|
|
if (this.$msgType.isRtcGroup(msg.type)) { |
|
|
this.loadGroupInfo(msg.groupId).then((group) => { |
|
|
this.$nextTick(() => { |
|
|
// 插入群聊消息 |
|
|
this.$refs.rtcGroupVideo.onRTCMessage(msg); |
|
|
this.insertGroupMessage(group, msg); |
|
|
}) |
|
|
}) |
|
|
return; |
|
|
}, |
|
|
} |
|
|
insertGroupMessage(group, msg) { |
|
|
this.loadGroupInfo(msg.groupId).then((group) => { |
|
|
let chatInfo = { |
|
|
// 插入群聊消息 |
|
|
type: 'GROUP', |
|
|
this.insertGroupMessage(group, msg); |
|
|
targetId: group.id, |
|
|
}) |
|
|
showName: group.showGroupName, |
|
|
}, |
|
|
headImage: group.headImageThumb |
|
|
insertGroupMessage(group, msg) { |
|
|
}; |
|
|
let chatInfo = { |
|
|
// 打开会话 |
|
|
type: 'GROUP', |
|
|
this.$store.commit("openChat", chatInfo); |
|
|
targetId: group.id, |
|
|
// 插入消息 |
|
|
showName: group.showGroupName, |
|
|
this.$store.commit("insertMessage", [msg, chatInfo]); |
|
|
headImage: group.headImageThumb |
|
|
// 播放提示音 |
|
|
}; |
|
|
if (!msg.selfSend && msg.type <= this.$enums.MESSAGE_TYPE.VIDEO && |
|
|
// 打开会话 |
|
|
msg.status != this.$enums.MESSAGE_STATUS.READED) { |
|
|
this.$store.commit("openChat", chatInfo); |
|
|
this.playAudioTip(); |
|
|
// 插入消息 |
|
|
} |
|
|
this.$store.commit("insertMessage", [msg, chatInfo]); |
|
|
}, |
|
|
// 播放提示音 |
|
|
handleSystemMessage(msg) { |
|
|
if (!msg.selfSend && msg.type <= this.$enums.MESSAGE_TYPE.VIDEO && |
|
|
// 用户被封禁 |
|
|
msg.status != this.$enums.MESSAGE_STATUS.READED) { |
|
|
|
|
|
this.playAudioTip(); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
handleSystemMessage(msg) { |
|
|
|
|
|
// 用户被封禁 |
|
|
|
|
|
|
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.USER_BANNED) { |
|
|
if (msg.type == this.$enums.MESSAGE_TYPE.USER_BANNED) { |
|
|
this.$wsApi.close(3000); |
|
|
this.$wsApi.close(3000); |
|
|
this.$alert("您的账号已被管理员封禁,原因:" + msg.content, "账号被封禁", { |
|
|
this.$alert("您的账号已被管理员封禁,原因:" + msg.content, "账号被封禁", { |
|
|
confirmButtonText: '确定', |
|
|
confirmButtonText: '确定', |
|
|
callback: action => { |
|
|
callback: action => { |
|
|
this.onExit(); |
|
|
this.onExit(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onExit() { |
|
|
onExit() { |
|
|
this.$wsApi.close(3000); |
|
|
this.$wsApi.close(3000); |
|
|
sessionStorage.removeItem("accessToken"); |
|
|
sessionStorage.removeItem("accessToken"); |
|
|
location.href = "/"; |
|
|
location.href = "/"; |
|
|
}, |
|
|
}, |
|
|
playAudioTip() { |
|
|
playAudioTip() { |
|
|
// 离线消息不播放铃声 |
|
|
// 离线消息不播放铃声 |
|
|
if (this.$store.getters.isLoading()) { |
|
|
if (this.$store.getters.isLoading()) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// 防止过于密集播放 |
|
|
// 防止过于密集播放 |
|
|
if (new Date().getTime() - this.lastPlayAudioTime > 1000) { |
|
|
if (new Date().getTime() - this.lastPlayAudioTime > 1000) { |
|
|
this.lastPlayAudioTime = new Date().getTime(); |
|
|
this.lastPlayAudioTime = new Date().getTime(); |
|
|
let audio = new Audio(); |
|
|
let audio = new Audio(); |
|
|
let url = require(`@/assets/audio/tip.wav`); |
|
|
let url = require(`@/assets/audio/tip.wav`); |
|
|
audio.src = url; |
|
|
audio.src = url; |
|
|
audio.play(); |
|
|
audio.play(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
showSetting() { |
|
|
showSetting() { |
|
|
this.showSettingDialog = true; |
|
|
this.showSettingDialog = true; |
|
|
}, |
|
|
}, |
|
|
closeSetting() { |
|
|
closeSetting() { |
|
|
this.showSettingDialog = false; |
|
|
this.showSettingDialog = false; |
|
|
}, |
|
|
}, |
|
|
loadFriendInfo(id) { |
|
|
loadFriendInfo(id) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
let friend = this.$store.state.friendStore.friends.find((f) => f.id == id); |
|
|
let friend = this.$store.state.friendStore.friends.find((f) => f.id == id); |
|
|
if (friend) { |
|
|
if (friend) { |
|
|
resolve(friend); |
|
|
resolve(friend); |
|
|
} else { |
|
|
} else { |
|
|
this.$http({ |
|
|
this.$http({ |
|
|
url: `/friend/find/${id}`, |
|
|
url: `/friend/find/${id}`, |
|
|
method: 'get' |
|
|
method: 'get' |
|
|
}).then((friend) => { |
|
|
}).then((friend) => { |
|
|
this.$store.commit("addFriend", friend); |
|
|
this.$store.commit("addFriend", friend); |
|
|
resolve(friend) |
|
|
resolve(friend) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
loadGroupInfo(id) { |
|
|
loadGroupInfo(id) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
let group = this.$store.state.groupStore.groups.find((g) => g.id == id); |
|
|
let group = this.$store.state.groupStore.groups.find((g) => g.id == id); |
|
|
if (group) { |
|
|
if (group) { |
|
|
resolve(group); |
|
|
resolve(group); |
|
|
} else { |
|
|
} else { |
|
|
this.$http({ |
|
|
this.$http({ |
|
|
url: `/group/find/${id}`, |
|
|
url: `/group/find/${id}`, |
|
|
method: 'get' |
|
|
method: 'get' |
|
|
}).then((group) => { |
|
|
}).then((group) => { |
|
|
resolve(group) |
|
|
resolve(group) |
|
|
this.$store.commit("addGroup", group); |
|
|
this.$store.commit("addGroup", group); |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
uiStore() { |
|
|
uiStore() { |
|
|
return this.$store.state.uiStore; |
|
|
return this.$store.state.uiStore; |
|
|
}, |
|
|
}, |
|
|
unreadCount() { |
|
|
unreadCount() { |
|
|
let unreadCount = 0; |
|
|
let unreadCount = 0; |
|
|
let chats = this.$store.state.chatStore.chats; |
|
|
let chats = this.$store.state.chatStore.chats; |
|
|
chats.forEach((chat) => { |
|
|
chats.forEach((chat) => { |
|
|
if (!chat.delete) { |
|
|
if (!chat.delete) { |
|
|
unreadCount += chat.unreadCount |
|
|
unreadCount += chat.unreadCount |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
return unreadCount; |
|
|
return unreadCount; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
|
unreadCount: { |
|
|
unreadCount: { |
|
|
handler(newCount, oldCount) { |
|
|
handler(newCount, oldCount) { |
|
|
let tip = newCount > 0 ? `${newCount}条未读` : ""; |
|
|
let tip = newCount > 0 ? `${newCount}条未读` : ""; |
|
|
this.$elm.setTitleTip(tip); |
|
|
this.$elm.setTitleTip(tip); |
|
|
}, |
|
|
}, |
|
|
immediate: true |
|
|
immediate: true |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
this.init(); |
|
|
this.init(); |
|
|
}, |
|
|
}, |
|
|
unmounted() { |
|
|
unmounted() { |
|
|
this.$wsApi.close(); |
|
|
this.$wsApi.close(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
<style scoped lang="scss"> |
|
|
.home-page { |
|
|
.home-page { |
|
|
height: 100vh; |
|
|
height: 100vh; |
|
|
width: 100vw; |
|
|
width: 100vw; |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
border-radius: 4px; |
|
|
border-radius: 4px; |
|
|
overflow: hidden; |
|
|
overflow: hidden; |
|
|
background: var(--im-color-primary-light-9); |
|
|
background: var(--im-color-primary-light-9); |
|
|
//background-image: url('../assets/image/background.jpg'); |
|
|
//background-image: url('../assets/image/background.jpg'); |
|
|
|
|
|
|
|
|
.app-container { |
|
|
.app-container { |
|
|
width: 62vw; |
|
|
width: 62vw; |
|
|
height: 80vh; |
|
|
height: 80vh; |
|
|
display: flex; |
|
|
display: flex; |
|
|
min-height: 600px; |
|
|
min-height: 600px; |
|
|
min-width: 970px; |
|
|
min-width: 970px; |
|
|
position: absolute; |
|
|
position: absolute; |
|
|
border-radius: 4px; |
|
|
border-radius: 4px; |
|
|
overflow: hidden; |
|
|
overflow: hidden; |
|
|
box-shadow: var(--im-box-shadow-dark); |
|
|
box-shadow: var(--im-box-shadow-dark); |
|
|
transition: 0.2s; |
|
|
transition: 0.2s; |
|
|
|
|
|
|
|
|
&.fullscreen { |
|
|
&.fullscreen { |
|
|
transition: 0.2s; |
|
|
transition: 0.2s; |
|
|
width: 100vw; |
|
|
width: 100vw; |
|
|
height: 100vh; |
|
|
height: 100vh; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.navi-bar { |
|
|
.navi-bar { |
|
|
--icon-font-size: 22px; |
|
|
--icon-font-size: 22px; |
|
|
--width: 60px; |
|
|
--width: 60px; |
|
|
width: var(--width); |
|
|
width: var(--width); |
|
|
background: var(--im-color-primary-light-1); |
|
|
background: var(--im-color-primary-light-1); |
|
|
padding-top: 20px; |
|
|
padding-top: 20px; |
|
|
|
|
|
|
|
|
.navi-bar-box { |
|
|
.navi-bar-box { |
|
|
height: 100%; |
|
|
height: 100%; |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
justify-content: space-between; |
|
|
justify-content: space-between; |
|
|
|
|
|
|
|
|
.botoom { |
|
|
.botoom { |
|
|
margin-bottom: 30px; |
|
|
margin-bottom: 30px; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.user-head-image { |
|
|
.user-head-image { |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.menu { |
|
|
.menu { |
|
|
height: 200px; |
|
|
height: 200px; |
|
|
//margin-top: 10px; |
|
|
//margin-top: 10px; |
|
|
display: flex; |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
align-content: center; |
|
|
align-content: center; |
|
|
|
|
|
|
|
|
.link { |
|
|
.link { |
|
|
text-decoration: none; |
|
|
text-decoration: none; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.router-link-active .menu-item { |
|
|
.router-link-active .menu-item { |
|
|
color: #fff; |
|
|
color: #fff; |
|
|
background: var(--im-color-primary-light-2); |
|
|
background: var(--im-color-primary-light-2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.link:not(.router-link-active) .menu-item:hover { |
|
|
.link:not(.router-link-active) .menu-item:hover { |
|
|
color: var(--im-color-primary-light-7); |
|
|
color: var(--im-color-primary-light-7); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.menu-item { |
|
|
.menu-item { |
|
|
position: relative; |
|
|
position: relative; |
|
|
color: var(--im-color-primary-light-4); |
|
|
color: var(--im-color-primary-light-4); |
|
|
width: var(--width); |
|
|
width: var(--width); |
|
|
height: 46px; |
|
|
height: 46px; |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
margin-bottom: 12px; |
|
|
margin-bottom: 12px; |
|
|
|
|
|
|
|
|
.icon { |
|
|
.icon { |
|
|
font-size: var(--icon-font-size) |
|
|
font-size: var(--icon-font-size) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.unread-text { |
|
|
.unread-text { |
|
|
position: absolute; |
|
|
position: absolute; |
|
|
background-color: var(--im-color-danger); |
|
|
background-color: var(--im-color-danger); |
|
|
left: 28px; |
|
|
left: 28px; |
|
|
top: 8px; |
|
|
top: 8px; |
|
|
color: white; |
|
|
color: white; |
|
|
border-radius: 30px; |
|
|
border-radius: 30px; |
|
|
padding: 0 5px; |
|
|
padding: 0 5px; |
|
|
font-size: var(--im-font-size-smaller); |
|
|
font-size: var(--im-font-size-smaller); |
|
|
text-align: center; |
|
|
text-align: center; |
|
|
white-space: nowrap; |
|
|
white-space: nowrap; |
|
|
border: 1px solid #f1e5e5; |
|
|
border: 1px solid #f1e5e5; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.botoom-item { |
|
|
.botoom-item { |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
height: 50px; |
|
|
height: 50px; |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
cursor: pointer; |
|
|
cursor: pointer; |
|
|
color: var(--im-color-primary-light-4); |
|
|
color: var(--im-color-primary-light-4); |
|
|
font-size: var(--icon-font-size); |
|
|
font-size: var(--icon-font-size); |
|
|
|
|
|
|
|
|
.icon { |
|
|
.icon { |
|
|
font-size: var(--icon-font-size) |
|
|
font-size: var(--icon-font-size) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
&:hover { |
|
|
&:hover { |
|
|
font-weight: 600; |
|
|
font-weight: 600; |
|
|
color: var(--im-color-primary-light-7); |
|
|
color: var(--im-color-primary-light-7); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.content-box { |
|
|
.content-box { |
|
|
flex: 1; |
|
|
flex: 1; |
|
|
padding: 0; |
|
|
padding: 0; |
|
|
background-color: #fff; |
|
|
background-color: #fff; |
|
|
text-align: center; |
|
|
text-align: center; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |