constant.ts


Overview

The constant.ts file serves as a centralized mapping and export module for running status constants used throughout the application. It imports an enumeration of running statuses from a knowledge base module (@/constants/knowledge) and defines a corresponding mapping object, RunningStatusMap, which associates each status with a user-friendly label and a color code. This mapping is useful for UI components or services that need to display status information with consistent text and color styling.

Additionally, this file re-exports all exports from the @/constants/knowledge module, effectively making it a pass-through module that consolidates related constants into one import point.


Detailed Explanation

Imported Entities


Exported Constants

RunningStatusMap

export const RunningStatusMap = {
  [RunningStatus.UNSTART]: {
    label: 'UNSTART',
    color: 'cyan',
  },
  [RunningStatus.RUNNING]: {
    label: 'Parsing',
    color: 'blue',
  },
  [RunningStatus.CANCEL]: { label: 'CANCEL', color: 'orange' },
  [RunningStatus.DONE]: { label: 'SUCCESS', color: 'geekblue' },
  [RunningStatus.FAIL]: { label: 'FAIL', color: 'red' },
};

Re-exported Entities

export * from '@/constants/knowledge';

Implementation Details


Interaction with Other Parts of the System


Visual Diagram

flowchart TD
    A[constant.ts] --> B[Import RunningStatus Enum]
    A --> C[Define RunningStatusMap]
    A --> D[Re-export all from @/constants/knowledge]
    C --> E[UNSTART: {label, color}]
    C --> F[RUNNING: {label, color}]
    C --> G[CANCEL: {label, color}]
    C --> H[DONE: {label, color}]
    C --> I[FAIL: {label, color}]

Summary