|
|
@@ -204,7 +204,7 @@
|
|
|
import type { AttachedFile, Message, ScheduleTask, SubAppRoute, Task } from '/@/views/ventAI/manageAssistent/types/index';
|
|
|
import { buildCapsuleFiles, buildCapsuleLinks, buildCapsuleAgents } from '/@/views/ventAI/manageAssistent/lib/capsule';
|
|
|
import { parseModalPreviewLink, isFileDownloadLink, downloadLinkFile } from '/@/views/ventAI/manageAssistent/lib/index';
|
|
|
- import { locateDevice, locateDeviceReport, locateTunnel } from '/@/views/ventAI/manageAssistent/lib/modalPreviewBridge';
|
|
|
+ import { locateDevice, locateDeviceReport, locateTunnel, onLocateResult } from '/@/views/ventAI/manageAssistent/lib/modalPreviewBridge';
|
|
|
import { useChatStream } from '../hooks/useChatStream';
|
|
|
import { useChatTasks } from '../hooks/useChatTasks';
|
|
|
import { useChatPanels } from '../hooks/useChatPanels';
|
|
|
@@ -380,12 +380,12 @@
|
|
|
* 同一模型下只做定位,不重载 iframe:
|
|
|
* tunid → 巷道定位,locationId → 设备定位,locationName → 报表定位。
|
|
|
*/
|
|
|
- const applyModelLocate = (route: SubAppRoute | null) => {
|
|
|
+ const applyModelLocate = (route: SubAppRoute | null): boolean => {
|
|
|
const query = route?.query || {};
|
|
|
const modelId = query.model_id || modelPreview.modelId;
|
|
|
- if (!modelId) return;
|
|
|
+ if (!modelId) return false;
|
|
|
const signature = [modelId, query.tunid || '', query.locationId || '', query.locationName || '', query.deviceType || ''].join('|');
|
|
|
- if (signature === lastModelLocateSignature) return;
|
|
|
+ if (signature === lastModelLocateSignature) return false;
|
|
|
lastModelLocateSignature = signature;
|
|
|
|
|
|
const deviceType = query.deviceType || (query.tunid ? 'tun' : 'fanlocal');
|
|
|
@@ -396,6 +396,7 @@
|
|
|
} else if (query.locationName) {
|
|
|
locateDeviceReport({ model_id: modelId, deviceType, locationName: query.locationName });
|
|
|
}
|
|
|
+ return true;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -410,7 +411,8 @@
|
|
|
|
|
|
if (modelPreview.loaded && modelPreview.modelId === modelId) {
|
|
|
modelPreview.ownerSessionId = currentSessionKey();
|
|
|
- applyModelLocate(route);
|
|
|
+ // 同一个模型只做定位;定位参数也没变时界面不会有任何变化,明确提示一下
|
|
|
+ if (!applyModelLocate(route)) message.info('当前显示的已是该模型');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -425,7 +427,7 @@
|
|
|
|
|
|
if (modelPreview.loaded && modelPreview.modelId === targetModelId) {
|
|
|
modelPreview.ownerSessionId = currentSessionKey();
|
|
|
- applyModelLocate(target);
|
|
|
+ if (!applyModelLocate(target)) message.info('当前显示的已是该模型');
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -468,10 +470,22 @@
|
|
|
};
|
|
|
|
|
|
const openModelPreview = (route: SubAppRoute, title?: string) => {
|
|
|
- openModalPreviewTab({ title: title || '二维模型', subAppRoute: route });
|
|
|
+ const tab = openModalPreviewTab({ title: title || '二维模型', subAppRoute: route });
|
|
|
+ if (!tab) {
|
|
|
+ // 没有当前会话时开不了标签页,不提示的话点击就是“没反应”
|
|
|
+ message.warning('请先新建或选择一个会话,再打开模型预览');
|
|
|
+ return;
|
|
|
+ }
|
|
|
void ensureModelPreview(route);
|
|
|
};
|
|
|
|
|
|
+ // 子应用没能定位(例如链接里的设备在模型里找不到)时界面不会有任何变化,必须提示用户,
|
|
|
+ // 否则表现就是“点了没反应”
|
|
|
+ const offLocateResult = onLocateResult((result) => {
|
|
|
+ if (result.ok) return;
|
|
|
+ message.warning(result.message || '未能在模型中找到该位置,请检查链接参数');
|
|
|
+ });
|
|
|
+
|
|
|
// 隐藏后开始 5 分钟空闲倒计时;重新显示立即取消
|
|
|
watch(modelPreviewVisible, (visible) => {
|
|
|
if (visible) clearModelPreviewIdleTimer();
|
|
|
@@ -1165,6 +1179,7 @@
|
|
|
);
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
+ offLocateResult();
|
|
|
// 移除挂载空壳,避免残留
|
|
|
portalWrapper.value?.remove();
|
|
|
portalWrapper.value = null;
|