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
649d67bf
Commit
649d67bf
authored
Dec 31, 2020
by
邓晓峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: message throme
parent
ed4cf05c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
8 deletions
+51
-8
civbase.zip
civbase.zip
+0
-0
index.js
src/components/Notifier/index.js
+51
-8
No files found.
civbase.zip
0 → 100644
View file @
649d67bf
This diff was suppressed by a .gitattributes entry.
src/components/Notifier/index.js
View file @
649d67bf
...
...
@@ -72,7 +72,8 @@ class Notifier {
// 对外接口
async
start
()
{
window
.
cc
=
this
.
messageCache
;
this
.
getMqttSiteCode
().
then
(()
=>
{
this
.
getMqttSiteCode
().
then
((
res
)
=>
{
console
.
log
(
res
);
this
.
loadHisMessages
(
this
.
currentPageIndex
,
this
.
currentPageSize
);
this
.
connectMQTTServer
();
});
...
...
@@ -288,7 +289,10 @@ class Notifier {
)
{
this
.
renderWindowsInfo
(
buffer
);
}
const
messContent
=
parseMessage
.
content
;
let
messContent
=
parseMessage
.
content
;
if
(
this
.
_siteConfig
.
MessageLevel
&&
this
.
_siteConfig
.
MessageLevel
===
"2.0"
)
{
messContent
=
this
.
messageThrome
(
infoType
,
JSON
.
parse
(
parseMessage
.
content
))
}
const
timeH
=
(
new
Date
()
-
new
Date
(
parseMessage
.
createTime
))
/
1000
/
60
;
const
timeMss
=
...
...
@@ -300,8 +304,8 @@ class Notifier {
?
`
${
timeH
.
toFixed
(
0
)}
分钟前`
:
'刚刚'
;
const
messString
=
{
id
:
parseMessage
.
ID
,
infoContent
:
this
.
_siteConfig
.
MessageLevel
===
DEFAULT_PARSE_LEVEL
?
messContent
:
JSON
.
parse
(
messContent
||
"{}"
)
,
id
:
parseMessage
.
infoId
,
infoContent
:
parseMessage
.
content
,
infoLevel
:
parseMessage
.
level
,
time
:
`
${
timeMss
}
`
,
infoType
,
...
...
@@ -313,14 +317,16 @@ class Notifier {
if
(
parseMessage
.
tousers
===
''
)
{
messString
.
messType
=
'公告'
;
const
content
=
messContent
.
replace
(
/
\\
n/g
,
','
);
let
content
=
messContent
.
replace
(
/
\\
n/g
,
','
);
content
=
this
.
replaceSpeak
(
content
)
state
=
new
window
.
SpeechSynthesisUtterance
(
`您有新的公告:
${
content
.
substring
(
0
,
content
.
lastIndexOf
(
','
))
.
replace
(
':'
,
','
)}
时间:
${
timeMss
}
`
,
);
}
else
{
const
content
=
messContent
.
replace
(
/
\\
n/g
,
','
);
let
content
=
messContent
.
replace
(
/
\\
n/g
,
','
);
content
=
this
.
replaceSpeak
(
content
)
state
=
new
window
.
SpeechSynthesisUtterance
(
`您有新的消息:
${
content
.
substring
(
0
,
content
.
lastIndexOf
(
','
))
...
...
@@ -366,6 +372,42 @@ class Notifier {
}
}
replaceSpeak
(
msg
)
{
msg
=
msg
.
replaceAll
(
" "
,
""
);
msg
=
msg
.
replace
(
/MPa/ig
,
"兆帕"
);
msg
=
msg
.
replace
(
/m³
\/
h/ig
,
"立方米每小时"
);
msg
=
msg
.
replace
(
/m³/ig
,
"立方米"
);
msg
=
msg
.
replace
(
/kWh/ig
,
"千瓦时"
);
msg
=
msg
.
replace
(
/kW/ig
,
"千瓦"
);
msg
=
msg
.
replace
(
/min/ig
,
"分钟"
);
msg
=
msg
.
replace
(
/m/ig
,
"米"
);
msg
=
msg
.
replace
(
/A/ig
,
"安"
);
msg
=
msg
.
replace
(
/V/ig
,
"伏"
);
msg
=
msg
.
replace
(
/h/ig
,
"小时"
);
return
msg
;
}
messageThrome
(
themeName
,
info
)
{
let
messageInfo
=
""
;
switch
(
themeName
)
{
case
MESSAGE_TYPE
.
CASE_TYPE
:
case
"工单提醒"
:
messageInfo
=
`【
${
info
.
caseType
}
】
${
info
.
flowName
}
\\n
${
info
.
nodeName
}
\\n承办意见:
${
info
.
content
}
`
;
break
;
case
MESSAGE_TYPE
.
SCADA_TYPE
:
case
"通用报警"
:
messageInfo
=
`【
${
info
.
title
}
】
${
info
.
alarmDevice
}
\\n
${
info
.
alarmContent
}
\\n
${
info
.
alarmValue
}
/
${
info
.
alarmThreshold
}
\\n
${
info
.
deviceCode
}
`
;
break
;
case
MESSAGE_TYPE
.
SYS_TYPE
:
case
"系统通知"
:
messageInfo
=
`【
${
info
.
noticeType
}
】
${
info
.
noticeTitle
}
\\n
${
info
.
noticeContent
}
`
;
break
;
default
:
messageInfo
=
info
;
break
;
}
return
messageInfo
;
}
renderWindowsInfo
(
message
)
{
function
notifyMessage
(
message
)
{
const
parseMessage
=
JSON
.
parse
(
message
.
payloadString
);
...
...
@@ -446,7 +488,7 @@ class Notifier {
self
.
messageCache
.
totalCount
=
result
.
totalCount
;
(
result
.
messages
||
[]).
forEach
(
message
=>
{
const
index
=
self
.
messageCache
.
messages
.
findIndex
(
item
=>
item
.
id
==
message
.
id
,
item
=>
item
.
id
==
=
message
.
id
,
);
index
===
-
1
&&
self
.
messageCache
.
messages
.
push
(
message
);
});
...
...
@@ -468,6 +510,7 @@ class Notifier {
return
Http
.
getMqttSiteCode
({
'request.preventCache'
:
Date
.
now
()
}).
then
(
res
=>
{
if
(
res
&&
res
.
say
.
statusCode
===
ERR_OK
)
{
if
(
Array
.
isArray
(
res
.
getMe
)
&&
res
.
getMe
.
length
>
0
)
{
if
(
res
.
getMe
[
0
])
{
self
.
_siteConfig
.
IsSSL
=
res
.
getMe
[
0
].
IsSSL
...
...
@@ -504,7 +547,7 @@ class Notifier {
return
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.
replace
(
/
[
xy
]
/g
,
function
(
c
)
{
const
r
=
(
Math
.
random
()
*
16
)
|
0
;
const
v
=
c
==
'x'
?
r
:
(
r
&
0x3
)
|
0x8
;
const
v
=
c
==
=
'x'
?
r
:
(
r
&
0x3
)
|
0x8
;
return
v
.
toString
(
16
);
})
.
toUpperCase
();
...
...
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