structure.md 3.0 KB

Project Structure

Root Level Organization

├── entry/                  # Main application module
├── ijkplayer/             # Media player native module
├── lib/                   # Shared library (lyrics component)
├── AppScope/              # Application-level resources
├── doc/                   # Documentation and build scripts
├── oh_modules/            # Dependencies (like node_modules)
└── build-profile.json5    # Multi-module build configuration

Entry Module (entry/)

Main application code following HarmonyOS Stage Model:

entry/src/main/
├── ets/                   # ArkTS source code
│   ├── pages/            # Page components (routing destinations)
│   ├── view/             # Reusable UI components
│   ├── viewmodel/        # Data models and business logic
│   ├── common/           # Shared utilities and constants
│   ├── controller/       # System controllers (media session, etc.)
│   ├── dialog/           # Dialog components
│   ├── entryability/     # Application abilities
│   └── workers/          # Background workers
├── cpp/                  # Native C++ code
├── resources/            # Resources (strings, images, etc.)
└── module.json5          # Module configuration

Key Directories

Pages (entry/src/main/ets/pages/)

  • Route-level components that represent full screens
  • Each page should be self-contained with its own state management
  • Examples: NewIndex.ets, UserCenter.ets, SettingPage.ets

Views (entry/src/main/ets/view/)

  • Reusable UI components
  • Should be stateless or manage only local UI state
  • Examples: TitleBar.ets, LocalMusic.ets, StreamContent.ets

ViewModels (entry/src/main/ets/viewmodel/)

  • Data models and business logic
  • Handle API calls, data transformation, and state management
  • Examples: MainViewModel.ets, VideoItem.ets, UserAuthModel.ets

Common (entry/src/main/ets/common/)

  • Shared utilities, constants, and helper classes
  • Organized by type: constants/, util/, model/

Native Modules

ijkplayer Module (ijkplayer/)

  • FFmpeg-based media player implementation
  • Contains C++ native code and ArkTS bindings
  • Provides media playback capabilities to the main app

Lib Module (lib/)

  • Shared library for lyrics functionality
  • Can be imported by other modules
  • Contains lyrics parsing and display components

Configuration Files

  • build-profile.json5: Multi-module build configuration
  • oh-package.json5: Root package dependencies
  • module.json5: Module-specific configuration (abilities, permissions)
  • hvigorfile.ts: Build script configuration

Naming Conventions

  • Files: PascalCase for components (NewIndex.ets), camelCase for utilities
  • Directories: camelCase for most, lowercase for standard dirs (pages, view)
  • Components: PascalCase struct names
  • Variables: camelCase
  • Constants: UPPER_SNAKE_CASE