|
|
@@ -28,9 +28,8 @@ export function useConnectMqtt() {
|
|
|
if (val) {
|
|
|
if (mqttState.value) return
|
|
|
const result = await postDrc({})
|
|
|
- localStorage.removeItem('client_id');
|
|
|
if (result?.code === 0) {
|
|
|
- const { address, client_id, username, password, expire_time } = result.data
|
|
|
+ const { address, client_id, username, password, expire_time } = result.data;
|
|
|
// @TODO: 校验 expire_time
|
|
|
mqttState.value = new UranusMqtt(address, {
|
|
|
clientId: client_id,
|
|
|
@@ -41,10 +40,8 @@ export function useConnectMqtt() {
|
|
|
mqttState.value?.on('onStatus', (statusOptions: StatusOptions) => {
|
|
|
// @TODO: 异常case
|
|
|
})
|
|
|
-
|
|
|
store.commit('SET_MQTT_STATE', mqttState.value)
|
|
|
- store.commit('SET_CLIENT_ID', client_id)
|
|
|
- localStorage.setItem('client_id', client_id)
|
|
|
+ store.commit('SET_CLIENT_ID', client_id);
|
|
|
}
|
|
|
// @TODO: 认证失败case
|
|
|
return
|
|
|
@@ -56,7 +53,6 @@ export function useConnectMqtt() {
|
|
|
mqttState.value = null
|
|
|
store.commit('SET_MQTT_STATE', null)
|
|
|
store.commit('SET_CLIENT_ID', '')
|
|
|
- localStorage.removeItem('client_id')
|
|
|
}
|
|
|
}, { immediate: true })
|
|
|
|