Commit 58659b8e authored by 罗超's avatar 罗超

1.0.0.2版本

parent 1b63a44a
......@@ -20,7 +20,7 @@ let config = {
// 我的手机图标
myPhoneIcon: 'http://yx-web.nos.netease.com/webdoc/h5/im/my-phone.png',
// 本地消息显示数量,会影响性能
localMsglimit: 360000,
localMsglimit: 36,
useDb: false
}
......
......@@ -10,6 +10,7 @@ const fs = require('fs')
const electron = require('electron')
const screenshot = require('screenshot-desktop')
const SDK = require('../../static/sdk/NIM_Web_NIM_nodejs_v5.9.1.js')
const http = require('http')
const ipc = electron.ipcMain
const shell =electron.shell
......@@ -19,7 +20,6 @@ const dialog = electron.dialog
const globalShortcut = electron.globalShortcut
const clipboard = electron.clipboard
const isupdating = false
const nativeImage = require('electron').nativeImage
global.LOGINUSER = {}
......@@ -64,7 +64,9 @@ let nim=null
let SCREENCOUNT=0
global.defaultdownloaddir=require('os').userInfo().homedir+'\\Downloads\\'
global.DEFAULT_SCREENSHOT_PATH=require('os').userInfo().homedir+'\\Pictures\\demo.png'
global.AUDIO_PATH=process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)
const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`
const mainUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/home` : `file://${__dirname}/index.html#/home`
const previewfileUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewfile` : `file://${__dirname}/index.html#/previewfile`
......@@ -76,6 +78,7 @@ const addnewuserUrl = process.env.NODE_ENV === 'development' ? `http://localhost
const appXmlPath = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) + 'app.json'
if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}
let windowIcon = nativeImage.createFromPath(path.join(__static, './icons/logo.png'))
......@@ -627,6 +630,28 @@ ipc.on('addClipboard', function (event,content) {
mainEvent.sender.send('new-screen-hot',content)
clipboard.writeImage(img)
})
ipc.on('setClipboard', function (event,content,type) {
if(type==1){
clipboard.writeText(content)
}
})
ipc.on('getNetworkImage', function (event,url) {
http.get(url, function (res) {
var chunks = [];
var size = 0;
res.on('data', function (chunk) {
chunks.push(chunk);
size += chunk.length;  //累加缓冲数据的长度
});
res.on('end', function (err) {
var data = Buffer.concat(chunks, size);
var base64Img = data.toString('base64');
let img = nativeImage.createFromDataURL(`data:image/png;base64,${base64Img}`)
clipboard.writeImage(img)
console.log('结束');
});
});
})
ipc.on('screens-session', function (event) {
screenEvent=event
})
......@@ -965,25 +990,13 @@ let getScrollerhotWindows=function(){
scrollerhotWindows.setFullScreen(true)
}
let screenHotBegin=function(){
let p=require('os').userInfo().homedir+'\\Pictures\\MAGE_'+formatDate(new Date(),'yyyyMMddhhmmss')+'.png'
global.DEFAULT_SCREENSHOT_PATH=p
screenshot({format: 'png',filename:p}).then((img) => {
if(scrollerhotWindows && !scrollerhotWindows.isDestroyed()){
screenEvent.sender.send('new-hot')
if(SCREENCOUNT==0){
scrollerhotWindows.reload()
scrollerhotWindows.once('ready-to-show', () => {
scrollerhotWindows.show()
})
}else{
scrollerhotWindows.show()
}
SCREENCOUNT++
}else{
getScrollerhotWindows()
let p=process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)+'PrintScr.exe'
var screen_window = cp.execFile(p)
screen_window.on('exit', function (code) {
// 执行成功返回 1,返回 0 没有截图
if (code){
mainEvent.sender.send('new-screen-hot',clipboard.readImage().toDataURL())
}
}).catch((err) => {
console.log(err)
})
}
let registScrollerHotKey=function(){
......@@ -1013,45 +1026,49 @@ let formatDate=function(date,format){
return format;
};
let initNIM=function(uid,token){
nim = SDK.getInstance({
debug: false,
appKey: 'b612b31e837c79c68f141aeb719d2b20',
account: uid,
token: token,
db: false,
onconnect: onConnect,
onwillreconnect: onWillReconnect,
ondisconnect: onDisconnect,
onerror: onError
})
function onConnect() {
}
function onWillReconnect(obj) {
// 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接
}
function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
if (error) {
switch (error.code) {
// 账号或者密码错误, 请跳转到登录页面并提示错误
case 302:
break;
// 重复登录, 已经在其它端登录了, 请跳转到登录页面并提示错误
case 417:
break;
// 被踢, 请提示错误后跳转到登录页面
case 'kicked':
break;
default:
break;
try {
nim = SDK.getInstance({
debug: false,
appKey: 'b612b31e837c79c68f141aeb719d2b20',
account: uid,
token: token,
db: false,
onconnect: onConnect,
onwillreconnect: onWillReconnect,
ondisconnect: onDisconnect,
onerror: onError
})
function onConnect() {
}
function onWillReconnect(obj) {
// 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接
}
function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
if (error) {
switch (error.code) {
// 账号或者密码错误, 请跳转到登录页面并提示错误
case 302:
break;
// 重复登录, 已经在其它端登录了, 请跳转到登录页面并提示错误
case 417:
break;
// 被踢, 请提示错误后跳转到登录页面
case 'kicked':
break;
default:
break;
}
}
}
}
function onError(error) {
console.log(error);
function onError(error) {
console.log(error);
}
} catch (error) {
}
}
......@@ -13,7 +13,7 @@ MyToastPlugin.install = function (Vue) {
position: 'middle'
})
} else {
alert(msg)
//alert(msg)
}
}
}
......
<style>
@import url("./assets/css/font.css");
@import url("./assets/css/global.css");
@import url("./assets/css/alifont");
</style>
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
......@@ -30,7 +24,6 @@ export default {
document.querySelector('#app').addEventListener(
"drop",
function(e) {
console.log(e)
if(e.target.id!='msgEditorBox'){
e.dataTransfer.dropEffect = 'none';
}else{
......@@ -43,4 +36,9 @@ export default {
);
}
};
</script>
\ No newline at end of file
</script>
<style>
@import url("./assets/css/font.css");
@import url("./assets/css/global.css");
@import url("./assets/css/alifont");
</style>
This diff is collapsed.
......@@ -58,7 +58,7 @@ button{
height: 4px;
}
*::-webkit-scrollbar-track{
background-color: #F5F5F5;
background-color: transparent;
}
*::-webkit-scrollbar-thumb{
border-radius: 20px;
......@@ -72,3 +72,17 @@ button{
width: 4px;
height: 4px;
} */
#chat-list::-webkit-scrollbar{
width: 7px;
}
.v-contextmenu{
box-shadow: 0 0 2px #ddd;
border-radius: 0;
min-width: 100px;
border:1px solid #ddd;
}
.v-contextmenu .v-contextmenu-item{
padding: 5px 20px;
font-family: 'Microsoft YaHei' !important;
font-size: 12px;
}
\ No newline at end of file
......@@ -84,7 +84,7 @@
<div class="manager-item">
<span class="t">群介绍</span>
<span class="d">
<span class="txt" v-show="!editorStatus.introStatus" @click="editorData('introStatus')">
<span class="txt" style='white-space: normal;' v-show="!editorStatus.introStatus" @click="editorData('introStatus')">
{{!teamInfo.intro || teamInfo.intro==''?'本群暂无介绍':teamInfo.intro}}
<i
class="el-icon-edit"
......@@ -138,6 +138,9 @@
<div class="invalidHint" v-if="scene==='team' && teamInvalid">
<span>{{`您已退出该${teamInfo && teamInfo.type==='normal' ? '讨论组':'群'}`}}</span>
</div>
<div class="msg-tips" id='msg_tips' style="display:none">
<i class="el-icon-warning"></i>
</div>
<chat-list
type="session"
:msglist="msglist"
......@@ -145,8 +148,22 @@
:myInfo="myInfo"
:isRobot="isRobot"
:sessionId="id"
:scene="scene"
:to="to"
@msgs-loaded="msgsLoaded"
:canLoadMore="canLoadMore"
></chat-list>
<div class="new-lst-msg" v-if="lstShowData" @click="goDown">
{{id.indexOf('team-')==-1?"":lstShowData.fromNick+":"}}{{lstShowData.lastMsgShow}}
</div>
<div class="at-msg-box" v-if="showAt">
<div class="at-close" @click="closeAtTip">
<i class="el-icon-close"></i>
</div>
<div class="at-msg" @click="findAtMsg">
有人@了你
</div>
</div>
</div>
<VueDraggableResizable
class-name="sendconsole"
......@@ -164,6 +181,7 @@
:sessionId="id"
:scene="scene"
:to="to"
:members='membersInDisplay'
:isRobot="isRobot"
:avatar="myInfo.avatar"
:invalid="teamInvalid || muteInTeam"
......@@ -180,11 +198,16 @@ import VueDraggableResizable from "vue-draggable-resizable";
import "vue-draggable-resizable/dist/VueDraggableResizable.css";
import chatList from "./chatlist";
import chateditor from "./chateditor";
import { clearTimeout } from 'timers';
export default {
props: {
id: {
type: String,
default: ""
},
idServer: {
type: String,
default: ""
}
},
components: {
......@@ -213,7 +236,12 @@ export default {
},
muteTeam: false,
showAllMember: false,
hasSearched: false
hasSearched: false,
lstTimer:0,
lstShowData:null,
showAt:false,
findTimer:null,
requestCount:0
};
},
updated() {
......@@ -233,6 +261,14 @@ export default {
introStatus: false
};
this.showAllMember = false;
this.lstTimer=0
this.lstShowData=null
clearTimeout(this.findTimer)
this.findTimer=null
this.requestCount=0
},
idServer(val) {
this.changeAtShow()
}
},
mounted() {
......@@ -263,6 +299,7 @@ export default {
that.teamShow = show;
}
});
this.changeAtShow()
},
computed: {
sessionId() {
......@@ -270,7 +307,7 @@ export default {
this.$store.dispatch("showLoading");
// 此时设置当前会话
let user;
this.$store.dispatch("setCurrSession", sessionId);
//this.$store.dispatch("setCurrSession", sessionId);
//pageUtil.scrollChatListDown();
return sessionId;
......@@ -339,6 +376,33 @@ export default {
},
msglist() {
let msgs = this.$store.state.currSessionMsgs;
if(this.lstTimer>0 && msgs[msgs.length-1].time>this.lstTimer && !pageUtil.openDown){
this.lstShowData=msgs[msgs.length-1]
if (this.lstShowData.type === "text") {
this.lstShowData.lastMsgShow = this.lstShowData.text || "";
} else if (this.lstShowData.type === "custom") {
this.lstShowData.lastMsgShow = util.parseCustomMsg(this.lstShowData);
} else if (
this.lstShowData.scene === "team" &&
this.lstShowData.type === "notification"
) {
this.lstShowData.lastMsgShow = util.generateTeamSysmMsg(this.lstShowData);
} else if (util.mapMsgType(this.lstShowData)) {
this.lstShowData.lastMsgShow = `[${util.mapMsgType(this.lstShowData)}]`;
} else {
this.lstShowData.lastMsgShow = "";
}
}
if(msgs.length>0)
this.lstTimer=msgs[msgs.length-1].time
if(this.scene=='team'){
msgs=msgs.filter(x=>{
if(x.type!='notification' ||(x.type=='notification' && !x.attach.team.custom))
return x
return;
})
}
console.log(msgs)
return msgs;
},
teamInfo() {
......@@ -448,9 +512,76 @@ export default {
}
});
return have;
},
canLoadMore () {
return !this.$store.state.noMoreHistoryMsgs
}
},
methods: {
findAtMsg(){
if(!this.isNotExsitAtMsg()){
let dom=document.querySelector(`li[data-server="msg_${this.idServer}"]`)
if(dom){
document.querySelector("#chat-list").scrollTop=dom.offsetTop-10
setTimeout(() => {
this.showAt=false
}, 100);
}
}else{
if(this.canLoadMore){
this.$store.dispatch("getHistoryMsgs", {
scene: this.scene,
to: this.to
});
this.findTimer=setTimeout(() => {
this.requestCount++
if(this.requestCount<4){
this.findAtMsg()
}
}, 500);
}
}
},
isNotExsitAtMsg(){
let t=this.msglist.find(x=>{
return x.idServer==this.idServer
})
return !t;
},
changeAtShow(){
this.showAt=false
console.log(this.idServer)
if(this.idServer && this.idServer!=''){
if(this.isNotExsitAtMsg()){
this.showAt=true
}else{
setTimeout(() => {
let dom=document.querySelector(`li[data-server="msg_${this.idServer}"]`)
if(dom){
let maxh =
document.querySelector("#chat-list").scrollTop +
document.querySelector("#chat-list").clientHeight;
let minh =
document.querySelector("#chat-list").scrollTop
if(dom.offsetTop>maxh || dom.offsetTop<minh){
this.showAt=true
}
}
}, 1000);
}
}
},
closeAtTip(){
this.showAt=false
},
goDown(){
pageUtil.openDown=true
pageUtil.scrollChatListDown()
this.lstShowData=null
},
goChat(member){
let obj={
id:'p2p-'+member.account,
......@@ -758,6 +889,84 @@ export default {
font-size: 24px;
color: #333;
}
.msgbox .msg-tips{
background: rgba(0,0,0,.5);
padding: 10px 15px;
border-radius: 8px;
font-size: 12px;
color: #FFF;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: none;
z-index: 9999999999999;
}
.msgbox .new-lst-msg{
position: absolute;
bottom: 0px;
left: 0;
right: 0;
height: 27px;
padding: 0 11px;
font-size: 12px;
font-family: 'microsoft yahei' !important;
background: rgba(58, 104, 255, 0.81);
color: #000;
display: flex;
align-items: center;
cursor: pointer;
z-index: 1111111;
}
.msgbox .msg-tips i{
font-size: 14px;
color: #3a68ff;
margin-right: 10px;
}
.msgbox .at-msg-box{
position: absolute;
bottom: 5px;
left: 0;
right: 5px;
height: 30px;
background: transparent;
display: flex;
align-items: center;
flex-direction: row-reverse;
z-index: 1111112;
}
.msgbox .at-msg-box .at-msg{
height: 30px;
display: inline-block;
background: #FFF;
border:1px solid #ddd;
box-sizing: border-box;
padding:0 10px;
line-height: 30px;
font-size: 14px;
color: #3a68ff;
cursor: pointer;
font-family: 'microsoft yahei' !important;
}
.msgbox .at-msg-box .at-close{
width: 30px;
line-height: 30px;
height: 30px;
border:1px solid #ddd;
border-left: none;
box-sizing: border-box;
text-align: center;
background: #FFF;
cursor: pointer;
}
.msgbox .at-msg-box .at-close i{
color: #333;
font-size: 14px;
}
.msgbox .at-msg-box .at-close i:hover{
color:maroon;
}
.msgbox .messagebox .opera-team-box {
top: 47px;
right: 0;
......@@ -1050,7 +1259,7 @@ export default {
left: 0;
right: 0;
overflow: auto;
background: #f1f1f1;
background: #eee;
box-sizing: border-box;
}
.msgbox .messagebox .messagecontent .invalidHint {
......
......@@ -19,7 +19,7 @@
<script>
import emojiObj from '../../../configs/emoji'
import pageUtil from "../../../utils/page";
function genEmojiList (type, emojiList) {
let result = {}
for (let name in emojiList) {
......@@ -83,6 +83,7 @@ export default {
// 由触发父组件事件,增加表情文案
this.$emit('add-emoji', emoji.key)
} else if (this.currType === 'pinup') {
pageUtil.openDown=true
if (this.type === 'session') {
let custommsg= {
type: 3,
......@@ -101,6 +102,7 @@ export default {
custom:JSON.stringify(custommsg)
})
} else if (this.type === 'chatroom') {
pageUtil.openDown=true
this.$store.dispatch('sendChatroomMsg', {
type: 'custom',
pushContent: '[贴图表情]',
......
<template>
<ul id="chat-list" class="chat__list">
<li class="u-msg item-time more" v-if="canLoadMore">
<li class="u-msg item-time more" @click="getHistoryMsgs" v-if="canLoadMore">
<i class="iconfont icon3lishi"></i>点击加载更多
</li>
<chat-item
v-for="(msg, index) in msglist"
:type="type"
:rawMsg="msg"
:isRobot="isRobot"
:userInfos="userInfos"
:myInfo="myInfo"
:key="(msg.idClient+'_'+index)"
:isHistory="isHistory"
@msg-loaded="msgLoaded"
ref="chatitem"
></chat-item>
<sending-item v-for="(item, index) in sendObjs" ref='sendObj' :key="index" :msg="item"></sending-item>
<template v-for="(msg, index) in msglist">
<chat-item
v-if="index!=0"
:type="type"
:rawMsg="msg"
:isRobot="isRobot"
:userInfos="userInfos"
:myInfo="myInfo"
:key="(msg.idClient+'_'+index)"
:isHistory="isHistory"
@msg-loaded="msgLoaded"
ref="chatitem"
@stop-play='stopOtherAudio'
@hide-right-menu='hiddenMenu'
></chat-item>
</template>
<sending-item v-for="(item, index) in sendObjs" ref="sendObj" :key="index" :msg="item"></sending-item>
<!-- <li class="u-msg item-time none" v-else>已无更多记录</li> -->
</ul>
</template>
......@@ -34,22 +38,21 @@ export default {
data() {
return {
msgLoadedTimer: null,
sendObjs:[]
sendObjs: []
};
},
mounted() {
document
.querySelector("#chat-list")
.addEventListener("scroll", this.handleScroll);
let that=this
let that = this;
this.MsgBus.$on("update-sending", function() {
console.log('in.....')
that.loadingCurrentSendingMsg();
});
},
props: {
type: String,
canLoadMore: [String, Boolean],
canLoadMore: Boolean,
isRobot: {
type: Boolean,
default() {
......@@ -80,7 +83,9 @@ export default {
return false;
}
},
sessionId: String
sessionId: String,
scene: String,
to: String
// robotInfos: {
// type: Object,
// default () {
......@@ -90,23 +95,46 @@ export default {
},
watch: {
sessionId(newVal, oldVal) {
this.loadingCurrentSendingMsg()
this.loadingCurrentSendingMsg();
}
},
methods: {
hiddenMenu(idClient){
if(this.$refs.chatitem && Array.isArray(this.$refs.chatitem)){
this.$refs.chatitem.forEach(x=>{
if(x.idClient!=idClient)
x.hiddenMenu()
})
}
},
stopOtherAudio(){
if(this.$refs.chatitem && Array.isArray(this.$refs.chatitem)){
this.$refs.chatitem.forEach(x=>{
x.stopAudio()
})
}
},
getHistoryMsgs() {
if (this.canLoadMore) {
this.$store.dispatch("getHistoryMsgs", {
scene: this.scene,
to: this.to
});
}
},
loadingCurrentSendingMsg() {
if (this.GLOBALSENDING) {
this.sendObjs = this.GLOBALSENDING.filter(x => {
return x.id == this.sessionId;
});
if (this.$refs.sendObj) {
this.$refs.sendObj.forEach(x=>{
this.sendObjs.forEach(y=>{
if(x.getMsgId()==y.msgId){
x.setProgess(y.progess)
this.$refs.sendObj.forEach(x => {
this.sendObjs.forEach(y => {
if (x.getMsgId() == y.msgId) {
x.setProgess(y.progess);
}
})
})
});
});
pageUtil.scrollChatListDown();
}
}
......@@ -116,15 +144,28 @@ export default {
document.querySelector("#chat-list").scrollTop +
document.querySelector("#chat-list").clientHeight -
40;
let scrollHeight =
document.querySelector("#chat-list").scrollHeight -
document.querySelector("#chat-list").clientHeight;
if (
scrollHeight - document.querySelector("#chat-list").scrollTop >=
100
) {
pageUtil.openDown = false;
} else {
pageUtil.openDown = true;
}
this.$refs.chatitem.forEach(x => {
if (x.$refs.msgvideo) {
let minh = x.$refs.msgvideo.offsetTop;
let maxh = x.$refs.msgvideo.offsetTop + x.$refs.msgvideo.clientHeight;
let minh = x.$refs.msgvideo.parentNode.offsetTop;
let maxh = x.$refs.msgvideo.parentNode.offsetTop + x.$refs.msgvideo.parentNode.clientHeight;
if (ch >= minh && ch <= maxh) {
x.$refs.msgvideo.play();
} else x.$refs.msgvideo.pause();
}
});
},
msgLoaded() {
clearTimeout(this.msgLoadedTimer);
......@@ -141,14 +182,18 @@ export default {
box-sizing: border-box;
margin: 0;
padding: 20px;
padding-right: 12px;
height: 100%;
overflow: auto;
}
.chat__list li {
list-style: none;
margin: 0;
padding: 0;
margin-bottom: 18px;
width: 100%;
box-sizing: border-box;
}
.chat__list .u-msg {
margin-bottom: 18px;
......
<template>
<div class="msgbox" id='msgbox'>
<audio id="msgaudio">
<source src="../../assets/audio/msg.mp3" type="audio/mpeg">
<source :src='audio_base+"msg.mp3"' type="audio/mpeg">
</audio>
<audio id="shakeaudio">
<source src="../../assets/audio/shake.wav" type="audio/wav">
<source :src='audio_base+"shake.wav"' type="audio/wav">
</audio>
<audio id="sysaudio">
<source src="../../assets/audio/system.wav" type="audio/wav">
<source :src='audio_base+"system.wav"' type="audio/wav">
</audio>
<div class="sessionbox">
......@@ -54,7 +54,7 @@
>
<div
class="headinfo"
:class="{'notice user':!session.avatar}"
: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>
......@@ -111,6 +111,7 @@
</div>
<div class="msgbase">
<div class="last">
<span class="at-me" v-if="session.atId">[有人@我]</span>
<span v-if="session.isMute && session.unread>0">[{{session.unread}}]</span>
{{session.lastMsgShow}}
</div>
......@@ -153,6 +154,7 @@
</div>
<div class="msgbase">
<div class="last">
<span class="at-me" v-if="session.atId">[有人@我]</span>
<span v-if="session.isMute && session.unread>0">[{{session.unread}}]</span>
{{session.lastMsgShow}}
</div>
......@@ -167,8 +169,9 @@
<right-menu @update-session="updateSession" v-if="menu.show" :config='menu' :top="menu.t" :left="menu.l" :session="menu.s" ></right-menu>
</div>
<div class="messagebox">
<div v-if="currentSession.id!=''">
<chat :id="currentSession.id" @update-session="updateSession"></chat>
<net-error v-if="netState"></net-error>
<div v-else-if="currentSession.id!=''">
<chat :id="currentSession.id" :idServer='atIds' @update-session="updateSession"></chat>
</div>
<notice v-else-if="openNoticeState" @clear-msg='clearNotice'></notice>
<div v-else class="nosession">
......@@ -186,6 +189,9 @@ import chat from "./chat";
import { isNumber } from "util";
import rightMenu from '../tools/mousemenu.vue'
import notice from '../system/notice'
import pageUtil from "../../../utils/page";
import { session } from 'electron';
import netError from '../system/netError'
export default {
props: {
user: {
......@@ -196,7 +202,8 @@ export default {
components: {
chat,
rightMenu,
notice
notice,
netError
},
data() {
return {
......@@ -215,7 +222,10 @@ export default {
},
createSessions:[],
openNoticeState:false,
noticeLastTime:0
noticeLastTime:0,
isNetError:true,
audio_base:'',
atIds:null
};
},
updated() {
......@@ -301,17 +311,57 @@ export default {
this.TOPSESSION = topSession;
},
enterChat(session) {
this.$electron.ipcRenderer.send("clearPrevImgs");
this.openNoticeState=false
let index = -1;
this.newMsgList.forEach((x, i) => {
if (x.id == session.id) {
index = i;
if(session.id!=this.currentSession.id){
this.atIds=null
pageUtil.openDown=true
this.$electron.ipcRenderer.send("clearPrevImgs");
this.openNoticeState=false
let index = -1;
this.newMsgList.forEach((x, i) => {
if (x.id == session.id) {
index = i;
}
});
if (index != -1) this.newMsgList.splice(index, 1);
this.$electron.ipcRenderer.send("close-team-box");
this.$store.dispatch('resetNoMoreHistoryMsgs')
this.currentSession = session;
if(session.atId){
this.clearAtMe()
this.atIds=session.atId
session.atId=null
}
});
if (index != -1) this.newMsgList.splice(index, 1);
this.$electron.ipcRenderer.send("close-team-box");
this.currentSession = session;
this.$store.dispatch("setCurrSession", session.id)
}
},
clearAtMe(){
let teamInfo = null;
if (this.currentSession.scene === "team") {
teamInfo = this.$store.state.teamlist.find(team => {
return team.teamId === this.currentSession.to;
});
}
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", {
functionName: 'updateTeam',
options: {
teamId: teamInfo.teamId,
custom: JSON.stringify(custom),
done: (error, team) => {
console.log('serverCustom Error:',error)
}
}
})
}
}
},
openNotice(){
this.$store.dispatch("resetCurrSession")
......@@ -383,13 +433,14 @@ export default {
if(h) {
this.enterChat(h)
} else {
obj.groupType==-1
obj.groupType=obj.groupType||obj.groupType==0?obj.groupType:-1
this.createSessions.push(obj)
this.enterChat(obj)
}
}
},
mounted() {
this.audio_base=this.$electron.remote.getGlobal("AUDIO_PATH")+'audio/'
if (window.localStorage.top) {
this.TOPSESSION = JSON.parse(window.localStorage.top);
}
......@@ -422,7 +473,6 @@ export default {
}
});
this.MsgBus.$on("create-session", function(obj) {
console.log(obj)
that.createSession(obj)
});
},
......@@ -447,10 +497,7 @@ export default {
let unreadList = [];
let sessionlist = this.$store.state.sessionlist.filter(item => {
if (item.to === "684cb79fe92f46877777"){
if(this.noticeLastTime<item.lastMsg.time){
this.noticeLastTime=item.lastMsg.time
this.showNotice()
}
return; //过滤推送消息
}
this.createSessions=this.createSessions.filter(x=>{
......@@ -491,6 +538,23 @@ export default {
? this.myGroupIcon
: this.myAdvancedIcon);
item.isMute = teamInfo.usermute ? teamInfo.usermute : false;
try {
if(teamInfo.custom){
let custom=JSON.parse(teamInfo.custom)
if(custom.ats){
let atme =custom.ats.find(x=>{
return x.account==this.$store.state.userUID
})
if(atme && this.currentSession.id!=item.id){
item.atId=atme.id
}else if(atme && this.currentSession.id==item.id){
setTimeout(() => {
this.clearAtMe()
}, 1000);
}
}
}
} catch (error) {}
} else {
return;
item.groupType = "normal";
......@@ -500,6 +564,23 @@ export default {
}
}
let lastMsg = item.lastMsg || {};
if (
lastMsg.scene === "team" &&
lastMsg.type === "notification" &&
lastMsg.attach &&
lastMsg.attach.team &&
lastMsg.attach.team.custom
) {
for (let i = this.$store.state.msgs[item.id].length-1; i >= 0; i--) {
lastMsg=this.$store.state.msgs[item.id][i]
if (
lastMsg.type != "notification" ||
(lastMsg.type == "notification" && !lastMsg.attach.team.custom)
){
break;
}
}
}
if (lastMsg.type === "text") {
item.lastMsgShow = lastMsg.text || "";
} else if (lastMsg.type === "custom") {
......@@ -514,10 +595,16 @@ export default {
} else {
item.lastMsgShow = "";
}
if(item.scene === "team")
item.lastMsgShow=`${lastMsg.fromNick}:${item.lastMsgShow}`
if (item.updateTime) {
item.updateTimeShow = util.formatDate(item.updateTime, true);
}
if (item.to == "684cb79fe92f46888888") {
if(this.noticeLastTime<item.lastMsg.time){
this.noticeLastTime=item.lastMsg.time
this.showNotice()
}
this.noticeObj = item;
return;
}
......@@ -562,6 +649,9 @@ export default {
}
this.newMsgList = unreadList;
return sessionlist;
},
netState(){
return this.$store.state.isNetError
}
}
};
......@@ -759,4 +849,9 @@ export default {
.msgbox .el-badge__content {
min-width: 6px;
}
.msgbox .at-me{
color: maroon;
font-size: 12px;
font-family: 'Microsoft YaHei' !important;
}
</style>
\ No newline at end of file
<template>
<div class="net-error">
<img src="../../assets/img/im/neterror.png">
<div class="error-text">当前网络不稳定,{{splitTime>8?'正在重新连接...':`${splitTime}秒后第${resetCount}次重新连接`}}</div>
</div>
</template>
<script>
export default {
data() {
return {
resetCount: 0,
splitTime: 10,
splitTimer: null
};
},
mounted() {
this.reconnect();
setInterval(() => {
this.reconnect();
}, 1000 * 10);
},
methods: {
reconnect() {
this.resetCount++;
this.$store.dispatch("connect");
this.splitTime = 10;
clearInterval(this.splitTimer);
this.splitTimer = null;
this.splitTimer = setInterval(() => {
this.splitTime = this.splitTime - 1;
}, 1000);
}
}
};
</script>
<style>
.net-error {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.net-error img {
width: 250px;
}
.net-error .error-text {
width: 390px;
color: gray;
font-size: 12px;
text-align: center;
margin-top: 50px;
font-family: "microsoft yahei" !important;
}
</style>
......@@ -70,11 +70,10 @@ export default {
RecPlatform: 2
};
this.apipost("SystemLog_post_LogSetReadStatusForUser", msg, res => {
console.log(res.data);
this.$store.dispatch("deleteSession", 'p2p-684cb79fe92f46888888');
this.$emit('clear-msg')
this.pages.pageIndex = 1;
this.getNotices();
this.notices=[]
});
},
openSystem(url) {
......@@ -108,7 +107,6 @@ export default {
"SystemLog_get_LogGetPageList",
msg,
res => {
console.log(res.data.data);
if (res.data.resultCode == 1) {
this.pages.total = res.data.data.count;
if (res.data.data.count > 0) {
......
......@@ -248,7 +248,6 @@ export default {
return x;
});
}
console.log(res.data.data);
this.isLoading = false;
},
err => {}
......@@ -308,7 +307,6 @@ export default {
res => {
if (res.data.resultCode == 1) {
this.webAllpartList = res.data.data;
console.log(res.data.data);
} else {
}
},
......@@ -319,7 +317,6 @@ export default {
this.$electron.remote.getCurrentWindow().close();
},
handleCheckChange(data, checked, indeterminate) {
console.log(this.$refs.tree.getCheckedNodes());
this.checkNodes = this.$refs.tree.getCheckedNodes();
}
}
......
......@@ -2,7 +2,7 @@
<div class="maillist">
<div class="split"></div>
<div class="content">
<div class="panle" style="width:300px;flex:unset;">
<div class="panle" style="width:297px;flex:unset;">
<div class="search__user_box">
<div class="seach_ctr">
<span class="seach__item__icon">
......@@ -19,7 +19,11 @@
</div>
</div>
<div class="search-result-box" v-show="groupboxSearch==0">
<div class="tree-box">
<el-tabs v-model="activeName">
<el-tab-pane label="我的同事" name="first"></el-tab-pane>
<el-tab-pane label="群聊" name="second"></el-tab-pane>
</el-tabs>
<div class="tree-box" v-show="activeName=='first'">
<el-tree
ref="tree"
@node-click="getChosenUser"
......@@ -48,9 +52,28 @@
</span>
</el-tree>
</div>
<div v-show="activeName=='second'">
<ul class="teams">
<li v-for="(item, index) in teamList" @dblclick="dblTeamChat(item)" :key="index">
<img :src="item.avatar" class="h" v-if="item.avatar">
<div class="headinfo notice blue" v-else>
<i class="iconfont icontaolun"></i>
</div>
<div class="u">
<span style="font-size:14px;">{{item.name}}</span>
</div>
<div class="last-time">{{item.lastTimeShow.split(' ')[0]}}</div>
</li>
</ul>
</div>
</div>
<ul class="members" v-show="groupboxSearch==1" style="bottom:0px;top:37px;">
<li v-for="(item, index) in searchResults" @dblclick='dblGoChat(item)' @click="createUserInf(item)" :key="index">
<li
v-for="(item, index) in searchResults"
@dblclick="dblGoChat(item)"
@click="createUserInf(item)"
:key="index"
>
<img :src="item.icon" class="h" v-if="item.icon">
<img src="../../assets/img/litheader.png" class="h" v-else>
<div class="u">
......@@ -97,8 +120,14 @@
</span>
<span class="val">{{chosenUser.account}}</span>
</div>
<div class='create-box' v-if="user.ImAccount!=chosenUser.account">
<el-button type="primary" @click="goChat(chosenUser)" :disabled="!chosenUser.account" icon="iconfont iconliaotian" size="small"> 和TA聊聊</el-button>
<div class="create-box" v-if="user.ImAccount!=chosenUser.account">
<el-button
type="primary"
@click="goChat(chosenUser)"
:disabled="!chosenUser.account"
icon="iconfont iconliaotian"
size="small"
>和TA聊聊</el-button>
<div class="err" v-if="!chosenUser.account">对方还未开通IM账户,无法和他聊天</div>
</div>
</div>
......@@ -107,6 +136,7 @@
</div>
</template>
<script>
import util from "../../../utils/index";
export default {
data() {
return {
......@@ -123,16 +153,17 @@ export default {
isLoading: false,
chosenUser: null,
loadingUser: false,
user:null
user: null,
activeName: "first"
};
},
mounted() {
this.getWebAllPart();
this.user = this.$electron.remote.getGlobal("LOGINUSER");
this.user = this.$electron.remote.getGlobal("LOGINUSER");
},
methods: {
goChat(member){
this.MsgBus.$emit('change-create-session',member)
goChat(member) {
this.MsgBus.$emit("change-create-session", member);
},
getChosenUser(data) {
if (data.EmpId) {
......@@ -152,26 +183,42 @@ export default {
this.chosenUser = null;
}
},
dblGoChat(data){
if(data.imAccount!=user.ImAccount){
this.createUserInf(data)
this.goChat(this.chosenUser)
dblGoChat(data) {
if (data.imAccount != user.ImAccount) {
this.createUserInf(data);
this.goChat(this.chosenUser);
}
},
dblTeamChat(item) {
this.goChat(this.createTeamInf(item));
},
createUserInf(data) {
this.chosenUser = {
id: 'p2p-'+data.imAccount,
id: "p2p-" + data.imAccount,
account: data.imAccount,
avatar: data.icon,
alias: data.name,
name:data.name,
companyName:data.companyName,
departmentName:data.departmentName,
postName:data.postName,
unread:0,
isMute:false,
top:false,
lastMsgShow:''
name: data.name,
companyName: data.companyName,
departmentName: data.departmentName,
postName: data.postName,
unread: 0,
isMute: false,
top: false,
lastMsgShow: ""
};
},
createTeamInf(data) {
return {
id: "team-" + data.teamId,
avatar: data.avatar,
alias: data.name,
name: data.name,
unread: 0,
isMute: false,
top: false,
groupType: 0,
lastMsgShow: ""
};
},
changePanle() {
......@@ -219,6 +266,14 @@ export default {
err => {}
);
}
},
computed: {
teamList() {
return this.$store.state.teamlist.filter(x => {
x.lastTimeShow = util.formatDate(x.updateTime);
return x;
});
}
}
};
</script>
......@@ -403,17 +458,17 @@ export default {
width: 100%;
display: flex;
}
.maillist .content .panle .user-box .user-item .label{
.maillist .content .panle .user-box .user-item .label {
width: 133px;
flex: 1;
margin-right: 40px;
text-align: right;
}
.maillist .content .panle .user-box .user-item .label i{
.maillist .content .panle .user-box .user-item .label i {
font-size: 16px;
margin-right: 5px;
}
.maillist .content .panle .user-box .user-item .val{
.maillist .content .panle .user-box .user-item .val {
flex: 1;
margin-left: 40px;
text-align: left;
......@@ -423,19 +478,19 @@ export default {
color: #000;
display: block;
}
.maillist .content .panle .user-box .create-box .el-button{
width:100%;
.maillist .content .panle .user-box .create-box .el-button {
width: 100%;
}
.maillist .content .panle .user-box .create-box .el-button i{
.maillist .content .panle .user-box .create-box .el-button i {
font-size: 14px;
margin-right: 4px;
}
.maillist .content .panle .user-box .create-box{
margin:30px auto;
.maillist .content .panle .user-box .create-box {
margin: 30px auto;
width: 230px;
text-align: center;
}
.maillist .content .panle .user-box .create-box .err{
.maillist .content .panle .user-box .create-box .err {
margin-top: 10px;
color: #eb3b5a;
font-size: 12px;
......@@ -503,7 +558,7 @@ export default {
.maillist .search-result-box .tree-box {
overflow-y: auto;
position: absolute;
top: 0;
top: 54px;
bottom: 5px;
left: 0;
right: 0;
......@@ -589,4 +644,95 @@ export default {
font-family: PingFangSC-Semibold !important;
margin: 15px 0 0 0;
}
.maillist .el-tabs {
padding: 0 20px;
}
.maillist .content .panle .teams {
margin: 0;
padding: 0;
overflow-y: auto;
position: absolute;
top: 54px;
bottom: 5px;
left: 0;
right: 0;
}
.maillist .content .panle .teams li {
padding: 0 20px;
height: 58px;
display: flex;
align-items: center;
cursor: default;
}
.maillist .content .panle .teams li .el-checkbox__inner {
width: 20px;
height: 20px;
border-radius: 100%;
}
.maillist .content .panle .teams li .el-checkbox__inner::after {
left: 7px;
top: 4px;
}
.maillist .content .panle .teams li .h {
width: 40px;
height: 40px;
border-radius: 100%;
margin-right: 10px;
}
.maillist .content .panle .teams li .u {
flex: 1;
font-size: 14px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.maillist .content .panle .teams li .i {
width: 20px;
cursor: pointer;
}
.maillist .content .panle .teams li .i i {
font-size: 14px;
color: #ddd;
}
.maillist .content .panle .teams li:hover {
background: rgb(241, 241, 241);
}
.maillist .content .panle .teams li .i i:hover {
color: #999;
}
.maillist .content .panle .teams li .last-time {
font-size: 12px;
font-family: "microsoft yahei" !important;
font-weight: 300;
color: gray;
margin-left: 10px;
}
.maillist .headinfo {
width: 40px;
height: 40px;
position: relative;
margin-right: 10px;
}
.maillist .headinfo.notice {
background: #fd9644;
border-radius: 100%;
text-align: center;
line-height: 40px;
color: #f1f1f1;
}
.maillist .headinfo.notice.blue {
background: #2d98da;
color: rgba(255, 255, 255, 0.5);
}
.maillist .headinfo.notice.green {
background: #00b894;
}
.maillist .headinfo.notice.user {
background: #d1d8e0;
color: #999;
}
.maillist .headinfo.notice i {
font-size: 22px;
}
</style>
<template>
<div
class="input"
contenteditable="true"
@input="changeTxt"
@focus="lock=true"
@blur="lock=false"
id="msgEditorBox"
draggable="false"
></div>
<at :members='showMember' name-key="alias">
<template slot="item" scope="s">
<img :src="s.item.avatar" v-if="s.item.account!='-1'">
<i class="iconfont iconall" v-else></i>
<span v-text="s.item.alias"></span>
</template>
<div
class="input"
contenteditable="true"
@input="changeTxt"
@focus="lock=true"
@blur="lock=false"
id="msgEditorBox"
draggable="false"
></div>
</at>
</template>
<script>
import BMF from "browser-md5-file";
import { setInterval } from "timers";
import At from 'vue-at'
export default {
props: {
child: {
......@@ -19,13 +27,21 @@ export default {
default: {
txt: ""
}
},
members:{
type: Array,
default:[]
}
},
components: {
At
},
data: function() {
return {
innerText: this.child.txt,
uploadFile: [],
lock: false
lock: false,
showMember:[]
};
},
watch: {
......@@ -36,11 +52,43 @@ export default {
}
},
deep: true
},
members: {
handler(newValue, oldValue) {
if(this.members && this.members.length>1){
this.showMember=this.members.filter(x=>{
if(x.alias=='我'){
return
}
return x
})
this.showMember.splice(0,0,{
alias:'全体成员(all)',
account:'-1'
})
}else{
this.showMember=[]
}
},
deep: true
}
},
mounted() {
this.initClip();
let that = this;
if(this.members && this.members.length>1){
this.showMember=this.members.filter(x=>{
if(x.alias=='我'){
return
}
return x
})
this.showMember.splice(0,0,{
alias:'全体成员(all)',
account:'-1'
})
}
let pDom = document.querySelector("#msgEditorBox");
this.MsgBus.$on("new-screen-hot", function(dataurl) {
that.createImage(dataurl)
......@@ -110,7 +158,14 @@ export default {
sel.removeAllRanges();
sel.addRange(range);
} else if (ec == 13) {
that.sendMsg();
// that.child.txt = document.querySelector('#msgEditorBox').innerText;
// that.$emit('force-update',that.child.txt)
let at=document.querySelector('.atwho-cur')
if(at){
at.click()
}else{
that.sendMsg();
}
e.preventDefault();
e.stopPropagation();
}
......@@ -136,10 +191,10 @@ export default {
});
this.updateClipboard();
let myInterval = window.setInterval(this.updateClipboard, 500);
},
},
methods: {
changeTxt: function(e) {
this.child.txt = this.$el.innerText;
this.child.txt = document.querySelector('#msgEditorBox').innerText;
},
updateClipboard() {
this.$electron.ipcRenderer.send("auto-update-clip");
......@@ -242,6 +297,28 @@ export default {
};
</script>
<style scope>
.atwho-wrap{
height: 100%;
}
.atwho-li img{
width: 20px;
height: 20px;
margin-right: 10px;
}
.atwho-li i{
font-size: 18px;
margin-right: 10px;
color: royalblue;
}
.atwho-li span {
overflow: hidden;
font-size: 12px;
text-overflow: ellipsis;
font-family: 'microsoft yahei' !important;
}
.atwho-view{
border-radius: 0px;
}
.file-send-box {
min-width: 30px;
overflow: hidden;
......
......@@ -13,7 +13,10 @@ import MyPlugin from '../plugin/plugin'
import encrypt from '../plugin/encry'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import contentmenu from 'v-contextmenu'
import 'v-contextmenu/dist/index.css'
Vue.use(contentmenu)
Vue.use(editor)
Vue.use(MyPlugin)
Vue.use(ElementUI)
......
......@@ -12,7 +12,7 @@ export function getChatroomInfo ({state, commit, dispatch}) {
chatroom.getChatroom({
done: function getChatroomDone (error, info) {
if (error) {
alert(error.message)
//alert(error.message)
return
}
info = info.chatroom || {creator: ''}
......@@ -21,7 +21,7 @@ export function getChatroomInfo ({state, commit, dispatch}) {
accounts: [creator],
done: function getChatroomMembersInfoDone (error, user) {
if (error) {
alert(error.message)
//alert(error.message)
return
}
commit('getChatroomInfo', Object.assign(info, {actor: user.members[0]}))
......@@ -51,7 +51,7 @@ function getChatroomMembersLocal (isGuest, callback) {
limit: 100,
done: function getChatroomMembersDone (error, obj) {
if (error) {
alert(error.message)
//alert(error.message)
return
}
callback(obj)
......
......@@ -21,7 +21,7 @@ export function onChatroomMsgs (msgs) {
function onSendMsgDone (error, msg) {
store.dispatch('hideLoading')
if (error) {
alert(error.message)
//(error.message)
return
}
onChatroomMsgs([msg])
......
......@@ -21,7 +21,7 @@ export function onFriends (friends) {
// 更新好友资料,添加好友成功
export function onUpdateFriend(error, friends) {
if (error) {
alert(error)
//alert(error)
return
}
if (!Array.isArray(friends)) {
......@@ -54,7 +54,7 @@ export function onUpdateFriend(error, friends) {
// 删除好友,这里使用标记删除
export function onDeleteFriend(error, friends) {
if (error) {
alert(error)
//alert(error)
return
}
if (!Array.isArray(friends)) {
......@@ -80,7 +80,7 @@ export function onSyncFriendAction(obj) {
// alert('你在其它端申请加了一个好友' + obj.account + ', 附言' + obj.ps);
break;
case 'passFriendApply':
alert('你在其它端通过了一个好友申请' + obj.account + ', 附言' + obj.ps);
//alert('你在其它端通过了一个好友申请' + obj.account + ', 附言' + obj.ps);
onUpdateFriend(null, obj.friend);
break;
case 'rejectFriendApply':
......
......@@ -46,8 +46,8 @@ function connectChatroom ({state, commit, dispatch}, obj) {
chatroomId,
done: function getChatroomAddressDone (error, obj) {
if (error) {
alert(error.message)
location.href = '#/room'
//alert(error.message)
//location.href = '#/room'
return
}
dispatch('initChatroomSDK', obj)
......
......@@ -41,16 +41,15 @@ export function initNimSDK ({ state, commit, dispatch }, loginInfo) {
if (loginInfo) {
// 连接上以后更新uid
commit('updateUserUID', loginInfo)
commit('updateNetError',false)
}
},
onerror: function onError (event) {
// alert(JSON.stringify(event))
debugger
alert('网络连接状态异常')
location.href = config.loginUrl
commit('updateNetError',true)
console.log('断网了')
},
onwillreconnect: function onWillReconnect () {
console.log(event)
commit('updateNetError',true)
},
ondisconnect: function onDisconnect (error) {
switch (error.code) {
......@@ -72,6 +71,7 @@ export function initNimSDK ({ state, commit, dispatch }, loginInfo) {
pageUtil.turnPage(errorMsg, 'login')
break
default:
console.log('断网了2')
break
}
},
......
......@@ -130,12 +130,13 @@ function onSendMsgDone (error, msg) {
// 消息撤回
export function onRevocateMsg (error, msg) {
console.log('onRevocateMsg')
const nim = store.state.nim
if (error) {
if (error.code === 508) {
alert('发送时间超过2分钟的消息,不能被撤回')
util.showTips('发送时间超过2分钟的消息,不能被撤回')
} else {
alert(error)
util.showTips(error)
}
return
}
......@@ -219,6 +220,19 @@ export function sendMsg ({state, commit}, obj) {
needMsgReceipt: obj.needMsgReceipt || false
})
break
case 'at':
nim.sendText({
scene: obj.scene,
to: obj.to,
text: obj.text,
done: function(err,msg){
obj.callbackTeam(obj.content,msg.idServer)
onMsg(msg)
},
needMsgReceipt: obj.needMsgReceipt || false,
custom: JSON.stringify(obj.content)
})
break
case 'custom':
nim.sendCustomMsg({
scene: obj.scene,
......@@ -426,7 +440,7 @@ export function sendMsgReceipt ({state, commit}) {
}
function sendMsgReceiptDone(error, obj) {
console.log('发送消息已读回执' + (!error?'成功':'失败'), error, obj);
console.log('发送消息已读回执' + (!error?'成功':'失败'), error, obj);
}
export function getHistoryMsgs ({state, commit}, obj) {
......@@ -447,6 +461,7 @@ export function getHistoryMsgs ({state, commit}, obj) {
let msgs = obj.msgs.map(msg => {
return formatMsg(msg)
})
console.log(msgs)
commit('updateCurrSessionMsgs', {
type: 'concat',
msgs: msgs
......
......@@ -21,7 +21,7 @@ export function searchUsers ({state, commit}, obj) {
accounts,
done: function searchUsersDone (error, users) {
if (error) {
alert(error)
//alert(error)
return
}
commit('updateSearchlist', {
......@@ -61,7 +61,7 @@ export function searchTeam ({ state, commit }, obj) {
// 群不存在或未发生变化
teams = []
} else {
alert(error)
//(error)
return
}
}
......
......@@ -53,14 +53,14 @@ export function deleteSession ({state, commit}, sessionId) {
done: function deleteServerSessionDone (error, obj) {
if (error) {
alert(error)
//alert(error)
return
}
nim.deleteLocalSession({
id: sessionId,
done: function deleteLocalSessionDone (error, obj) {
if (error) {
alert(error)
//alert(error)
return
}
commit('deleteSessions', [sessionId])
......@@ -81,6 +81,7 @@ export function setCurrSession ({state, commit, dispatch}, sessionId) {
if (nim) {
// 如果在聊天页面刷新,此时还没有nim实例,需要在onSessions里同步
nim.setCurrSession(sessionId)
console.log('初始化了')
commit('updateCurrSessionMsgs', {
type: 'init',
sessionId
......
......@@ -137,6 +137,9 @@ export default {
state.mutelist=nim.mergeRelations(state.mutelist,mutelist)
state.mutelist = nim.cutRelations(state.mutelist, mutelist.invalid)
},
updateNetError (state, status){
state.isNetError=status
},
// 初始化,收到离线漫游消息时调用
updateMsgs (state, msgs) {
const nim = state.nim
......@@ -331,6 +334,7 @@ export default {
if (obj.msgs[0]) {
state.currSessionLastMsg = obj.msgs[0]
}
console.log(state.currSessionMsgs)
store.dispatch('checkTeamMsgReceipt', currSessionMsgs)
} else if (type === 'replace') {
let msgLen = state.currSessionMsgs.length
......
......@@ -100,5 +100,5 @@ export default {
currChatroomInfo: {},
// 聊天室成员列表
currChatroomMembers: [],
isNetError:false
}
......@@ -341,6 +341,19 @@ Utils.getTeamUpdateInfo = function(msg) {
return text
}
Utils.showTips = function(msg){
let dom=document.querySelector('#msg_tips')
if(dom && dom.style.display=='none'){
dom.innerText=msg
dom.style.display='block'
setTimeout(() => {
dom.style.display='none'
}, 2000);
}else{
console.log('没有找到div',dom.style.display)
}
}
Utils.teamConfigMap = {
joinMode: {
'noVerify': '不需要验证',
......
......@@ -11,7 +11,7 @@ var page = {
// 切换页面,并错误提示
turnPage: (message, url) => {
if (message) {
alert(message)
//(message)
}
if (url) {
if (pageMap[url]) {
......@@ -20,6 +20,7 @@ var page = {
window.location.href = url
}
},
openDown:true,
// 确定导航tab页,是否show nav
showNav: path => {
switch (path) {
......@@ -39,22 +40,24 @@ var page = {
},
// 滚动聊天列表到底部
scrollChatListDown: (pos, initCount) => {
let dom = document.getElementById('chat-list')
if (!dom) {
return
}
let maxCount = 5
initCount = initCount || 1
if (typeof pos !== 'number') {
pos = Math.max(dom.scrollHeight - dom.clientHeight, 888888)
}
dom.scrollTop = pos
if ((dom.scrollTop < pos) && (initCount < maxCount)) {
clearTimeout(scrollTimer)
scrollTimer = setTimeout(() => {
initCount++
page.scrollChatListDown(pos, initCount)
}, 200)
if(page.openDown){
let dom = document.getElementById('chat-list')
if (!dom) {
return
}
let maxCount = 5
initCount = initCount || 1
if (typeof pos !== 'number') {
pos = Math.max(dom.scrollHeight - dom.clientHeight, 888888)
}
dom.scrollTop = pos
if ((dom.scrollTop < pos) && (initCount < maxCount)) {
clearTimeout(scrollTimer)
scrollTimer = setTimeout(() => {
initCount++
page.scrollChatListDown(pos, initCount)
}, 200)
}
}
},
getChatListHeight: () => {
......
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