编辑 | blame | 历史 | 原始文档

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is a uni-app mobile application project for Quality Control (QC) and Warehouse management in a Manufacturing Execution System (MES). The application is built for PDA devices and supports quality inspection processes and warehouse operations.

  • Framework: uni-app (Vue 2.x based)
  • App Name: GS-MES-AP (广深科技 MES Application)
  • Target Platform: Android mobile/PDA devices
  • UI Framework: uView UI library

Build and Development Commands

This is a uni-app project that builds through HBuilderX IDE or uni-app CLI. The build output is generated in the unpackage/ directory:

  • Development Build: Use HBuilderX IDE or npm run dev:app-plus for development
  • Production Build: APK files are generated in unpackage/release/apk/
  • Cache: Build cache and temporary files are stored in unpackage/cache/
  • Testing: Use HBuilderX IDE's built-in testing tools or deploy to PDA devices for testing

Note: This project does not have traditional npm scripts. Development and building are primarily done through HBuilderX IDE.

Architecture Overview

Core Structure

  • Entry Point: main.js - Contains Vue prototypes, global mixins, and API configuration
  • State Management: store/index.js - Vuex store with server configuration and minimal state
  • Routing: pages.json - uni-app page configuration with tabBar navigation
  • Global Config: manifest.json - App configuration including permissions and build settings

Key Directories

  • pages/BasePages/ - Core app pages (login, main menu, user profile)
  • pages/QC/ - Quality Control modules (来料检验 LLJ, 巡检 XJ, 首检 SJ, 入库检 RKJ)
  • pages/Warehouse/ - Warehouse operations (inventory, purchasing, allocation)
  • components/ - Reusable UI components and third-party integrations
  • static/ - Static assets (images, audio files, CSS)
  • uni_modules/ - uni-app plugin modules including uView UI

API Architecture

  • Base API: Configured in Vuex store with environment-specific URLs
  • Request Methods: Custom Vue prototypes ($post, $get, $uni_request) with loading states
  • Authentication: User login state managed globally via $loginInfo
  • Error Handling: Centralized error handling with toast messages

Main Features

  1. Quality Control (QC):
  • 来料检验 (LLJ) - Incoming Material Inspection
  • 巡检 (XJ) - Patrol Inspection
  • 首检 (SJ) - First Article Inspection
  • 入库检 (RKJ) - Warehouse Inspection
  1. Warehouse Operations:
  • Purchase inventory management
  • Material allocation and transfers
  • Barcode printing and scanning
  1. Common Functions:
  • Barcode/QR code scanning
  • Photo capture and upload
  • Bluetooth printing integration
  • Offline data synchronization

Navigation Structure

  • Tab Bar: 3 main tabs (首页/Home, 消息中心/Message Center, 我的/Profile)
  • Menu System: Dynamic menu loading based on user permissions via $getUserMenu()
  • Page Flow: List → Detail → Form pattern for most workflows

Development Guidelines

Server Configuration

The app connects to different servers based on environment:
- Development: http://localhost:10054 or http://192.168.1.104:10056/api
- Check store/index.js for current active server endpoints

Global Utilities

  • $showMessage() - Display toast notifications
  • $showDialog() - Show confirmation dialogs
  • $camera() - Camera/photo selection functionality
  • $getDate() - Date formatting utilities
  • $getUrlParams() - URL parameter parsing

Component Dependencies

  • uView UI: Primary UI component library
  • Custom Components: Scanner, printer utilities in components/kk-printer/
  • Third-party: Charts (u-charts), maps (amap), markdown parsing

File Upload System

Image uploads use base64 encoding via $fileUpload() method, sending to /Base/saveImage endpoint.

Authentication System

  • User authentication is managed through $loginInfo object in main.js
  • Login state persists using uni.getStorageSync() and uni.setStorageSync()
  • Global mixin globalMixin.js provides checkUserAuth() for automatic login verification
  • Users are redirected to /pages/BasePages/login if not authenticated

Request Architecture

  • $post() and $get(): Standard API requests with automatic loading indicators
  • $uni_request(): Core request method with error handling and status checking
  • $toERP(): External ERP system integration requests
  • $postSyncPost(): Promise-based synchronous POST requests
  • All requests automatically handle loading states, error messages, and network failures

Hardware Integration

  • Camera: Native camera access via $camera() with image compression options
  • Barcode Scanner: QR/barcode scanning capabilities for PDA devices
  • Bluetooth Printing: Printer integration through components/kk-printer/
  • Device Permissions: Configured in manifest.json for camera, storage, network, and Bluetooth access

Page Architecture Patterns

  • List Pages: Pagination with pull-to-refresh and infinite scroll
  • Detail Pages: Read-only view with navigation to edit forms
  • Add/Edit Forms: Input validation and submission with photo upload capabilities
  • Scan Pages: Barcode scanning with immediate data processing

Environment Configuration

Current server endpoints are configured in store/index.js:
- Development: http://localhost:5184/api
- Internal Network: http://192.168.11.251:10054
- Testing: http://192.168.1.104:10056/api or 10057/api
- Switch between environments by updating serverAPI in the Vuex store