lxl-dev #3

Merged
zhanghao merged 122 commits from lxl-dev into dev 2026-08-24 13:55:18 +08:00
4 changed files with 27 additions and 15 deletions
Showing only changes of commit 8d2f3e37b4 - Show all commits

View File

@ -17,6 +17,9 @@ const DEVICE_KIND_META = Object.freeze({
const clone = (value) => JSON.parse(JSON.stringify(value ?? null)) const clone = (value) => JSON.parse(JSON.stringify(value ?? null))
const normalizedText = (value) => String(value || '').trim() const normalizedText = (value) => String(value || '').trim()
const LEGACY_NODE_TYPE_ALIASES = Object.freeze({
device_universal: 'deviceUniversal',
})
export const createResourceKey = (prefix) => { export const createResourceKey = (prefix) => {
const random = globalThis.crypto?.randomUUID?.().replace(/-/g, '').slice(0, 10) const random = globalThis.crypto?.randomUUID?.().replace(/-/g, '').slice(0, 10)
@ -90,6 +93,11 @@ const findOrCreateLegacySlot = (role, node, legacySlotByIdentity, legacyDeviceId
*/ */
export const normalizeFlowResourceSchema = (sourceGraph) => { export const normalizeFlowResourceSchema = (sourceGraph) => {
const graph = clone(sourceGraph || { nodes: [], edges: [] }) const graph = clone(sourceGraph || { nodes: [], edges: [] })
graph.nodes = Array.isArray(graph.nodes) ? graph.nodes : []
graph.edges = Array.isArray(graph.edges) ? graph.edges : []
graph.nodes.forEach((node) => {
node.type = LEGACY_NODE_TYPE_ALIASES[node.type] || node.type
})
const start = getStartNode(graph) const start = getStartNode(graph)
if (!start) return graph if (!start) return graph

View File

@ -62,7 +62,7 @@ const currentComponent = computed(() => {
if (type === 'http') return HttpNodeParams if (type === 'http') return HttpNodeParams
if (type === 'sdAgent') return SdAgentNodeParams if (type === 'sdAgent') return SdAgentNodeParams
if (type === 'recognize') return RecognizeNodeParams if (type === 'recognize') return RecognizeNodeParams
if (type === 'deviceUniversal') return DeviceUniversal if (['deviceUniversal', 'device_universal'].includes(type)) return DeviceUniversal
if (type === 'branch') return SwitchNodeParams if (type === 'branch') return SwitchNodeParams
return null return null
}) })

View File

@ -791,35 +791,38 @@ const loopFlowView = async (instId, taskId = null) => {
if (flowDisposed) return; if (flowDisposed) return;
if (res.code === 200) { if (res.code === 200) {
const arr = res.data || []; const arr = res.data || [];
if (arr.length === 0) {
if (!flowInfoData.value.isLog) scheduleFlowView(instId, taskId);
return;
}
if (arr.length > 0) hasRunResult.value = true; if (arr.length > 0) hasRunResult.value = true;
arr.forEach((item) => { arr.forEach((item) => {
emitter.emit("changeNodeState", item); emitter.emit("changeNodeState", item);
}); });
oldFlowData = JSON.parse(JSON.stringify(lf.getGraphData())); oldFlowData = JSON.parse(JSON.stringify(lf.getGraphData()));
if ( const first = arr[0];
arr[arr.length - 1]?.nodeType !== "END" && const last = arr[arr.length - 1];
!["FAILED", "STOPPED"].includes(arr[arr.length - 1]?.status) const lastNodeType = String(last?.nodeType || "").toUpperCase();
) { const lastStatus = String(last?.status || "").toUpperCase();
scheduleFlowView(instId); if (lastNodeType === "END" && lastStatus === "SUCCESS") {
} else if (
arr[arr.length - 1]?.nodeType === "END" &&
arr[arr.length - 1]?.status === "SUCCESS"
) {
if (!flowInfoData.value.isLog) { if (!flowInfoData.value.isLog) {
flowStore.updateDisableForm(false); flowStore.updateDisableForm(false);
flowState.value = "testRunFinish"; flowState.value = "testRunFinish";
totalRunningTime.value = arr[arr.length - 1].endTime - arr[0].startTime totalRunningTime.value = last.endTime - first.startTime;
} }
} else { } else if (["FAILED", "STOPPED", "PAUSED"].includes(lastStatus)) {
if (!flowInfoData.value.isLog) { if (!flowInfoData.value.isLog) {
if (["PAUSED", "STOPPED"].includes(arr[arr.length - 1]?.status)) { if (["PAUSED", "STOPPED"].includes(lastStatus)) {
flowState.value = arr[arr.length - 1]?.status === "PAUSED" ? "pause" : "stop"; flowState.value = lastStatus === "PAUSED" ? "pause" : "stop";
} else { } else {
flowState.value = "testRunError"; flowState.value = "testRunError";
totalRunningTime.value = arr[arr.length - 1].endTime - arr[0].startTime totalRunningTime.value = last.endTime - first.startTime;
flowStore.updateDisableForm(false); flowStore.updateDisableForm(false);
} }
} }
} else if (!flowInfoData.value.isLog) {
// END is first persisted as RUNNING and updated to SUCCESS after the handler returns.
scheduleFlowView(instId, taskId);
} }
} }
}; };

View File

@ -105,6 +105,7 @@ const componentMap = {
sdAgent: SdAgentNode, sdAgent: SdAgentNode,
recognize: RecognizeNode, recognize: RecognizeNode,
deviceUniversal: DeviceUniversal, deviceUniversal: DeviceUniversal,
device_universal: DeviceUniversal,
}; };
const flowStore = useFlowStore(); const flowStore = useFlowStore();