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