Commit ebacf562 authored by 罗超's avatar 罗超

修复BUG

parent 5de2722d
'use strict' 'use strict'
import { app, BrowserWindow, protocol, desktopCapturer,systemPreferences } from 'electron' import { app, BrowserWindow, protocol, desktopCapturer, systemPreferences } from 'electron'
const cp = require('child_process') const cp = require('child_process')
...@@ -13,7 +13,7 @@ const SDK = require('../../static/sdk/NIM_Web_NIM_nodejs_v5.9.1.js') ...@@ -13,7 +13,7 @@ const SDK = require('../../static/sdk/NIM_Web_NIM_nodejs_v5.9.1.js')
const http = require('http') const http = require('http')
const ipc = electron.ipcMain const ipc = electron.ipcMain
const shell =electron.shell const shell = electron.shell
const Menu = electron.Menu const Menu = electron.Menu
const Tray = electron.Tray const Tray = electron.Tray
const dialog = electron.dialog const dialog = electron.dialog
...@@ -30,11 +30,11 @@ global.FILEURL = '' ...@@ -30,11 +30,11 @@ global.FILEURL = ''
global.VERSION = '' global.VERSION = ''
global.ISCUSTOM = false global.ISCUSTOM = false
global.PREVIWERURL = '' global.PREVIWERURL = ''
global.PREVIWERVIDEOURL='' global.PREVIWERVIDEOURL = ''
global.PREVIWERIMGS = [] global.PREVIWERIMGS = []
global.PREVIWERIMG = 0 global.PREVIWERIMG = 0
global.DIALOG_MESSAGE='' global.DIALOG_MESSAGE = ''
global.CURRENT_TEAM_MEMBERS={} global.CURRENT_TEAM_MEMBERS = {}
let updateTimer let updateTimer
let loginWindow let loginWindow
let mainWindow let mainWindow
...@@ -47,6 +47,7 @@ let scrollerhotWindows ...@@ -47,6 +47,7 @@ let scrollerhotWindows
let addNewUserWinodes let addNewUserWinodes
let dialogWindows let dialogWindows
let noticeWindows let noticeWindows
let forwardWindows
let appIcon = null let appIcon = null
let isLogin = false let isLogin = false
let timeout = null let timeout = null
...@@ -59,12 +60,12 @@ let mainEvent = null ...@@ -59,12 +60,12 @@ let mainEvent = null
let screenEvent = null let screenEvent = null
let messageEvent = null let messageEvent = null
let messageProtocol = null let messageProtocol = null
let CAP_IMG='' let CAP_IMG = ''
let nim=null let nim = null
let SCREENCOUNT=0 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'
global.AUDIO_PATH=process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) global.AUDIO_PATH = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)
const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html` const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`
...@@ -76,13 +77,14 @@ const dialogUrl = process.env.NODE_ENV === 'development' ? `http://localhost:908 ...@@ -76,13 +77,14 @@ const dialogUrl = process.env.NODE_ENV === 'development' ? `http://localhost:908
const noticeUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/notice` : `file://${__dirname}/index.html#/notice` const noticeUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/notice` : `file://${__dirname}/index.html#/notice`
const addnewuserUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/addnewuser` : `file://${__dirname}/index.html#/addnewuser` const addnewuserUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/addnewuser` : `file://${__dirname}/index.html#/addnewuser`
const appXmlPath = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) + 'app.json' const appXmlPath = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) + 'app.json'
const forwardUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/forwardMsg` : `file://${__dirname}/index.html#/forwardMsg`
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
} }
let windowIcon = nativeImage.createFromPath(path.join(__static, './icons/logo.png')) let windowIcon = nativeImage.createFromPath(path.join(__static, './icons/logo.png'))
fs.readFile(appXmlPath, 'utf-8', function (err, result) { fs.readFile(appXmlPath, 'utf-8', function(err, result) {
if (result) { if (result) {
let version let version
try { try {
...@@ -125,7 +127,7 @@ const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) ...@@ -125,7 +127,7 @@ const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory)
mainEvent.sender.send('openMsgBox') mainEvent.sender.send('openMsgBox')
} }
if (messageEvent) { if (messageEvent) {
setTimeout(function () { setTimeout(function() {
if (messageEvent) { if (messageEvent) {
if (messageProtocol) { if (messageProtocol) {
messageEvent.sender.send('openCurrentNewMessage', 'p2p-' + messageProtocol) messageEvent.sender.send('openCurrentNewMessage', 'p2p-' + messageProtocol)
...@@ -147,7 +149,8 @@ const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) ...@@ -147,7 +149,8 @@ const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory)
if (isSecondInstance) { if (isSecondInstance) {
app.exit(0) app.exit(0)
} }
function createWindow () {
function createWindow() {
if (process.argv.length > 1) { if (process.argv.length > 1) {
if (process.argv[1] && process.argv[1].indexOf('woyou:') != -1) { if (process.argv[1] && process.argv[1].indexOf('woyou:') != -1) {
try { try {
...@@ -176,13 +179,10 @@ function createWindow () { ...@@ -176,13 +179,10 @@ function createWindow () {
let pathAll = folderpath + `\\` + downloadname let pathAll = folderpath + `\\` + downloadname
item.setSavePath(pathAll) item.setSavePath(pathAll)
item.on('updated', (event, state) => { item.on('updated', (event, state) => {
if (state === 'interrupted') { if (state === 'interrupted') {} else if (state === 'progressing') {
} else if (state === 'progressing') { if (item.isPaused()) {} else {}
if (item.isPaused()) {
} else {
}
mainWindow.setProgressBar(item.getReceivedBytes() / totalBytes) mainWindow.setProgressBar(item.getReceivedBytes() / totalBytes)
downloadObj.sender.send('downloading', (parseFloat(item.getReceivedBytes()) / parseFloat(totalBytes))*100) downloadObj.sender.send('downloading', (parseFloat(item.getReceivedBytes()) / parseFloat(totalBytes)) * 100)
} }
}) })
item.once('done', (event, state) => { item.once('done', (event, state) => {
...@@ -206,7 +206,7 @@ function createWindow () { ...@@ -206,7 +206,7 @@ function createWindow () {
const iconPath = path.join(__static, iconName) const iconPath = path.join(__static, iconName)
appIcon = new Tray(iconPath) appIcon = new Tray(iconPath)
appIcon.setToolTip('麦子助手') appIcon.setToolTip('麦子助手')
appIcon.on('click', function () { appIcon.on('click', function() {
if (global.NEWMESSAGE && global.NEWMESSAGE.length > 0) { if (global.NEWMESSAGE && global.NEWMESSAGE.length > 0) {
//getNewMsgWindows() //getNewMsgWindows()
newMsgWindow.show() newMsgWindow.show()
...@@ -224,7 +224,7 @@ function createWindow () { ...@@ -224,7 +224,7 @@ function createWindow () {
} }
} }
}) })
appIcon.on('double-click', function () { appIcon.on('double-click', function() {
if (isLogin) { if (isLogin) {
mainWindow.show() mainWindow.show()
} else { } else {
...@@ -237,7 +237,7 @@ function createWindow () { ...@@ -237,7 +237,7 @@ function createWindow () {
}) })
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([{
label: '打开主界面', label: '打开主界面',
click: function () { click: function() {
if (isLogin) { if (isLogin) {
mainWindow.show() mainWindow.show()
} else { } else {
...@@ -251,10 +251,11 @@ function createWindow () { ...@@ -251,10 +251,11 @@ function createWindow () {
}, },
{ {
label: '退出', label: '退出',
click: function () { click: function() {
app.exit(0) app.exit(0)
} }
}]) }
])
appIcon.setContextMenu(contextMenu) appIcon.setContextMenu(contextMenu)
Menu.setApplicationMenu(null) Menu.setApplicationMenu(null)
...@@ -265,10 +266,10 @@ function createWindow () { ...@@ -265,10 +266,10 @@ function createWindow () {
let updateDir = startDir + 'update\\' let updateDir = startDir + 'update\\'
let pa = fs.readdirSync(updateDir) let pa = fs.readdirSync(updateDir)
if (pa) { if (pa) {
pa.forEach(function (ele, index) { pa.forEach(function(ele, index) {
var info = fs.statSync(updateDir + ele) var info = fs.statSync(updateDir + ele)
if (!info.isDirectory()) { if (!info.isDirectory()) {
fs.rename(updateDir + ele, startDir + ele, function (err) { fs.rename(updateDir + ele, startDir + ele, function(err) {
// if (ele.indexOf('UpdateAuthority.exe') != -1 && startDir.toLowerCase().indexOf('c:') != -1) { // if (ele.indexOf('UpdateAuthority.exe') != -1 && startDir.toLowerCase().indexOf('c:') != -1) {
// shell.openItem(startDir + 'UpdateAuthority.exe') // shell.openItem(startDir + 'UpdateAuthority.exe')
// } // }
...@@ -279,19 +280,19 @@ function createWindow () { ...@@ -279,19 +280,19 @@ function createWindow () {
} }
} }
app.on('ready', createWindow) app.on('ready', createWindow)
// app.on('window-all-closed', () => { // app.on('window-all-closed', () => {
// if (process.platform !== 'darwin') { // if (process.platform !== 'darwin') {
// app.exit(0) // app.exit(0)
// } // }
// }) // })
app.on('activate', () => { app.on('activate', () => {
if (loginWindow === null) { if (loginWindow === null) {
createWindow() createWindow()
} }
}) })
ipc.on('loginSuccess', function (event, userInfo) { ipc.on('loginSuccess', function(event, userInfo) {
initNIM(userInfo.ImAccount,userInfo.ImToken) initNIM(userInfo.ImAccount, userInfo.ImToken)
registScrollerHotKey() registScrollerHotKey()
getScrollerhotWindows() getScrollerhotWindows()
global.LOGINUSER = userInfo global.LOGINUSER = userInfo
...@@ -301,7 +302,7 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -301,7 +302,7 @@ ipc.on('loginSuccess', function (event, userInfo) {
isLogin = true isLogin = true
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([{
label: '打开主界面', label: '打开主界面',
click: function () { click: function() {
if (isLogin) { if (isLogin) {
if (!mainWindow.isDestroyed()) { if (!mainWindow.isDestroyed()) {
mainWindow.show() mainWindow.show()
...@@ -319,7 +320,7 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -319,7 +320,7 @@ ipc.on('loginSuccess', function (event, userInfo) {
}, },
{ {
label: '注销', label: '注销',
click: function () { click: function() {
global.ISSIGNOUT = true global.ISSIGNOUT = true
global.LOGINUSER = null global.LOGINUSER = null
global.LOGINTYPE = null global.LOGINTYPE = null
...@@ -334,7 +335,7 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -334,7 +335,7 @@ ipc.on('loginSuccess', function (event, userInfo) {
} catch (error) {} } catch (error) {}
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([{
label: '打开主界面', label: '打开主界面',
click: function () { click: function() {
if (isLogin) { if (isLogin) {
if (!mainWindow.isDestroyed()) { if (!mainWindow.isDestroyed()) {
mainWindow.show() mainWindow.show()
...@@ -352,10 +353,11 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -352,10 +353,11 @@ ipc.on('loginSuccess', function (event, userInfo) {
}, },
{ {
label: '退出', label: '退出',
click: function () { click: function() {
app.exit(0) app.exit(0)
} }
}]) }
])
appIcon.setContextMenu(contextMenu) appIcon.setContextMenu(contextMenu)
loginWindow.show() loginWindow.show()
} }
...@@ -363,15 +365,16 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -363,15 +365,16 @@ ipc.on('loginSuccess', function (event, userInfo) {
{ {
label: '退出', label: '退出',
click: function () { click: function() {
app.exit(0) app.exit(0)
} }
}]) }
])
appIcon.setContextMenu(contextMenu) appIcon.setContextMenu(contextMenu)
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {
let startDir = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) let startDir = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)
fs.readFile(appXmlPath, 'utf-8', function (err, result) { fs.readFile(appXmlPath, 'utf-8', function(err, result) {
let version let version
try { try {
version = JSON.parse(result) version = JSON.parse(result)
...@@ -380,7 +383,7 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -380,7 +383,7 @@ ipc.on('loginSuccess', function (event, userInfo) {
version = JSON.parse(result) version = JSON.parse(result)
} }
version.CurrentUser = userInfo.ImAccount version.CurrentUser = userInfo.ImAccount
fs.writeFile(appXmlPath, JSON.stringify(version), function (err) { fs.writeFile(appXmlPath, JSON.stringify(version), function(err) {
//setTimeout(function () { //setTimeout(function () {
// shell.openItem(startDir + 'AutoUpdate.exe') // shell.openItem(startDir + 'AutoUpdate.exe')
// }, 1000 * 60 * 5) // }, 1000 * 60 * 5)
...@@ -393,10 +396,10 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -393,10 +396,10 @@ ipc.on('loginSuccess', function (event, userInfo) {
}) })
}) })
} }
setTimeout(function () { setTimeout(function() {
try { try {
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)
}) })
...@@ -407,14 +410,14 @@ ipc.on('loginSuccess', function (event, userInfo) { ...@@ -407,14 +410,14 @@ ipc.on('loginSuccess', function (event, userInfo) {
} }
}, 1000 * 60 * 10) }, 1000 * 60 * 10)
}) })
ipc.on('newMessage', function (event, data) { ipc.on('newMessage', function(event, data) {
global.NEWMESSAGE = data global.NEWMESSAGE = data
if (data && data.length > 0) { if (data && data.length > 0) {
var count = 0 var count = 0
if (timeout) { if (timeout) {
clearInterval(timeout) clearInterval(timeout)
} }
timeout = setInterval(function () { timeout = setInterval(function() {
if (count++ % 2 == 0) { if (count++ % 2 == 0) {
appIcon.setImage(path.join(__static, './icons/logo.png')) appIcon.setImage(path.join(__static, './icons/logo.png'))
} else { } else {
...@@ -434,7 +437,7 @@ ipc.on('newMessage', function (event, data) { ...@@ -434,7 +437,7 @@ ipc.on('newMessage', function (event, data) {
newMsgWindow.hide() newMsgWindow.hide()
} }
}) })
ipc.on('openSystemNotice', function (event, sessionid) { ipc.on('openSystemNotice', function(event, sessionid) {
if (!xNoticeWindow || xNoticeWindow.isDestroyed()) { if (!xNoticeWindow || xNoticeWindow.isDestroyed()) {
sNoticeWindow = new BrowserWindow({ sNoticeWindow = new BrowserWindow({
y: electron.screen.getPrimaryDisplay().workAreaSize.height - 190, y: electron.screen.getPrimaryDisplay().workAreaSize.height - 190,
...@@ -462,45 +465,45 @@ ipc.on('openSystemNotice', function (event, sessionid) { ...@@ -462,45 +465,45 @@ ipc.on('openSystemNotice', function (event, sessionid) {
}) })
} }
}) })
ipc.on('openNewMessage', function (event, currentSession) { ipc.on('openNewMessage', function(event, currentSession) {
mainWindow.show() mainWindow.show()
mainWindow.setAlwaysOnTop(true) mainWindow.setAlwaysOnTop(true)
mainWindow.setAlwaysOnTop(false) mainWindow.setAlwaysOnTop(false)
global.NEWMESSAGE.splice(global.NEWMESSAGE.indexOf(currentSession), 1) global.NEWMESSAGE.splice(global.NEWMESSAGE.indexOf(currentSession), 1)
mainEvent.sender.send('openMsgBox',currentSession) mainEvent.sender.send('openMsgBox', currentSession)
if (global.NEWMESSAGE && global.NEWMESSAGE.length == 0) { if (global.NEWMESSAGE && global.NEWMESSAGE.length == 0) {
clearInterval(timeout) clearInterval(timeout)
appIcon.setImage(path.join(__static, './icons/logo.png')) appIcon.setImage(path.join(__static, './icons/logo.png'))
newMsgWindow.hide() newMsgWindow.hide()
} }
}) })
ipc.on('openNewMessageOther', function (event, IMid) { ipc.on('openNewMessageOther', function(event, IMid) {
mainWindow.show() mainWindow.show()
mainEvent.sender.send('openMsgBox') mainEvent.sender.send('openMsgBox')
messageEvent.sender.send('openCurrentNewMessage', 'p2p-' + IMid) messageEvent.sender.send('openCurrentNewMessage', 'p2p-' + IMid)
}) })
ipc.on('clearMessage', function (event) { ipc.on('clearMessage', function(event) {
global.USER_CURRENTSESSION = null global.USER_CURRENTSESSION = null
// mainWindow.show() // mainWindow.show()
}) })
ipc.on('ignore-all-message', function (event) { ipc.on('ignore-all-message', function(event) {
clearInterval(timeout) clearInterval(timeout)
appIcon.setImage(path.join(__static, './icons/logo.png')) appIcon.setImage(path.join(__static, './icons/logo.png'))
newMsgWindow.hide() newMsgWindow.hide()
mainEvent.sender.send('ignore-all-unRead') mainEvent.sender.send('ignore-all-unRead')
global.NEWMESSAGE.length = 0 global.NEWMESSAGE.length = 0
}) })
ipc.on('create-session', function (event) { ipc.on('create-session', function(event) {
mainEvent = event mainEvent = event
if (messageProtocol) { if (messageProtocol) {
mainEvent.sender.send('openMsgBox') mainEvent.sender.send('openMsgBox')
} }
}) })
ipc.on('create-message-session', function (event) { ipc.on('create-message-session', function(event) {
messageEvent = event messageEvent = event
if (messageProtocol) { if (messageProtocol) {
setTimeout(function () { setTimeout(function() {
messageEvent.sender.send('openCurrentNewMessage', 'p2p-' + messageProtocol) messageEvent.sender.send('openCurrentNewMessage', 'p2p-' + messageProtocol)
messageProtocol = null messageProtocol = null
}, 3000) }, 3000)
...@@ -521,7 +524,7 @@ ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => { ...@@ -521,7 +524,7 @@ ipc.on('download', (evt, pdownloadpath, pfolderpath, dfileName, pmsgId) => {
}) })
ipc.on('OpenFile', (evt, filePaht) => { ipc.on('OpenFile', (evt, filePaht) => {
var a = shell.openItem(filePaht) var a = shell.openItem(filePaht)
let isHave=true let isHave = true
if (!a) { if (!a) {
dialog.showErrorBox('打开文件', '此文件不存在,可能被删除或者移动到其它位置') dialog.showErrorBox('打开文件', '此文件不存在,可能被删除或者移动到其它位置')
isHave = false isHave = false
...@@ -534,10 +537,10 @@ ipc.on('showItemInFolder', (evt, filePaht) => { ...@@ -534,10 +537,10 @@ ipc.on('showItemInFolder', (evt, filePaht) => {
ipc.on('openUrl', (evt, url) => { ipc.on('openUrl', (evt, url) => {
shell.openExternal(url) shell.openExternal(url)
}) })
ipc.on('exit', function (event) { ipc.on('exit', function(event) {
app.exit(0) app.exit(0)
}) })
ipc.on('signOut', function (event) { ipc.on('signOut', function(event) {
global.ISSIGNOUT = true global.ISSIGNOUT = true
global.LOGINUSER = null global.LOGINUSER = null
global.LOGINTYPE = null global.LOGINTYPE = null
...@@ -582,7 +585,7 @@ ipc.on('signOut', function (event) { ...@@ -582,7 +585,7 @@ ipc.on('signOut', function (event) {
loginWindow.show() loginWindow.show()
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([{
label: '打开主界面', label: '打开主界面',
click: function () { click: function() {
if (isLogin) { if (isLogin) {
mainWindow.show() mainWindow.show()
} else { } else {
...@@ -596,54 +599,55 @@ ipc.on('signOut', function (event) { ...@@ -596,54 +599,55 @@ ipc.on('signOut', function (event) {
}, },
{ {
label: '退出', label: '退出',
click: function () { click: function() {
app.exit(0) app.exit(0)
} }
}]) }
])
appIcon.setContextMenu(contextMenu) appIcon.setContextMenu(contextMenu)
loginWindow.show() loginWindow.show()
}) })
ipc.on('openPreviwerfile', function (event,url) { ipc.on('openPreviwerfile', function(event, url) {
global.PREVIWERURL=url global.PREVIWERURL = url
getPreviwerFileWindow() getPreviwerFileWindow()
}) })
ipc.on('openPreviwerfile', function (event,url) { ipc.on('openPreviwerfile', function(event, url) {
global.PREVIWERURL=url global.PREVIWERURL = url
getPreviwerFileWindow() getPreviwerFileWindow()
}) })
ipc.on('clearPrevImgs', function (event) { ipc.on('clearPrevImgs', function(event) {
global.PREVIWERIMGS=[] global.PREVIWERIMGS = []
}) })
ipc.on('addPrevImgs', function (event,url) { ipc.on('addPrevImgs', function(event, url) {
global.PREVIWERIMGS.push(url) global.PREVIWERIMGS.push(url)
}) })
ipc.on('openPreviwerImg', function (event,url) { ipc.on('openPreviwerImg', function(event, url) {
global.PREVIWERIMG=global.PREVIWERIMGS.indexOf(url) global.PREVIWERIMG = global.PREVIWERIMGS.indexOf(url)
getPreviwerImgWindow() getPreviwerImgWindow()
}) })
ipc.on('openPreviwerVideo', function (event,url) { ipc.on('openPreviwerVideo', function(event, url) {
global.PREVIWERVIDEOURL=url global.PREVIWERVIDEOURL = url
getPreviwerVideoWindow() getPreviwerVideoWindow()
}) })
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) mainEvent.sender.send('new-screen-hot', content)
clipboard.writeImage(img) clipboard.writeImage(img)
}) })
ipc.on('setClipboard', function (event,content,type) { ipc.on('setClipboard', function(event, content, type) {
if(type==1){ if (type == 1) {
clipboard.writeText(content) clipboard.writeText(content)
} }
}) })
ipc.on('getNetworkImage', function (event,url) { ipc.on('getNetworkImage', function(event, url) {
http.get(url, function (res) { http.get(url, function(res) {
var chunks = []; var chunks = [];
var size = 0; var size = 0;
res.on('data', function (chunk) { res.on('data', function(chunk) {
chunks.push(chunk); chunks.push(chunk);
size += chunk.length;  //累加缓冲数据的长度 size += chunk.length;   //累加缓冲数据的长度
}); });
res.on('end', function (err) { res.on('end', function(err) {
var data = Buffer.concat(chunks, size); var data = Buffer.concat(chunks, size);
var base64Img = data.toString('base64'); var base64Img = data.toString('base64');
let img = nativeImage.createFromDataURL(`data:image/png;base64,${base64Img}`) let img = nativeImage.createFromDataURL(`data:image/png;base64,${base64Img}`)
...@@ -652,31 +656,31 @@ ipc.on('getNetworkImage', function (event,url) { ...@@ -652,31 +656,31 @@ ipc.on('getNetworkImage', function (event,url) {
}); });
}); });
}) })
ipc.on('screens-session', function (event) { ipc.on('screens-session', function(event) {
screenEvent=event screenEvent = event
}) })
ipc.on('open-screenhot', function (event) { ipc.on('open-screenhot', function(event) {
screenHotBegin() screenHotBegin()
}) })
ipc.on('delete-file', function (event,p) { ipc.on('delete-file', function(event, p) {
fs.unlink(p, function(err){}) fs.unlink(p, function(err) {})
}) })
ipc.on('send-file', function (event,obj) { ipc.on('send-file', function(event, obj) {
let {scene, to, filePath, name,size,md5,type,file} = obj let { scene, to, filePath, name, size, md5, type, file } = obj
let customMsg = { let customMsg = {
"msgtype":"custom_file", "msgtype": "custom_file",
"data":{ "data": {
"pushContent":name, "pushContent": name,
"Height":"84", "Height": "84",
"content":{ "content": {
"fileType":name.substring(name.lastIndexOf('.')+1,name.length), "fileType": name.substring(name.lastIndexOf('.') + 1, name.length),
"fileUrl":"-1", "fileUrl": "-1",
"fileName":name, "fileName": name,
"fileSize":size, "fileSize": size,
'md5':md5 'md5': md5
}, },
"recentContent":name, "recentContent": name,
"Width":"210" "Width": "210"
} }
} }
nim.sendFile({ nim.sendFile({
...@@ -685,70 +689,80 @@ ipc.on('send-file', function (event,obj) { ...@@ -685,70 +689,80 @@ ipc.on('send-file', function (event,obj) {
type, type,
filePath, filePath,
custom: JSON.stringify(customMsg), custom: JSON.stringify(customMsg),
uploadprogress: function(data){ uploadprogress: function(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() {
}, },
uploaddone: function (error, file) { uploaddone: function(error, file) {
file.progess=100 file.progess = 100
event.sender.send('sending-process',file) event.sender.send('sending-process', file)
}, },
beforesend: function (msg) {}, beforesend: function(msg) {},
done: function (error, msg) { done: function(error, msg) {
//onSendMsgDone(error, msg) //onSendMsgDone(error, msg)
} }
}) })
}) })
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'), '');
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) {
if(stats.size<=100*1024*1024){ if (stats.size <= 100 * 1024 * 1024) {
event.sender.send('new-send-file',filePath,stats.size) event.sender.send('new-send-file', filePath, stats.size)
return 'finish' return 'finish'
}else{ } else {
global.DIALOG_MESSAGE='发送的文件不能大于100M' global.DIALOG_MESSAGE = '发送的文件不能大于100M'
getDialogWindows() getDialogWindows()
} }
}else{ } else {
console.log(error) console.log(error)
} }
}) })
} }
return 'end' return 'end'
}) })
ipc.on('auto-update-clip', function (event) { ipc.on('auto-update-clip', function(event) {
let text = clipboard.readText(); let text = clipboard.readText();
if(text && text.length>0){ if (text && text.length > 0) {
text=escapeHTML(text) text = escapeHTML(text)
clipboard.writeText(text) clipboard.writeText(text)
} }
}) })
//global.CURRENT_TEAM_MEMBERS //global.CURRENT_TEAM_MEMBERS
ipc.on('createo-or-open-team', function (event,obj) { ipc.on('createo-or-open-team', function(event, obj) {
global.CURRENT_TEAM_MEMBERS=obj global.CURRENT_TEAM_MEMBERS = obj
getAddNewUserWinodes() getAddNewUserWinodes()
}) })
ipc.on('close-team-box', function (event,obj) { ipc.on('open-forward-msg', function(event, obj) {
if(addNewUserWinodes && !addNewUserWinodes.isDestroyed()){ global.FORWARD_MSG = obj
getForwardWindows()
})
ipc.on('close-team-box', function(event, obj) {
if (addNewUserWinodes && !addNewUserWinodes.isDestroyed()) {
addNewUserWinodes.close() addNewUserWinodes.close()
} }
}) })
ipc.on('save-team-members', function (event,obj) { ipc.on('close-forward', function(event, obj) {
mainEvent.sender.send('save-team-members',obj) if (forwardWindows && !forwardWindows.isDestroyed()) {
forwardWindows.close()
}
})
ipc.on('save-team-members', function(event, obj) {
mainEvent.sender.send('save-team-members', obj)
}) })
ipc.on('load-notice', function (event) { ipc.on('load-notice', function(event) {
getNoticeWindows() getNoticeWindows()
}) })
function escapeHTML(a) { function escapeHTML(a) {
return a.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/ /g, " ").replace(/"/g, "\"").replace(/'/g, "'") 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: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -758,7 +772,7 @@ let getLoginWindow=function(){ ...@@ -758,7 +772,7 @@ let getLoginWindow=function(){
height: 470, height: 470,
width: 330, width: 330,
icon: windowIcon, icon: windowIcon,
alwaysOnTop:true alwaysOnTop: true
}) })
loginWindow.loadURL(winURL) loginWindow.loadURL(winURL)
loginWindow.setMenu(null) loginWindow.setMenu(null)
...@@ -766,8 +780,8 @@ let getLoginWindow=function(){ ...@@ -766,8 +780,8 @@ let getLoginWindow=function(){
loginWindow.show() loginWindow.show()
}) })
} }
let getMainWinodw=function(isLoad){ let getMainWinodw = function(isLoad) {
if(!mainWindow || mainWindow.isDestroyed()){ if (!mainWindow || mainWindow.isDestroyed()) {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -777,16 +791,16 @@ let getMainWinodw=function(isLoad){ ...@@ -777,16 +791,16 @@ let getMainWinodw=function(isLoad){
height: 600, height: 600,
width: 900, width: 900,
icon: windowIcon, icon: windowIcon,
minWidth:850, minWidth: 850,
minHeight:580, minHeight: 580,
webPreferences:{webSecurity: false}, webPreferences: { webSecurity: false },
}) })
mainWindow.on('close', (e) => { mainWindow.on('close', (e) => {
mainWindow.hide() mainWindow.hide()
e.preventDefault() e.preventDefault()
}) })
} }
if(isLoad==0){ if (isLoad == 0) {
mainWindow.loadURL(mainUrl) mainWindow.loadURL(mainUrl)
mainWindow.once('ready-to-show', () => { mainWindow.once('ready-to-show', () => {
mainWindow.show() mainWindow.show()
...@@ -797,7 +811,7 @@ let getMainWinodw=function(isLoad){ ...@@ -797,7 +811,7 @@ let getMainWinodw=function(isLoad){
}) })
} }
//加载隐藏窗口防止用户关闭 //加载隐藏窗口防止用户关闭
if(!hideWindow || hideWindow.isDestroyed()){ if (!hideWindow || hideWindow.isDestroyed()) {
hideWindow = new BrowserWindow({ hideWindow = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -812,8 +826,8 @@ let getMainWinodw=function(isLoad){ ...@@ -812,8 +826,8 @@ let getMainWinodw=function(isLoad){
hideWindow.webContents.closeDevTools() hideWindow.webContents.closeDevTools()
} }
} }
let getPreviwerFileWindow=function(){ let getPreviwerFileWindow = function() {
if(!previewfileWindow || previewfileWindow.isDestroyed()){ if (!previewfileWindow || previewfileWindow.isDestroyed()) {
previewfileWindow = new BrowserWindow({ previewfileWindow = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -821,9 +835,9 @@ let getPreviwerFileWindow=function(){ ...@@ -821,9 +835,9 @@ let getPreviwerFileWindow=function(){
resizable: false, resizable: false,
show: false, show: false,
icon: windowIcon, icon: windowIcon,
width:electron.screen.getPrimaryDisplay().workAreaSize.width-40, width: electron.screen.getPrimaryDisplay().workAreaSize.width - 40,
height:electron.screen.getPrimaryDisplay().workAreaSize.height-40, height: electron.screen.getPrimaryDisplay().workAreaSize.height - 40,
skipTaskbar:true skipTaskbar: true
}) })
} }
previewfileWindow.loadURL(previewfileUrl) previewfileWindow.loadURL(previewfileUrl)
...@@ -834,8 +848,8 @@ let getPreviwerFileWindow=function(){ ...@@ -834,8 +848,8 @@ let getPreviwerFileWindow=function(){
previewfileWindow.show() previewfileWindow.show()
}) })
} }
let getPreviwerImgWindow=function(){ let getPreviwerImgWindow = function() {
if(!previwerImgWindow || previwerImgWindow.isDestroyed()){ if (!previwerImgWindow || previwerImgWindow.isDestroyed()) {
previwerImgWindow = new BrowserWindow({ previwerImgWindow = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -843,9 +857,9 @@ let getPreviwerImgWindow=function(){ ...@@ -843,9 +857,9 @@ let getPreviwerImgWindow=function(){
resizable: false, resizable: false,
show: false, show: false,
icon: windowIcon, icon: windowIcon,
width:electron.screen.getPrimaryDisplay().workAreaSize.width-40, width: electron.screen.getPrimaryDisplay().workAreaSize.width - 40,
height:electron.screen.getPrimaryDisplay().workAreaSize.height-40, height: electron.screen.getPrimaryDisplay().workAreaSize.height - 40,
skipTaskbar:true skipTaskbar: true
}) })
} }
previwerImgWindow.loadURL(previewfileImg) previwerImgWindow.loadURL(previewfileImg)
...@@ -857,8 +871,8 @@ let getPreviwerImgWindow=function(){ ...@@ -857,8 +871,8 @@ let getPreviwerImgWindow=function(){
}) })
} }
let getPreviwerVideoWindow=function(){ let getPreviwerVideoWindow = function() {
if(!previwerVideoWindow || previwerVideoWindow.isDestroyed()){ if (!previwerVideoWindow || previwerVideoWindow.isDestroyed()) {
previwerVideoWindow = new BrowserWindow({ previwerVideoWindow = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -866,9 +880,9 @@ let getPreviwerVideoWindow=function(){ ...@@ -866,9 +880,9 @@ let getPreviwerVideoWindow=function(){
resizable: false, resizable: false,
show: false, show: false,
icon: windowIcon, icon: windowIcon,
width:400, width: 400,
height:600, height: 600,
skipTaskbar:true skipTaskbar: true
}) })
} }
previwerVideoWindow.loadURL(previewfVideoUrl) previwerVideoWindow.loadURL(previewfVideoUrl)
...@@ -878,10 +892,10 @@ let getPreviwerVideoWindow=function(){ ...@@ -878,10 +892,10 @@ let getPreviwerVideoWindow=function(){
previwerVideoWindow.once('ready-to-show', () => { previwerVideoWindow.once('ready-to-show', () => {
previwerVideoWindow.show() previwerVideoWindow.show()
}) })
} }
//dialogWindows //dialogWindows
let getDialogWindows=function(){ let getDialogWindows = function() {
if(!dialogWindows || dialogWindows.isDestroyed()){ if (!dialogWindows || dialogWindows.isDestroyed()) {
dialogWindows = new BrowserWindow({ dialogWindows = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -889,10 +903,10 @@ let getDialogWindows=function(){ ...@@ -889,10 +903,10 @@ let getDialogWindows=function(){
resizable: false, resizable: false,
show: false, show: false,
icon: windowIcon, icon: windowIcon,
width:300, width: 300,
height:150, height: 150,
skipTaskbar:true, skipTaskbar: true,
alwaysOnTop:true alwaysOnTop: true
}) })
} }
dialogWindows.loadURL(dialogUrl) dialogWindows.loadURL(dialogUrl)
...@@ -900,10 +914,10 @@ let getDialogWindows=function(){ ...@@ -900,10 +914,10 @@ let getDialogWindows=function(){
dialogWindows.once('ready-to-show', () => { dialogWindows.once('ready-to-show', () => {
dialogWindows.show() dialogWindows.show()
}) })
} }
//noticeWindows //noticeWindows
let getNoticeWindows=function(){ let getNoticeWindows = function() {
if(!noticeWindows || noticeWindows.isDestroyed()){ if (!noticeWindows || noticeWindows.isDestroyed()) {
noticeWindows = new BrowserWindow({ noticeWindows = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -911,10 +925,10 @@ let getNoticeWindows=function(){ ...@@ -911,10 +925,10 @@ let getNoticeWindows=function(){
resizable: false, resizable: false,
show: false, show: false,
icon: windowIcon, icon: windowIcon,
width:300, width: 300,
height:115, height: 115,
skipTaskbar:true, skipTaskbar: true,
alwaysOnTop:true alwaysOnTop: true
}) })
noticeWindows.setBounds({ noticeWindows.setBounds({
y: electron.screen.getPrimaryDisplay().workAreaSize.height - 115, y: electron.screen.getPrimaryDisplay().workAreaSize.height - 115,
...@@ -929,8 +943,8 @@ let getNoticeWindows=function(){ ...@@ -929,8 +943,8 @@ let getNoticeWindows=function(){
noticeWindows.show() noticeWindows.show()
}) })
} }
let getAddNewUserWinodes=function(){ let getAddNewUserWinodes = function() {
if(!addNewUserWinodes || addNewUserWinodes.isDestroyed()){ if (!addNewUserWinodes || addNewUserWinodes.isDestroyed()) {
addNewUserWinodes = new BrowserWindow({ addNewUserWinodes = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -938,24 +952,49 @@ let getAddNewUserWinodes=function(){ ...@@ -938,24 +952,49 @@ let getAddNewUserWinodes=function(){
resizable: false, resizable: false,
show: false, show: false,
icon: windowIcon, icon: windowIcon,
width:500, width: 500,
height:430, height: 430,
skipTaskbar:true, skipTaskbar: true,
alwaysOnTop:true alwaysOnTop: true
}) })
addNewUserWinodes.loadURL(addnewuserUrl) addNewUserWinodes.loadURL(addnewuserUrl)
addNewUserWinodes.setMenu(null) addNewUserWinodes.setMenu(null)
addNewUserWinodes.once('ready-to-show', () => { addNewUserWinodes.once('ready-to-show', () => {
addNewUserWinodes.show() addNewUserWinodes.show()
}) })
}else{ } else {
addNewUserWinodes.focus() addNewUserWinodes.focus()
} }
} }
let getNewMsgWindows=function(){ let getForwardWindows = function() {
if(!newMsgWindow || newMsgWindow.isDestroyed()){ if (!forwardWindows || forwardWindows.isDestroyed()) {
forwardWindows = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(),
frame: false,
maximizable: true,
resizable: false,
show: false,
icon: windowIcon,
width: 500,
height: 430,
skipTaskbar: true,
alwaysOnTop: true
})
forwardWindows.loadURL(forwardUrl)
forwardWindows.setMenu(null)
forwardWindows.once('ready-to-show', () => {
forwardWindows.show()
})
} else {
forwardWindows.focus()
}
}
let getNewMsgWindows = function() {
if (!newMsgWindow || newMsgWindow.isDestroyed()) {
newMsgWindow = new BrowserWindow({ newMsgWindow = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
frame: false, frame: false,
...@@ -966,13 +1005,13 @@ let getNewMsgWindows=function(){ ...@@ -966,13 +1005,13 @@ let getNewMsgWindows=function(){
alwaysOnTop: true, alwaysOnTop: true,
width: 260, width: 260,
icon: windowIcon, icon: windowIcon,
skipTaskbar:true skipTaskbar: true
}) })
} }
let urls = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/newmsg` : `file://${__dirname}/index.html#newmsg` let urls = process.env.NODE_ENV === 'development' ? `http://localhost:9080/#/newmsg` : `file://${__dirname}/index.html#newmsg`
newMsgWindow.loadURL(urls) newMsgWindow.loadURL(urls)
} }
let getScrollerhotWindows=function(){ let getScrollerhotWindows = function() {
// let scroll_info=electron.screen.getAllDisplays() // let scroll_info=electron.screen.getAllDisplays()
scrollerhotWindows = new BrowserWindow({ scrollerhotWindows = new BrowserWindow({
transparent: systemPreferences.isAeroGlassEnabled(), transparent: systemPreferences.isAeroGlassEnabled(),
...@@ -982,50 +1021,50 @@ let getScrollerhotWindows=function(){ ...@@ -982,50 +1021,50 @@ let getScrollerhotWindows=function(){
show: false, show: false,
alwaysOnTop: true, alwaysOnTop: true,
icon: windowIcon, icon: windowIcon,
webPreferences:{webSecurity: false}, webPreferences: { webSecurity: false },
skipTaskbar:true 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 screenHotBegin=function(){ let screenHotBegin = function() {
let p=process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1)+'PrintScr.exe' let p = process.execPath.substring(0, process.execPath.lastIndexOf('\\') + 1) + 'PrintScr.exe'
var screen_window = cp.execFile(p) var screen_window = cp.execFile(p)
screen_window.on('exit', function (code) { screen_window.on('exit', function(code) {
// 执行成功返回 1,返回 0 没有截图 // 执行成功返回 1,返回 0 没有截图
if (code){ if (code) {
mainEvent.sender.send('new-screen-hot',clipboard.readImage().toDataURL()) mainEvent.sender.send('new-screen-hot', clipboard.readImage().toDataURL())
} }
}) })
} }
let registScrollerHotKey=function(){ let registScrollerHotKey = function() {
globalShortcut.register('CommandOrControl+Alt+Q', function () { globalShortcut.register('CommandOrControl+Alt+Q', function() {
screenHotBegin() 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
"d+" : date.getDate(), //day "d+": date.getDate(), //day
"h+" : date.getHours(), //hour "h+": date.getHours(), //hour
"m+" : date.getMinutes(), //minute "m+": date.getMinutes(), //minute
"s+" : date.getSeconds(), //second "s+": date.getSeconds(), //second
"q+" : Math.floor((date.getMonth()+3)/3), //quarter "q+": Math.floor((date.getMonth() + 3) / 3), //quarter
"S" : date.getMilliseconds() //millisecond "S": date.getMilliseconds() //millisecond
}; };
if(/(y+)/.test(format)) { if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length)); format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
} }
for(var k in o) { for (var k in o) {
if(new RegExp("("+ k +")").test(format)) { if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
} }
} }
return format; return format;
}; };
let initNIM=function(uid,token){ let initNIM = function(uid, token) {
try { try {
nim = SDK.getInstance({ nim = SDK.getInstance({
debug: false, debug: false,
...@@ -1042,10 +1081,12 @@ let initNIM=function(uid,token){ ...@@ -1042,10 +1081,12 @@ let initNIM=function(uid,token){
function onConnect() { function onConnect() {
} }
function onWillReconnect(obj) { function onWillReconnect(obj) {
// 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接 // 此时说明 SDK 已经断开连接, 请开发者在界面上提示用户连接已断开, 而且正在重新建立连接
} }
function onDisconnect(error) { function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面 // 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
...@@ -1065,6 +1106,7 @@ let initNIM=function(uid,token){ ...@@ -1065,6 +1106,7 @@ let initNIM=function(uid,token){
} }
} }
} }
function onError(error) { function onError(error) {
console.log(error); console.log(error);
} }
......
...@@ -164,6 +164,8 @@ export default { ...@@ -164,6 +164,8 @@ export default {
this.MsgBus.$emit("delete-members",obj.teamMembers) this.MsgBus.$emit("delete-members",obj.teamMembers)
}else if(obj.action=='create'){ }else if(obj.action=='create'){
this.MsgBus.$emit("create-group",obj.teamMembers) this.MsgBus.$emit("create-group",obj.teamMembers)
}else if(obj.action=='forward'){
this.MsgBus.$emit("goForward",obj.sessions)
} }
// //
}) })
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
v-if="msg.type=='image' || msg.type=='video' || msg.type=='audio'" v-if="msg.type=='image' || msg.type=='video' || msg.type=='audio'"
@click="downloadFile(msg,1)" @click="downloadFile(msg,1)"
>另存为...</v-contextmenu-item> >另存为...</v-contextmenu-item>
<v-contextmenu-item @click="forwardMsg(msg)">转发</v-contextmenu-item>
<v-contextmenu-item divider v-if="msg.flow==='out'"></v-contextmenu-item> <v-contextmenu-item divider v-if="msg.flow==='out'"></v-contextmenu-item>
<v-contextmenu-item @click="revocateMsg" v-if="msg.flow==='out'">撤回消息</v-contextmenu-item> <v-contextmenu-item @click="revocateMsg" v-if="msg.flow==='out'">撤回消息</v-contextmenu-item>
</v-contextmenu> </v-contextmenu>
...@@ -770,6 +771,9 @@ export default { ...@@ -770,6 +771,9 @@ export default {
// 在会话聊天页 // 在会话聊天页
this.$store.dispatch("revocateMsg", this.msg); this.$store.dispatch("revocateMsg", this.msg);
}, },
forwardMsg(msg){
this.MsgBus.$emit("forward",msg);
},
sendRobotBlockMsg(msg, originMsg) { sendRobotBlockMsg(msg, originMsg) {
if (this.isHistory) { if (this.isHistory) {
// 在历史消息中,不进行机器人交互 // 在历史消息中,不进行机器人交互
......
...@@ -225,7 +225,8 @@ export default { ...@@ -225,7 +225,8 @@ export default {
noticeLastTime:0, noticeLastTime:0,
isNetError:true, isNetError:true,
audio_base:'', audio_base:'',
atIds:null atIds:null,
forwardMsgInfo:{}
}; };
}, },
updated() { updated() {
...@@ -455,6 +456,20 @@ export default { ...@@ -455,6 +456,20 @@ export default {
this.MsgBus.$on("create-group", function(members) { this.MsgBus.$on("create-group", function(members) {
that.createGroup(members); that.createGroup(members);
}); });
this.MsgBus.$on("forward",function(msg){
that.forwardMsgInfo=msg
console.log(that.forwardMsgInfo)
that.$electron.ipcRenderer.send("open-forward-msg",that.sessionlist);
})
this.MsgBus.$on("goForward",function(sessions){
sessions.forEach(x=>{
that.$store.dispatch("forwardMsg", {
scene: x.scene,
to: x.to,
msg: that.forwardMsgInfo
});
})
})
this.MsgBus.$on("dispose-session", function() { this.MsgBus.$on("dispose-session", function() {
that.$store.dispatch("resetCurrSession"); that.$store.dispatch("resetCurrSession");
that.currentSession = { that.currentSession = {
......
<template>
<div class="forward-msg">
<div class="header__opera">
<span class="opera__item close" @click="close">
<i class="iconfont iconguanbi"></i>
</span>
</div>
<div class="split"></div>
<div class="content">
<div class="panle">
<div class="search__user_box">
<div class="seach_ctr">
<span class="seach__item__icon">
<i class="iconfont iconsearch"></i>
</span>
<input
type="text"
@keyup="getSearch"
class="seach__item__input"
v-model="searchMember"
placeholder="搜索"
>
</div>
</div>
<ul class="members" style="bottom:0px;top:37px;">
<li class="split-title" v-if="searchMember!=''">最近会话</li>
<template v-for="(item, index) in sessions">
<li :key="index" v-if="searchMember=='' || item.name.indexOf(searchMember)!=-1">
<img :src="item.avatar" class="h" v-if="item.avatar">
<i class="iconfont icontaolun head-i" v-else-if="item.groupType == 0"></i>
<i class="iconfont iconqunzu head-i" v-else-if="item.groupType == 1"></i>
<i class="iconfont iconyonghutouxiang head-i" v-else></i>
<div class="u">{{item.name}}</div>
<div>
<el-checkbox
:checked="isExsitmember(item.to)"
@change="checked=>chosenChange(index,item,checked)"
></el-checkbox>
</div>
</li>
</template>
<li class="split-title" v-if="searchResults && searchResults.length>0">同事</li>
<template v-for="(item, index) in searchResults">
<li :key="index">
<img :src="item.avatar" class="h" v-if="item.avatar">
<img src="../../assets/img/litheader.png" class="h" v-else>
<div class="u">{{item.name}}</div>
<div>
<el-checkbox
:checked="isExsitmember(item.to)"
@change="checked=>chosenChange(index,item,checked)"
></el-checkbox>
</div>
</li>
</template>
</ul>
</div>
<div class="panle">
<div class="remark">分别转发给:</div>
<ul class="members" v-loading="isLoading">
<template v-for="(item, index) in checkNodes">
<li :key="index">
<img :src="item.avatar" class="h" v-if="item.avatar">
<i class="iconfont icontaolun head-i" v-else-if="item.groupType == 0"></i>
<i class="iconfont iconqunzu head-i" v-else-if="item.groupType == 1"></i>
<img src="../../assets/img/litheader.png" class="h" v-else>
<div class="u">{{item.name}}</div>
</li>
</template>
</ul>
<div class="bnt-box">
<el-button type="primary" :disabled="checkNodes.length==0" size="mini" @click="save">确定</el-button>
<el-button size="mini" @click="close">取消</el-button>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
groupboxSearch: 0,
webAllpartList: [],
searchMember: "",
checkNodes: [],
sessions: [],
searchResults: [],
isLoading: false,
action:'forward',
deleteCount:0
};
},
mounted() {
this.sessions=this.$electron.remote.getGlobal("FORWARD_MSG")
},
methods: {
save(){
let obj={
action:this.action,
sessions:this.checkNodes
}
this.$electron.ipcRenderer.send('save-team-members',obj)
this.close()
},
chosenChange(index, item, checked){
if (checked) {
this.checkNodes.push(item)
}else{
let i=0
this.checkNodes.forEach((x,index)=>{
if(x.to==item.to){
i=index
return false
}
})
this.checkNodes.splice(i,1)
}
},
handleChosenChange(index, item, checked) {
if (item) {
item.isCheck = checked;
this.$set(this.searchResults, index, item);
if (!checked) {
this.delMember(item.imAccount);
} else {
if (item.imAccount && !this.isExsitmember(item.imAccount).h) {
let member = {
account: item.imAccount,
alias: item.name,
avatar: item.icon,
isExsit:false
};
if(this.teamMembers.length<200)
this.teamMembers.push(member);
}
}
}
},
getSearch() {
this.searchResults=[]
if (this.searchMember != "") {
this.apipost(
"admin_Get_Chat_All_SelectEmpName",
{ EmName: this.searchMember },
res => {
if (res.data.resultCode == 1) {
this.searchResults = res.data.data.filter(x => {
if (!x.imAccount) {
return;
}
x.scene = 'p2p'
x.to=x.imAccount
x.avatar=x.icon
x.groupType=3
return x;
});
console.log(this.searchResults)
}
},
err => {}
);
}
},
isExsitmember(account) {
let isExsit=false
this.checkNodes.forEach(x=>{
if(x.to==account){
isExsit=true
return false
}
})
return isExsit;
},
close() {
this.$electron.remote.getCurrentWindow().close();
},
handleCheckChange(data, checked, indeterminate) {
this.checkNodes = this.$refs.tree.getCheckedNodes();
}
}
};
</script>
<style>
.forward-msg {
width: 100%;
height: 100%;
box-sizing: border-box;
border: 1px solid #ddd;
box-shadow: 0 0 2px #ccc;
background: #fff;
padding-top: 20px;
-webkit-app-region: drag !important;
}
.forward-msg .members .head-i{
width: 40px;
height: 40px;
border-radius: 100%;
margin-right: 10px;
background: #2d98da;
line-height: 40px;
text-align: center;
font-size: 22px;
color: #FFF;
}
.forward-msg .el-tree {
cursor: default;
background: #fff;
padding-left: 12px;
border: none;
}
.forward-msg .el-tree-node__content:hover {
background: transparent;
}
.el-tree-node__content {
line-height: 30px;
}
.forward-msg .header__opera {
position: absolute;
top: 0px;
right: 0px;
text-align: right;
}
.forward-msg .split {
position: absolute;
top: 3px;
left: 50%;
bottom: 3px;
width: 1px;
background: #eee;
z-index: 3;
}
.forward-msg .content {
display: flex;
position: absolute;
top: 23px;
left: 3px;
right: 3px;
bottom: 3px;
-webkit-app-region: no-drag !important;
}
.forward-msg .content .panle {
flex: 1;
position: relative;
}
.forward-msg .content .split-title{
height: 20px !important;
line-height: 20px !important;
padding: 0 10px !important;
font-size: 12px;
color: #777;
background: #f1f1f1;
font-family: 'microsoft yahei' !important;
}
.forward-msg .content .panle .remark {
margin: 0 20px 10px 20px;
font-size: 12px;
}
.forward-msg .content .panle .search__user_box {
display: flex;
margin: 0 20px 10px 20px;
}
.forward-msg .content .panle .search__user_box .seach_ctr {
flex: 1;
position: relative;
}
.forward-msg .content .panle .search__user_box .seach_ctr .seach__item__input {
width: 100%;
text-indent: 23px;
height: 23px;
line-height: 23px;
border: none;
border: 1px solid rgb(225, 225, 225);
outline: none;
font-size: 12px;
color: #000;
background: transparent;
box-sizing: border-box;
background: rgb(225, 225, 225);
border-radius: 2px;
}
.forward-msg
.content
.panle
.search__user_box
.seach_ctr
.seach__item__input:focus {
background: #fff;
}
.forward-msg .content .panle .search__user_box .seach_ctr .seach__item__icon {
font-size: 14px;
color: #999;
position: absolute;
top: 2px;
left: 0;
padding-left: 7px;
max-width: 24px !important;
}
.forward-msg .content .panle .search__user_box .seach_ctr .seach__item__icon i {
font-size: 12px;
}
.forward-msg .content .panle .members {
position: absolute;
top: 26px;
left: 0;
right: 0;
bottom: 30px;
overflow-y: auto;
margin: 0;
padding: 0;
}
.forward-msg .content .panle .members li {
padding: 0 20px;
height: 58px;
display: flex;
align-items: center;
cursor: default;
}
.forward-msg .content .panle .members li .el-checkbox__inner {
width: 20px;
height: 20px;
border-radius: 100%;
}
.forward-msg .content .panle .members li .el-checkbox__inner::after {
left: 7px;
top: 4px;
}
.forward-msg .content .panle .members li .h {
width: 40px;
height: 40px;
border-radius: 100%;
margin-right: 10px;
}
.forward-msg .content .panle .members li .u {
flex: 1;
font-size: 14px;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
}
.forward-msg .content .panle .members li .i {
width: 20px;
cursor: pointer;
}
.forward-msg .content .panle .members li .i i {
font-size: 14px;
color: #ddd;
}
.forward-msg .content .panle .members li:hover {
background: rgb(241, 241, 241);
}
.forward-msg .content .panle .members li .i i:hover {
color: #999;
}
.forward-msg .content .panle .bnt-box {
text-align: right;
position: absolute;
bottom: 0px;
left: 0;
right: 0;
height: 30px;
line-height: 30px;
padding: 0 20px;
}
.forward-msg .content .panle .bnt-box .el-button--mini,
.forward-msg .content .panle .bnt-box .el-button--mini.is-round {
padding: 4px 12px;
}
.forward-msg .header__opera .opera__item {
padding: 2px 5px;
color: #aaa;
cursor: pointer;
display: inline-block;
-webkit-app-region: no-drag !important;
}
.forward-msg .header__opera .opera__item i {
font-size: 14px;
}
.forward-msg .header__opera .close:hover {
color: #f1f1f1;
background: #eb3b5a;
}
.forward-msg .header__opera .opera__item.min:hover {
background: rgba(255, 255, 255, 0.2);
}
.forward-msg .new-group-name .search-input {
width: 100%;
height: 30px;
line-height: 30px;
padding: 5px;
box-sizing: border-box;
border: 1.5px solid #ddd;
border-radius: 1.5px;
color: #666;
}
.forward-msg .group-body {
width: 100%;
display: flex;
height: 360px;
overflow: hidden;
}
.forward-msg .group-foot {
width: 100%;
display: block;
height: 40px;
text-align: right;
}
.forward-msg .search-input {
width: 100%;
height: 30px;
line-height: 30px;
padding: 5px;
box-sizing: border-box;
border: 1.5px solid #ddd;
border-radius: 1.5px;
color: #666;
}
.forward-msg .search-input:focus,
.forward-msg .new-group-name .search-input:focus {
border: 1.5px solid #bbb;
border-radius: 1.5px;
}
.forward-msg .search-result-box {
height: calc(100% - 34px);
font-size: 14px;
position: relative;
color: #000;
font-weight: 600;
}
/* .forward-msg .search-result-box .tree-box .el-tree *:not(i) {
font-family: 'Microsoft YaHei' !important;
} */
.forward-msg .search-result-box .tree-box {
overflow-y: auto;
position: absolute;
top: 0;
bottom: 35px;
left: 0;
right: 0;
}
.forward-msg .search-result-box .sure-bottom {
position: absolute;
bottom: 0px;
left: 0;
right: 0;
height: 30px;
background: #ddd;
color: #999;
text-align: center;
line-height: 30px;
font-size: 14px;
font-weight: 300;
cursor: pointer;
}
.forward-msg .search-result-box .sure-bottom.active {
background: #409eff;
color: #f1f1f1;
}
.forward-msg .search-result-box .el-tree-node__content {
height: auto !important;
}
.forward-msg .search-result-box .IM_messageList {
top: 0px;
bottom: 0px;
}
.forward-msg .search-result-box .IM_messageList ul li {
height: 40px;
padding: 5px;
}
.forward-msg .search-result-box .IM_messageList ul li img {
height: 30px;
width: 30px;
}
.forward-msg .search-result-box .IM_messageList ul li .close {
visibility: hidden;
position: absolute;
top: 7px;
right: 10px;
}
.forward-msg .search-result-box .IM_messageList ul li:hover .close {
visibility: visible;
}
.forward-msg .group-body .team-member-box {
position: absolute;
left: 0;
top: 0px;
right: 0;
height: 200px;
padding: 10px;
border-bottom: 1px solid #d9d9d9;
background-color: #fff;
box-shadow: none;
z-index: 2;
}
.forward-msg .group-body .team-member-box ul {
width: 100%;
height: 100%;
display: flex;
overflow-y: auto;
flex-wrap: wrap;
padding-top: 10px;
}
.forward-msg .group-body .team-member-box ul li {
width: 120px;
text-align: center;
height: 100px;
position: relative;
}
.forward-msg .group-body .team-member-box ul li img {
width: 48px;
height: 48px;
border-radius: 100%;
}
.forward-msg .group-body .team-member-box ul li span {
display: block;
padding: 0 3px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 14px;
}
.forward-msg .group-body .team-member-box ul li .icon-close1 {
position: absolute;
top: -11px;
right: 28px;
cursor: pointer;
}
.forward-msg .group-body .team-member-box ul li .icon-close1:hover {
color: #ef4455;
}
.forward-msg .cl-name {
padding: 5px 0;
font-size: 14px;
color: #999;
font-family: PingFangSC-Semibold !important;
margin: 15px 0 0 0;
}
</style>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
></div> ></div>
<div class="tool-copy" :style="{'top': toolTop+'px','left': toolLeft+'px'}" v-if="toolShow"> <div class="tool-copy" :style="{'top': toolTop+'px','left': toolLeft+'px'}" v-if="toolShow">
<!-- <li>复制</li> --> <!-- <li>复制</li> -->
<li @click="toolPaste">粘贴</li> <li @paste="toolPaste">粘贴</li>
</div> </div>
</at> </at>
</template> </template>
...@@ -206,7 +206,7 @@ export default { ...@@ -206,7 +206,7 @@ export default {
methods: { methods: {
toolPaste: function (e) { toolPaste: function (e) {
let clipboardData = 1 let clipboardData = 1
console.log(e) console.log('111111111',e)
}, },
copyBox: function (e) { copyBox: function (e) {
this.toolTop = e.offsetY this.toolTop = e.offsetY
......
...@@ -3,8 +3,7 @@ import Router from 'vue-router' ...@@ -3,8 +3,7 @@ import Router from 'vue-router'
Vue.use(Router) Vue.use(Router)
export default new Router({ export default new Router({
routes: [ routes: [{
{
path: '/', path: '/',
name: 'landing-page', name: 'landing-page',
component: require('@/components/login') component: require('@/components/login')
...@@ -53,6 +52,11 @@ export default new Router({ ...@@ -53,6 +52,11 @@ export default new Router({
path: '/notice', path: '/notice',
name: 'notice', name: 'notice',
component: require('@/components/tools/notice') component: require('@/components/tools/notice')
},
{
path: '/forwardMsg',
name: 'forwardMsg',
component: require('@/components/team/forwardMsg')
} }
] ]
}) })
\ No newline at end of file
...@@ -92,7 +92,7 @@ export function forwardMsg({ state, commit }, obj) { ...@@ -92,7 +92,7 @@ export function forwardMsg({ state, commit }, obj) {
nim.forwardMsg({ nim.forwardMsg({
scene: obj.scene, scene: obj.scene,
to: obj.to, to: obj.to,
msg: obj.tip, msg: obj.msg,
done: function(err, msg) { done: function(err, msg) {
onMsg(msg) onMsg(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