Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivWeb
Project
Project
Details
Activity
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
ReactWeb5
CivWeb
Commits
7537eaf7
Commit
7537eaf7
authored
Dec 31, 2020
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: notice bug
parent
9c0fcfdb
Pipeline
#21603
passed with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
136 additions
and
66 deletions
+136
-66
NoticeIconView.js
src/components/GlobalHeader/NoticeIconView.js
+35
-13
index.js
src/components/NoticeIcon/Templates/Alarm/index.js
+5
-6
index.js
src/components/NoticeIcon/Templates/Notice/index.js
+4
-0
index.js
src/components/Notifier/index.js
+63
-40
configureStore.js
src/configureStore.js
+5
-6
reducer.js
src/containers/App/store/reducer.js
+10
-1
utils.js
src/utils/utils.js
+14
-0
No files found.
src/components/GlobalHeader/NoticeIconView.js
View file @
7537eaf7
...
...
@@ -6,9 +6,10 @@ import { connect } from 'react-redux';
import
isProd
from
'../../utils/env'
;
import
NoticeIcon
from
'../NoticeIcon'
;
import
Notifier
from
'../Notifier'
;
import
{
NEW_MESSAGE
}
from
'../Notifier/constants'
;
import
{
MESSAGE_TYPE
,
NEW_MESSAGE
}
from
'../Notifier/constants'
;
import
styles
from
'./index.less'
;
import
{
findPathByWidget
}
from
'../../utils/utils'
;
import
{
findPathByWidget
,
isJSON
}
from
'../../utils/utils'
;
import
{
actionCreators
}
from
'../../containers/App/store'
;
class
NoticeIconView
extends
Component
{
constructor
(
props
)
{
...
...
@@ -30,6 +31,7 @@ class NoticeIconView extends Component {
this
.
props
.
global
.
userInfo
,
this
.
renderVideo
,
this
.
renderPlatform
,
this
.
props
,
);
}
...
...
@@ -72,6 +74,7 @@ class NoticeIconView extends Component {
};
renderPlatform
=
message
=>
{
const
messageContent
=
(
this
.
props
.
global
.
mqtt_mess
.
MessageLevel
===
"2.0"
&&
isJSON
(
message
.
infoContent
))
?
JSON
.
parse
(
message
.
infoContent
):
message
.
infoContent
;
this
.
setState
({
platformVisible
:
true
,
});
...
...
@@ -94,7 +97,7 @@ class NoticeIconView extends Component {
<
div
className
=
{
styles
.
content
}
>
<
div
className
=
{
styles
[
'content-top'
]}
>
<
a
onClick
=
{()
=>
this
.
handlerMointer
(
message
,
true
)}
>
{
message
.
info
Content
.
alarmDevice
}
{
messageContent
.
alarmDevice
}
<
/a
>
<
span
title
=
"点击标为已读"
...
...
@@ -103,13 +106,13 @@ class NoticeIconView extends Component {
<
/div
>
<
div
className
=
{
styles
[
'content-mid'
]}
>
<
b
>
{
message
.
info
Content
.
alarmType
}
<
/b
>
{
`|
${
message
.
info
Content
.
alarmContent
}
`
}
<
b
>
{
messageContent
.
alarmType
}
<
/b
>
{
`|
${
messageContent
.
alarmContent
}
`
}
<
/div
>
<
div
className
=
{
styles
[
'content-bottom'
]}
>
<
p
>
<
b
>
{
message
.
info
Content
.
alarmValue
}
/</
b
>
{
message
.
info
Content
.
alarmThreshold
}
<
b
>
{
messageContent
.
alarmValue
}
/</
b
>
{
messageContent
.
alarmThreshold
}
<
/p
>
<
span
>
{
message
.
time
}
<
/span
>
<
/div
>
...
...
@@ -124,9 +127,22 @@ class NoticeIconView extends Component {
videoVisible
:
true
,
});
const
{
props
}
=
this
;
const
data
=
(
message
&&
message
.
messContent
&&
message
.
messContent
.
split
(
'
\\
n'
))
||
[];
const
infoType
=
message
.
infoType
?
message
.
infoType
:
MESSAGE_TYPE
.
SCADA_TYPE
;
let
data
=
[];
if
(
this
.
props
.
global
.
mqtt_mess
.
MessageLevel
===
'2.0'
)
{
// eslint-disable-next-line no-shadow
const
message
=
this
.
notifier
.
messageThrome
(
infoType
,
// eslint-disable-next-line no-use-before-define
JSON
.
parse
(
message
.
messContent
),
);
data
=
message
.
split
(
'
\\
n'
);
}
else
{
data
=
message
.
messContent
.
split
(
'
\\
n'
);
}
const
id
=
data
[
3
];
const
name
=
data
[
0
];
const
baseURI
=
isProd
...
...
@@ -166,9 +182,7 @@ class NoticeIconView extends Component {
if
(
detail
)
{
const
widgetID
=
'widget_city_综合运营_管网监控_实时监控_报警监控'
;
const
webPath
=
'product/scada/AlertMonitoring/AlertMonitoring'
;
debugger
let
widget
=
findPathByWidget
(
"productex/water/IOTMonitor/RealTimeAlarm/RealTimeAlarm"
,
this
.
props
.
global
.
widgets
,
""
,
"url"
);
console
.
log
(
widget
)
window
.
share
.
event
.
emit
(
'listenerMointer'
,
{
widgetId
:
widgetID
,
label
:
'实时报警'
,
...
...
@@ -219,7 +233,15 @@ const mapStateToProps = state => ({
global
:
state
.
getIn
([
'global'
,
'globalConfig'
]),
});
const
mapDispatchToProps
=
dispatch
=>
{
return
{
updateConfig
(
config
)
{
dispatch
(
actionCreators
.
getConfig
(
config
));
},
}
}
export
default
connect
(
mapStateToProps
,
null
,
mapDispatchToProps
,
)(
NoticeIconView
);
src/components/NoticeIcon/Templates/Alarm/index.js
View file @
7537eaf7
import
React
from
'react'
;
import
classNames
from
'classnames'
;
import
{
findPathByWidget
}
from
'../../../../utils/utils'
;
import
{
findPathByWidget
,
isJSON
}
from
'../../../../utils/utils'
;
import
commonStyles
from
'../common.less'
;
import
styles
from
'./index.less'
;
/* eslint-disable */
...
...
@@ -26,8 +26,9 @@ export class AlarmContent {
}
const
Alarm
=
({
message
,
confirmRead
,
config
})
=>
{
const
alarmContent
=
message
.
infoContent
;
const
alarmContent
=
(
config
.
mqtt_mess
.
MessageLevel
===
"2.0"
&&
isJSON
(
message
.
infoContent
))
?
JSON
.
parse
(
message
.
infoContent
):
message
.
infoContent
;
const
goPath
=
item
=>
{
debugger
confirmRead
(
false
,
[
message
.
id
]);
const
widgetID
=
'widget_city_综合运营_管网监控_实时监控_报警监控'
;
const
webPath
=
'product/scada/AlertMonitoring/AlertMonitoring'
;
...
...
@@ -39,10 +40,8 @@ const Alarm = ({ message, confirmRead, config }) => {
url
:
widget
.
url
||
webPath
,
});
};
const
alarmValue
=
alarmContent
&&
alarmContent
.
alarmValue
&&
alarmContent
.
alarmValue
.
split
(
' '
);
console
.
log
(
"alarmContent"
,
alarmContent
,
config
);
const
alarmValue
=
alarmContent
&&
alarmContent
.
alarmValue
&&
alarmContent
.
alarmValue
.
split
(
' '
);
return
(
<
div
className
=
{
classNames
(
styles
.
scada
,
commonStyles
.
messageContainer
)}
...
...
src/components/NoticeIcon/Templates/Notice/index.js
View file @
7537eaf7
...
...
@@ -16,8 +16,12 @@ export class NoticeContent {
}
const
Notice
=
({
message
,
confirmRead
})
=>
{
// eslint-disable-next-line no-debugger
debugger
const
noticeContent
=
message
.
infoContent
;
const
goPath
=
item
=>
{
// eslint-disable-next-line no-debugger
debugger
confirmRead
(
false
,
[
message
.
id
]);
const
webPath
=
item
.
webPath
||
'product/notification/HistoryNotice/HistoryNotice'
;
...
...
src/components/Notifier/index.js
View file @
7537eaf7
...
...
@@ -25,7 +25,7 @@ import createMessage from './message';
// eslint-disable-next-line no-undef
const
Logger
=
logger
(
'mqtt'
);
class
Notifier
{
constructor
(
userInfo
,
renderVideo
,
renderPlatform
)
{
constructor
(
userInfo
,
renderVideo
,
renderPlatform
,
props
)
{
this
.
userInfo
=
userInfo
;
this
.
messageCache
=
{
totalCount
:
0
,
...
...
@@ -41,14 +41,17 @@ class Notifier {
KeepAlive
:
''
,
IsSSL
:
true
,
mqtt_path
:
DEFAULT_MQTT_PATH
,
mqtt_mess
:
{},
nginxStart
:
false
};
this
.
_config
=
{
mqtt_path
:
'/mqtt'
,
nginxStart
:
'false'
,
mqtt_mess
:
{
IsSSL
:
false
,
},
};
//
this._config = {
//
mqtt_path: '/mqtt',
//
nginxStart: 'false',
//
mqtt_mess: {
//
IsSSL: false,
//
},
//
};
this
.
MQTTCount
=
0
;
this
.
MQTTClient
=
null
;
this
.
MQTTOptions
=
{};
...
...
@@ -67,13 +70,13 @@ class Notifier {
this
.
renderVideoElement
=
null
;
this
.
renderPlatform
=
renderPlatform
;
this
.
renderPlatformElement
=
null
;
this
.
props
=
props
;
}
// 对外接口
async
start
()
{
window
.
cc
=
this
.
messageCache
;
this
.
getMqttSiteCode
().
then
((
res
)
=>
{
console
.
log
(
res
);
this
.
loadHisMessages
(
this
.
currentPageIndex
,
this
.
currentPageSize
);
this
.
connectMQTTServer
();
});
...
...
@@ -277,6 +280,7 @@ class Notifier {
const
userInfo
=
this
.
getUserInfo
();
const
infoType
=
this
.
getMessageType
(
parseMessage
.
infoType
);
let
state
=
null
;
if
(
_
.
isEmpty
(
parseMessage
.
tousers
)
||
userInfo
.
OID
==
parseMessage
.
tousers
||
...
...
@@ -290,6 +294,7 @@ class Notifier {
this
.
renderWindowsInfo
(
buffer
);
}
let
messContent
=
parseMessage
.
content
;
if
(
this
.
_siteConfig
.
MessageLevel
&&
this
.
_siteConfig
.
MessageLevel
===
"2.0"
)
{
messContent
=
this
.
messageThrome
(
infoType
,
JSON
.
parse
(
parseMessage
.
content
))
}
...
...
@@ -317,7 +322,7 @@ class Notifier {
if
(
parseMessage
.
tousers
===
''
)
{
messString
.
messType
=
'公告'
;
let
content
=
messContent
.
replace
(
/
\\
n/g
,
','
);
let
content
=
(
_
.
isObject
(
messContent
)
?
messContent
.
content
:
messContent
)
.
replace
(
/
\\
n/g
,
','
);
content
=
this
.
replaceSpeak
(
content
)
state
=
new
window
.
SpeechSynthesisUtterance
(
`您有新的公告:
${
content
...
...
@@ -325,7 +330,7 @@ class Notifier {
.
replace
(
':'
,
','
)}
时间:
${
timeMss
}
`
,
);
}
else
{
let
content
=
messContent
.
replace
(
/
\\
n/g
,
','
);
let
content
=
(
_
.
isObject
(
messContent
)
?
messContent
.
content
:
messContent
)
.
replace
(
/
\\
n/g
,
','
);
content
=
this
.
replaceSpeak
(
content
)
state
=
new
window
.
SpeechSynthesisUtterance
(
`您有新的消息:
${
content
...
...
@@ -409,12 +414,20 @@ class Notifier {
}
renderWindowsInfo
(
message
)
{
const
self
=
this
;
function
notifyMessage
(
message
)
{
const
parseMessage
=
JSON
.
parse
(
message
.
payloadString
);
let
content
=
''
;
for
(
let
i
=
0
;
i
<
parseMessage
.
content
.
split
(
'
\\
n'
).
length
;
i
++
)
{
content
+=
`
${
parseMessage
.
content
.
split
(
'
\\
n'
)[
i
]}
`
;
if
(
self
.
getMessageLevel
()
===
"2.0"
)
{
const
messageContent
=
JSON
.
parse
(
parseMessage
.
content
);
content
+=
`
${
messageContent
.
alarmType
}
${
messageContent
.
alarmDevice
}
${
messageContent
.
alarmContent
}
${
messageContent
.
alarmValue
}
/
${
messageContent
.
alarmThreshold
}
`
}
else
{
for
(
let
i
=
0
;
i
<
parseMessage
.
content
.
split
(
'
\\
n'
).
length
;
i
++
)
{
content
+=
`
${
parseMessage
.
content
.
split
(
'
\\
n'
)[
i
]}
`
;
}
}
const
messageBody
=
{
title
:
''
,
content
,
...
...
@@ -510,31 +523,42 @@ class Notifier {
return
Http
.
getMqttSiteCode
({
'request.preventCache'
:
Date
.
now
()
}).
then
(
res
=>
{
if
(
res
&&
res
.
say
.
statusCode
===
ERR_OK
)
{
let
mqttConfig
=
{
mqtt_mess
:
{},
mqtt_path
:
self
.
_siteConfig
.
mqtt_path
,
nginxStart
:
self
.
_siteConfig
.
NginxStart
,
mqtt_IsSSL
:
true
};
if
(
Array
.
isArray
(
res
.
getMe
)
&&
res
.
getMe
.
length
>
0
)
{
if
(
res
.
getMe
[
0
])
{
self
.
_siteConfig
.
IsSSL
=
res
.
getMe
[
0
].
IsSSL
?
res
.
getMe
[
0
].
IsSSL
:
false
;
self
.
_siteConfig
.
site_code
=
res
.
getMe
[
0
].
SiteCode
||
self
.
_siteConfig
.
site_code
;
self
.
_siteConfig
.
TcpIP
=
res
.
getMe
[
0
].
TcpIP
;
self
.
_siteConfig
.
TcpPort
=
res
.
getMe
[
0
].
TcpPort
?
parseInt
(
res
.
getMe
[
0
].
TcpPort
)
:
8083
;
self
.
_siteConfig
.
MessageLevel
=
res
.
getMe
[
0
].
MessageLevel
?
res
.
getMe
[
0
].
MessageLevel
:
DEFAULT_PARSE_LEVEL
;
}
if
(
res
.
getMe
[
0
].
NginxStart
)
{
self
.
_siteConfig
.
TcpIP
=
window
.
location
.
hostname
;
self
.
_siteConfig
.
TcpPort
=
parseInt
(
window
.
location
.
port
);
self
.
_siteConfig
.
mqtt_path
=
'/ws/'
;
}
else
{
self
.
_siteConfig
.
TcpIP
=
DEFAULT_TCP_IP
;
self
.
_siteConfig
.
TcpPort
=
DEFAULT_TCP_PORT
;
self
.
_siteConfig
.
IsSSL
=
true
;
const
data
=
res
.
getMe
[
0
];
mqttConfig
.
mqtt_IsSSL
=
self
.
_siteConfig
.
IsSSL
=
data
.
IsSSL
?
data
.
IsSSL
:
false
;
mqttConfig
.
mqtt_mess
.
site_code
=
self
.
_siteConfig
.
site_code
=
data
.
SiteCode
||
self
.
_siteConfig
.
site_code
;
mqttConfig
.
mqtt_mess
.
TcpIP
=
self
.
_siteConfig
.
TcpIP
=
data
.
TcpIP
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
self
.
_siteConfig
.
TcpPort
=
data
.
TcpPort
?
parseInt
(
data
.
TcpPort
)
:
8083
;
mqttConfig
.
mqtt_mess
.
MessageLevel
=
self
.
_siteConfig
.
MessageLevel
=
data
.
MessageLevel
?
data
.
MessageLevel
:
DEFAULT_PARSE_LEVEL
;
if
(
data
.
NginxStart
)
{
mqttConfig
.
NginxStart
=
self
.
_siteConfig
.
NginxStart
=
data
.
NginxStart
;
mqttConfig
.
mqtt_mess
.
TcpIP
=
self
.
_siteConfig
.
mqtt_mess
.
TcpIP
=
window
.
location
.
hostname
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
self
.
_siteConfig
.
mqtt_mess
.
TcpPort
=
parseInt
(
window
.
location
.
port
);
mqttConfig
.
mqtt_path
=
self
.
_siteConfig
.
mqtt_path
=
'/ws/'
;
}
else
{
mqttConfig
.
nginxStart
=
data
.
NginxStart
}
}
else
{
mqttConfig
.
mqtt_mess
.
TcpIP
=
self
.
_siteConfig
.
mqtt_mess
.
TcpIP
=
DEFAULT_TCP_IP
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
self
.
_siteConfig
.
mqtt_mess
.
TcpPort
=
DEFAULT_TCP_PORT
;
mqttConfig
.
mqtt_IsSSL
=
self
.
_siteConfig
.
IsSSL
=
self
.
_siteConfig
.
mqtt_mess
.
TcpIP
+
":"
+
self
.
_siteConfig
.
mqtt_mess
.
TcpPort
;
}
mqttConfig
.
mqtt_iotIP
=
self
.
_siteConfig
.
mqtt_iotIP
=
mqttConfig
.
mqtt_mess
.
TcpIP
+
":"
+
mqttConfig
.
mqtt_mess
.
TcpPort
;
self
.
props
.
updateConfig
&&
self
.
props
.
updateConfig
(
Object
.
assign
({},
self
.
props
.
global
,
{
...
mqttConfig
}))
}
}
else
{
logger
.
info
(
'获取mqtt服务器参数失败'
);
...
...
@@ -542,7 +566,9 @@ class Notifier {
},
);
}
getMessageLevel
()
{
return
this
.
_siteConfig
.
MessageLevel
}
generatedId
()
{
return
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
...
...
@@ -554,7 +580,7 @@ class Notifier {
}
getMessageType
(
messageType
)
{
let
infoType
=
MESSAGE_TYPE
.
UNKNOWN
;
let
infoType
=
MESSAGE_TYPE
.
SCADA_TYPE
;
switch
(
messageType
)
{
case
MESSAGE_TEXT_TYPE
.
PROJECT_FLOW
:
infoType
=
MESSAGE_TYPE
.
CASE_TYPE
;
...
...
@@ -572,9 +598,6 @@ class Notifier {
case
MESSAGE_TEXT_TYPE
.
MESSAGE_ALERT
:
infoType
=
MESSAGE_TYPE
.
MESSAGE_ALERT
;
break
;
case
MESSAGE_TEXT_TYPE
.
SCADA_ALARM
:
case
''
:
infoType
=
MESSAGE_TYPE
.
SCADA_TYPE
;
default
:
break
;
}
...
...
src/configureStore.js
View file @
7537eaf7
...
...
@@ -30,12 +30,11 @@ export default function configureStore(initialState = {}, history) {
const
sagaMiddleware
=
createSagaMiddleware
(
reduxSagaMonitorOptions
);
const
middlewares
=
[
sagaMiddleware
,
routerMiddleware
(
history
),
logger
,
thunk
,
];
const
middlewares
=
[
sagaMiddleware
,
routerMiddleware
(
history
),
thunk
];
if
(
process
.
env
.
NODE_ENV
!==
'production'
&&
typeof
window
===
'object'
)
{
middlewares
.
push
(
logger
);
}
const
enhancers
=
[
applyMiddleware
(...
middlewares
)];
...
...
src/containers/App/store/reducer.js
View file @
7537eaf7
...
...
@@ -66,12 +66,21 @@ export const initialState = fromJS({
const
appReducer
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
GET_CONFIG
:
// eslint-disable-next-line no-debugger
debugger
// eslint-disable-next-line no-underscore-dangle
window
.
__INITIAL_STATE__
=
Object
.
assign
({},
action
.
data
,
{
allWidgets
:
action
.
data
.
widgets
||
[],
});
// eslint-disable-next-line global-require
window
.
globalConfig
=
require
(
'kit_global_config'
).
default
;
if
(
!
window
.
globalConfig
)
{
// eslint-disable-next-line global-require
window
.
globalConfig
=
require
(
'kit_global_config'
).
default
;
}
else
{
// eslint-disable-next-line no-underscore-dangle
window
.
globalConfig
=
window
.
__INITIAL_STATE__
;
}
// eslint-disable-next-line no-undef
createStoreage
.
set
(
'globalConfig'
,
window
.
globalConfig
);
// eslint-disable-next-line no-undef,no-case-declarations
...
...
src/utils/utils.js
View file @
7537eaf7
...
...
@@ -113,3 +113,17 @@ export function findPathByWidget(leafId, nodes, path, key) {
}
return
tmpPath
;
}
export
function
isJSON
(
str
)
{
if
(
typeof
str
===
'string'
)
{
try
{
const
obj
=
JSON
.
parse
(
str
);
if
(
typeof
obj
===
'object'
&&
obj
)
{
return
true
;
}
return
false
;
}
catch
(
e
)
{
return
false
;
}
}
}
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