feat: ws 封装工具测试

This commit is contained in:
TsMask
2024-01-25 11:06:39 +08:00
parent 4572c2060d
commit 9eaaba2d0a
3 changed files with 118 additions and 38 deletions

View File

@@ -13,10 +13,29 @@ import { ColumnsType } from 'ant-design-vue/lib/table/Table';
import { message } from 'ant-design-vue/lib';
import { hasPermissions } from '@/plugins/auth-user';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { WS, OptionsType } from '@/plugins/ws-websocket';
import useI18n from '@/hooks/useI18n';
const { t } = useI18n();
onMounted(() => {});
onMounted(() => {
const options: OptionsType = {
params: {
subGroupID: '1005',
},
onmessage: ev => {
// 接收数据后回调
console.log(ev);
},
onerror: (ev: any) => {
// 接收数据后回调
console.log(ev);
},
// 保活周期 10s
heartTimer: 0,
// 断线重连
reconnectTimer: 0,
};
const ws = new WS(options);
});
</script>
<template>