Commit 52471885 authored by 罗超's avatar 罗超

以防万一

parent 983e192f
......@@ -286,6 +286,7 @@ app.on('activate', () => {
})
ipc.on('loginSuccess', function (event, userInfo) {
initNIM(userInfo.ImAccount,userInfo.ImToken)
registScrollerHotKey()
getScrollerhotWindows()
global.LOGINUSER = userInfo
......@@ -634,9 +635,52 @@ ipc.on('open-screenhot', function (event) {
ipc.on('delete-file', function (event,p) {
fs.unlink(p, function(err){})
})
ipc.on('send-file', function (event,obj) {
let {scene, to, filePath, name,size,md5,type,file} = obj
let customMsg = {
"msgtype":"custom_file",
"data":{
"pushContent":name,
"Height":"84",
"content":{
"fileType":name.substring(name.lastIndexOf('.')+1,name.length),
"fileUrl":"-1",
"fileName":name,
"fileSize":size,
'md5':md5
},
"recentContent":name,
"Width":"210"
}
}
nim.sendFile({
scene,
to,
type,
filePath,
custom: JSON.stringify(customMsg),
uploadprogress: function(data){
console.log(data)
file.progess=data.percentage
event.sender.send('sending-process',file)
},
uploaderror: function () {
console && console.log('上传失败')
},
uploaddone: function (error, file) {
file.progess=100
event.sender.send('sending-process',file)
},
beforesend: function (msg) {},
done: function (error, msg) {
//onSendMsgDone(error, msg)
}
})
})
ipc.on('read-clip', function (event) {
const rawFilePath = clipboard.readBuffer('FileNameW').toString('ucs2');
let filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
console.log(filePath)
if(filePath && filePath.length>0){
fs.stat(filePath,function(error,stats){
if(!error){
......@@ -889,19 +933,49 @@ let formatDate=function(date,format){
return format;
};
let initNIM=function(uid,token){
nim = SDK.NIM.getInstance({
console.log(uid,token)
nim = SDK.getInstance({
debug: false,
appKey: 'b612b31e837c79c68f141aeb719d2b20',
account: uid,
token: token,
transports: ['websocket'],
db: false,
syncSessionUnread: true,
syncRobots: true,
autoMarkRead: true,
onconnect: function onConnect (event) {},
onerror: function onError (event) {},
onwillreconnect: function onWillReconnect () {},
ondisconnect: function onDisconnect (error) {}
onconnect: onConnect,
onwillreconnect: onWillReconnect,
ondisconnect: onDisconnect,
onerror: onError
})
}
\ No newline at end of file
function onConnect() {
console.log('连接成功');
}
function onWillReconnect(obj) {
// 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接
console.log('即将重连');
console.log(obj.retryCount);
console.log(obj.duration);
}
function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
console.log('丢失连接');
console.log(error);
if (error) {
switch (error.code) {
// 账号或者密码错误, 请跳转到登录页面并提示错误
case 302:
break;
// 重复登录, 已经在其它端登录了, 请跳转到登录页面并提示错误
case 417:
break;
// 被踢, 请提示错误后跳转到登录页面
case 'kicked':
break;
default:
break;
}
}
}
function onError(error) {
console.log(error);
}
}
......@@ -3,6 +3,7 @@ import MsgBus from './msgBus'
export default {
install (Vue, options) {
Vue.prototype.MsgBus = MsgBus;
Vue.prototype.GLOBALSENDING = [],
Vue.prototype.isOnline = function() {
return process.env.NODE_ENV !== 'development';
},
......
......@@ -16,6 +16,7 @@
:userInfos="userInfos"
:myInfo="myInfo"
:isRobot="isRobot"
:sessionId='id'
@msgs-loaded="msgsLoaded"
></chat-list>
</div>
......@@ -32,9 +33,11 @@
>
<chateditor
type="session"
:sessionId='id'
:scene="scene"
:to="to"
:isRobot="isRobot"
:avatar="myInfo.avatar"
:invalid="teamInvalid || muteInTeam"
:invalidHint="sendInvalidHint"
:advancedTeam="teamInfo && teamInfo.type === 'advanced'"
......
......@@ -69,6 +69,28 @@ export default {
new kscreenshot({
key: 65
});
let that = this;
this.$electron.ipcRenderer.on("sending-process", (event, file) => {
this.GLOBALSENDING.forEach(x => {
if ((x.msgId = file.msgId)) {
x = file;
}
});
if (file.progess == 100) {
setTimeout(() => {
let index = 0;
that.GLOBALSENDING.forEach((x, i) => {
if (x.msgId == file.msgId) {
index = i;
return false;
}
});
that.GLOBALSENDING.splice(index, 1);
that.MsgBus.$emit("update-sending");
}, 1000);
}
that.MsgBus.$emit("update-sending");
});
},
props: {
type: String,
......@@ -91,7 +113,9 @@ export default {
advancedTeam: {
type: Boolean,
default: false
}
},
sessionId: String,
avatar: String
},
watch: {
continueRobotAccid(curVal, oldVal) {
......@@ -195,20 +219,28 @@ export default {
let crt = this;
for (var i = 0; i < fileList.length; i++) {
let crtItem = fileList[i];
let fileInfo = {
name: crtItem.name,
path: crtItem.path,
size: crtItem.size
};
const bmf = new BMF();
bmf.md5(
crtItem,
(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
});
// 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.md5 = md5;
crt.sendingBang(fileInfo);
});
},
progress => {}
......@@ -425,16 +457,35 @@ export default {
sendFilePathMsg() {
if (this.inputObj.file && this.inputObj.file.length > 0) {
this.inputObj.file.forEach(x => {
let md5=this.$encrypt.Encrypt(x.path)
console.log(md5)
let md5 = this.$encrypt.Encrypt(x.path);
this.setLocationPath(md5, x.path);
this.$store.dispatch("sendDataFilePath", {
let type = "file";
if (/(png|jpg|bmp|jpeg|gif)$/i.test(x.name)) {
type = "image";
} else if (/(mov|mp4|ogg|webm)$/i.test(x.name)) {
type = "video";
} else if (/\.(wav|mp3|wma)$/i.test(x.name)) {
type = "file";
}
x.type = type;
x.icon = this.loadFileICON(x.ext);
x.size = this.bytesToSize(x.size);
x.md5 = md5;
x.msgId = new Date().getTime();
x.id = this.sessionId;
x.progess = 0;
x.avatar = this.avatar;
this.GLOBALSENDING.push(x)
this.MsgBus.$emit("update-sending");
this.$electron.ipcRenderer.send("send-file", {
scene: this.scene,
to: this.to,
filePath: x.path,
name: x.name,
size: this.bytesToSize(x.size),
md5: md5
size: x.size,
md5: md5,
type,
file:x
});
});
}
......@@ -446,20 +497,20 @@ export default {
if (files.length > 0) {
for (var i = 0; i < files.length; i++) {
let crtItem = files[i];
let fileInfo = {
name: crtItem.name,
path: crtItem.path,
size: crtItem.size
};
const bmf = new BMF();
bmf.md5(
crtItem,
(err, md5) => {
that.setLocationPath(md5, crtItem.path);
that.readBlobAsDataURL(crtItem, function(dataurl) {
that.$store.dispatch("sendDataUrlMsg", {
scene: that.scene,
to: that.to,
dataURL: dataurl,
name: crtItem.name,
size: that.bytesToSize(crtItem.size),
md5
});
fileInfo.dataurl = dataurl;
fileInfo.md5 = md5;
that.sendingBang(fileInfo);
});
},
progress => {}
......@@ -503,6 +554,59 @@ export default {
callback(e.target.result);
};
a.readAsDataURL(blob);
},
sendingBang(file) {
let type = "file";
if (/(png|jpg|bmp|jpeg|gif)$/i.test(file.name)) {
type = "image";
} else if (/(mov|mp4|ogg|webm)$/i.test(file.name)) {
type = "video";
} else if (/\.(wav|mp3|wma)$/i.test(file.name)) {
type = "file";
}
let that = this;
let exts = file.name.split(".");
file.ext = exts[exts.length - 1].toLowerCase();
file.type = type;
file.msgId = new Date().getTime();
file.id = this.sessionId;
file.progess = 0;
file.size = this.bytesToSize(file.size);
file.icon = this.loadFileICON(file.ext);
file.avatar = this.avatar;
this.GLOBALSENDING.push(file);
this.MsgBus.$emit("update-sending");
this.$store.dispatch("sendDataUrlMsgCall", {
scene: this.scene,
to: this.to,
dataURL: file.dataurl,
name: file.name,
size: file.size,
md5: file.md5,
type,
onUploadprogress: function(data) {
console.log("上传文件中....", data.percentage);
that.GLOBALSENDING.forEach(x => {
if (x.msgId == file.msgId) {
x.progess = data.percentage;
}
});
that.MsgBus.$emit("update-sending");
},
onUploaddone: function(error, file) {
setTimeout(() => {
let index = 0;
that.GLOBALSENDING.forEach((x, i) => {
if (x.msgId == file.msgId) {
index = i;
return false;
}
});
that.GLOBALSENDING.splice(index, 1);
that.MsgBus.$emit("update-sending");
}, 1000);
}
});
}
}
};
......
......@@ -15,25 +15,37 @@
@msg-loaded="msgLoaded"
ref="chatitem"
></chat-item>
<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>
<script>
import util from "../../../utils";
import pageUtil from "../../../utils/page";
import config from "../../../configs";
import emojiObj from "../../../configs/emoji";
import chatItem from "./chatitem";
import sendingItem from "./sendingFile";
export default {
components: {
chatItem
chatItem,
sendingItem
},
data() {
return {
msgLoadedTimer: null
msgLoadedTimer: null,
sendObjs:[]
};
},
mounted () {
document.querySelector('#chat-list').addEventListener('scroll', this.handleScroll);
mounted() {
document
.querySelector("#chat-list")
.addEventListener("scroll", this.handleScroll);
let that=this
this.MsgBus.$on("update-sending", function() {
console.log('in.....')
that.loadingCurrentSendingMsg();
});
},
props: {
type: String,
......@@ -67,7 +79,8 @@ export default {
default() {
return false;
}
}
},
sessionId: String
// robotInfos: {
// type: Object,
// default () {
......@@ -75,19 +88,43 @@ export default {
// }
// }
},
watch: {
sessionId(newVal, oldVal) {
this.loadingCurrentSendingMsg()
}
},
methods: {
handleScroll(){
let ch=document.querySelector('#chat-list').scrollTop+document.querySelector('#chat-list').clientHeight-40
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
if(ch>=minh && ch<=maxh){
x.$refs.msgvideo.play()
} else
x.$refs.msgvideo.pause()
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)
}
})
})
pageUtil.scrollChatListDown();
}
}
},
handleScroll() {
let ch =
document.querySelector("#chat-list").scrollTop +
document.querySelector("#chat-list").clientHeight -
40;
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;
if (ch >= minh && ch <= maxh) {
x.$refs.msgvideo.play();
} else x.$refs.msgvideo.pause();
}
})
});
},
msgLoaded() {
clearTimeout(this.msgLoadedTimer);
......
<template>
<li class="u-msg item-me">
<div class="out">
<!-- v-touch:hold="revocateMsg" -->
<a class="msg-head" v-if="msg.avatar">
<img class="icon u-circle" :src="msg.avatar">
</a>
<div class="pool" ref="mediaMsgSplit" v-if="msg.type!=='video'">
<img class="split-item" src="../../assets/img/im/right(1).png">
</div>
<span v-if="msg.type==='image'" class="msg-text" style="width: 170px; overflow: hidden;">
<img
class="imimage"
:src="msg.path"
style="margin: -8px -8px -14px; border-radius: 6px; width: 170px;min-height:70px;"
>
<div class="process-box">
<el-progress type="circle" :percentage="msg.progess" :stroke-width='3' :width="50"></el-progress>
</div>
</span>
<span v-else-if="msg.type==='video'" class="msg-text video">
<video :src="msg.path" loop muted width="200"></video>
<div class="process-box">
<el-progress type="circle" :percentage="msg.progess" :stroke-width='3' :width="50"></el-progress>
</div>
</span>
<span v-else-if="msg.type==='file'" class="msg-text">
<div class="file-box">
<div class="split">
<div class="icon">
<div class="fileIcon" :class="msg.icon"></div>
</div>
<div class="file-info">
<div class="name">{{msg.name}}</div>
<div class="size">{{msg.size}}</div>
</div>
</div>
<div class="opera-box">
<div class="pro">
<el-progress :percentage="msg.progess" :show-text="false"></el-progress>
</div>
<div class="state">
正在上传
</div>
</div>
</div>
</span>
</div>
</li>
</template>
<script>
export default {
props: ["msg"],
mounted() {},
methods: {
getMsgId() {
return this.msg.msgId;
},
setProgess(progess) {
this.msg.progess = progess;
}
}
};
</script>
<style scoped>
@import url("../../assets/css/icon.css");
.item-me .error-msg {
color: #eb3b5a;
font-size: 12px;
height: 20px;
line-height: 20px;
right: 50px;
bottom: -22px;
position: absolute;
}
.item-you .error-msg {
color: #eb3b5a;
font-size: 12px;
height: 20px;
line-height: 20px;
left: 50px;
bottom: -22px;
position: absolute;
}
.p-chat-history {
.u-msg {
.msg-link {
display: none;
}
}
}
.p-room-chat-list {
.u-msg {
.msg-text {
max-width: 80%;
}
.msg-link {
bottom: 0;
right: -4rem;
font-size: 0.9rem;
}
}
}
.msg-unread {
position: relative;
float: right;
top: 0.3rem;
right: 0.5rem;
font-size: 0.9rem;
color: #0091e4;
}
.timeTag {
color: #000 !important;
font-family: pingfang !important;
}
.tip {
text-align: center;
}
.tip span {
height: 22px;
background: rgba(0, 0, 0, 0.15);
border-radius: 6px;
line-height: 22px;
color: #fff;
font-size: 12px;
display: inline-block;
margin: 0 auto;
padding: 0 6px;
}
.notification {
text-align: center;
}
.notification .el-alert {
padding: 5px 1px;
margin: 0;
box-sizing: border-box;
border-radius: 4px;
position: relative;
background-color: #778ca3;
overflow: hidden;
color: #dedede;
opacity: 1;
display: table;
transition: opacity 0.2s;
font-size: 12px;
display: inline-block;
margin: 0 auto;
width: auto !important;
}
.notification .el-alert__title {
font-size: 12px;
color: #dedede;
}
.item-you .in,
.item-me .out {
width: 70%;
padding-right: 30%;
display: flex;
flex-direction: row;
}
.item-me .out {
padding-left: 30%;
padding-right: 0;
width: 70%;
flex-direction: row-reverse;
}
.item-you .in .msg-head,
.item-me .out .msg-head {
width: 38px;
height: 38px;
border-radius: 100%;
display: inline-block;
overflow: hidden;
}
.error-tips {
width: 18px;
height: 18px;
overflow: hidden;
text-align: center;
line-height: 18px;
background: #eb3b5a;
margin: 0 5px;
color: #f1f1f1;
border-radius: 100%;
font-size: 12px;
}
.error-tips i {
font-size: 12px;
}
.item-you .in .msg-head img,
.item-me .out .msg-head img {
width: 100%;
height: 100%;
}
.item-you .in span,
.item-me .out span {
width: auto;
padding: 8px;
font-size: 14px;
color: #000;
background: #fff;
border-radius: 8px;
-webkit-user-select: text !important;
box-sizing: border-box;
border: 1px solid rgb(220, 220, 220);
max-width: calc(100% - 60px);
word-wrap: break-word;
position: relative;
}
.item-me .out span {
background: rgba(71, 165, 255, 1);
}
.pool {
width: 11px;
height: 19px;
position: relative;
overflow: hidden;
background: #fff;
position: relative;
margin-top: 1px;
}
.item-you .in .pool {
margin-left: 10px;
margin-right: -1px;
}
.item-me .out .pool {
margin-right: 10px;
margin-left: -1px;
background: rgba(71, 165, 255, 1);
}
.pool .split-item {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 2;
}
.imimage {
margin: -8px;
border-radius: 6px;
margin-bottom: 10px;
}
.msg-text.video {
margin: 0 10px;
margin-top: 12px;
}
.msg-text video {
margin: -8px;
margin-bottom: -14px;
border-radius: 6px;
}
.item-you .in .file-box {
width: 270px;
border-radius: 2px;
user-select: none;
}
.item-me .out .file-box {
background: #fff;
border: 1px solid #eee;
border-radius: 2px;
width: 270px;
box-sizing: border-box;
user-select: none;
}
.file-box .split {
padding: 5px;
border-bottom: 1px solid #eee;
display: flex;
}
.file-box .icon {
height: 60px;
width: 60px;
}
.file-box .file-info {
height: 60px;
overflow: hidden;
flex: 1;
margin-left: 5px;
}
.file-box .file-info .name {
height: 30px;
font-size: 20px;
color: #333;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-box .file-info .size {
height: 30px;
/* line-height: 30px; */
font-size: 12px;
color: #999;
}
.file-box .opera-box {
padding: 5px;
display: flex;
position: relative;
padding-top: 7px;
}
.file-box .opera-box .pro {
height: 5px;
top: -4px;
left: 5px;
right: 5px;
position: absolute;
}
.file-box .opera-box .btn {
flex: 1;
}
.file-box .opera-box .state {
font-size: 12px;
color: #888;
}
.file-box .opera-box .state i {
font-size: 14px;
color: #20bf6b;
margin-right: 3px;
}
.file-box .opera-box .btn {
text-align: right;
}
.file-box .opera-box .btn .item_btn {
font-size: 12px;
color: #0091e4;
margin-left: 3px;
cursor: pointer;
display: inline;
}
.file-box .opera-box .btn .item_btn:hover {
text-decoration: underline;
}
.process-box{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
display:flex;
justify-content:center;
align-items:center;
border-radius: 8px;
}
/* .item-me .out .msg-head{
position: absolute;
right: 0;
top: 0;
} */
</style>
\ No newline at end of file
......@@ -7,7 +7,6 @@
@blur="lock=false"
id="msgEditorBox"
draggable="false"
v-html="innerText"
></div>
</template>
<script>
......@@ -108,6 +107,8 @@ export default {
sel.addRange(range);
} else if (ec == 13){
that.sendMsg()
e.preventDefault();
e.stopPropagation();
}
});
this.$electron.ipcRenderer.on("new-send-file", (event, path,size) => {
......@@ -157,7 +158,7 @@ export default {
if (clipboardData) {
items = clipboardData.items;
if (!items || items.length == 0) {
console.log(_this.$electron.ipcRenderer.send("read-clip"))
_this.$electron.ipcRenderer.send("read-clip")
return false;
} else {
// 保存在剪贴板中的数据类型
......@@ -229,7 +230,14 @@ export default {
clearContent() {
this.child.file = [];
this.child.txt = "";
document.querySelector("#msgEditorBox").innerHTML = "";
let dom=document.querySelector("#msgEditorBox")
dom.innerHTML = "";
while(dom.hasChildNodes())
{
dom.removeChild(dom.firstChild);
}
console.log(dom.hasChildNodes())
}
}
};
......
......@@ -11,7 +11,7 @@ import {updateBlack} from './blacks'
import {updateFriend, addFriend, deleteFriend} from './friends'
import {resetSearchResult, searchUsers, searchTeam} from './search'
import {deleteSession, setCurrSession, resetCurrSession} from './session'
import {sendMsg, sendTip,sendDataFilePath, sendFileMsg,sendDataUrlMsg, sendMsgReceipt, sendRobotMsg, revocateMsg, updateLocalMsg, getHistoryMsgs, resetNoMoreHistoryMsgs, continueRobotMsg} from './msgs'
import {sendMsg, sendTip, sendFileMsg,sendDataUrlMsg,sendDataUrlMsgCall, sendMsgReceipt, sendRobotMsg, revocateMsg, updateLocalMsg, getHistoryMsgs, resetNoMoreHistoryMsgs, continueRobotMsg} from './msgs'
import {markSysMsgRead, resetSysMsgs, deleteSysMsgs, markCustomSysMsgRead} from './sysMsgs'
import {sendChatroomMsg, sendChatroomRobotMsg, sendChatroomFileMsg, getChatroomHistoryMsgs} from './chatroomMsgs'
import {initChatroomInfos, getChatroomInfo, getChatroomMembers, clearChatroomMembers} from './chatroomInfos'
......@@ -116,7 +116,7 @@ export default {
sendTip,
sendFileMsg,
sendDataUrlMsg,
sendDataFilePath,
sendDataUrlMsgCall,
sendRobotMsg,
// 发送消息已读回执
sendMsgReceipt,
......
......@@ -29,7 +29,6 @@ export function initNimSDK ({ state, commit, dispatch }, loginInfo) {
appKey: config.appkey,
account: loginInfo.uid,
token: loginInfo.sdktoken,
transports: ['websocket'],
db: config.useDb,
// logFunc: new SDK.NIM.LoggerPlugin({
// url: '/webdemo/h5/getlogger',
......
......@@ -205,7 +205,7 @@ export function sendFileMsg ({state, commit}, obj) {
} else if (/\.(mov|mp4|ogg|webm)$/i.test(fileInput.value)) {
type = 'video'
} else if (/\.(wav|mp3|wma)$/i.test(fileInput.value)) {
type = 'music'
type = 'file'
}
}
......@@ -244,7 +244,7 @@ export function sendDataUrlMsg ({state, commit}, obj) {
} else if (/(mov|mp4|ogg|webm)$/i.test(name)) {
type = 'video'
} else if (/\.(wav|mp3|wma)$/i.test(name)) {
type = 'music'
type = 'file'
}
let customMsg = {
"msgtype":"custom_file",
......@@ -262,12 +262,12 @@ export function sendDataUrlMsg ({state, commit}, obj) {
"Width":"210"
}
}
store.dispatch('showLoading')
nim.sendFile({
scene: scene,
to: to,
type: type,
dataURL: dataURL,
scene,
to,
type,
dataURL,
fastPass:{md5},
custom: JSON.stringify(customMsg),
uploadprogress: function (data) {
console.log('正在发送消息, id=', data);
......@@ -279,27 +279,17 @@ export function sendDataUrlMsg ({state, commit}, obj) {
// console.log(error);
// console.log(file);
},
beforesend: function (msg) {
console.log('正在发送消息, id=', msg);
onMsg(msg)
},
beforesend: function (msg) {},
done: function (error, msg) {
onSendMsgDone(error, msg)
}
})
}
export function sendDataFilePath ({state, commit}, obj) {
export function sendDataUrlMsgCall ({state, commit}, obj) {
const nim = state.nim
let {scene, to, filePath, name,size,md5} = obj
let type = 'file'
if (/(png|jpg|bmp|jpeg|gif)$/i.test(name)) {
type = 'image'
} else if (/(mov|mp4|ogg|webm)$/i.test(name)) {
type = 'video'
} else if (/\.(wav|mp3|wma)$/i.test(name)) {
type = 'music'
}
let {scene, to, dataURL, name,size,md5,type} = obj
console.log(obj)
let customMsg = {
"msgtype":"custom_file",
"data":{
......@@ -316,27 +306,22 @@ export function sendDataFilePath ({state, commit}, obj) {
"Width":"210"
}
}
nim.previewFile({
nim.sendFile({
scene,
to,
type,
filePath: filePath,
uploadprogress(obj) {
// ...
},
done: (error, file) => {
console.log(file)
// if (!error) {
// nim.sendFile({
// type,
// scene,
// to,
// file,
// done: (err, msg) => {
// onSendMsgDone(error, msg)
// }
// });
// }
dataURL,
custom: JSON.stringify(customMsg),
uploadprogress: obj.onUploadprogress,
uploaderror: function () {
console && console.log('上传失败')
},
});
uploaddone: obj.onUploaddone,
beforesend: function (msg) {},
done: function (error, msg) {
onSendMsgDone(error, msg)
}
})
}
// 发送机器人消息
......
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