Commit 983e192f authored by 罗超's avatar 罗超

临时推送

parent f7bb0081
...@@ -11,8 +11,10 @@ const BabiliWebpackPlugin = require('babili-webpack-plugin') ...@@ -11,8 +11,10 @@ const BabiliWebpackPlugin = require('babili-webpack-plugin')
let mainConfig = { let mainConfig = {
entry: { entry: {
main: path.join(__dirname, '../src/main/index.js'), main: path.join(__dirname, '../src/main/index.js'),
sdk1: path.join(__dirname, '../src/sdk/NIM_Web_SDK_v6.1.0.js'), 'NIM_Web_SDK_v6.1.0': path.join(__dirname, '../src/sdk/NIM_Web_SDK_v6.1.0.js'),
sdk2: path.join(__dirname, '../src/sdk/NIM_Web_SDK_v5.8.0.js') 'NIM_Web_SDK_v5.8.0': path.join(__dirname, '../src/sdk/NIM_Web_SDK_v5.8.0.js'),
'NIM_Web_NIM_v6.1.0': path.join(__dirname, '../src/sdk/NIM_Web_NIM_v6.1.0.js'),
// 'NIM_Web_SDK_nodejs_v5.9.1': path.join(__dirname, '../src/sdk/NIM_Web_SDK_nodejs_v5.9.1.js')
}, },
externals: [ externals: [
...Object.keys(dependencies || {}) ...Object.keys(dependencies || {})
......
...@@ -24,8 +24,10 @@ let rendererConfig = { ...@@ -24,8 +24,10 @@ let rendererConfig = {
devtool: '#cheap-module-eval-source-map', devtool: '#cheap-module-eval-source-map',
entry: { entry: {
renderer: path.join(__dirname, '../src/renderer/main.js'), renderer: path.join(__dirname, '../src/renderer/main.js'),
sdk1: path.join(__dirname, '../src/sdk/NIM_Web_SDK_v6.1.0.js'), 'NIM_Web_SDK_v6.1.0': path.join(__dirname, '../src/sdk/NIM_Web_SDK_v6.1.0.js'),
sdk2: path.join(__dirname, '../src/sdk/NIM_Web_SDK_v5.8.0.js') 'NIM_Web_SDK_v5.8.0': path.join(__dirname, '../src/sdk/NIM_Web_SDK_v5.8.0.js'),
'NIM_Web_NIM_v6.1.0': path.join(__dirname, '../src/sdk/NIM_Web_NIM_v6.1.0.js'),
// 'NIM_Web_SDK_nodejs_v5.9.1': path.join(__dirname, '../src/sdk/NIM_Web_SDK_nodejs_v5.9.1.js')
}, },
externals: [ externals: [
...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d)) ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))
......
let config = { let config = {
sdk: 'NIM_Web_SDK_v6.1.0', sdk: 'NIM_Web_SDK_nodejs_v5.9.1',
// 用户自定义的登录注册地址 // 用户自定义的登录注册地址
loginUrl: '/webdemo/h5/login.html', loginUrl: '/webdemo/h5/login.html',
registUrl: '/webdemo/h5/regist.html', registUrl: '/webdemo/h5/regist.html',
...@@ -20,7 +20,7 @@ let config = { ...@@ -20,7 +20,7 @@ let config = {
// 我的手机图标 // 我的手机图标
myPhoneIcon: 'http://yx-web.nos.netease.com/webdoc/h5/im/my-phone.png', myPhoneIcon: 'http://yx-web.nos.netease.com/webdoc/h5/im/my-phone.png',
// 本地消息显示数量,会影响性能 // 本地消息显示数量,会影响性能
localMsglimit: 36, localMsglimit: 360000,
useDb: false useDb: false
} }
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
import { app, BrowserWindow, protocol, desktopCapturer } from 'electron' import { app, BrowserWindow, protocol, desktopCapturer } from 'electron'
const cp = require('child_process') const cp = require('child_process')
const path = require('path') const path = require('path')
const WinReg = require('winreg') const WinReg = require('winreg')
const fs = require('fs') const fs = require('fs')
const electron = require('electron') const electron = require('electron')
const screenshot = require('screenshot-desktop') const screenshot = require('screenshot-desktop')
const SDK = require('../../static/sdk/NIM_Web_NIM_nodejs_v5.9.1.js')
const ipc = electron.ipcMain const ipc = electron.ipcMain
const shell =electron.shell const shell =electron.shell
...@@ -31,6 +33,7 @@ global.PREVIWERURL = '' ...@@ -31,6 +33,7 @@ global.PREVIWERURL = ''
global.PREVIWERVIDEOURL='' global.PREVIWERVIDEOURL=''
global.PREVIWERIMGS = [] global.PREVIWERIMGS = []
global.PREVIWERIMG = 0 global.PREVIWERIMG = 0
global.DIALOG_MESSAGE=''
let updateTimer let updateTimer
let loginWindow let loginWindow
let mainWindow let mainWindow
...@@ -40,6 +43,7 @@ let previwerVideoWindow ...@@ -40,6 +43,7 @@ let previwerVideoWindow
let hideWindow let hideWindow
let newMsgWindow let newMsgWindow
let scrollerhotWindows let scrollerhotWindows
let dialogWindows
let appIcon = null let appIcon = null
let isLogin = false let isLogin = false
let timeout = null let timeout = null
...@@ -53,6 +57,7 @@ let screenEvent = null ...@@ -53,6 +57,7 @@ let screenEvent = null
let messageEvent = null let messageEvent = null
let messageProtocol = null let messageProtocol = null
let CAP_IMG='' let CAP_IMG=''
let nim=null
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'
...@@ -61,6 +66,7 @@ const mainUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/ ...@@ -61,6 +66,7 @@ const mainUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/
const previewfileUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewfile` : `file://${__dirname}/index.html#/previewfile` const previewfileUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewfile` : `file://${__dirname}/index.html#/previewfile`
const previewfileImg = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewerimg` : `file://${__dirname}/index.html#/previewerimg` const previewfileImg = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewerimg` : `file://${__dirname}/index.html#/previewerimg`
const previewfVideoUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewervideo` : `file://${__dirname}/index.html#/previewervideo` const previewfVideoUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/previewervideo` : `file://${__dirname}/index.html#/previewervideo`
const dialogUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/dialog` : `file://${__dirname}/index.html#/dialog`
const appXmlPath = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) + 'app.json' const appXmlPath = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) + 'app.json'
...@@ -622,6 +628,42 @@ ipc.on('addClipboard', function (event,content) { ...@@ -622,6 +628,42 @@ ipc.on('addClipboard', function (event,content) {
ipc.on('screens-session', function (event) { ipc.on('screens-session', function (event) {
screenEvent=event screenEvent=event
}) })
ipc.on('open-screenhot', function (event) {
screenHotBegin()
})
ipc.on('delete-file', function (event,p) {
fs.unlink(p, function(err){})
})
ipc.on('read-clip', function (event) {
const rawFilePath = clipboard.readBuffer('FileNameW').toString('ucs2');
let filePath = rawFilePath.replace(new RegExp(String.fromCharCode(0), 'g'), '');
if(filePath && filePath.length>0){
fs.stat(filePath,function(error,stats){
if(!error){
if(stats.size<=100*1024*1024){
event.sender.send('new-send-file',filePath,stats.size)
return 'finish'
}else{
global.DIALOG_MESSAGE='发送的文件不能大于100M'
getDialogWindows()
}
}else{
console.log(error)
}
})
}
return 'end'
})
ipc.on('auto-update-clip', function (event) {
let text = clipboard.readText();
if(text && text.length>0){
text=escapeHTML(text)
clipboard.writeText(text)
}
})
function escapeHTML(a) {
return a.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/ /g, " ").replace(/"/g, "\"").replace(/'/g, "'")
}
let getLoginWindow=function(){ let getLoginWindow=function(){
loginWindow = new BrowserWindow({ loginWindow = new BrowserWindow({
transparent: true, transparent: true,
...@@ -651,7 +693,8 @@ let getMainWinodw=function(isLoad){ ...@@ -651,7 +693,8 @@ let getMainWinodw=function(isLoad){
width: 900, width: 900,
icon: windowIcon, icon: windowIcon,
minWidth:850, minWidth:850,
minHeight:580 minHeight:580,
webPreferences:{webSecurity: false},
}) })
mainWindow.on('close', (e) => { mainWindow.on('close', (e) => {
mainWindow.hide() mainWindow.hide()
...@@ -747,6 +790,28 @@ let getPreviwerVideoWindow=function(){ ...@@ -747,6 +790,28 @@ let getPreviwerVideoWindow=function(){
previwerVideoWindow.show() previwerVideoWindow.show()
}) })
} }
//dialogWindows
let getDialogWindows=function(){
if(!dialogWindows || dialogWindows.isDestroyed()){
dialogWindows = new BrowserWindow({
transparent: true,
frame: false,
maximizable: true,
resizable: false,
show: false,
icon: windowIcon,
width:300,
height:200,
skipTaskbar:true,
alwaysOnTop:true
})
}
dialogWindows.loadURL(dialogUrl)
dialogWindows.setMenu(null)
dialogWindows.once('ready-to-show', () => {
dialogWindows.show()
})
}
let getNewMsgWindows=function(){ let getNewMsgWindows=function(){
if(!newMsgWindow || newMsgWindow.isDestroyed()){ if(!newMsgWindow || newMsgWindow.isDestroyed()){
...@@ -776,24 +841,33 @@ let getScrollerhotWindows=function(){ ...@@ -776,24 +841,33 @@ let getScrollerhotWindows=function(){
show: false, show: false,
alwaysOnTop: true, alwaysOnTop: true,
icon: windowIcon, icon: windowIcon,
webPreferences:{webSecurity: false} webPreferences:{webSecurity: false},
skipTaskbar:true
}) })
let urls = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/scrollerhot` : `file://${__dirname}/index.html#scrollerhot` let urls = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/scrollerhot` : `file://${__dirname}/index.html#scrollerhot`
scrollerhotWindows.loadURL(urls) scrollerhotWindows.loadURL(urls)
scrollerhotWindows.setFullScreen(true) scrollerhotWindows.setFullScreen(true)
} }
let registScrollerHotKey=function(){ let screenHotBegin=function(){
globalShortcut.register('CommandOrControl+Alt+Q', function () { let p=require('os').userInfo().homedir+'\\Pictures\\MAGE_'+formatDate(new Date(),'yyyyMMddhhmmss')+'.png'
let p=require('os').userInfo().homedir+'\\Pictures\\MAGE_'+formatDate(new Date(),'yyyyMMddHHmmss')+'.png' global.DEFAULT_SCREENSHOT_PATH=p
global.DEFAULT_SCREENSHOT_PATH=p screenshot({format: 'png',filename:p}).then((img) => {
screenshot({format: 'png',filename:p}).then((img) => { if(scrollerhotWindows && !scrollerhotWindows.isDestroyed()){
screenEvent.sender.send('new-hot') screenEvent.sender.send('new-hot')
scrollerhotWindows.show() scrollerhotWindows.show()
}).catch((err) => { }else{
console.log(err) getScrollerhotWindows()
}) }
}).catch((err) => {
console.log(err)
}) })
} }
let registScrollerHotKey=function(){
globalShortcut.register('CommandOrControl+Alt+Q', function () {
screenHotBegin()
})
}
let formatDate=function(date,format){ let formatDate=function(date,format){
var o = { var o = {
"M+" : date.getMonth()+1, //month "M+" : date.getMonth()+1, //month
...@@ -813,4 +887,21 @@ let formatDate=function(date,format){ ...@@ -813,4 +887,21 @@ let formatDate=function(date,format){
} }
} }
return format; return format;
}; };
\ No newline at end of file let initNIM=function(uid,token){
nim = SDK.NIM.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) {}
})
}
\ No newline at end of file
...@@ -81,7 +81,8 @@ export default { ...@@ -81,7 +81,8 @@ export default {
} }
} }
Vue.prototype.loadFileICON = function (suffix) { Vue.prototype.loadFileICON = function (suffix,size) {
size=size?size:1
let icons = [{ let icons = [{
"name": "\u7f51\u76d8BT\u79bb\u7ebf\u4e0b\u8f7d", "name": "\u7f51\u76d8BT\u79bb\u7ebf\u4e0b\u8f7d",
...@@ -355,7 +356,7 @@ export default { ...@@ -355,7 +356,7 @@ export default {
icons.forEach(x => { icons.forEach(x => {
//console.log(x.filesIcon.hasOwnProperty(suffix)) //console.log(x.filesIcon.hasOwnProperty(suffix))
if (x.filesIcon.hasOwnProperty(suffix)) { if (x.filesIcon.hasOwnProperty(suffix)) {
css = x.filesIcon[suffix][1] 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_wpmx8pr4mo.css'); @import url("//at.alicdn.com/t/font_1062339_lofkb8xnbrf.css");
</style> </style>
...@@ -12,7 +12,35 @@ ...@@ -12,7 +12,35 @@
</template> </template>
<script> <script>
export default { export default {
name: 'MageOffice' name: "MageOffice",
mounted() {
document.querySelector('#app').addEventListener(
"dragover",
function(e) {
e.preventDefault();
if(e.target.id!='msgEditorBox'){
e.dataTransfer.dropEffect = 'none';
}else{
e.dataTransfer.dropEffect = 'copy';
}
},
false
);
document.querySelector('#app').addEventListener(
"drop",
function(e) {
console.log(e)
if(e.target.id!='msgEditorBox'){
e.dataTransfer.dropEffect = 'none';
}else{
e.dataTransfer.dropEffect = 'copy';
}
e.preventDefault();
e.stopPropagation;
},
false
);
} }
};
</script> </script>
\ No newline at end of file
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<el-tooltip class="item" effect="dark" content="向同事发送窗口抖动" placement="top"> <el-tooltip class="item" effect="dark" content="向同事发送窗口抖动" placement="top">
<i class="iconfont iconzhendong" @click.stop="sendDou"></i> <i class="iconfont iconzhendong" @click.stop="sendDou"></i>
</el-tooltip> </el-tooltip>
<el-tooltip class="item" effect="dark" content="截图" placement="top"> <el-tooltip class="item" effect="dark" content="截图,快捷键Ctrl+Alt+Q" placement="top">
<i class="iconfont iconjietu"></i> <i class="iconfont iconjietu" @click="openScreenhot"></i>
</el-tooltip> </el-tooltip>
<input <input
type="file" type="file"
...@@ -25,8 +25,10 @@ ...@@ -25,8 +25,10 @@
multiple="multiple" multiple="multiple"
> >
</div> </div>
<div draggable="true" @dragstart="drag($event)" id="text-box" ref="box"> <div draggable="true" id="text-box" ref="box">
<textarea v-model="msgToSent" class="input" @keyup.13="sendTextMsg"></textarea> <!-- <textarea v-model="msgToSent" class="input" @keyup.13="sendTextMsg"></textarea>
<div class='input' @keyup.13="sendTextMsg"></div>-->
<content-editor :child="inputObj" ref="editor" @send="sendTextMsg"></content-editor>
</div> </div>
<div class="bottom-op-box"> <div class="bottom-op-box">
<span class="errorTip">{{errorTip}}</span> <span class="errorTip">{{errorTip}}</span>
...@@ -40,6 +42,7 @@ ...@@ -40,6 +42,7 @@
v-on:add-emoji="addEmoji" v-on:add-emoji="addEmoji"
v-on:hide-emoji="hideEmoji" v-on:hide-emoji="hideEmoji"
></chat-emoji> ></chat-emoji>
<div id="dirtyData" style="display:none"></div>
</div> </div>
</template> </template>
...@@ -49,9 +52,11 @@ import util from "../../../utils/"; ...@@ -49,9 +52,11 @@ import util from "../../../utils/";
import config from "../../../configs"; import config from "../../../configs";
import BMF from "browser-md5-file"; import BMF from "browser-md5-file";
import kscreenshot from "kscreenshot"; import kscreenshot from "kscreenshot";
import contentEditor from "../tools/contenteditor";
export default { export default {
components: { components: {
ChatEmoji ChatEmoji,
contentEditor
}, },
updated() { updated() {
window.document.body.addEventListener("click", () => { window.document.body.addEventListener("click", () => {
...@@ -108,6 +113,13 @@ export default { ...@@ -108,6 +113,13 @@ export default {
} else if (this.isRobotListShown === true) { } else if (this.isRobotListShown === true) {
this.isRobotListShown = false; this.isRobotListShown = false;
} }
},
inputObj: {
handler(val, oldVal) {
this.msgToSent = val.txt;
console.log(val.file);
},
deep: true
} }
}, },
data() { data() {
...@@ -120,7 +132,11 @@ export default { ...@@ -120,7 +132,11 @@ export default {
icon2: `${config.resourceUrl}/im/chat-editor-2.png`, icon2: `${config.resourceUrl}/im/chat-editor-2.png`,
icon3: `${config.resourceUrl}/im/chat-editor-3.png`, icon3: `${config.resourceUrl}/im/chat-editor-3.png`,
accpet: "", accpet: "",
canSendDou: true canSendDou: true,
inputObj: {
txt: "",
file: []
}
}; };
}, },
computed: { computed: {
...@@ -138,6 +154,10 @@ export default { ...@@ -138,6 +154,10 @@ export default {
} }
}, },
methods: { methods: {
openScreenhot() {
console.log("截图");
this.$electron.ipcRenderer.send("open-screenhot");
},
dataURLtoBlob(dataurl) { dataURLtoBlob(dataurl) {
var arr = dataurl.split(","), var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1], mime = arr[0].match(/:(.*?);/)[1],
...@@ -158,8 +178,15 @@ export default { ...@@ -158,8 +178,15 @@ export default {
}, },
addDropSupport() { addDropSupport() {
let BOX = this.$refs.box; let BOX = this.$refs.box;
document.querySelector("#text-box").addEventListener(
"dragover",
function(e) {
e.preventDefault();
e.dataTransfer.dropEffect = "move";
},
false
);
BOX.addEventListener("drop", e => { BOX.addEventListener("drop", e => {
e.preventDefault();
if (this.readonly) return false; if (this.readonly) return false;
let fileList = e.dataTransfer.files; let fileList = e.dataTransfer.files;
if (fileList.length === 0) { if (fileList.length === 0) {
...@@ -187,6 +214,9 @@ export default { ...@@ -187,6 +214,9 @@ export default {
progress => {} progress => {}
); );
} }
e.preventDefault();
e.stopPropagation;
return false;
}); });
}, },
setLocationPath(msgId, path) { setLocationPath(msgId, path) {
...@@ -211,28 +241,76 @@ export default { ...@@ -211,28 +241,76 @@ export default {
}, },
sendTextMsg() { sendTextMsg() {
this.errorTip = ""; this.errorTip = "";
if (/^\s*$/.test(this.msgToSent)) { this.sendFilePathMsg();
// this.errorTip='请不要刷屏' if (this.inputObj.file.length > 0) {
return; this.inputObj.file.forEach(x => {
} else if (this.msgToSent.length > 800) { this.msgToSent = this.msgToSent.replace(x.name, "");
this.errorTip = "请不要超过800个字"; });
return;
} }
this.msgToSent = this.msgToSent.trim(); if (!/^\s*$/.test(this.msgToSent)) {
if (this.type === "session") { this.msgToSent = this.msgToSent.trim();
// 如果是机器人 if (this.type === "session") {
if (this.isRobot) { // 如果是机器人
this.$store.dispatch("sendRobotMsg", { if (this.isRobot) {
type: "text", this.$store.dispatch("sendRobotMsg", {
scene: this.scene, type: "text",
to: this.to, scene: this.scene,
robotAccid: this.to, to: this.to,
// 机器人后台消息 robotAccid: this.to,
content: this.msgToSent, // 机器人后台消息
// 显示的文本消息 content: this.msgToSent,
body: this.msgToSent // 显示的文本消息
}); body: this.msgToSent
} else { });
} else {
let robotAccid = "";
let robotText = "";
let atUsers = this.msgToSent.match(/@[^\s@$]+/g);
if (atUsers) {
for (let i = 0; i < atUsers.length; i++) {
let item = atUsers[i].replace("@", "");
if (this.robotInfosByNick[item]) {
robotAccid = this.robotInfosByNick[item].account;
robotText = (this.msgToSent + "")
.replace(atUsers[i], "")
.trim();
break;
}
}
}
if (robotAccid) {
if (robotText) {
this.$store.dispatch("sendRobotMsg", {
type: "text",
scene: this.scene,
to: this.to,
robotAccid,
// 机器人后台消息
content: robotText,
// 显示的文本消息
body: this.msgToSent
});
} else {
this.$store.dispatch("sendRobotMsg", {
type: "welcome",
scene: this.scene,
to: this.to,
robotAccid,
// 显示的文本消息
body: this.msgToSent
});
}
} else {
this.$store.dispatch("sendMsg", {
type: "text",
scene: this.scene,
to: this.to,
text: this.msgToSent
});
}
}
} else if (this.type === "chatroom") {
let robotAccid = ""; let robotAccid = "";
let robotText = ""; let robotText = "";
...@@ -251,10 +329,8 @@ export default { ...@@ -251,10 +329,8 @@ export default {
} }
if (robotAccid) { if (robotAccid) {
if (robotText) { if (robotText) {
this.$store.dispatch("sendRobotMsg", { this.$store.dispatch("sendChatroomRobotMsg", {
type: "text", type: "text",
scene: this.scene,
to: this.to,
robotAccid, robotAccid,
// 机器人后台消息 // 机器人后台消息
content: robotText, content: robotText,
...@@ -262,65 +338,26 @@ export default { ...@@ -262,65 +338,26 @@ export default {
body: this.msgToSent body: this.msgToSent
}); });
} else { } else {
this.$store.dispatch("sendRobotMsg", { this.$store.dispatch("sendChatroomRobotMsg", {
type: "welcome", type: "welcome",
scene: this.scene,
to: this.to,
robotAccid, robotAccid,
// 显示的文本消息 // 显示的文本消息
body: this.msgToSent body: this.msgToSent
}); });
} }
} else { } else {
this.$store.dispatch("sendMsg", { this.$store.dispatch("sendChatroomMsg", {
type: "text", type: "text",
scene: this.scene,
to: this.to,
text: this.msgToSent text: this.msgToSent
}); });
} }
} }
} else if (this.type === "chatroom") {
let robotAccid = "";
let robotText = "";
let atUsers = this.msgToSent.match(/@[^\s@$]+/g);
if (atUsers) {
for (let i = 0; i < atUsers.length; i++) {
let item = atUsers[i].replace("@", "");
if (this.robotInfosByNick[item]) {
robotAccid = this.robotInfosByNick[item].account;
robotText = (this.msgToSent + "").replace(atUsers[i], "").trim();
break;
}
}
}
if (robotAccid) {
if (robotText) {
this.$store.dispatch("sendChatroomRobotMsg", {
type: "text",
robotAccid,
// 机器人后台消息
content: robotText,
// 显示的文本消息
body: this.msgToSent
});
} else {
this.$store.dispatch("sendChatroomRobotMsg", {
type: "welcome",
robotAccid,
// 显示的文本消息
body: this.msgToSent
});
}
} else {
this.$store.dispatch("sendChatroomMsg", {
type: "text",
text: this.msgToSent
});
}
} }
this.msgToSent = ""; this.msgToSent = "";
this.inputObj.file = [];
this.inputObj.txt = "";
this.$refs.editor.clearContent();
}, // 产品消息,用于快捷发送产品IM消息 }, // 产品消息,用于快捷发送产品IM消息
sendDou() { sendDou() {
if (this.canSendDou) { if (this.canSendDou) {
...@@ -385,6 +422,23 @@ export default { ...@@ -385,6 +422,23 @@ 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)
this.setLocationPath(md5, x.path);
this.$store.dispatch("sendDataFilePath", {
scene: this.scene,
to: this.to,
filePath: x.path,
name: x.name,
size: this.bytesToSize(x.size),
md5: md5
});
});
}
},
sendFileMsg(e) { sendFileMsg(e) {
let ipt = this.$refs.fileToSent; let ipt = this.$refs.fileToSent;
let files = e.target.files; let files = e.target.files;
......
...@@ -79,9 +79,13 @@ ...@@ -79,9 +79,13 @@
</div> </div>
<div class="state" v-if="msg.locationPath!=='' && msg.locationPath!=='-1'"> <div class="state" v-if="msg.locationPath!=='' && msg.locationPath!=='-1'">
<i class="iconfont icondagou"></i>{{msg.flow=='out'?'发送成功':'已成功下载到本地'}} <i class="iconfont icondagou"></i>
{{msg.flow=='out'?'发送成功':'已成功下载到本地'}}
</div> </div>
<div class="state" v-else>{{msg.locationPath!=='-1' && msg.flow=='out'?'未下载临时文件':'本地文件已被移除'}}</div> <div
class="state"
v-else
>{{msg.locationPath!=='-1' && msg.flow=='out'?'未下载临时文件':'本地文件已被移除'}}</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>
...@@ -160,17 +164,15 @@ ...@@ -160,17 +164,15 @@
</span>--> </span>-->
<span v-else-if="msg.type==='notification'" class="msg-text notify">{{msg.showText}}</span> <span v-else-if="msg.type==='notification'" class="msg-text notify">{{msg.showText}}</span>
<span v-else class="msg-text" v-html="msg.showText"></span> <span v-else class="msg-text" v-html="msg.showText"></span>
<span v-if="msg.status==='fail'" class="msg-failed"> <div class="error-tips" v-if="msg.error || msg.status==='fail'">
<i class="weui-icon-warn"></i> <i class="iconfont icongantanhao"></i>
</span> </div>
<!-- <a <!-- <a
v-if="teamMsgUnRead >=0" v-if="teamMsgUnRead >=0"
class="msg-unread" class="msg-unread"
:href="`#/msgReceiptDetail/${msg.to}-${msg.idServer}`" :href="`#/msgReceiptDetail/${msg.to}-${msg.idServer}`"
>{{teamMsgUnRead>0 ? `${teamMsgUnRead}人未读`: '全部已读'}}</a>--> >{{teamMsgUnRead>0 ? `${teamMsgUnRead}人未读`: '全部已读'}}</a>-->
</div> </div>
<div class="error-msg" v-if="msg.errormsg!=''">{{msg.errormsg}}</div>
</li> </li>
</template> </template>
<script> <script>
...@@ -216,7 +218,7 @@ export default { ...@@ -216,7 +218,7 @@ export default {
msg: "", msg: "",
isDownloading: false, isDownloading: false,
progess: -1, progess: -1,
douTimer:null douTimer: null
}; };
}, },
computed: { computed: {
...@@ -252,6 +254,9 @@ export default { ...@@ -252,6 +254,9 @@ export default {
}, },
mounted() { mounted() {
let item = this.msg; let item = this.msg;
if(window.localStorage.errorMsg && window.localStorage.errorMsg.indexOf(this.msg.idClient)!=-1){
this.msg.status='fail'
}
// 有时序问题的操作 // 有时序问题的操作
this.$nextTick(() => { this.$nextTick(() => {
let media = null; let media = null;
...@@ -263,7 +268,7 @@ export default { ...@@ -263,7 +268,7 @@ export default {
media.style.marginBottom = "-14px"; media.style.marginBottom = "-14px";
media.style.borderRadius = "6px"; media.style.borderRadius = "6px";
media.style.paddingRight = "-10px"; media.style.paddingRight = "-10px";
media.style.width = '170px' media.style.width = "170px";
media.src = item.file.url + "?imageView&thumbnail=180x0&quality=85"; media.src = item.file.url + "?imageView&thumbnail=180x0&quality=85";
if (item.flow === "in") { if (item.flow === "in") {
this.$refs.mediaMsg.style.width = "170px"; this.$refs.mediaMsg.style.width = "170px";
...@@ -306,7 +311,6 @@ export default { ...@@ -306,7 +311,6 @@ export default {
}); // end this.nextTick }); // end this.nextTick
}, },
methods: { methods: {
computedItem() { computedItem() {
let item = Object.assign({}, this.rawMsg); let item = Object.assign({}, this.rawMsg);
// 标记用户,区分聊天室、普通消息 // 标记用户,区分聊天室、普通消息
...@@ -347,7 +351,9 @@ export default { ...@@ -347,7 +351,9 @@ export default {
if (emojiCnt[text]) { if (emojiCnt[text]) {
item.showText = item.showText.replace( item.showText = item.showText.replace(
text, text,
`<img class="emoji-small" style='width:28px;' src="${emojiCnt[text].img}">` `<img class="emoji-small" style='width:28px;' src="${
emojiCnt[text].img
}">`
); );
} }
}); });
...@@ -517,8 +523,10 @@ export default { ...@@ -517,8 +523,10 @@ export default {
item.file.ext item.file.ext
); );
item.showText = item.customData.content.fileName; item.showText = item.customData.content.fileName;
let key = item.file.md5?item.file.md5:this.$encrypt.Encrypt(JSON.stringify(item.customData)); let key = item.file.md5
key = item.flow=='in'?key:key+"_me"; ? item.file.md5
: this.$encrypt.Encrypt(JSON.stringify(item.customData));
key = item.flow == "in" ? key : key + "_me";
item.locationPath = this.getLocationPath(key); item.locationPath = this.getLocationPath(key);
item.locationFolder = item.locationFolder =
item.locationPath === "" item.locationPath === ""
...@@ -531,13 +539,13 @@ export default { ...@@ -531,13 +539,13 @@ export default {
} }
} else { } else {
item.showText = item.file.name; item.showText = item.file.name;
let key = item.flow=='in'?item.file.md5:item.file.md5+"_me"; let key = item.flow == "in" ? item.file.md5 : item.file.md5 + "_me";
item.ispreviwer = /(doc|docx|xls|xlsx|ppt|pptx|pdf)/i.test( item.ispreviwer = /(doc|docx|xls|xlsx|ppt|pptx|pdf)/i.test(
item.file.ext item.file.ext
); );
item.file.icon = this.loadFileICON(item.file.ext) item.file.icon = this.loadFileICON(item.file.ext);
item.locationPath = this.getLocationPath(key); item.locationPath = this.getLocationPath(key);
item.file.size = this.bytesToSize(item.file.size) item.file.size = this.bytesToSize(item.file.size);
item.locationFolder = item.locationFolder =
item.locationPath === "" item.locationPath === ""
? "" ? ""
...@@ -574,7 +582,9 @@ export default { ...@@ -574,7 +582,9 @@ export default {
}, },
beginDownload(res) { beginDownload(res) {
this.isDownloading = true; this.isDownloading = true;
let key = this.msg.file.md5?this.msg.file.md5:this.$encrypt.Encrypt(JSON.stringify(this.msg.customData)); let key = this.msg.file.md5
? this.msg.file.md5
: this.$encrypt.Encrypt(JSON.stringify(this.msg.customData));
let name = res.substring(res.lastIndexOf("\\") + 1, res.length); let name = res.substring(res.lastIndexOf("\\") + 1, res.length);
this.$electron.ipcRenderer.send( this.$electron.ipcRenderer.send(
"download", "download",
...@@ -760,7 +770,7 @@ export default { ...@@ -760,7 +770,7 @@ export default {
var nextMsgNode = currentMsgNode.nextElementSibling; var nextMsgNode = currentMsgNode.nextElementSibling;
var nextAudioNode; var nextAudioNode;
while (nextMsgNode) { while (nextMsgNode) {
if (~nextMsgNode.className.indexOf("item-you")) { if (nextMsgNode.className.indexOf("item-you")) {
nextAudioNode = nextMsgNode.querySelector(".msg-audio"); nextAudioNode = nextMsgNode.querySelector(".msg-audio");
if (nextAudioNode) { if (nextAudioNode) {
break; break;
...@@ -952,6 +962,21 @@ export default { ...@@ -952,6 +962,21 @@ export default {
display: inline-block; display: inline-block;
overflow: hidden; 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-you .in .msg-head img,
.item-me .out .msg-head img { .item-me .out .msg-head img {
width: 100%; width: 100%;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
:isRobot="isRobot" :isRobot="isRobot"
:userInfos="userInfos" :userInfos="userInfos"
:myInfo="myInfo" :myInfo="myInfo"
:key="(msg.idClient || index)" :key="(msg.idClient+'_'+index)"
:isHistory="isHistory" :isHistory="isHistory"
@msg-loaded="msgLoaded" @msg-loaded="msgLoaded"
ref="chatitem" ref="chatitem"
......
<template>
<div
class="input"
contenteditable="true"
@input="changeTxt"
@focus="lock=true"
@blur="lock=false"
id="msgEditorBox"
draggable="false"
v-html="innerText"
></div>
</template>
<script>
import BMF from "browser-md5-file";
import { setInterval } from "timers";
export default {
props: {
child: {
type: Object,
default: {
txt: ""
}
}
},
data: function() {
return {
innerText: this.child.txt,
uploadFile: [],
lock: false
};
},
watch: {
child: {
handler(newValue, oldValue) {
if (!this.lock) {
this.innerText = this.child.txt;
}
},
deep: true
}
},
mounted() {
this.initClip();
let that = this;
let pDom = document.querySelector("#msgEditorBox");
pDom.addEventListener("drop", e => {
return false;
});
pDom.addEventListener("click", e => {
if (e.target.className == "file-send-box") {
if (e.target.style.filter != "invert(100%)") {
e.target.style.filter = "invert(100%)";
} else {
e.target.style.filter = "invert(0%)";
}
document
.querySelector("#msgEditorBox")
.querySelectorAll(".file-send-box")
.forEach(x => {
if (x.innerText != e.target.innerText)
x.style.filter = "invert(0%)";
});
} else {
document
.querySelector("#msgEditorBox")
.querySelectorAll(".file-send-box")
.forEach(x => {
x.style.filter = "invert(0%)";
});
}
});
pDom.addEventListener("keydown", e => {
var e = e || window.event, ec = e.keyCode || e.which;
if (ec == 8 || ec == 46) {
let dom = null;
pDom.querySelectorAll(".file-send-box").forEach((x, i) => {
if (x.style.filter == "invert(100%)") {
dom = x;
this.child.file.splice(i, 1);
}
});
if (dom) {
pDom.removeChild(dom);
e.preventDefault();
e.stopPropagation();
} else {
setTimeout(() => {
let delArray = [];
this.child.file = this.child.file.filter(x => {
return pDom.innerText.indexOf(x.name) != -1;
});
this.child.file = this.child.file ? this.child.file : [];
}, 100);
}
} else if (e.ctrlKey && 13 == ec) {
var div = document.createElement('div');
var newContent = document.createElement('br')
div.appendChild(newContent)
pDom.appendChild(div)
var o = pDom.lastChild;
var sel = window.getSelection();
var range = document.createRange();
range.selectNodeContents(pDom);
range.collapse(false);
range.setEndAfter(o);
range.setStartAfter(o);
sel.removeAllRanges();
sel.addRange(range);
} else if (ec == 13){
that.sendMsg()
}
});
this.$electron.ipcRenderer.on("new-send-file", (event, path,size) => {
let h = that.child.file.find(x => {
return x.path == path;
});
if (!h) {
let exts = path.split(".");
let f = {
path,
size,
icon: that.loadFileICON(exts[exts.length - 1], 2),
ext: exts[exts.length - 1],
name: path.substring(path.lastIndexOf("\\") + 1, path.length)
};
that.formatHTML(f);
that.child.file.push(f);
} else {
//do
}
});
this.updateClipboard();
let myInterval = window.setInterval(this.updateClipboard, 500);
},
methods: {
changeTxt: function(e) {
this.child.txt = this.$el.innerText;
},
updateClipboard() {
console.log("update....");
this.$electron.ipcRenderer.send("auto-update-clip");
},
readBlobAsDataURL(blob, callback) {
var a = new FileReader();
a.onload = function(e) {
callback(e.target.result);
};
a.readAsDataURL(blob);
},
initClip() {
let _this = this;
document
.querySelector("#msgEditorBox")
.addEventListener("paste", function(event) {
var clipboardData = event.clipboardData;
var items, item, types;
if (clipboardData) {
items = clipboardData.items;
if (!items || items.length == 0) {
console.log(_this.$electron.ipcRenderer.send("read-clip"))
return false;
} else {
// 保存在剪贴板中的数据类型
types = clipboardData.types || [];
for (var i = 0; i < types.length; i++) {
if (types[i] === "Files") {
item = items[i];
break;
}
}
if (
item &&
item.kind === "file" &&
item.type.match(/^image\//i)
) {
console.log(item);
// 读取该图片
// var file = item.getAsFile(),
// reader = new FileReader(),
// name = "";
// if (item.type.match(/^image\//i))
// name = `截图_${Date.parse(new Date())}.png`;
// reader.onload = function(e) {
// 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
// });
// });
// },
// 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);
}
}
}
});
},
formatHTML(f) {
let html = `<div title='${
f.name
}' contenteditable="false" class="file-send-box"><div class="icon"><div class="fileIcon ${
f.icon ? f.icon : "default-small"
}"></div></div><div class='name-info'>${f.name}</div></div>`;
document.querySelector("#msgEditorBox").innerHTML =
document.querySelector("#msgEditorBox").innerHTML + html;
},
sendMsg() {
this.$emit("send");
this.clearContent();
},
clearContent() {
this.child.file = [];
this.child.txt = "";
document.querySelector("#msgEditorBox").innerHTML = "";
}
}
};
</script>
<style>
.file-send-box {
min-width: 30px;
overflow: hidden;
height: 60px;
box-sizing: border-box;
margin-right: 7px;
display: inline-block;
vertical-align: text-bottom;
padding: 5px;
cursor: pointer;
max-width: 100px;
background: rgba(255, 255, 255, 0.5);
user-select: none;
position: relative;
}
.file-send-box::after {
content: " ";
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: transparent;
}
.file-send-box .icon {
height: 30px;
width: 30px;
margin: 0px auto;
text-align: center;
}
.file-send-box .name-info {
margin-top: 10px;
height: 20px;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
font-size: 12px;
color: #333;
word-wrap: none;
white-space: nowrap;
text-align: center;
}
</style>
<template>
<div style="width:100%;height:100%">
<el-dialog title="提示" :visible.sync="visible" :before-close="handleClose" width="100%">
<span>{{msg}}</span>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="close">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
msg: "",
visible:true
};
},
mounted() {
this.msg = this.$electron.remote.getGlobal("DIALOG_MESSAGE");
},
methods: {
close() {
this.$electron.remote.getCurrentWindow().close();
},
handleClose(done) {
console.log('in........')
this.close()
}
}
};
</script>
<style>
.el-dialog{
top: 0px !important;
width: 100% !important;
bottom: 0 !important;
transform: translateX(0%);
margin-bottom: 0;
left: 0;
border:1px solid #ccc;
border-radius: 2px;
box-sizing: border-box;
}
.el-dialog__header {
padding: 10px 10px 0;
-webkit-app-region: drag !important;
}
.el-dialog__footer {
padding: 10px 20px 15px;
text-align: right;
box-sizing: border-box;
position: absolute;
bottom: 0;
width: 100%;
}
.el-dialog__close{
font-size: 11px !important;
}
.el-dialog__close:hover{
color:tomato;
}
</style>
...@@ -19,16 +19,24 @@ export default { ...@@ -19,16 +19,24 @@ export default {
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()
}); });
}, },
updated() {
//this.imgPath = null;
// this.imgPath = this.$electron.remote.getGlobal("DEFAULT_SCREENSHOT_PATH")
// this.screenhot()
},
mounted() { mounted() {
let that = this; let that = this;
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) {
that.$electron.remote.getCurrentWindow().hide(); that.$electron.remote.getCurrentWindow().hide();
that.$electron.ipcRenderer.send("delete-file",that.imgPath);
that.imgPath=null
} }
} }
document.onmouseup = function(e) { document.onmouseup = function(e) {
...@@ -37,6 +45,8 @@ export default { ...@@ -37,6 +45,8 @@ export default {
let cnt = document.querySelectorAll("#kss").length; let cnt = document.querySelectorAll("#kss").length;
if (cnt == 0) { if (cnt == 0) {
that.$electron.remote.getCurrentWindow().hide(); that.$electron.remote.getCurrentWindow().hide();
that.$electron.ipcRenderer.send("delete-file",that.imgPath);
that.imgPath=null
} }
}, 100); }, 100);
} }
...@@ -51,6 +61,8 @@ export default { ...@@ -51,6 +61,8 @@ export default {
endCB: function(e) { endCB: function(e) {
that.$electron.ipcRenderer.send("addClipboard", e); that.$electron.ipcRenderer.send("addClipboard", e);
that.$electron.remote.getCurrentWindow().hide(); that.$electron.remote.getCurrentWindow().hide();
that.$electron.ipcRenderer.send("delete-file",that.imgPath);
that.imgPath=null
}, },
immediately: true, immediately: true,
toolShow: { toolShow: {
......
...@@ -38,6 +38,11 @@ export default new Router({ ...@@ -38,6 +38,11 @@ export default new Router({
path: '/scrollerhot', path: '/scrollerhot',
name: 'scrollerhot', name: 'scrollerhot',
component: require('@/components/tools/scrollerhot') component: require('@/components/tools/scrollerhot')
},
{
path: '/dialog',
name: 'dialog',
component: require('@/components/tools/dialog')
} }
] ]
}) })
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -11,7 +11,7 @@ import {updateBlack} from './blacks' ...@@ -11,7 +11,7 @@ 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, sendMsgReceipt, sendRobotMsg, revocateMsg, updateLocalMsg, getHistoryMsgs, resetNoMoreHistoryMsgs, continueRobotMsg} from './msgs' import {sendMsg, sendTip,sendDataFilePath, sendFileMsg,sendDataUrlMsg, 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'
...@@ -116,6 +116,7 @@ export default { ...@@ -116,6 +116,7 @@ export default {
sendTip, sendTip,
sendFileMsg, sendFileMsg,
sendDataUrlMsg, sendDataUrlMsg,
sendDataFilePath,
sendRobotMsg, sendRobotMsg,
// 发送消息已读回执 // 发送消息已读回执
sendMsgReceipt, sendMsgReceipt,
......
...@@ -8,7 +8,7 @@ import util from '../../utils' ...@@ -8,7 +8,7 @@ import util from '../../utils'
import store from '../' import store from '../'
import {onChatroomMsgs} from './chatroomMsgs' import {onChatroomMsgs} from './chatroomMsgs'
const SDK = require('../../sdk/NIM_Web_SDK_v6.1.0') const SDK = require('../../sdk/NIM_Web_NIM_v6.1.0')
// 切换聊天室之前需要断开连接,原因是移动端不断累积连接实例,消息并发较大时会有性能问题 // 切换聊天室之前需要断开连接,原因是移动端不断累积连接实例,消息并发较大时会有性能问题
// 重新初始化 NIM SDK // 重新初始化 NIM SDK
......
...@@ -71,12 +71,23 @@ function onSendMsgDone (error, msg) { ...@@ -71,12 +71,23 @@ function onSendMsgDone (error, msg) {
store.dispatch('hideLoading') store.dispatch('hideLoading')
if (error) { if (error) {
// 被拉黑 // 被拉黑
if (error.code === 7101) { msg.error=error.message
msg.status = 'success' let errMsgArray=[]
alert(error.message) if(window.localStorage.errorMsg){
} else { errMsgArray=JSON.parse(window.localStorage.errorMsg)
alert(error.message)
} }
errMsgArray.push(msg.idClient)
window.localStorage.errorMsg=JSON.stringify(errMsgArray)
let errorString=error.message
errorString=errorString.indexOf(": ")!=-1?errorString.split(": ")[1]:errorString
nim.sendTipMsg({
scene: msg.scene,
to: msg.to,
tip: errorString,
done: function sendTipMsgDone (error, msg) {
onSendMsgDone(null, msg)
}
})
} }
onMsg(msg) onMsg(msg)
} }
...@@ -215,6 +226,7 @@ export function sendFileMsg ({state, commit}, obj) { ...@@ -215,6 +226,7 @@ export function sendFileMsg ({state, commit}, obj) {
}, },
beforesend: function (msg) { beforesend: function (msg) {
// console && console.log('正在发送消息, id=', msg); // console && console.log('正在发送消息, id=', msg);
onMsg(msg);
}, },
done: function (error, msg) { done: function (error, msg) {
onSendMsgDone (error, msg) onSendMsgDone (error, msg)
...@@ -231,7 +243,7 @@ export function sendDataUrlMsg ({state, commit}, obj) { ...@@ -231,7 +243,7 @@ export function sendDataUrlMsg ({state, commit}, obj) {
type = 'image' type = 'image'
} else if (/(mov|mp4|ogg|webm)$/i.test(name)) { } else if (/(mov|mp4|ogg|webm)$/i.test(name)) {
type = 'video' type = 'video'
} else if (/\.(wav|mp3|wma)$/i.test(fileInput.value)) { } else if (/\.(wav|mp3|wma)$/i.test(name)) {
type = 'music' type = 'music'
} }
let customMsg = { let customMsg = {
...@@ -258,7 +270,7 @@ export function sendDataUrlMsg ({state, commit}, obj) { ...@@ -258,7 +270,7 @@ export function sendDataUrlMsg ({state, commit}, obj) {
dataURL: dataURL, dataURL: dataURL,
custom: JSON.stringify(customMsg), custom: JSON.stringify(customMsg),
uploadprogress: function (data) { uploadprogress: function (data) {
// console.log(data.percentageText) console.log('正在发送消息, id=', data);
}, },
uploaderror: function () { uploaderror: function () {
console && console.log('上传失败') console && console.log('上传失败')
...@@ -268,7 +280,8 @@ export function sendDataUrlMsg ({state, commit}, obj) { ...@@ -268,7 +280,8 @@ export function sendDataUrlMsg ({state, commit}, obj) {
// console.log(file); // console.log(file);
}, },
beforesend: function (msg) { beforesend: function (msg) {
// console && console.log('正在发送消息, id=', msg); console.log('正在发送消息, id=', msg);
onMsg(msg)
}, },
done: function (error, msg) { done: function (error, msg) {
onSendMsgDone(error, msg) onSendMsgDone(error, msg)
...@@ -276,6 +289,56 @@ export function sendDataUrlMsg ({state, commit}, obj) { ...@@ -276,6 +289,56 @@ export function sendDataUrlMsg ({state, commit}, obj) {
}) })
} }
export function sendDataFilePath ({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 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.previewFile({
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)
// }
// });
// }
},
});
}
// 发送机器人消息 // 发送机器人消息
export function sendRobotMsg ({state, commit}, obj) { export function sendRobotMsg ({state, commit}, obj) {
const nim = state.nim const nim = state.nim
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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