constant.ts


Overview

The constant.ts file serves as a centralized mapping module for representing different running statuses within an application. It defines a mapping object, RunningStatusMap, which associates status identifiers with their human-readable labels and corresponding UI color codes. This facilitates consistent status display throughout the UI components by standardizing the presentation of running statuses.

Additionally, this file re-exports all constants from the @/constants/knowledge module, acting as a pass-through to consolidate constants in one place, simplifying imports elsewhere in the application.


Detailed Explanation

Imports

import { RunningStatus } from '@/constants/knowledge';

Exported Constant: RunningStatusMap

export const RunningStatusMap = {
  [RunningStatus.UNSTART]: {
    label: 'UNSTART',
    color: 'var(--accent-primary)',
  },
  [RunningStatus.RUNNING]: {
    label: 'Parsing',
    color: 'var(--team-member)',
  },
  [RunningStatus.CANCEL]: { 
    label: 'CANCEL', 
    color: 'var(--state-warning)' 
  },
  [RunningStatus.DONE]: { 
    label: 'SUCCESS', 
    color: 'var(--state-success)' 
  },
  [RunningStatus.FAIL]: { 
    label: 'FAIL', 
    color: 'var(--state-error'  // Note: Missing closing parenthesis - potential bug
  },
};

Re-export

export * from '@/constants/knowledge';

Implementation Details


Interaction with Other Parts of the System


Visual Diagram

This is a utility/constants file exporting a mapping object and re-exporting constants. A flowchart showing the relationships between imports and exports is most appropriate.

flowchart TD
    A[RunningStatus Enum<br/>(from @/constants/knowledge)] --> B[RunningStatusMap]
    B --> C[Export RunningStatusMap]
    A --> D[Re-export all from @/constants/knowledge]
    D --> E[Consumers import constants and RunningStatusMap]

    style A fill:#f9f,stroke:#333,stroke-width:1px
    style B fill:#bbf,stroke:#333,stroke-width:1px
    style D fill:#bbf,stroke:#333,stroke-width:1px
    style C fill:#bfb,stroke:#333,stroke-width:1px
    style E fill:#fbf,stroke:#333,stroke-width:1px

Summary

Aspect

Description

File Purpose

Define a mapping for running statuses to labels and colors; re-export knowledge constants.

Key Export

RunningStatusMap - maps status keys to UI labels and colors.

Dependencies

Imports RunningStatus enum/constants from @/constants/knowledge.

Usage

Used by UI components for consistent status display.

Implementation Note

Minor bug in the color string for the FAIL status (missing )).

Re-exports

All constants from knowledge are re-exported to consolidate imports.


If you maintain or extend this file, consider fixing the typo in the FAIL color value to avoid UI bugs. Also, ensure any additions to the RunningStatus enum are reflected in RunningStatusMap for consistent UI representation.