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
=
{
sdk
:
'NIM_Web_SDK_nodejs_v5.9.1'
,
// 用户自定义的登录注册地址
loginUrl
:
'/webdemo/h5/login.html'
,
registUrl
:
'/webdemo/h5/regist.html'
,
homeUrl
:
'/webdemo/h5/index.html#/session'
,
sdk
:
'NIM_Web_SDK_nodejs_v5.9.1'
,
// 用户自定义的登录注册地址
loginUrl
:
'/webdemo/h5/login.html'
,
registUrl
:
'/webdemo/h5/regist.html'
,
homeUrl
:
'/webdemo/h5/index.html#/session'
,
// 资源路径根目录,为了方便用户部署在二级以上URL路径上
resourceUrl
:
'http://yx-web.nos.netease.com/webdoc/h5'
,
// 用户logo地址
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'
,
// 默认普通群头像
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'
,
// 系统通知图标
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'
,
// 本地消息显示数量,会影响性能
localMsglimit
:
36
,
useDb
:
false
// 资源路径根目录,为了方便用户部署在二级以上URL路径上
resourceUrl
:
'http://yx-web.nos.netease.com/webdoc/h5'
,
// 用户logo地址
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'
,
// 默认普通群头像
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'
,
// 系统通知图标
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'
,
// 本地消息显示数量,会影响性能
localMsglimit
:
36
,
useDb
:
false
}
const
env
=
'online'
let
appConfig
=
{
// 用户的appkey
// 用于在web demo中注册账号异步请求demo 服务器中使用
test
:
{
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
postUrl
:
'https://apptest.netease.im'
},
online
:
{
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
postUrl
:
'https://app.netease.im'
}
// 用户的appkey
// 用于在web demo中注册账号异步请求demo 服务器中使用
test
:
{
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
postUrl
:
'https://apptest.netease.im'
},
online
:
{
appkey
:
'b612b31e837c79c68f141aeb719d2b20'
,
postUrl
:
'https://app.netease.im'
}
}
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
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
') {
global.__static = require('
path
').join(__dirname, '
/
static
').replace(/
\\
/g, '
\\\\
')
...
...
@@ -290,8 +292,8 @@ app.on('activate', () => {
createWindow()
}
})
ipc.on('
reconnect
',
function(event)
{
nim
=
null
ipc.on('
reconnect
',
function(event)
{
nim
=
null
initNIM(global.LOGINUSER.ImAccount, global.LOGINUSER.ImToken)
})
ipc.on('
loginSuccess
', function(event, userInfo) {
...
...
@@ -697,6 +699,7 @@ ipc.on('send-file', function(event, obj) {
custom: JSON.stringify(customMsg),
uploadprogress: function(data) {
file.progess = data.percentage
console.log(file)
event.sender.send('
sending
-
process
', file)
},
uploaderror: function() {
...
...
@@ -814,8 +817,8 @@ let getMainWinodw = function(isLoad) {
mainWindow
.
show
()
mainWindow
.
setAlwaysOnTop
(
true
)
mainWindow
.
setAlwaysOnTop
(
false
)
//mainWindow.webContents.openDevTools(true);
//getNoticeWindows()
//mainWindow.webContents.openDevTools(true);
//getNoticeWindows()
})
}
//加载隐藏窗口防止用户关闭
...
...
@@ -936,7 +939,8 @@ let getNoticeWindows = function() {
width
:
300
,
height
:
115
,
skipTaskbar
:
true
,
alwaysOnTop
:
true
alwaysOnTop
:
false
,
focusable
:
false
})
noticeWindows
.
setBounds
({
y
:
electron
.
screen
.
getPrimaryDisplay
().
workAreaSize
.
height
-
115
,
...
...
@@ -970,7 +974,7 @@ let getAddNewUserWinodes = function() {
addNewUserWinodes
.
setMenu
(
null
)
addNewUserWinodes
.
once
(
'ready-to-show'
,
()
=>
{
addNewUserWinodes
.
show
()
//addNewUserWinodes.webContents.openDevTools(true);
//addNewUserWinodes.webContents.openDevTools(true);
})
}
else
{
addNewUserWinodes
.
focus
()
...
...
@@ -1099,7 +1103,6 @@ let initNIM = function(uid, token) {
function onDisconnect(error) {
// 此时说明 SDK 处于断开状态, 开发者此时应该根据错误码提示相应的错误信息, 并且跳转到登录页面
if (error) {
switch (error.code) {
// 账号或者密码错误, 请跳转到登录页面并提示错误
...
...
@@ -1115,6 +1118,7 @@ let initNIM = function(uid, token) {
break;
}
}
console.log('
异常了
');
}
function onError(error) {
...
...
src/renderer/App.vue
View file @
4669e85c
...
...
@@ -9,6 +9,9 @@
export
default
{
name
:
"MageOffice"
,
mounted
()
{
window
.
alert
=
function
()
{
return
false
;
}
document
.
querySelector
(
'#app'
).
addEventListener
(
"dragover"
,
function
(
e
)
{
...
...
src/renderer/components/index.vue
View file @
4669e85c
...
...
@@ -195,7 +195,6 @@ export default {
},
8
*
1000
);
},
atMsg
(){
console
.
log
(
11111111111111
)
this
.
MsgBus
.
$emit
(
'send-at-name'
,
this
.
atInfo
.
atName
)
},
showCard
(
e
){
...
...
src/renderer/components/msssage/chateditor.vue
View file @
4669e85c
...
...
@@ -85,6 +85,7 @@ export default {
});
this
.
$electron
.
ipcRenderer
.
on
(
"sending-process"
,
(
event
,
file
)
=>
{
console
.
log
(
file
)
this
.
GLOBALSENDING
.
forEach
(
x
=>
{
if
((
x
.
msgId
=
file
.
msgId
))
{
x
=
file
;
...
...
src/renderer/components/msssage/index.vue
View file @
4669e85c
...
...
@@ -590,7 +590,9 @@ export default {
lastMsg
.
type
===
"notification"
&&
lastMsg
.
attach
&&
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
--
)
{
lastMsg
=
this
.
$store
.
state
.
msgs
[
item
.
id
][
i
]
...
...
src/store/actions/session.js
View file @
4669e85c
...
...
@@ -5,96 +5,96 @@
import
store
from
'../'
// 如果会话对象不是好友,需要更新好友名片
function
updateSessionAccount
(
sessions
)
{
let
accountsNeedSearch
=
[]
sessions
.
forEach
(
item
=>
{
if
(
item
.
scene
===
'p2p'
)
{
// 如果不存在缓存资料
if
(
!
store
.
state
.
userInfos
[
item
.
to
])
{
accountsNeedSearch
.
push
(
item
.
to
)
}
}
})
if
(
accountsNeedSearch
.
length
>
0
)
{
store
.
dispatch
(
'searchUsers'
,
{
accounts
:
accountsNeedSearch
function
updateSessionAccount
(
sessions
)
{
let
accountsNeedSearch
=
[]
sessions
.
forEach
(
item
=>
{
if
(
item
.
scene
===
'p2p'
)
{
// 如果不存在缓存资料
if
(
!
store
.
state
.
userInfos
[
item
.
to
])
{
accountsNeedSearch
.
push
(
item
.
to
)
}
}
})
}
if
(
accountsNeedSearch
.
length
>
0
)
{
store
.
dispatch
(
'searchUsers'
,
{
accounts
:
accountsNeedSearch
})
}
}
// onSessions只在初始化完成后回调
export
function
onSessions
(
sessions
)
{
updateSessionAccount
(
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
export
function
onSessions
(
sessions
)
{
updateSessionAccount
(
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
}
export
function
onUpdateSession
(
session
)
{
let
sessions
=
[
session
]
updateSessionAccount
(
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
export
function
onUpdateSession
(
session
)
{
let
sessions
=
[
session
]
updateSessionAccount
(
sessions
)
store
.
commit
(
'updateSessions'
,
sessions
)
}
export
function
deleteSession
({
state
,
commit
},
sessionId
)
{
const
nim
=
state
.
nim
sessionId
=
sessionId
||
''
let
scene
=
null
let
account
=
null
if
(
/^p2p-/
.
test
(
sessionId
))
{
scene
=
'p2p'
account
=
sessionId
.
replace
(
/^p2p-/
,
''
)
}
else
if
(
/^team-/
.
test
(
sessionId
))
{
scene
=
'team'
account
=
sessionId
.
replace
(
/^team-/
,
''
)
}
if
(
account
&&
scene
)
{
nim
.
deleteSession
({
scene
,
to
:
account
,
done
:
function
deleteServerSessionDone
(
error
,
obj
)
{
if
(
error
)
{
//alert(error)
return
}
nim
.
deleteLocalSession
({
id
:
sessionId
,
done
:
function
deleteLocalSessionDone
(
error
,
obj
)
{
if
(
error
)
{
//alert(error)
return
export
function
deleteSession
({
state
,
commit
},
sessionId
)
{
const
nim
=
state
.
nim
sessionId
=
sessionId
||
''
let
scene
=
null
let
account
=
null
if
(
/^p2p-/
.
test
(
sessionId
))
{
scene
=
'p2p'
account
=
sessionId
.
replace
(
/^p2p-/
,
''
)
}
else
if
(
/^team-/
.
test
(
sessionId
))
{
scene
=
'team'
account
=
sessionId
.
replace
(
/^team-/
,
''
)
}
if
(
account
&&
scene
)
{
nim
.
deleteSession
({
scene
,
to
:
account
,
done
:
function
deleteServerSessionDone
(
error
,
obj
)
{
if
(
error
)
{
//alert(error)
return
}
nim
.
deleteLocalSession
({
id
:
sessionId
,
done
:
function
deleteLocalSessionDone
(
error
,
obj
)
{
if
(
error
)
{
//alert(error)
return
}
commit
(
'deleteSessions'
,
[
sessionId
])
}
})
}
commit
(
'deleteSessions'
,
[
sessionId
])
}
})
}
})
}
}
}
export
function
setCurrSession
({
state
,
commit
,
dispatch
},
sessionId
)
{
const
nim
=
state
.
nim
if
(
sessionId
)
{
commit
(
'updateCurrSessionId'
,
{
type
:
'init'
,
sessionId
})
if
(
nim
)
{
// 如果在聊天页面刷新,此时还没有nim实例,需要在onSessions里同步
nim
.
setCurrSession
(
sessionId
)
commit
(
'updateCurrSessionMsgs'
,
{
type
:
'init'
,
sessionId
})
// 发送已读回执
dispatch
(
'sendMsgReceipt'
)
export
function
setCurrSession
({
state
,
commit
,
dispatch
},
sessionId
)
{
const
nim
=
state
.
nim
if
(
sessionId
)
{
commit
(
'updateCurrSessionId'
,
{
type
:
'init'
,
sessionId
})
if
(
nim
)
{
// 如果在聊天页面刷新,此时还没有nim实例,需要在onSessions里同步
nim
.
setCurrSession
(
sessionId
)
commit
(
'updateCurrSessionMsgs'
,
{
type
:
'init'
,
sessionId
})
// 发送已读回执
dispatch
(
'sendMsgReceipt'
)
}
}
}
}
export
function
resetCurrSession
({
state
,
commit
})
{
const
nim
=
state
.
nim
nim
.
resetCurrSession
()
commit
(
'updateCurrSessionMsgs'
,
{
type
:
'destroy'
})
}
export
function
resetCurrSession
({
state
,
commit
})
{
const
nim
=
state
.
nim
nim
.
resetCurrSession
()
commit
(
'updateCurrSessionMsgs'
,
{
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