Moonglade

Modern Markdown blogging with AI-powered localization and search.

Tag: react

RSS

Upgrading umijs 3 to 4

This article documents the complete process and insights gained from upgrading the frontend framework of a legacy project from UmiJS 3 to UmiJS 4. The upgrade aims to address low development efficiency, clean up redundant code and libraries, and strengthen engineering standards such as TypeScript and ESLint. The author adopted a strategy of creating a new UmiJS 4 project and gradually migrating code, ensuring functionality stability before merging back into the original project. Specific changes include: replacing configurations with @umijs/max, removing dependencies on webpack-chain, proxy, and mock; rewriting the permission system to support dynamic routing and menus; refactoring class components into function components and introducing Hooks; updating Ant Design to the latest version and removing Less dependencies; deprecating umi-request in favor of axios; and adjusting tsconfig and internationalization configurations. Although specific errors were not detailed in this record, compatibility issues were successfully resolved through official documentation and community assistance, providing a practical reference for similar project upgrades.

Views 126
2024 configuration migration react ts umijs upgrade work

Frontend Excel Import Related Optimizations

This article introduces an implementation approach for an Excel import component based on Ant Design Pro Components. The component uses the Steps component to implement step-by-step operations and integrates ProTable to support online data editing, deletion, and paginated display. Core features include using class-validator for data validation, intuitively displaying validation error messages within the table, and supporting custom validation rules. The component utilizes the ActionProvider pattern to pass data sources, column configurations, and properties between steps, thereby achieving state transitions and data linkage across steps. However, the current implementation has several areas for optimization: the stepChange function should be exposed as a public API; the validation logic is currently hard-coded to depend on class-validator and needs to support pluggable validation libraries; the rawColumns and nextColumns parameter design is redundant and difficult to adapt to single-step or multi-step scenarios; the implicit length-matching convention between the stepActions array and the step list is not flexible enough, so it is recommended to refactor it into a clearer state machine pattern combined with stepProp. The overall architecture aims to provide a flexible data import experience, but further improvements are needed in API design, extensibility, and state management to enhance generality and maintainability.

Views 135
2024 Data Processing Form Validation improve react ts