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
60e83527
Commit
60e83527
authored
Sep 19, 2024
by
李纪文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 消息订阅增加mqtt账户信息设置
parent
84938fcb
Pipeline
#92738
waiting for manual action with stages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
constants.js
src/layouts/AppLayout/notifier/constants.js
+2
-2
notice.js
src/layouts/AppLayout/notifier/notice.js
+24
-2
No files found.
src/layouts/AppLayout/notifier/constants.js
View file @
60e83527
...
...
@@ -17,8 +17,8 @@ export const MESSAGE_TYPE = {
export
const
NEW_MESSAGE
=
'NEW_MESSAGE'
;
export
const
USERNAME
=
'
mao2080
'
;
export
const
PASSWORD
=
'
123
'
;
export
const
USERNAME
=
'
admin
'
;
export
const
PASSWORD
=
'
public
'
;
export
const
PLATFORM_LEVEL
=
'4'
;
export
const
VIDEO_LEVEL
=
'5'
;
export
const
SYS_LEVEL
=
'6'
;
...
...
src/layouts/AppLayout/notifier/notice.js
View file @
60e83527
import
logger
from
'@wisdom-utils/utils/lib/logger'
;
import
_
,
{
isEmpty
,
isString
}
from
'lodash'
;
import
MqttClient
from
'mqtt-client'
;
import
CryptoJS
from
'crypto-js'
;
import
{
isJSON
}
from
'@wisdom-utils/components/lib/AppLayout/helpers/index'
;
import
{
api
}
from
'./api'
;
import
{
replaceSpeak
,
generatedId
}
from
'./utils'
;
...
...
@@ -27,6 +28,25 @@ import { createMessageFromHis, createMessageFromReal } from './message';
/* eslint-disable */
// eslint-disable-next-line no-undef
const
Logger
=
logger
(
'mqtt'
);
// mqtt密码解密
export
const
getDecryptedValue
=
(
encryptedText
)
=>
{
const
AESKey
=
'1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'
;
//32位
const
AES_IV
=
'1234567890000000'
;
//16位
const
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
AESKey
);
const
iv
=
CryptoJS
.
enc
.
Utf8
.
parse
(
AES_IV
);
// 解密
const
decrypted
=
CryptoJS
.
AES
.
decrypt
(
{
ciphertext
:
CryptoJS
.
enc
.
Hex
.
parse
(
encryptedText
)
},
key
,
{
iv
:
iv
},
);
// 转换为明文
const
plaintext
=
decrypted
.
toString
(
CryptoJS
.
enc
.
Utf8
);
return
plaintext
;
};
class
Notifier
{
constructor
(
userInfo
,
renderVideo
,
renderPlatform
,
renderSysPlatform
,
props
)
{
this
.
userInfo
=
userInfo
;
...
...
@@ -185,8 +205,8 @@ class Notifier {
const
keepAlive
=
DEFAULT_KEEPLIVE
;
const
cleanSession
=
true
;
const
ssl
=
this
.
_siteConfig
.
IsSSL
;
const
userName
=
USERNAME
;
const
password
=
PASSWORD
;
const
userName
=
this
.
_siteConfig
?.
mqtt_account
||
USERNAME
;
const
password
=
this
.
_siteConfig
?.
mqtt_cyphers
?
getDecryptedValue
(
this
.
_siteConfig
?.
mqtt_cyphers
)
:
PASSWORD
;
const
path
=
this
.
_siteConfig
.
mqtt_path
;
const
siteCode
=
this
.
_siteConfig
.
site_code
??
''
;
this
.
MQTTCount
=
0
;
...
...
@@ -244,6 +264,8 @@ class Notifier {
mqttConfig
.
mqtt_mess
.
MessageLevel
=
self
.
_siteConfig
.
MessageLevel
=
data
.
MessageLevel
?
data
.
MessageLevel
:
DEFAULT_PARSE_LEVEL
;
mqttConfig
.
mqtt_account
=
self
.
_siteConfig
.
mqtt_account
=
data
?.
EmqAccount
||
''
;
mqttConfig
.
mqtt_cyphers
=
self
.
_siteConfig
.
mqtt_cyphers
=
data
?.
EmqPassword
||
''
;
if
(
data
.
NginxStart
)
{
mqttConfig
.
NginxStart
=
self
.
_siteConfig
.
NginxStart
=
data
.
NginxStart
;
...
...
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