Commit d50e7b74 authored by 罗超's avatar 罗超

no message

parent 52471885
...@@ -58,6 +58,7 @@ let messageEvent = null ...@@ -58,6 +58,7 @@ let messageEvent = null
let messageProtocol = null let messageProtocol = null
let CAP_IMG='' let CAP_IMG=''
let nim=null let nim=null
let SCREENCOUNT=0
global.defaultdownloaddir=require('os').userInfo().homedir+'\\Downloads\\' global.defaultdownloaddir=require('os').userInfo().homedir+'\\Downloads\\'
global.DEFAULT_SCREENSHOT_PATH=require('os').userInfo().homedir+'\\Pictures\\demo.png' global.DEFAULT_SCREENSHOT_PATH=require('os').userInfo().homedir+'\\Pictures\\demo.png'
...@@ -163,19 +164,14 @@ function createWindow () { ...@@ -163,19 +164,14 @@ function createWindow () {
mainWindow.webContents.session.on('will-download', (event, item, webContents) => { mainWindow.webContents.session.on('will-download', (event, item, webContents) => {
const totalBytes = item.getTotalBytes() const totalBytes = item.getTotalBytes()
let pathAll = folderpath + `\\` + downloadname let pathAll = folderpath + `\\` + downloadname
console.log(pathAll)
item.setSavePath(pathAll) item.setSavePath(pathAll)
item.on('updated', (event, state) => { item.on('updated', (event, state) => {
if (state === 'interrupted') { if (state === 'interrupted') {
console.log('Download is interrupted but can be resumed')
} else if (state === 'progressing') { } else if (state === 'progressing') {
if (item.isPaused()) { if (item.isPaused()) {
console.log('Download is paused')
} else { } else {
console.log(`Received bytes: ${item.getReceivedBytes()}`)
} }
mainWindow.setProgressBar(item.getReceivedBytes() / totalBytes) mainWindow.setProgressBar(item.getReceivedBytes() / totalBytes)
console.log(downloadObj)
downloadObj.sender.send('downloading', (parseFloat(item.getReceivedBytes()) / parseFloat(totalBytes))*100) downloadObj.sender.send('downloading', (parseFloat(item.getReceivedBytes()) / parseFloat(totalBytes))*100)
} }
}) })
...@@ -183,8 +179,6 @@ function createWindow () { ...@@ -183,8 +179,6 @@ function createWindow () {
if (!mainWindow.isDestroyed()) { if (!mainWindow.isDestroyed()) {
mainWindow.setProgressBar(-1) mainWindow.setProgressBar(-1)
mainWindow.flashFrame(true) mainWindow.flashFrame(true)
// console.log(BrowserWindow.getFocusedWindow())
} }
if (state === 'completed') { if (state === 'completed') {
try { try {
...@@ -193,7 +187,7 @@ function createWindow () { ...@@ -193,7 +187,7 @@ function createWindow () {
} }
} else { } else {
console.log(`Download failed: ${state}`)
} }
}) })
}) })
...@@ -331,7 +325,6 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -331,7 +325,6 @@ ipc.on('loginSuccess', function (event, userInfo) {
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([{
label: '打开主界面', label: '打开主界面',
click: function () { click: function () {
console.log(loginWindow.isDestroyed())
if (isLogin) { if (isLogin) {
if (!mainWindow.isDestroyed()) { if (!mainWindow.isDestroyed()) {
mainWindow.show() mainWindow.show()
...@@ -394,7 +387,7 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -394,7 +387,7 @@ ipc.on('loginSuccess', function (event, userInfo) {
const RUN_LOCATION = '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run' const RUN_LOCATION = '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
let key = new WinReg({hive: WinReg.HKCU, key: RUN_LOCATION}) let key = new WinReg({hive: WinReg.HKCU, key: RUN_LOCATION})
key.set('WYOFFICE', WinReg.REG_SZ, process.execPath, (err) => { key.set('WYOFFICE', WinReg.REG_SZ, process.execPath, (err) => {
console.log('设置自动启动' + err) //console.log('设置自动启动' + err)
}) })
app.setAsDefaultProtocolClient('Woyou') app.setAsDefaultProtocolClient('Woyou')
...@@ -511,7 +504,6 @@ ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => { ...@@ -511,7 +504,6 @@ ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => {
msgId = pmsgId msgId = pmsgId
// evt.sender.send('tips',downloadpath); // evt.sender.send('tips',downloadpath);
mainWindow.webContents.downloadURL(downloadpath) mainWindow.webContents.downloadURL(downloadpath)
console.log(downloadpath)
} catch (error) { } catch (error) {
} }
...@@ -624,6 +616,7 @@ ipc.on('openPreviwerVideo', function (event,url) { ...@@ -624,6 +616,7 @@ ipc.on('openPreviwerVideo', function (event,url) {
}) })
ipc.on('addClipboard', function (event,content) { ipc.on('addClipboard', function (event,content) {
let img = nativeImage.createFromDataURL(content) let img = nativeImage.createFromDataURL(content)
mainEvent.sender.send('new-screen-hot',content)
clipboard.writeImage(img) clipboard.writeImage(img)
}) })
ipc.on('screens-session', function (event) { ipc.on('screens-session', function (event) {
...@@ -660,12 +653,11 @@ ipc.on('send-file', function (event,obj) { ...@@ -660,12 +653,11 @@ ipc.on('send-file', function (event,obj) {
filePath, filePath,
custom: JSON.stringify(customMsg), custom: JSON.stringify(customMsg),
uploadprogress: function(data){ uploadprogress: function(data){
console.log(data)
file.progess=data.percentage file.progess=data.percentage
event.sender.send('sending-process',file) event.sender.send('sending-process',file)
}, },
uploaderror: function () { uploaderror: function () {
console && console.log('上传失败')
}, },
uploaddone: function (error, file) { uploaddone: function (error, file) {
file.progess=100 file.progess=100
...@@ -680,7 +672,6 @@ ipc.on('send-file', function (event,obj) { ...@@ -680,7 +672,6 @@ ipc.on('send-file', function (event,obj) {
ipc.on('read-clip', function (event) { ipc.on('read-clip', function (event) {
const rawFilePath = clipboard.readBuffer('FileNameW').toString('ucs2'); const rawFilePath = clipboard.readBuffer('FileNameW').toString('ucs2');
let filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), ''); let filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
console.log(filePath)
if(filePath && filePath.length>0){ if(filePath && filePath.length>0){
fs.stat(filePath,function(error,stats){ fs.stat(filePath,function(error,stats){
if(!error){ if(!error){
...@@ -898,7 +889,15 @@ let screenHotBegin=function(){ ...@@ -898,7 +889,15 @@ let screenHotBegin=function(){
screenshot({format: 'png',filename:p}).then((img) => { screenshot({format: 'png',filename:p}).then((img) => {
if(scrollerhotWindows && !scrollerhotWindows.isDestroyed()){ if(scrollerhotWindows && !scrollerhotWindows.isDestroyed()){
screenEvent.sender.send('new-hot') screenEvent.sender.send('new-hot')
scrollerhotWindows.show() if(SCREENCOUNT==0){
scrollerhotWindows.reload()
scrollerhotWindows.once('ready-to-show', () => {
scrollerhotWindows.show()
})
}else{
scrollerhotWindows.show()
}
SCREENCOUNT++
}else{ }else{
getScrollerhotWindows() getScrollerhotWindows()
} }
...@@ -933,7 +932,6 @@ let formatDate=function(date,format){ ...@@ -933,7 +932,6 @@ let formatDate=function(date,format){
return format; return format;
}; };
let initNIM=function(uid,token){ let initNIM=function(uid,token){
console.log(uid,token)
nim = SDK.getInstance({ nim = SDK.getInstance({
debug: false, debug: false,
appKey: 'b612b31e837c79c68f141aeb719d2b20', appKey: 'b612b31e837c79c68f141aeb719d2b20',
...@@ -947,18 +945,15 @@ let initNIM=function(uid,token){ ...@@ -947,18 +945,15 @@ let initNIM=function(uid,token){
}) })
function onConnect() { function onConnect() {
console.log('连接成功');
} }
function onWillReconnect(obj) { function onWillReconnect(obj) {
// 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接 // 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接
console.log('即将重连');
console.log(obj.retryCount);
console.log(obj.duration);
} }
function onDisconnect(error) { function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面 // 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
console.log('丢失连接');
console.log(error);
if (error) { if (error) {
switch (error.code) { switch (error.code) {
// 账号或者密码错误, 请跳转到登录页面并提示错误 // 账号或者密码错误, 请跳转到登录页面并提示错误
......
...@@ -3,10 +3,11 @@ import MsgBus from './msgBus' ...@@ -3,10 +3,11 @@ import MsgBus from './msgBus'
export default { export default {
install (Vue, options) { install (Vue, options) {
Vue.prototype.MsgBus = MsgBus; Vue.prototype.MsgBus = MsgBus;
Vue.prototype.GLOBALSENDING = [], Vue.prototype.GLOBALSENDING = [];
Vue.prototype.TOPSESSION = [];
Vue.prototype.isOnline = function() { Vue.prototype.isOnline = function() {
return process.env.NODE_ENV !== 'development'; return process.env.NODE_ENV !== 'development';
}, }
Vue.prototype.domainManager = function() { Vue.prototype.domainManager = function() {
var domainUrl = "http://reborn.oytour.com";//主域名 var domainUrl = "http://reborn.oytour.com";//主域名
if (this.isOnline()) { if (this.isOnline()) {
...@@ -355,7 +356,6 @@ export default { ...@@ -355,7 +356,6 @@ export default {
return "dir-small" return "dir-small"
let css = "" let css = ""
icons.forEach(x => { icons.forEach(x => {
//console.log(x.filesIcon.hasOwnProperty(suffix))
if (x.filesIcon.hasOwnProperty(suffix)) { if (x.filesIcon.hasOwnProperty(suffix)) {
css = x.filesIcon[suffix][size] css = x.filesIcon[suffix][size]
return false return false
......
<style> <style>
@import url("./assets/css/font.css"); @import url("./assets/css/font.css");
@import url("./assets/css/global.css"); @import url("./assets/css/global.css");
@import url("//at.alicdn.com/t/font_1062339_lofkb8xnbrf.css"); @import url("//at.alicdn.com/t/font_1062339_2wir0xyzmh3.css");
</style> </style>
......
...@@ -86,6 +86,9 @@ export default { ...@@ -86,6 +86,9 @@ export default {
this.$electron.ipcRenderer.on('ignore-all-unRead', (event,session) => { this.$electron.ipcRenderer.on('ignore-all-unRead', (event,session) => {
this.MsgBus.$emit("ignore-all-unRead") this.MsgBus.$emit("ignore-all-unRead")
}) })
this.$electron.ipcRenderer.on('new-screen-hot', (event,dataurl) => {
this.MsgBus.$emit("new-screen-hot",dataurl)
})
}, },
methods: { methods: {
changeMenu(i, n) { changeMenu(i, n) {
......
This diff is collapsed.
...@@ -141,7 +141,6 @@ export default { ...@@ -141,7 +141,6 @@ export default {
inputObj: { inputObj: {
handler(val, oldVal) { handler(val, oldVal) {
this.msgToSent = val.txt; this.msgToSent = val.txt;
console.log(val.file);
}, },
deep: true deep: true
} }
...@@ -179,7 +178,6 @@ export default { ...@@ -179,7 +178,6 @@ export default {
}, },
methods: { methods: {
openScreenhot() { openScreenhot() {
console.log("截图");
this.$electron.ipcRenderer.send("open-screenhot"); this.$electron.ipcRenderer.send("open-screenhot");
}, },
dataURLtoBlob(dataurl) { dataURLtoBlob(dataurl) {
...@@ -230,14 +228,6 @@ export default { ...@@ -230,14 +228,6 @@ export default {
(err, md5) => { (err, md5) => {
crt.setLocationPath(md5, crtItem.path); crt.setLocationPath(md5, crtItem.path);
crt.readBlobAsDataURL(crtItem, function(dataurl) { crt.readBlobAsDataURL(crtItem, function(dataurl) {
// crt.$store.dispatch("sendDataUrlMsg", {
// scene: crt.scene,
// to: crt.to,
// dataURL: dataurl,
// name: crtItem.name,
// size: crt.bytesToSize(crtItem.size),
// md5
// });
fileInfo.dataurl = dataurl; fileInfo.dataurl = dataurl;
fileInfo.md5 = md5; fileInfo.md5 = md5;
crt.sendingBang(fileInfo); crt.sendingBang(fileInfo);
...@@ -476,17 +466,22 @@ export default { ...@@ -476,17 +466,22 @@ export default {
x.progess = 0; x.progess = 0;
x.avatar = this.avatar; x.avatar = this.avatar;
this.GLOBALSENDING.push(x) this.GLOBALSENDING.push(x)
x.path=x.dataurl?x.dataurl:x.path
this.MsgBus.$emit("update-sending"); this.MsgBus.$emit("update-sending");
this.$electron.ipcRenderer.send("send-file", { if(!x.dataurl){
scene: this.scene, this.$electron.ipcRenderer.send("send-file", {
to: this.to, scene: this.scene,
filePath: x.path, to: this.to,
name: x.name, filePath: x.path,
size: x.size, name: x.name,
md5: md5, size: x.size,
type, md5: md5,
file:x type,
}); file:x
});
}else{
this.sendFileDataUrl(x)
}
}); });
} }
}, },
...@@ -530,9 +525,8 @@ export default { ...@@ -530,9 +525,8 @@ export default {
this.isEmojiShown = false; this.isEmojiShown = false;
}, },
addEmoji(emojiName) { addEmoji(emojiName) {
console.log("emojiName");
this.msgToSent += emojiName; this.msgToSent += emojiName;
//this.hideEmoji() this.$refs.editor.addContent(emojiName)
}, },
chooseRobot(robot) { chooseRobot(robot) {
if (robot && robot.account) { if (robot && robot.account) {
...@@ -564,7 +558,6 @@ export default { ...@@ -564,7 +558,6 @@ export default {
} else if (/\.(wav|mp3|wma)$/i.test(file.name)) { } else if (/\.(wav|mp3|wma)$/i.test(file.name)) {
type = "file"; type = "file";
} }
let that = this;
let exts = file.name.split("."); let exts = file.name.split(".");
file.ext = exts[exts.length - 1].toLowerCase(); file.ext = exts[exts.length - 1].toLowerCase();
file.type = type; file.type = type;
...@@ -576,6 +569,10 @@ export default { ...@@ -576,6 +569,10 @@ export default {
file.avatar = this.avatar; file.avatar = this.avatar;
this.GLOBALSENDING.push(file); this.GLOBALSENDING.push(file);
this.MsgBus.$emit("update-sending"); this.MsgBus.$emit("update-sending");
this.sendFileDataUrl(file)
},
sendFileDataUrl(file){
let that=this
this.$store.dispatch("sendDataUrlMsgCall", { this.$store.dispatch("sendDataUrlMsgCall", {
scene: this.scene, scene: this.scene,
to: this.to, to: this.to,
...@@ -583,9 +580,8 @@ export default { ...@@ -583,9 +580,8 @@ export default {
name: file.name, name: file.name,
size: file.size, size: file.size,
md5: file.md5, md5: file.md5,
type, type:file.type,
onUploadprogress: function(data) { onUploadprogress: function(data) {
console.log("上传文件中....", data.percentage);
that.GLOBALSENDING.forEach(x => { that.GLOBALSENDING.forEach(x => {
if (x.msgId == file.msgId) { if (x.msgId == file.msgId) {
x.progess = data.percentage; x.progess = data.percentage;
......
...@@ -84,18 +84,21 @@ export default { ...@@ -84,18 +84,21 @@ export default {
this.$emit('add-emoji', emoji.key) this.$emit('add-emoji', emoji.key)
} else if (this.currType === 'pinup') { } else if (this.currType === 'pinup') {
if (this.type === 'session') { if (this.type === 'session') {
let custommsg= {
type: 3,
msgtype:'custom_chartlet',
data: {
catalog: this.currAlbum,
chartlet: emoji.key
}
}
this.$store.dispatch('sendMsg', { this.$store.dispatch('sendMsg', {
type: 'custom', type: 'custom',
scene: this.scene, scene: this.scene,
to: this.to, to: this.to,
pushContent: '[贴图表情]', pushContent: '[贴图表情]',
content: { content: custommsg,
type: 3, custom:JSON.stringify(custommsg)
data: {
catalog: this.currAlbum,
chartlet: emoji.key
}
}
}) })
} else if (this.type === 'chatroom') { } else if (this.type === 'chatroom') {
this.$store.dispatch('sendChatroomMsg', { this.$store.dispatch('sendChatroomMsg', {
...@@ -103,11 +106,13 @@ export default { ...@@ -103,11 +106,13 @@ export default {
pushContent: '[贴图表情]', pushContent: '[贴图表情]',
content: { content: {
type: 3, type: 3,
msgtype:101,
data: { data: {
catalog: this.currAlbum, catalog: this.currAlbum,
chartlet: emoji.key chartlet: emoji.key
} }
} },
custom:JSON.stringify(custommsg)
}) })
} }
this.$emit('hide-emoji') this.$emit('hide-emoji')
......
...@@ -26,9 +26,11 @@ ...@@ -26,9 +26,11 @@
:type="msg.type" :type="msg.type"
:class="{'in':msg.flow==='in','out':msg.flow==='out'}" :class="{'in':msg.flow==='in','out':msg.flow==='out'}"
> >
<!-- v-touch:hold="revocateMsg" --> <!-- v-touch:hold="revocateMsg" -->
<a class="msg-head" v-if="msg.avatar"> <a class="msg-head" v-if="msg.avatar">
<img class="icon u-circle" :src="msg.avatar"> <img class="icon u-circle" :src="msg.avatar">
<div class="userName" v-if="msg.flow=='in' && msg.scene==='team'">{{msg.fromNick}}</div>
</a> </a>
<p class="msg-user" v-else-if="msg.type!=='notification'"> <p class="msg-user" v-else-if="msg.type!=='notification'">
<em>{{msg.showTime}}</em> <em>{{msg.showTime}}</em>
...@@ -85,7 +87,7 @@ ...@@ -85,7 +87,7 @@
<div <div
class="state" class="state"
v-else v-else
>{{msg.locationPath!=='-1' && msg.flow=='out'?'未下载临时文件':'本地文件已被移除'}}</div> >{{msg.locationPath!=='-1'?'未下载临时文件':'本地文件已被移除'}}</div>
<div class="btn" v-if="msg.locationPath!=='' && msg.locationPath!=='-1'"> <div class="btn" v-if="msg.locationPath!=='' && msg.locationPath!=='-1'">
<div class="item_btn" @click="openLocaltion(msg.locationPath)">打开</div> <div class="item_btn" @click="openLocaltion(msg.locationPath)">打开</div>
<div class="item_btn" @click="openLocaltionFoled(msg.locationPath)">打开文件夹</div> <div class="item_btn" @click="openLocaltionFoled(msg.locationPath)">打开文件夹</div>
...@@ -947,6 +949,7 @@ export default { ...@@ -947,6 +949,7 @@ export default {
padding-right: 30%; padding-right: 30%;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: flex-start;
} }
.item-me .out { .item-me .out {
padding-left: 30%; padding-left: 30%;
...@@ -956,9 +959,6 @@ export default { ...@@ -956,9 +959,6 @@ export default {
} }
.item-you .in .msg-head, .item-you .in .msg-head,
.item-me .out .msg-head { .item-me .out .msg-head {
width: 38px;
height: 38px;
border-radius: 100%;
display: inline-block; display: inline-block;
overflow: hidden; overflow: hidden;
} }
...@@ -979,8 +979,15 @@ export default { ...@@ -979,8 +979,15 @@ export default {
} }
.item-you .in .msg-head img, .item-you .in .msg-head img,
.item-me .out .msg-head img { .item-me .out .msg-head img {
width: 100%; width: 38px;
height: 100%; height: 38px;
border-radius: 100%;
}
.item-you .in .msg-head .userName{
width: 38px;
font-size: 12px;
text-align: center;
color: #333;
} }
.item-you .in span, .item-you .in span,
.item-me .out span { .item-me .out span {
......
<template> <template>
<div class="msgbox"> <div class="msgbox">
<audio id="msgaudio" > <audio id="msgaudio">
<source src="../../static/audio/msg.mp3" type="audio/mpeg"> <source src="../../static/audio/msg.mp3" type="audio/mpeg">
</audio> </audio>
<audio id="shakeaudio"> <audio id="shakeaudio">
<source src="../../static/audio/shake.wav" type="audio/wav"> <source src="../../static/audio/shake.wav" type="audio/wav">
</audio> </audio>
<div class="sessionbox"> <div class="sessionbox">
<div class="search__session__box"> <div class="search__session__box">
<div class="seach_ctr"> <div class="seach_ctr">
...@@ -37,36 +37,81 @@ ...@@ -37,36 +37,81 @@
</div> </div>
</div> </div>
</li> </li>
<li <template v-for="(session, index) in sessionlist">
:class="{'active':currentSession.id==session.id}" <li
v-for="(session, index) in sessionlist" :class="{'active':currentSession.id==session.id}"
:key="index" v-if="session.top"
@click="enterChat(session)" :key="index"
> @click="enterChat(session)"
<el-badge :value="session.unread" :max="99" class="item"> >
<div <el-badge
class="headinfo" :value="session.unread"
:class="{'notice':!session.avatar,'blue':session.groupType==0,'green':session.groupType==1,'user':session.groupType==-1}" :max="99"
class="item"
:is-dot="session.isMute && session.unread>0"
> >
<img :src="session.avatar" v-if="session.avatar"> <div
<i class="iconfont icontaolun" v-else-if="session.groupType == 0"></i> class="headinfo"
<i class="iconfont iconqunzu" v-else-if="session.groupType == 1"></i> :class="{'notice':!session.avatar,'blue':session.groupType==0,'green':session.groupType==1,'user':session.groupType==-1}"
<i class="iconfont iconyonghutouxiang" v-else></i> >
<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">
<span v-if="session.isMute && session.unread>0">[{{session.unread}}]</span>
{{session.lastMsgShow}}
</div>
</div> </div>
</el-badge> </li>
<div class="baseinfo"> </template>
<div class="userbase"> <template v-for="(session, index) in sessionlist">
<div class="name">{{session.name}}</div> <li
<div class="time">{{session.updateTimeShow}}</div> :class="{'active':currentSession.id==session.id}"
v-if="!session.top"
:key="index"
@click="enterChat(session)"
>
<el-badge
:value="session.unread"
:max="99"
class="item"
: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">
<span v-if="session.isMute && session.unread>0">[{{session.unread}}]</span>
{{session.lastMsgShow}}
</div>
</div> </div>
<div class="msgbase">{{session.lastMsgShow}}</div> </li>
</div> </template>
</li>
</ul> </ul>
</div> </div>
<div class="messagebox"> <div class="messagebox">
<div v-if="currentSession.id!=''"> <div v-if="currentSession.id!=''">
<chat :id="currentSession.id"></chat> <chat :id="currentSession.id" @update-session='updateSession'></chat>
</div> </div>
<div v-else class="nosession"> <div v-else class="nosession">
<img src="../../assets/img/backgroundlogo.png"> <img src="../../assets/img/backgroundlogo.png">
...@@ -108,16 +153,27 @@ export default { ...@@ -108,16 +153,27 @@ export default {
this.$store.dispatch("updateRefreshState"); this.$store.dispatch("updateRefreshState");
}, },
methods: { methods: {
updateSession(topSession){
this.sessionlist.forEach(item=>{
item.top = false
topSession.forEach(x => {
if (item.id == x) {
item.top = true;
return false;
}
});
})
this.TOPSESSION=topSession
},
enterChat(session) { enterChat(session) {
this.$electron.ipcRenderer.send("clearPrevImgs"); this.$electron.ipcRenderer.send("clearPrevImgs");
let index=-1 let index = -1;
this.newMsgList.forEach((x,i)=>{ this.newMsgList.forEach((x, i) => {
if(x.id==session.id){ if (x.id == session.id) {
index=i index = i;
} }
}) });
if(index!=-1) if (index != -1) this.newMsgList.splice(index, 1);
this.newMsgList.splice(index,1)
this.currentSession = session; this.currentSession = session;
}, },
dou() { dou() {
...@@ -155,8 +211,7 @@ export default { ...@@ -155,8 +211,7 @@ export default {
}, },
calcUnRead(oldarr, newarr) { calcUnRead(oldarr, newarr) {
let isplay = false; let isplay = false;
if(newarr.length>oldarr.length) if (newarr.length > oldarr.length) return true;
return true
newarr.forEach(x => { newarr.forEach(x => {
let isExsit = false; let isExsit = false;
oldarr.forEach(y => { oldarr.forEach(y => {
...@@ -173,10 +228,13 @@ export default { ...@@ -173,10 +228,13 @@ export default {
return false; return false;
} }
}); });
return isplay return isplay;
} }
}, },
mounted() { mounted() {
if (window.localStorage.top) {
this.TOPSESSION=JSON.parse(window.localStorage.top)
}
this.$store.dispatch("connect"); this.$store.dispatch("connect");
let that = this; let that = this;
this.MsgBus.$on("doudong", function() { this.MsgBus.$on("doudong", function() {
...@@ -186,16 +244,16 @@ export default { ...@@ -186,16 +244,16 @@ export default {
that.enterChat(data); that.enterChat(data);
}); });
this.MsgBus.$on("dispose-session", function() { this.MsgBus.$on("dispose-session", function() {
that.$store.dispatch('resetCurrSession') that.$store.dispatch("resetCurrSession");
that.currentSession={ that.currentSession = {
id: "" id: ""
} };
}); });
this.MsgBus.$on("ignore-all-unRead", function() { this.MsgBus.$on("ignore-all-unRead", function() {
that.newMsgList.forEach(x=>{ that.newMsgList.forEach(x => {
that.$store.dispatch('setCurrSession', x.id) that.$store.dispatch("setCurrSession", x.id);
that.$store.dispatch('sendMsgReceipt') that.$store.dispatch("sendMsgReceipt");
}) });
}); });
}, },
computed: { computed: {
...@@ -210,6 +268,7 @@ export default { ...@@ -210,6 +268,7 @@ export default {
return this.$store.state.userInfos; return this.$store.state.userInfos;
}, },
myInfo() { myInfo() {
return this.$store.state.myInfo; return this.$store.state.myInfo;
}, },
myPhoneId() { myPhoneId() {
...@@ -240,18 +299,23 @@ export default { ...@@ -240,18 +299,23 @@ export default {
let teamInfo = null; let teamInfo = null;
teamInfo = this.$store.state.teamlist.find(team => { teamInfo = this.$store.state.teamlist.find(team => {
return team.teamId === item.to; return team.teamId === item.to;
}); });
item.groupType = teamInfo.type == "normal" ? 0 : 1;
if (teamInfo) { if (teamInfo) {
if(!teamInfo.validToCurrentUser || !teamInfo.valid) return;
item.groupType = teamInfo.type == "normal" ? 0 : 1;
item.name = teamInfo.name; item.name = teamInfo.name;
item.avatar = item.avatar =
teamInfo.avatar || teamInfo.avatar ||
(teamInfo.type === "normal" (teamInfo.type === "normal"
? this.myGroupIcon ? this.myGroupIcon
: this.myAdvancedIcon); : this.myAdvancedIcon);
item.isMute=teamInfo.usermute?teamInfo.usermute:false
} else { } else {
return;
item.groupType = 'normal'
item.name = `群${item.to}`; item.name = `群${item.to}`;
item.avatar = item.avatar || this.myGroupIcon; item.avatar = item.avatar || this.myGroupIcon;
item.isMute=false
} }
} }
let lastMsg = item.lastMsg || {}; let lastMsg = item.lastMsg || {};
...@@ -276,7 +340,24 @@ export default { ...@@ -276,7 +340,24 @@ export default {
this.noticeObj = item; this.noticeObj = item;
return; return;
} }
if (item.unread > 0) { if(item.scene !== "team"){
item.isMute = false;
this.$store.state.mutelist.forEach(x => {
if (x.account == item.to) {
item.isMute = true;
return false;
}
});
}
item.top = false;
this.TOPSESSION.forEach(x => {
if (item.id == x) {
item.top = true;
return false;
}
});
if (item.unread > 0 && !item.isMute) {
if (item.lastMsg.tip && item.lastMsg.tip.indexOf("抖了一下") != -1) { if (item.lastMsg.tip && item.lastMsg.tip.indexOf("抖了一下") != -1) {
this.dou(); this.dou();
this.enterChat(item); this.enterChat(item);
...@@ -286,19 +367,19 @@ export default { ...@@ -286,19 +367,19 @@ export default {
return item; return item;
}); });
if (!this.$electron.remote.getCurrentWindow().isVisible()) { if (!this.$electron.remote.getCurrentWindow().isVisible()) {
if(this.calcUnRead(this.newMsgList,unreadList)){ if (this.calcUnRead(this.newMsgList, unreadList)) {
document.querySelector("#msgaudio").play(); document.querySelector("#msgaudio").play();
} }
this.$electron.ipcRenderer.send("newMessage", this.newMsgList); this.$electron.ipcRenderer.send("newMessage", this.newMsgList);
} else { } else {
this.$electron.ipcRenderer.send("newMessage", []); this.$electron.ipcRenderer.send("newMessage", []);
} }
if(!this.$electron.remote.getCurrentWindow().isFocused()){ if (!this.$electron.remote.getCurrentWindow().isFocused()) {
if(this.calcUnRead(this.newMsgList,unreadList)){ if (this.calcUnRead(this.newMsgList, unreadList)) {
this.$electron.remote.getCurrentWindow().flashFrame(true) this.$electron.remote.getCurrentWindow().flashFrame(true);
} }
} }
this.newMsgList=unreadList this.newMsgList = unreadList;
return sessionlist; return sessionlist;
} }
} }
......
<template>
</template>
<script>
export default {
}
</script>
<style>
</style>
...@@ -42,6 +42,9 @@ export default { ...@@ -42,6 +42,9 @@ export default {
this.initClip(); this.initClip();
let that = this; let that = this;
let pDom = document.querySelector("#msgEditorBox"); let pDom = document.querySelector("#msgEditorBox");
this.MsgBus.$on("new-screen-hot", function(dataurl) {
that.createImage(dataurl)
});
pDom.addEventListener("drop", e => { pDom.addEventListener("drop", e => {
return false; return false;
}); });
...@@ -69,7 +72,8 @@ export default { ...@@ -69,7 +72,8 @@ export default {
} }
}); });
pDom.addEventListener("keydown", e => { pDom.addEventListener("keydown", e => {
var e = e || window.event, ec = e.keyCode || e.which; var e = e || window.event,
ec = e.keyCode || e.which;
if (ec == 8 || ec == 46) { if (ec == 8 || ec == 46) {
let dom = null; let dom = null;
pDom.querySelectorAll(".file-send-box").forEach((x, i) => { pDom.querySelectorAll(".file-send-box").forEach((x, i) => {
...@@ -92,10 +96,10 @@ export default { ...@@ -92,10 +96,10 @@ export default {
}, 100); }, 100);
} }
} else if (e.ctrlKey && 13 == ec) { } else if (e.ctrlKey && 13 == ec) {
var div = document.createElement('div'); var div = document.createElement("div");
var newContent = document.createElement('br') var newContent = document.createElement("br");
div.appendChild(newContent) div.appendChild(newContent);
pDom.appendChild(div) pDom.appendChild(div);
var o = pDom.lastChild; var o = pDom.lastChild;
var sel = window.getSelection(); var sel = window.getSelection();
var range = document.createRange(); var range = document.createRange();
...@@ -105,13 +109,13 @@ export default { ...@@ -105,13 +109,13 @@ export default {
range.setStartAfter(o); range.setStartAfter(o);
sel.removeAllRanges(); sel.removeAllRanges();
sel.addRange(range); sel.addRange(range);
} else if (ec == 13){ } else if (ec == 13) {
that.sendMsg() that.sendMsg();
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
} }
}); });
this.$electron.ipcRenderer.on("new-send-file", (event, path,size) => { this.$electron.ipcRenderer.on("new-send-file", (event, path, size) => {
let h = that.child.file.find(x => { let h = that.child.file.find(x => {
return x.path == path; return x.path == path;
}); });
...@@ -138,7 +142,6 @@ export default { ...@@ -138,7 +142,6 @@ export default {
this.child.txt = this.$el.innerText; this.child.txt = this.$el.innerText;
}, },
updateClipboard() { updateClipboard() {
console.log("update....");
this.$electron.ipcRenderer.send("auto-update-clip"); this.$electron.ipcRenderer.send("auto-update-clip");
}, },
readBlobAsDataURL(blob, callback) { readBlobAsDataURL(blob, callback) {
...@@ -149,7 +152,7 @@ export default { ...@@ -149,7 +152,7 @@ export default {
a.readAsDataURL(blob); a.readAsDataURL(blob);
}, },
initClip() { initClip() {
let _this = this; let that = this;
document document
.querySelector("#msgEditorBox") .querySelector("#msgEditorBox")
.addEventListener("paste", function(event) { .addEventListener("paste", function(event) {
...@@ -158,7 +161,7 @@ export default { ...@@ -158,7 +161,7 @@ export default {
if (clipboardData) { if (clipboardData) {
items = clipboardData.items; items = clipboardData.items;
if (!items || items.length == 0) { if (!items || items.length == 0) {
_this.$electron.ipcRenderer.send("read-clip") that.$electron.ipcRenderer.send("read-clip");
return false; return false;
} else { } else {
// 保存在剪贴板中的数据类型 // 保存在剪贴板中的数据类型
...@@ -174,46 +177,41 @@ export default { ...@@ -174,46 +177,41 @@ export default {
item.kind === "file" && item.kind === "file" &&
item.type.match(/^image\//i) item.type.match(/^image\//i)
) { ) {
console.log(item);
// 读取该图片 // 读取该图片
// var file = item.getAsFile(), var file = item.getAsFile(),
// reader = new FileReader(), reader = new FileReader(),
// name = ""; name = "";
// if (item.type.match(/^image\//i)) if (item.type.match(/^image\//i))
// name = `截图_${Date.parse(new Date())}.png`; name = `截图_${Date.parse(new Date())}.png`;
// reader.onload = function(e) { reader.onload = function(e) {
// const bmf = new BMF(); that.createImage(e.target.result)
// bmf.md5( };
// crtItem, reader.readAsDataURL(file);
// (err, md5) => {
// crt.setLocationPath(md5, crtItem.path);
// crt.readBlobAsDataURL(crtItem, function(dataurl) {
// crt.$store.dispatch("sendDataUrlMsg", {
// scene: crt.scene,
// to: crt.to,
// dataURL: dataurl,
// name: crtItem.name,
// size: crt.bytesToSize(crtItem.size),
// md5
// });
// });
// },
// progress => {}
// )
// _this.$store.dispatch("sendDataUrlMsg", {
// scene: util.parseSession(window.localStorage.sessionId).scene,
// to: util.parseSession(window.localStorage.sessionId).to,
// dataURL: e.target.result,
// name
// });
// pageUtil.scrollChatListDown();
//};
//reader.readAsDataURL(file);
} }
} }
} }
}); });
}, },
createImage(dataurl){
var strLen = dataurl.length;
var size = strLen-(strLen/8)*2;
let f = {
path:'',
size,
icon: '',
ext: 'png',
name: `截图_${Date.parse(new Date())}.png`,
dataurl
};
this.child.file.push(f);
let img = document.createElement("img");
img.src = dataurl;
img.style.maxWidth = "150px";
img.style.maxHeight = "150px";
img.className='file-send-box'
document.querySelector("#msgEditorBox").appendChild(img);
},
formatHTML(f) { formatHTML(f) {
let html = `<div title='${ let html = `<div title='${
f.name f.name
...@@ -230,14 +228,15 @@ export default { ...@@ -230,14 +228,15 @@ export default {
clearContent() { clearContent() {
this.child.file = []; this.child.file = [];
this.child.txt = ""; this.child.txt = "";
let dom=document.querySelector("#msgEditorBox") let dom = document.querySelector("#msgEditorBox");
dom.innerHTML = ""; dom.innerHTML = "";
while(dom.hasChildNodes()) while (dom.hasChildNodes()) {
{
dom.removeChild(dom.firstChild); dom.removeChild(dom.firstChild);
} }
console.log(dom.hasChildNodes()) },
addContent(txt) {
var txtElement = document.createTextNode(txt);
document.querySelector("#msgEditorBox").appendChild(txtElement);
} }
} }
}; };
......
...@@ -24,7 +24,6 @@ export default { ...@@ -24,7 +24,6 @@ export default {
this.$electron.remote.getCurrentWindow().close(); this.$electron.remote.getCurrentWindow().close();
}, },
handleClose(done) { handleClose(done) {
console.log('in........')
this.close() this.close()
} }
} }
......
...@@ -18,7 +18,6 @@ export default { ...@@ -18,7 +18,6 @@ export default {
}, },
mounted() { mounted() {
this.url = this.$electron.remote.getGlobal("PREVIWERURL"); this.url = this.$electron.remote.getGlobal("PREVIWERURL");
console.log(this.url);
}, },
methods: { methods: {
closeWin() { closeWin() {
......
...@@ -24,7 +24,6 @@ export default { ...@@ -24,7 +24,6 @@ export default {
mounted() { mounted() {
this.url=this.$electron.remote.getGlobal('PREVIWERVIDEOURL') this.url=this.$electron.remote.getGlobal('PREVIWERVIDEOURL')
setTimeout(() => { setTimeout(() => {
console.log(this.$electron.remote.getCurrentWindow().height)
this.$electron.remote.getCurrentWindow().setSize(420,document.querySelector("#videos").clientHeight+20) this.$electron.remote.getCurrentWindow().setSize(420,document.querySelector("#videos").clientHeight+20)
this.bg='rgba(0, 0, 0, 1)' this.bg='rgba(0, 0, 0, 1)'
}, 1000); }, 1000);
......
...@@ -15,11 +15,10 @@ export default { ...@@ -15,11 +15,10 @@ export default {
created() { created() {
// //
let that = this; let that = this;
this.imgPath = this.$electron.remote.getGlobal("DEFAULT_SCREENSHOT_PATH");
this.$electron.ipcRenderer.send("screens-session"); this.$electron.ipcRenderer.send("screens-session");
this.$electron.ipcRenderer.on("new-hot", event => { this.$electron.ipcRenderer.on("new-hot", event => {
that.imgPath = null; that.imgPath = null;
console.log(that.$electron.remote.getGlobal("DEFAULT_SCREENSHOT_PATH"))
that.imgPath = that.$electron.remote.getGlobal("DEFAULT_SCREENSHOT_PATH") that.imgPath = that.$electron.remote.getGlobal("DEFAULT_SCREENSHOT_PATH")
that.screenhot() that.screenhot()
}); });
...@@ -31,6 +30,8 @@ export default { ...@@ -31,6 +30,8 @@ export default {
}, },
mounted() { mounted() {
let that = this; let that = this;
this.imgPath = this.$electron.remote.getGlobal("DEFAULT_SCREENSHOT_PATH");
console.log(this.imgPath,'imgPath')
document.onkeydown = function(event) { document.onkeydown = function(event) {
var e = event || window.event || arguments.callee.caller.arguments[0]; var e = event || window.event || arguments.callee.caller.arguments[0];
if (e && e.keyCode == 27) { if (e && e.keyCode == 27) {
......
...@@ -43,6 +43,11 @@ export default new Router({ ...@@ -43,6 +43,11 @@ export default new Router({
path: '/dialog', path: '/dialog',
name: 'dialog', name: 'dialog',
component: require('@/components/tools/dialog') component: require('@/components/tools/dialog')
},
{
path: '/addnewuser',
name: 'addnewuser',
component: require('@/components/team/addNewUser')
} }
] ]
}) })
...@@ -37,20 +37,50 @@ export function onMarkInBlacklist (obj) { ...@@ -37,20 +37,50 @@ export function onMarkInBlacklist (obj) {
} }
} }
export function updateBlack ({state}, {account, isBlack}) { export function updateBlack ({state}, obj) {
let {account, isBlack, scene, to, name} = obj
const nim = state.nim const nim = state.nim
if (account && (typeof isBlack === 'boolean')) { if (account && (typeof isBlack === 'boolean')) {
nim.markInBlacklist({ nim.markInBlacklist({
account, account,
// `true`表示加入黑名单, `false`表示从黑名单移除
isAdd: isBlack, isAdd: isBlack,
done: function (error, obj) { done: function (error, obj) {
if (error) {
alert(error)
return
}
onMarkInBlacklist(obj) onMarkInBlacklist(obj)
} }
}) })
} }
}
export function onMsg (msg) {
msg = formatMsg(msg)
store.commit('putMsg', msg)
if (msg.sessionId === store.state.currSessionId) {
store.commit('updateCurrSessionMsgs', {
type: 'put',
msg
})
}
}
export function formatMsg (msg) {
const nim = store.state.nim
if (msg.type === 'robot') {
if (msg.content && msg.content.flag === 'bot') {
if (msg.content.message) {
msg.content.message = msg.content.message.map(item => {
switch (item.type) {
case 'template':
item.content = nim.parseRobotTemplate(item.content)
break
case 'text':
case 'image':
case 'answer':
break
}
return item
})
}
}
}
return msg
} }
\ No newline at end of file
...@@ -11,11 +11,11 @@ import {updateBlack} from './blacks' ...@@ -11,11 +11,11 @@ import {updateBlack} from './blacks'
import {updateFriend, addFriend, deleteFriend} from './friends' import {updateFriend, addFriend, deleteFriend} from './friends'
import {resetSearchResult, searchUsers, searchTeam} from './search' import {resetSearchResult, searchUsers, searchTeam} from './search'
import {deleteSession, setCurrSession, resetCurrSession} from './session' import {deleteSession, setCurrSession, resetCurrSession} from './session'
import {sendMsg, sendTip, sendFileMsg,sendDataUrlMsg,sendDataUrlMsgCall, sendMsgReceipt, sendRobotMsg, revocateMsg, updateLocalMsg, getHistoryMsgs, resetNoMoreHistoryMsgs, continueRobotMsg} from './msgs' import {sendMsg, sendTip,markInMutelist, sendFileMsg,sendDataUrlMsg,sendDataUrlMsgCall, sendMsgReceipt, sendRobotMsg, revocateMsg, updateLocalMsg, getHistoryMsgs, resetNoMoreHistoryMsgs, continueRobotMsg} from './msgs'
import {markSysMsgRead, resetSysMsgs, deleteSysMsgs, markCustomSysMsgRead} from './sysMsgs' import {markSysMsgRead, resetSysMsgs, deleteSysMsgs, markCustomSysMsgRead} from './sysMsgs'
import {sendChatroomMsg, sendChatroomRobotMsg, sendChatroomFileMsg, getChatroomHistoryMsgs} from './chatroomMsgs' import {sendChatroomMsg, sendChatroomRobotMsg, sendChatroomFileMsg, getChatroomHistoryMsgs} from './chatroomMsgs'
import {initChatroomInfos, getChatroomInfo, getChatroomMembers, clearChatroomMembers} from './chatroomInfos' import {initChatroomInfos, getChatroomInfo, getChatroomMembers, clearChatroomMembers} from './chatroomInfos'
import { delegateTeamFunction, onTeamNotificationMsg, enterSettingPage, getTeamMembers, checkTeamMsgReceipt, getTeamMsgReads} from './team' import { delegateTeamFunction, getNotifyForNewTeamMsg,onTeamNotificationMsg, enterSettingPage, getTeamMembers, checkTeamMsgReceipt, getTeamMsgReads} from './team'
function connectNim ({state, commit, dispatch}, obj) { function connectNim ({state, commit, dispatch}, obj) {
let {force} = Object.assign({}, obj) let {force} = Object.assign({}, obj)
...@@ -117,6 +117,7 @@ export default { ...@@ -117,6 +117,7 @@ export default {
sendFileMsg, sendFileMsg,
sendDataUrlMsg, sendDataUrlMsg,
sendDataUrlMsgCall, sendDataUrlMsgCall,
markInMutelist,
sendRobotMsg, sendRobotMsg,
// 发送消息已读回执 // 发送消息已读回执
sendMsgReceipt, sendMsgReceipt,
...@@ -151,6 +152,7 @@ export default { ...@@ -151,6 +152,7 @@ export default {
delegateTeamFunction, delegateTeamFunction,
// 处理群消息回调 // 处理群消息回调
onTeamNotificationMsg, onTeamNotificationMsg,
getNotifyForNewTeamMsg,
// 进入群信息设置页 // 进入群信息设置页
enterSettingPage, enterSettingPage,
// 获取群成员 // 获取群成员
......
...@@ -11,7 +11,7 @@ import {onRobots} from './robots' ...@@ -11,7 +11,7 @@ import {onRobots} from './robots'
import {onBlacklist, onMarkInBlacklist} from './blacks' import {onBlacklist, onMarkInBlacklist} from './blacks'
import {onMyInfo, onUserInfo} from './userInfo' import {onMyInfo, onUserInfo} from './userInfo'
import {onSessions, onUpdateSession} from './session' import {onSessions, onUpdateSession} from './session'
import {onRoamingMsgs, onOfflineMsgs, onMsg} from './msgs' import {onRoamingMsgs, onOfflineMsgs, onMsg, onMutelist, onMarkInMutelist} from './msgs'
import {onSysMsgs, onSysMsg, onSysMsgUnread, onCustomSysMsgs} from './sysMsgs' import {onSysMsgs, onSysMsg, onSysMsgUnread, onCustomSysMsgs} from './sysMsgs'
import { onTeams, onSynCreateTeam, onCreateTeam, onUpdateTeam, onTeamMembers, onUpdateTeamMember, onAddTeamMembers, onRemoveTeamMembers, onUpdateTeamManagers, onDismissTeam, onUpdateTeamMembersMute, onTeamMsgReceipt} from './team' import { onTeams, onSynCreateTeam, onCreateTeam, onUpdateTeam, onTeamMembers, onUpdateTeamMember, onAddTeamMembers, onRemoveTeamMembers, onUpdateTeamManagers, onDismissTeam, onUpdateTeamMembersMute, onTeamMsgReceipt} from './team'
...@@ -80,8 +80,8 @@ export function initNimSDK ({ state, commit, dispatch }, loginInfo) { ...@@ -80,8 +80,8 @@ export function initNimSDK ({ state, commit, dispatch }, loginInfo) {
// 用户关系及好友关系 // 用户关系及好友关系
onblacklist: onBlacklist, onblacklist: onBlacklist,
onsyncmarkinblacklist: onMarkInBlacklist, onsyncmarkinblacklist: onMarkInBlacklist,
// onmutelist: onMutelist, onmutelist: onMutelist,
// onsyncmarkinmutelist: onMarkInMutelist, onsyncmarkinmutelist: onMarkInMutelist,
onfriends: onFriends, onfriends: onFriends,
onsyncfriendaction: onSyncFriendAction, onsyncfriendaction: onSyncFriendAction,
// 机器人 // 机器人
......
...@@ -39,14 +39,50 @@ export function onOfflineMsgs (obj) { ...@@ -39,14 +39,50 @@ export function onOfflineMsgs (obj) {
store.commit('updateMsgs', msgs) store.commit('updateMsgs', msgs)
} }
export function onMutelist (mutelist){
store.commit('updateMutelist', mutelist)
}
export function onMarkInMutelist (obj){
console.log(obj.account + '被你' + (obj.isAdd ? '加入' : '移除') + '静音列表');
if (obj.isAdd) {
addToMutelist(obj);
} else {
removeFromMutelist(obj);
}
}
export function addToMutelist(obj) {
store.commit('addToMutelist', obj)
}
export function removeFromMutelist(obj) {
store.commit('removeFromMutelist', obj)
}
export function markInMutelist({state,commit}, obj){
const nim = store.state.nim
let {account,isAdd,scene,to,name} = obj
nim.markInMutelist({
account,
isAdd,
done: function markInMutelistDone(error, obj) {
console.log(error)
onMarkInMutelist(obj)
}
});
}
export function sendTip ({state, commit}, obj) { export function sendTip ({state, commit}, obj) {
const nim = store.state.nim const nim = store.state.nim
let isLocal='isLocal' in obj ? obj.isLocal : false
nim.sendTipMsg({ nim.sendTipMsg({
scene: obj.scene, scene: obj.scene,
to: obj.to, to: obj.to,
tip: obj.tip, tip: obj.tip,
isLocal,
done: function sendTipMsgDone (error, msg) { done: function sendTipMsgDone (error, msg) {
onSendMsgDone(error, msg) console.log(msg)
onMsg(msg)
} }
}) })
} }
......
...@@ -6,7 +6,9 @@ export function onTeams(teams) { ...@@ -6,7 +6,9 @@ export function onTeams(teams) {
teams = [teams] teams = [teams]
} }
teams = teams.filter(item => !!item) teams = teams.filter(item => !!item)
let teamIds = []
teams.forEach(team=>{ teams.forEach(team=>{
teamIds.push(team.teamId)
if (team.validToCurrentUser === undefined) { if (team.validToCurrentUser === undefined) {
team.validToCurrentUser = true team.validToCurrentUser = true
} }
...@@ -14,6 +16,8 @@ export function onTeams(teams) { ...@@ -14,6 +16,8 @@ export function onTeams(teams) {
team.avatar = team.avatar + '?imageView&thumbnail=300y300' team.avatar = team.avatar + '?imageView&thumbnail=300y300'
} }
}) })
getNotifyForNewTeamMsg(store,teamIds)
store.commit('updateTeamList', teams) store.commit('updateTeamList', teams)
} }
...@@ -119,9 +123,9 @@ export function onTeamMsgReceipt(obj) { ...@@ -119,9 +123,9 @@ 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`
}, 20) // }, 20)
} }
...@@ -165,6 +169,17 @@ export function getTeamMembers({ state }, teamId) { ...@@ -165,6 +169,17 @@ export function getTeamMembers({ state }, teamId) {
}) })
} }
export function getNotifyForNewTeamMsg({state,commit},teamIds) {
const nim = state.nim
nim.notifyForNewTeamMsg({
teamIds: teamIds,
done: (err, 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) {
......
...@@ -124,6 +124,19 @@ export default { ...@@ -124,6 +124,19 @@ export default {
const nim = state.nim const nim = state.nim
state.sessionlist = nim.cutSessionsByIds(state.sessionlist, sessionIds) state.sessionlist = nim.cutSessionsByIds(state.sessionlist, sessionIds)
}, },
addToMutelist(state,obj){
const nim = state.nim
state.mutelist = nim.mergeRelations(state.mutelist, obj.record);
},
removeFromMutelist(state,obj){
const nim = state.nim
state.mutelist = nim.cutRelations(state.mutelist, obj.record);
},
updateMutelist (state, mutelist) {
const nim = state.nim
state.mutelist=nim.mergeRelations(state.mutelist,mutelist)
state.mutelist = nim.cutRelations(state.mutelist, mutelist.invalid)
},
// 初始化,收到离线漫游消息时调用 // 初始化,收到离线漫游消息时调用
updateMsgs (state, msgs) { updateMsgs (state, msgs) {
const nim = state.nim const nim = state.nim
...@@ -170,6 +183,9 @@ export default { ...@@ -170,6 +183,9 @@ export default {
store.commit('updateMsgByIdClient', msg) store.commit('updateMsgByIdClient', msg)
let tempMsgs = state.msgs[sessionId] let tempMsgs = state.msgs[sessionId]
let lastMsgIndex = tempMsgs.length - 1 let lastMsgIndex = tempMsgs.length - 1
if(msg.isLocal && lastMsgIndex>=0){
msg.time = tempMsgs[lastMsgIndex].time+1
}
if (tempMsgs.length === 0 || msg.time >= tempMsgs[lastMsgIndex].time) { if (tempMsgs.length === 0 || msg.time >= tempMsgs[lastMsgIndex].time) {
tempMsgs.push(msg) tempMsgs.push(msg)
} else { } else {
...@@ -208,7 +224,6 @@ export default { ...@@ -208,7 +224,6 @@ export default {
let lastMsgIndex = tempMsgs.length - 1 let lastMsgIndex = tempMsgs.length - 1
for (let i = lastMsgIndex; i >= 0; i--) { for (let i = lastMsgIndex; i >= 0; i--) {
let currMsg = tempMsgs[i] let currMsg = tempMsgs[i]
console.log(idClient, currMsg.idClient, currMsg.text)
if (idClient === currMsg.idClient) { if (idClient === currMsg.idClient) {
state.msgs[sessionId].splice(i, 1, msg) state.msgs[sessionId].splice(i, 1, msg)
break break
...@@ -481,6 +496,13 @@ export default { ...@@ -481,6 +496,13 @@ export default {
store.state.teamlist = nim.mergeTeams(store.state.teamlist, teams) store.state.teamlist = nim.mergeTeams(store.state.teamlist, teams)
store.state.teamlist = nim.cutTeams(store.state.teamlist, teams.invalid) store.state.teamlist = nim.cutTeams(store.state.teamlist, teams.invalid)
}, },
updateTeamUserMute (state, map) {
store.state.teamlist.forEach(x=>{
if(map[x.teamId]!=undefined && map[x.teamId]!=null){
x.usermute=map[x.teamId]=='1'
}
})
},
updateTeamMembers (state, obj) { updateTeamMembers (state, obj) {
const nim = state.nim const nim = state.nim
var teamId = obj.teamId var teamId = obj.teamId
......
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
// 黑名单列表 // 黑名单列表
blacklist: [], blacklist: [],
// 禁言列表 // 禁言列表
// mutelist: [], mutelist: [],
teamlist: [], teamlist: [],
// 群自身的属性,数据结构如:{tid: {attr: ...}, ...} // 群自身的属性,数据结构如:{tid: {attr: ...}, ...}
......
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