From cdd0a28197fb9b432a45bbf9ebc0cfd8db939125 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 25 七月 2024 10:34:44 +0800 Subject: [PATCH] websocket更新,配置文件增加websocket地址 --- src/views/tigerprojects/system/lowcode/normal/index.vue | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/views/tigerprojects/system/lowcode/normal/index.vue b/src/views/tigerprojects/system/lowcode/normal/index.vue index 8e45715..eed529b 100644 --- a/src/views/tigerprojects/system/lowcode/normal/index.vue +++ b/src/views/tigerprojects/system/lowcode/normal/index.vue @@ -4,7 +4,7 @@ * @version: * @Date: 2024-05-30 13:28:20 * @LastEditors: Ben Lin - * @LastEditTime: 2024-07-20 05:21:44 + * @LastEditTime: 2024-07-24 23:47:07 --> <template> <div> @@ -14,7 +14,7 @@ </div> </template> <script lang="ts" setup> - import { Ref, defineAsyncComponent, h, onMounted, provide, ref, unref } from 'vue'; + import { Ref, defineAsyncComponent, h, onMounted, provide, ref, unref, watch } from 'vue'; import mainTable from './mainTable.vue'; import { DeleteEntity, GetEnum, getEntity, getListByPage } from '/@/api/tigerapi/system'; import { useRoute, useRouter } from 'vue-router'; @@ -26,8 +26,10 @@ import { useGo } from '/@/hooks/web/usePage'; import { useI18n } from '/@/hooks/web/useI18n'; import { getRoleButtons } from '/@/api/sys/menu'; + import { useWebSocketStore } from '/@/store/modules/websocket'; const { getLocale } = useLocale(); + const webSocketStore = useWebSocketStore(); const { t } = useI18n(); const route = useRoute(); const { currentRoute } = useRouter(); @@ -46,6 +48,7 @@ const custImport = ref<any>(null); const isMounted = ref(false); const buttons = ref([]); + const readyState = ref<number>(WebSocket.CONNECTING); const AuthOption = ref({ BY_ORG: '', BY_PROD: '', @@ -59,7 +62,13 @@ provide<Ref<string>>('isExistSql', isExistSql); provide<Ref<{}>>('AuthOption', AuthOption); provide<Ref<any>>('keyFieldValues', keyFieldValues); - + // 鐩戝惉readyState鍙樺寲 + watch(readyState, (newState) => { + if (newState === WebSocket.CLOSED || newState === WebSocket.CLOSING) { + // 灏濊瘯閲嶈繛 + setTimeout(webSocketStore.connectWebSocket, 3000); + } + }); onMounted(async () => { /* 鐢╦son鑾峰彇鍒� */ // _searchFormSchema.value = await fetchJson( @@ -81,6 +90,7 @@ // } // _columns.value = objs; + webSocketStore.connectWebSocket(); isMounted.value = false; /* 鍔ㄦ�乮mport瀹炰綋鍚�.ts鐨勮嚜瀹氫箟鏂规硶 */ try { @@ -188,5 +198,4 @@ }; } } - </script> -- Gitblit v1.9.3