罗广辉
4 hours ago 2e68b1338ea04125ce4360e6d2ddf03f54df86ac
apps/workbench-console/src/stores/artifacts.ts
@@ -6,11 +6,13 @@
  loadSemanticArtifacts,
  loadMeasurementArtifacts,
  loadTrajectoryArtifacts,
  loadAnomalyArtifacts,
  type DetectionCase,
  type ChangeCase,
  type SemanticCase,
  type MeasurementCase,
  type TrajectoryCase
  type TrajectoryCase,
  type AnomalyCase
} from "@/api/artifacts";
interface ArtifactState {
@@ -19,6 +21,7 @@
  semanticCases: Record<string, SemanticCase>;
  measurementCases: Record<string, MeasurementCase>;
  changeCases: Record<string, ChangeCase>;
  anomalyCases: Record<string, AnomalyCase>;
  loading: boolean;
  error: string | null;
}
@@ -28,7 +31,7 @@
    detectionRun: (state) => Object.values(state.detectionCases)[0]?.run ?? null,
    detectionImages: (state) => Object.values(state.detectionCases)[0]?.images ?? []
  },
  state: (): ArtifactState => ({ detectionCases: {}, trajectoryCases: {}, semanticCases: {}, measurementCases: {}, changeCases: {}, loading: false, error: null }),
  state: (): ArtifactState => ({ detectionCases: {}, trajectoryCases: {}, semanticCases: {}, measurementCases: {}, changeCases: {}, anomalyCases: {}, loading: false, error: null }),
  actions: {
    async loadChange(force = false) {
      if (!force && Object.keys(this.changeCases).length) return;
@@ -64,6 +67,13 @@
      try { this.measurementCases = await loadMeasurementArtifacts(); }
      catch (error) { this.error = error instanceof Error ? error.message : "空间测量结果读取失败"; }
      finally { this.loading = false; }
    },
    async loadAnomaly(force = false) {
      if (!force && Object.keys(this.anomalyCases).length) return;
      this.loading = true; this.error = null;
      try { this.anomalyCases = await loadAnomalyArtifacts(); }
      catch (error) { this.error = error instanceof Error ? error.message : "异常检测结果读取失败"; }
      finally { this.loading = false; }
    }
  }
});