Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Madara
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
Madara
Commits
4669e85c
Commit
4669e85c
authored
Sep 29, 2019
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
93929c38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
708 additions
and
696 deletions
+708
-696
index.js
src/configs/index.js
+33
-33
index.js
src/main/index.js
+11
-7
App.vue
src/renderer/App.vue
+3
-0
index.vue
src/renderer/components/index.vue
+0
-1
chateditor.vue
src/renderer/components/msssage/chateditor.vue
+1
-0
index.vue
src/renderer/components/msssage/index.vue
+3
-1
session.js
src/store/actions/session.js
+78
-78
index.js
src/store/mutations/index.js
+579
-576
No files found.
src/configs/index.js
View file @
4669e85c
let
config
=
{
let
config
=
{
sdk
:
'NIM_Web_SDK_nodejs_v5.9.1'
,
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'
,
homeUrl
:
'/webdemo/h5/index.html#/session'
,
homeUrl
:
'/webdemo/h5/index.html#/session'
,
// 资源路径根目录,为了方便用户部署在二级以上URL路径上
// 资源路径根目录,为了方便用户部署在二级以上URL路径上
resourceUrl
:
'http://yx-web.nos.netease.com/webdoc/h5'
,
resourceUrl
:
'http://yx-web.nos.netease.com/webdoc/h5'
,
// 用户logo地址
// 用户logo地址
logo
:
'http://yx-web.nos.netease.com/webdoc/h5/im/logo.png'
,
logo
:
'http://yx-web.nos.netease.com/webdoc/h5/im/logo.png'
,
// 默认用户头像
// 默认用户头像
defaultUserIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/default-icon.png'
,
defaultUserIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/default-icon.png'
,
// 默认普通群头像
// 默认普通群头像
defaultGroupIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/default-group.png'
,
defaultGroupIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/default-group.png'
,
// 默认高级群头像
// 默认高级群头像
defaultAdvancedIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/default-advanced.png'
,
defaultAdvancedIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/default-advanced.png'
,
// 系统通知图标
// 系统通知图标
noticeIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/notice-icon.png'
,
noticeIcon
:
'http://yx-web.nos.netease.com/webdoc/h5/im/notice-icon.png'
,
// 我的手机图标
// 我的手机图标
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
:
36
,
useDb
:
false
useDb
:
false
}
}
const
env
=
'online'
const
env
=
'online'
let
appConfig
=
{
let
appConfig
=
{
// 用户的appkey
// 用户的appkey
// 用于在web demo中注册账号异步请求demo 服务器中使用
// 用于在web demo中注册账号异步请求demo 服务器中使用
test
:
{
test
:
{
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
postUrl
:
'https://apptest.netease.im'
postUrl
:
'https://apptest.netease.im'
},
},
online
:
{
online
:
{
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
postUrl
:
'https://app.netease.im'
postUrl
:
'https://app.netease.im'
}
}
}
}
config
=
Object
.
assign
(
config
,
appConfig
[
env
])
config
=
Object
.
assign
(
config
,
appConfig
[
env
])
export
default
config
export
default
config
\ No newline at end of file
src/main/index.js
View file @
4669e85c
...
@@ -79,6 +79,8 @@ const addnewuserUrl = process.env.NODE_ENV === 'development' ? `http://localhost
...
@@ -79,6 +79,8 @@ const addnewuserUrl = process.env.NODE_ENV === 'development' ? `http://localhost
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`
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, '
\\\\
')
...
@@ -290,8 +292,8 @@ app.on('activate', () => {
...
@@ -290,8 +292,8 @@ app.on('activate', () => {
createWindow()
createWindow()
}
}
})
})
ipc.on('
reconnect
',
function(event)
{
ipc.on('
reconnect
',
function(event)
{
nim
=
null
nim
=
null
initNIM(global.LOGINUSER.ImAccount, global.LOGINUSER.ImToken)
initNIM(global.LOGINUSER.ImAccount, global.LOGINUSER.ImToken)
})
})
ipc.on('
loginSuccess
', function(event, userInfo) {
ipc.on('
loginSuccess
', function(event, userInfo) {
...
@@ -697,6 +699,7 @@ ipc.on('send-file', function(event, obj) {
...
@@ -697,6 +699,7 @@ ipc.on('send-file', function(event, obj) {
custom: JSON.stringify(customMsg),
custom: JSON.stringify(customMsg),
uploadprogress: function(data) {
uploadprogress: function(data) {
file.progess = data.percentage
file.progess = data.percentage
console.log(file)
event.sender.send('
sending
-
process
', file)
event.sender.send('
sending
-
process
', file)
},
},
uploaderror: function() {
uploaderror: function() {
...
@@ -814,8 +817,8 @@ let getMainWinodw = function(isLoad) {
...
@@ -814,8 +817,8 @@ let getMainWinodw = function(isLoad) {
mainWindow
.
show
()
mainWindow
.
show
()
mainWindow
.
setAlwaysOnTop
(
true
)
mainWindow
.
setAlwaysOnTop
(
true
)
mainWindow
.
setAlwaysOnTop
(
false
)
mainWindow
.
setAlwaysOnTop
(
false
)
//mainWindow.webContents.openDevTools(true);
//mainWindow.webContents.openDevTools(true);
//getNoticeWindows()
//getNoticeWindows()
})
})
}
}
//加载隐藏窗口防止用户关闭
//加载隐藏窗口防止用户关闭
...
@@ -936,7 +939,8 @@ let getNoticeWindows = function() {
...
@@ -936,7 +939,8 @@ let getNoticeWindows = function() {
width
:
300
,
width
:
300
,
height
:
115
,
height
:
115
,
skipTaskbar
:
true
,
skipTaskbar
:
true
,
alwaysOnTop
:
true
alwaysOnTop
:
false
,
focusable
:
false
})
})
noticeWindows
.
setBounds
({
noticeWindows
.
setBounds
({
y
:
electron
.
screen
.
getPrimaryDisplay
().
workAreaSize
.
height
-
115
,
y
:
electron
.
screen
.
getPrimaryDisplay
().
workAreaSize
.
height
-
115
,
...
@@ -970,7 +974,7 @@ let getAddNewUserWinodes = function() {
...
@@ -970,7 +974,7 @@ let getAddNewUserWinodes = function() {
addNewUserWinodes
.
setMenu
(
null
)
addNewUserWinodes
.
setMenu
(
null
)
addNewUserWinodes
.
once
(
'ready-to-show'
,
()
=>
{
addNewUserWinodes
.
once
(
'ready-to-show'
,
()
=>
{
addNewUserWinodes
.
show
()
addNewUserWinodes
.
show
()
//addNewUserWinodes.webContents.openDevTools(true);
//addNewUserWinodes.webContents.openDevTools(true);
})
})
}
else
{
}
else
{
addNewUserWinodes
.
focus
()
addNewUserWinodes
.
focus
()
...
@@ -1099,7 +1103,6 @@ let initNIM = function(uid, token) {
...
@@ -1099,7 +1103,6 @@ let initNIM = function(uid, token) {
function onDisconnect(error) {
function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
if (error) {
if (error) {
switch (error.code) {
switch (error.code) {
// 账号或者密码错误, 请跳转到登录页面并提示错误
// 账号或者密码错误, 请跳转到登录页面并提示错误
...
@@ -1115,6 +1118,7 @@ let initNIM = function(uid, token) {
...
@@ -1115,6 +1118,7 @@ let initNIM = function(uid, token) {
break;
break;
}
}
}
}
console.log('
异常了
');
}
}
function onError(error) {
function onError(error) {
...
...
src/renderer/App.vue
View file @
4669e85c
...
@@ -9,6 +9,9 @@
...
@@ -9,6 +9,9 @@
export
default
{
export
default
{
name
:
"MageOffice"
,
name
:
"MageOffice"
,
mounted
()
{
mounted
()
{
window
.
alert
=
function
()
{
return
false
;
}
document
.
querySelector
(
'#app'
).
addEventListener
(
document
.
querySelector
(
'#app'
).
addEventListener
(
"dragover"
,
"dragover"
,
function
(
e
)
{
function
(
e
)
{
...
...
src/renderer/components/index.vue
View file @
4669e85c
...
@@ -195,7 +195,6 @@ export default {
...
@@ -195,7 +195,6 @@ export default {
},
8
*
1000
);
},
8
*
1000
);
},
},
atMsg
(){
atMsg
(){
console
.
log
(
11111111111111
)
this
.
MsgBus
.
$emit
(
'send-at-name'
,
this
.
atInfo
.
atName
)
this
.
MsgBus
.
$emit
(
'send-at-name'
,
this
.
atInfo
.
atName
)
},
},
showCard
(
e
){
showCard
(
e
){
...
...
src/renderer/components/msssage/chateditor.vue
View file @
4669e85c
...
@@ -85,6 +85,7 @@ export default {
...
@@ -85,6 +85,7 @@ export default {
});
});
this
.
$electron
.
ipcRenderer
.
on
(
"sending-process"
,
(
event
,
file
)
=>
{
this
.
$electron
.
ipcRenderer
.
on
(
"sending-process"
,
(
event
,
file
)
=>
{
console
.
log
(
file
)
this
.
GLOBALSENDING
.
forEach
(
x
=>
{
this
.
GLOBALSENDING
.
forEach
(
x
=>
{
if
((
x
.
msgId
=
file
.
msgId
))
{
if
((
x
.
msgId
=
file
.
msgId
))
{
x
=
file
;
x
=
file
;
...
...
src/renderer/components/msssage/index.vue
View file @
4669e85c
...
@@ -590,7 +590,9 @@ export default {
...
@@ -590,7 +590,9 @@ export default {
lastMsg
.
type
===
"notification"
&&
lastMsg
.
type
===
"notification"
&&
lastMsg
.
attach
&&
lastMsg
.
attach
&&
lastMsg
.
attach
.
team
&&
lastMsg
.
attach
.
team
&&
lastMsg
.
attach
.
team
.
custom
lastMsg
.
attach
.
team
.
custom
&&
this
.
$store
.
state
.
msgs
[
item
.
id
]
&&
this
.
$store
.
state
.
msgs
[
item
.
id
].
length
>
0
)
{
)
{
for
(
let
i
=
this
.
$store
.
state
.
msgs
[
item
.
id
].
length
-
1
;
i
>=
0
;
i
--
)
{
for
(
let
i
=
this
.
$store
.
state
.
msgs
[
item
.
id
].
length
-
1
;
i
>=
0
;
i
--
)
{
lastMsg
=
this
.
$store
.
state
.
msgs
[
item
.
id
][
i
]
lastMsg
=
this
.
$store
.
state
.
msgs
[
item
.
id
][
i
]
...
...
src/store/actions/session.js
View file @
4669e85c
...
@@ -5,96 +5,96 @@
...
@@ -5,96 +5,96 @@
import
store
from
'../'
import
store
from
'../'
// 如果会话对象不是好友,需要更新好友名片
// 如果会话对象不是好友,需要更新好友名片
function
updateSessionAccount
(
sessions
)
{
function
updateSessionAccount
(
sessions
)
{
let
accountsNeedSearch
=
[]
let
accountsNeedSearch
=
[]
sessions
.
forEach
(
item
=>
{
sessions
.
forEach
(
item
=>
{
if
(
item
.
scene
===
'p2p'
)
{
if
(
item
.
scene
===
'p2p'
)
{
// 如果不存在缓存资料
// 如果不存在缓存资料
if
(
!
store
.
state
.
userInfos
[
item
.
to
])
{
if
(
!
store
.
state
.
userInfos
[
item
.
to
])
{
accountsNeedSearch
.
push
(
item
.
to
)
accountsNeedSearch
.
push
(
item
.
to
)
}
}
}
}
})
if
(
accountsNeedSearch
.
length
>
0
)
{
store
.
dispatch
(
'searchUsers'
,
{
accounts
:
accountsNeedSearch
})
})
}
if
(
accountsNeedSearch
.
length
>
0
)
{
store
.
dispatch
(
'searchUsers'
,
{
accounts
:
accountsNeedSearch
})
}
}
}
// onSessions只在初始化完成后回调
// onSessions只在初始化完成后回调
export
function
onSessions
(
sessions
)
{
export
function
onSessions
(
sessions
)
{
updateSessionAccount
(
sessions
)
updateSessionAccount
(
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
}
}
export
function
onUpdateSession
(
session
)
{
export
function
onUpdateSession
(
session
)
{
let
sessions
=
[
session
]
let
sessions
=
[
session
]
updateSessionAccount
(
sessions
)
updateSessionAccount
(
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
}
}
export
function
deleteSession
({
state
,
commit
},
sessionId
)
{
export
function
deleteSession
({
state
,
commit
},
sessionId
)
{
const
nim
=
state
.
nim
const
nim
=
state
.
nim
sessionId
=
sessionId
||
''
sessionId
=
sessionId
||
''
let
scene
=
null
let
scene
=
null
let
account
=
null
let
account
=
null
if
(
/^p2p-/
.
test
(
sessionId
))
{
if
(
/^p2p-/
.
test
(
sessionId
))
{
scene
=
'p2p'
scene
=
'p2p'
account
=
sessionId
.
replace
(
/^p2p-/
,
''
)
account
=
sessionId
.
replace
(
/^p2p-/
,
''
)
}
else
if
(
/^team-/
.
test
(
sessionId
))
{
}
else
if
(
/^team-/
.
test
(
sessionId
))
{
scene
=
'team'
scene
=
'team'
account
=
sessionId
.
replace
(
/^team-/
,
''
)
account
=
sessionId
.
replace
(
/^team-/
,
''
)
}
}
if
(
account
&&
scene
)
{
if
(
account
&&
scene
)
{
nim
.
deleteSession
({
nim
.
deleteSession
({
scene
,
scene
,
to
:
account
,
to
:
account
,
done
:
function
deleteServerSessionDone
(
error
,
obj
)
{
done
:
function
deleteServerSessionDone
(
error
,
obj
)
{
if
(
error
)
{
if
(
error
)
{
//alert(error)
//alert(error)
return
return
}
}
nim
.
deleteLocalSession
({
nim
.
deleteLocalSession
({
id
:
sessionId
,
id
:
sessionId
,
done
:
function
deleteLocalSessionDone
(
error
,
obj
)
{
done
:
function
deleteLocalSessionDone
(
error
,
obj
)
{
if
(
error
)
{
if
(
error
)
{
//alert(error)
//alert(error)
return
return
}
commit
(
'deleteSessions'
,
[
sessionId
])
}
})
}
}
commit
(
'deleteSessions'
,
[
sessionId
])
}
})
})
}
}
})
}
}
}
export
function
setCurrSession
({
state
,
commit
,
dispatch
},
sessionId
)
{
export
function
setCurrSession
({
state
,
commit
,
dispatch
},
sessionId
)
{
const
nim
=
state
.
nim
const
nim
=
state
.
nim
if
(
sessionId
)
{
if
(
sessionId
)
{
commit
(
'updateCurrSessionId'
,
{
commit
(
'updateCurrSessionId'
,
{
type
:
'init'
,
type
:
'init'
,
sessionId
sessionId
})
})
if
(
nim
)
{
if
(
nim
)
{
// 如果在聊天页面刷新,此时还没有nim实例,需要在onSessions里同步
// 如果在聊天页面刷新,此时还没有nim实例,需要在onSessions里同步
nim
.
setCurrSession
(
sessionId
)
nim
.
setCurrSession
(
sessionId
)
commit
(
'updateCurrSessionMsgs'
,
{
commit
(
'updateCurrSessionMsgs'
,
{
type
:
'init'
,
type
:
'init'
,
sessionId
sessionId
})
})
// 发送已读回执
// 发送已读回执
dispatch
(
'sendMsgReceipt'
)
dispatch
(
'sendMsgReceipt'
)
}
}
}
}
}
}
export
function
resetCurrSession
({
state
,
commit
})
{
export
function
resetCurrSession
({
state
,
commit
})
{
const
nim
=
state
.
nim
const
nim
=
state
.
nim
nim
.
resetCurrSession
()
nim
.
resetCurrSession
()
commit
(
'updateCurrSessionMsgs'
,
{
commit
(
'updateCurrSessionMsgs'
,
{
type
:
'destroy'
type
:
'destroy'
})
})
}
}
\ No newline at end of file
src/store/mutations/index.js
View file @
4669e85c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment