common.ts


Overview

The common.ts file serves as a centralized utility and constants module within the application, providing key mappings, enumerations, and lists related to file handling, language localization, platform identification, and theming. This file primarily defines static data structures such as icon mappings for file extensions, supported languages with their translations and abbreviations, MIME types for common file formats, and configuration constants for previewing files and platform/theme options.

This file is designed to be imported and used throughout the application wherever these constants or mappings are needed, thus promoting consistency and reducing hard-coded values scattered across the codebase.


Detailed Explanations

1. fileIconMap

export const fileIconMap: { [extension: string]: string }

2. LanguageList

export const LanguageList: string[]

3. LanguageMap

export const LanguageMap: { [language: string]: string }

4. LanguageAbbreviation (enum)

export enum LanguageAbbreviation {
  En = 'en',
  Zh = 'zh',
  ZhTraditional = 'zh-TRADITIONAL',
  Id = 'id',
  Ja = 'ja',
  Es = 'es',
  Vi = 'vi',
  PtBr = 'pt-BR',
  De = 'de',
  Fr = 'fr',
}

5. LanguageAbbreviationMap

export const LanguageAbbreviationMap: { [key in LanguageAbbreviation]: string }

6. LanguageTranslationMap

export const LanguageTranslationMap: { [language: string]: string }

7. FileMimeType (enum)

export enum FileMimeType {
  Bmp = 'image/bmp',
  Csv = 'text/csv',
  Odt = 'application/vnd.oasis.opendocument.text',
  Doc = 'application/msword',
  Docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  Gif = 'image/gif',
  Htm = 'text/htm',
  Html = 'text/html',
  Jpg = 'image/jpg',
  Jpeg = 'image/jpeg',
  Pdf = 'application/pdf',
  Png = 'image/png',
  Ppt = 'application/vnd.ms-powerpoint',
  Pptx = 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  Tiff = 'image/tiff',
  Txt = 'text/plain',
  Xls = 'application/vnd.ms-excel',
  Xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  Mp4 = 'video/mp4',
  Json = 'application/json',
}

8. Domain

export const Domain = 'demo.ragflow.io';

9. File Preview Configuration

Images

export const Images: string[]

ExceptiveType

export const ExceptiveType: string[]

SupportedPreviewDocumentTypes

export const SupportedPreviewDocumentTypes: string[]

10. Platform (enum)

export enum Platform {
  RAGFlow = 'RAGFlow',
  Dify = 'Dify',
  FastGPT = 'FastGPT',
  Coze = 'Coze',
}

11. ThemeEnum (enum)

export enum ThemeEnum {
  Dark = 'dark',
  Light = 'light',
  System = 'system',
}

Implementation Details and Algorithms


Interaction with Other Parts of the System


Visual Diagram

flowchart TD
    A[fileIconMap]
    B[LanguageList]
    C[LanguageMap]
    D[LanguageAbbreviation Enum]
    E[LanguageAbbreviationMap]
    F[LanguageTranslationMap]
    G[FileMimeType Enum]
    H[Domain]
    I[Images Array]
    J[ExceptiveType Array]
    K[SupportedPreviewDocumentTypes Array]
    L[Platform Enum]
    M[ThemeEnum Enum]

    B --> C
    D --> E
    B --> F
    I --> J
    J --> K

Diagram Explanation:


Summary

The common.ts file is a foundational constants and enums module that standardizes file icons, language data, MIME types, platform identifiers, and theming options across the application. It contains no executable logic but provides essential lookup tables and enums that other modules rely on to ensure consistency, maintainability, and localization support throughout the system.