From efce40f50f4a27dc764f1e26db67227c6ba819ca Mon Sep 17 00:00:00 2001 From: liutao <790864623@qq.com> Date: Fri, 12 Jun 2026 10:47:04 +0800 Subject: [PATCH] update --- src/views/mes/printconfig/index.vue | 46 ++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/views/mes/printconfig/index.vue b/src/views/mes/printconfig/index.vue index eb9210a9..bb10d7cd 100644 --- a/src/views/mes/printconfig/index.vue +++ b/src/views/mes/printconfig/index.vue @@ -257,6 +257,13 @@ const getActiveXComputerName = () => { const getSocketHostName = () => { const socket = getHiwebSocket() + + // ���ȼ�� socket.clientInfo����ǰ���ӿͻ�����Ϣ�� + const hostNameFromInfo = extractHostName(socket?.clientInfo) + if (hostNameFromInfo) { + return hostNameFromInfo + } + const clients = socket?.clients const clientList = Array.isArray(clients) ? clients : Object.values(clients || {}) @@ -309,14 +316,37 @@ const resolveCurrentHostName = async () => { window.clearTimeout(timer) resolve(hostName || getSocketHostName()) } - const timer = window.setTimeout(() => finish(), 1500) + + const timer = window.setTimeout(() => finish(), 3000) + const socket = getHiwebSocket() + + // ������ socket.io ʵ����ֱ�Ӽ��� clients/clientInfo �¼� + if (socket?.socket?.on) { + const onClients = () => { + const hn = getSocketHostName() + if (hn) finish(hn) + } + const onClientInfo = () => { + const hn = extractHostName(socket.clientInfo) || getSocketHostName() + if (hn) finish(hn) + } + socket.socket.on('clients', onClients) + socket.socket.on('clientInfo', onClientInfo) + } + + // ���������������������� + if (socket) { + if (typeof socket.getClients === 'function') socket.getClients() + if (typeof socket.getClientInfo === 'function') socket.getClientInfo() + if (typeof socket.refreshPrinterList === 'function') socket.refreshPrinterList() + } + + // autoConnect ���� socket�����������ص��� false���ȴ����ӳɹ���� true�� autoConnect((status: boolean) => { if (!status) { - finish() return } - const socket = getHiwebSocket() - socket?.refreshPrinterList?.() + getHiwebSocket()?.refreshPrinterList?.() window.setTimeout(() => finish(getSocketHostName()), 300) }) }) @@ -327,13 +357,9 @@ const resolveCurrentHostName = async () => { const initCurrentHostName = async () => { const hostName = await resolveCurrentHostName() - if (!hostName) { - let s = normalizeClientHost(); - currentHostName.value = s - queryParams.hostName = s - }else{ + if (hostName) { currentHostName.value = hostName - queryParams.hostName = hostName || undefined + queryParams.hostName = hostName } }