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
a4a765a9
Commit
a4a765a9
authored
Mar 31, 2022
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 登录获取网站配置同时获取mqtt配置
parent
0e5b9e51
Pipeline
#47037
skipped with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
16 deletions
+58
-16
index.js
src/components/Notifier/index.js
+6
-7
login.js
src/pages/user/login/login.js
+52
-9
No files found.
src/components/Notifier/index.js
View file @
a4a765a9
...
...
@@ -558,7 +558,6 @@ class Notifier {
mqtt_IsSSL
:
true
};
if
(
Array
.
isArray
(
res
.
getMe
)
&&
res
.
getMe
.
length
>
0
)
{
debugger
if
(
res
.
getMe
[
0
])
{
const
data
=
res
.
getMe
[
0
];
mqttConfig
.
mqtt_IsSSL
=
self
.
_siteConfig
.
IsSSL
=
data
.
IsSSL
?
data
.
IsSSL
:
false
;
...
...
@@ -583,14 +582,14 @@ class Notifier {
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
}))
//
self.props.updateConfig && self.props.updateConfig(Object.assign({}, self.props.global, {
//
...mqttConfig
//
}))
// 应用共享状态只在initMicro中更新了一次,异步修改了的globalConfig,子应用读取到的是旧的,需要更新一下应用共享状态
setGlobalState
({
globalConfig
:
window
.
globalConfig
});
//
setGlobalState({
//
globalConfig: window.globalConfig
//
});
}
}
else
{
Logger
.
info
(
'获取mqtt服务器参数失败'
);
...
...
src/pages/user/login/login.js
View file @
a4a765a9
...
...
@@ -6,7 +6,7 @@ import Cookies from 'js-cookie';
import
sha1
from
'sha1'
;
import
{
SlideVerify
}
from
'@wisdom-utils/components'
;
import
{
appService
}
from
'@/api'
;
import
{
appService
,
noticeService
}
from
'@/api'
;
import
{
getUserInfo
,
getWebSiteConfig
}
from
'@/api/service/base'
;
import
{
SERVICE_APP_LOGIN_MODE
,
...
...
@@ -14,6 +14,7 @@ import {
WX_REDIRECT_URI
,
}
from
'@/constants'
;
import
store
from
'@/stores'
;
import
{
DEFAULT_MQTT_PATH
,
DEFAULT_TCP_IP
,
DEFAULT_TCP_PORT
,
DEFAULT_PARSE_LEVEL
}
from
'@/components/Notifier/constants'
;
// eslint-disable-next-line no-undef
const
Logger
=
logger
(
'login'
);
...
...
@@ -23,7 +24,7 @@ class Login {
this
.
events
=
window
.
share
.
event
;
this
.
globalConfig
=
props
.
global
;
// this.updateConfig = props.updateConfig;
this
.
updateConfig
=
(
config
)
=>
{
props
.
updateConfig
(
config
);
this
.
globalConfig
=
getGlobalConfig
();
console
.
log
(
'11'
)
}
this
.
updateConfig
=
(
config
)
=>
{
props
.
updateConfig
(
config
);
this
.
globalConfig
=
getGlobalConfig
();
}
this
.
createContext
=
props
.
createContext
;
this
.
history
=
props
.
history
;
this
.
callback
=
callback
;
...
...
@@ -210,13 +211,55 @@ class Login {
const
self
=
this
;
// eslint-disable-next-line no-undef
getWebSiteConfig
({
client
:
self
.
globalConfig
.
client
,
token
,
'request.preventCache'
:
Date
.
now
(),
})
.
then
(
response
=>
{
debugger
// 获取网站配置的同时,预先获取到mqtt配置,注册进子应用
Promise
.
all
([
noticeService
.
getMqttSiteCode
({
'request.preventCache'
:
Date
.
now
()
}),
getWebSiteConfig
({
client
:
self
.
globalConfig
.
client
,
token
,
'request.preventCache'
:
Date
.
now
(),
})
]).
then
(
results
=>
{
const
res
=
results
[
0
]
??
{};
if
(
res
&&
res
.
say
.
statusCode
===
'0000'
)
{
let
mqttConfig
=
{
mqtt_mess
:
{},
mqtt_path
:
DEFAULT_MQTT_PATH
,
nginxStart
:
false
,
mqtt_IsSSL
:
true
};
if
(
Array
.
isArray
(
res
.
getMe
)
&&
res
.
getMe
.
length
>
0
)
{
if
(
res
.
getMe
[
0
])
{
const
data
=
res
.
getMe
[
0
];
mqttConfig
.
mqtt_IsSSL
=
data
.
IsSSL
?
data
.
IsSSL
:
false
;
mqttConfig
.
mqtt_mess
.
site_code
=
data
.
SiteCode
||
self
.
globalConfig
.
userInfo
.
site
;
mqttConfig
.
mqtt_mess
.
TcpIP
=
data
.
TcpIP
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
data
.
TcpPort
?
parseInt
(
data
.
TcpPort
)
:
8083
;
mqttConfig
.
mqtt_mess
.
MessageLevel
=
data
.
MessageLevel
?
data
.
MessageLevel
:
DEFAULT_PARSE_LEVEL
;
if
(
data
.
NginxStart
)
{
mqttConfig
.
NginxStart
=
data
.
NginxStart
;
mqttConfig
.
mqtt_mess
.
TcpIP
=
window
.
location
.
hostname
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
parseInt
(
window
.
location
.
port
);
mqttConfig
.
mqtt_path
=
'/ws/'
;
}
else
{
mqttConfig
.
nginxStart
=
data
.
NginxStart
}
}
else
{
mqttConfig
.
mqtt_mess
.
TcpIP
=
DEFAULT_TCP_IP
;
mqttConfig
.
mqtt_mess
.
TcpPort
=
DEFAULT_TCP_PORT
;
mqttConfig
.
mqtt_IsSSL
=
mqttConfig
.
mqtt_mess
.
TcpIP
+
":"
+
mqttConfig
.
mqtt_mess
.
TcpPort
;
}
mqttConfig
.
mqtt_iotIP
=
mqttConfig
.
mqtt_mess
.
TcpIP
+
":"
+
mqttConfig
.
mqtt_mess
.
TcpPort
;
self
.
globalConfig
=
Object
.
assign
(
self
.
globalConfig
,
{
...
mqttConfig
});
}
}
else
{
Logger
.
info
(
'获取mqtt服务器参数失败'
);
}
return
results
;
}).
then
(
results
=>
{
const
response
=
results
[
1
]
??
{};
const
result
=
response
&&
response
.
code
===
SERVICE_INTERFACE_SUCCESS_CODE
?
Array
.
isArray
(
response
.
data
)
...
...
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