parent
6274b1f01d
commit
699dabd490
|
@ -25,4 +25,6 @@ export default {
|
|||
queryProvider: (data?: any) => server.post<any>(`/gateway/device/detail/_query`, data),
|
||||
// 查询网关配置
|
||||
getConfiguration: (id: string, transport: string) => server.get<any>(`/protocol/${id}/${transport}/configuration`),
|
||||
//校验ID合法
|
||||
validateId: (id:string) => server.get<any>('/media/device/id/_validate',{id:id})
|
||||
}
|
|
@ -13,10 +13,11 @@ const timeout = 5000
|
|||
const tempQueue: any[] = [] // websocket未连接上时,缓存消息列
|
||||
|
||||
export const initWebSocket = () => {
|
||||
const token = getToken()
|
||||
if (!token) return
|
||||
if (ws) {
|
||||
return ws
|
||||
}
|
||||
const token = getToken()
|
||||
const url = `${document.location.protocol.replace('http', 'ws')}//${document.location.host}${BASE_API_PATH}/messaging/${token}?:X_Access_Token=${token}`;
|
||||
if (count < total) {
|
||||
count += 1
|
||||
|
@ -102,6 +103,13 @@ export const getWebSocket = (id: string, topic: string, parameter: Record<string
|
|||
}
|
||||
})
|
||||
|
||||
export const closeWs = () => {
|
||||
if (ws) {
|
||||
ws.close()
|
||||
timer && clearInterval(timer)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重连
|
||||
*/
|
||||
|
|
|
@ -162,6 +162,7 @@ const save = () => {
|
|||
const importCancel = () => {
|
||||
importVisible.value = false
|
||||
emit('save')
|
||||
cancel()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ import DeviceApi from '@/api/media/device';
|
|||
import { PROVIDER_OPTIONS } from '@/views/media/Device/const';
|
||||
import type { ProductType } from '@/views/media/Device/typings';
|
||||
import SaveProduct from './SaveProduct.vue';
|
||||
import { notification } from 'jetlinks-ui-components';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
@ -425,13 +426,18 @@ const handleSubmit = () => {
|
|||
formRef.value
|
||||
?.validate()
|
||||
.then(async () => {
|
||||
btnLoading.value = true;
|
||||
const res = !route.query.id
|
||||
? await DeviceApi.save(params)
|
||||
: await DeviceApi.update(params);
|
||||
if (res?.success) {
|
||||
onlyMessage('保存成功');
|
||||
history.back();
|
||||
const resq:any = await DeviceApi.validateId(id)
|
||||
if(resq.status === 200 && resq?.result?.passed){
|
||||
btnLoading.value = true;
|
||||
const res = !route.query.id
|
||||
? await DeviceApi.save(params)
|
||||
: await DeviceApi.update(params);
|
||||
if (res?.success) {
|
||||
onlyMessage('保存成功');
|
||||
history.back();
|
||||
}
|
||||
}else{
|
||||
notification.error({ key: 'error', message: '设备ID已重复'})
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
|
|
|
@ -178,6 +178,7 @@ import { LocalStore } from '@/utils/comm';
|
|||
import { BASE_API_PATH, TOKEN_KEY, Version_Code } from '@/utils/variable';
|
||||
import { SystemConst } from '@/utils/consts';
|
||||
import {encrypt} from '@/utils/encrypt'
|
||||
import { closeWs } from '@/utils/websocket'
|
||||
|
||||
const store = useUserInfo();
|
||||
const systemStore = useSystem();
|
||||
|
@ -382,6 +383,7 @@ getOpen();
|
|||
getCode();
|
||||
screenRotation(screenWidth.value, screenHeight.value);
|
||||
|
||||
closeWs()
|
||||
onMounted(()=>{
|
||||
getRsa()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue