Application management method and device based on micro-front-end architecture and computer equipment
Monorepo technology centrally manages the code and resources of sub-applications in the main project structure, solving the problems of complex code management and low deployment efficiency in large front-end projects, simplifying code sharing and resource management, and improving development efficiency.
Patent Information
- Application Number
- CN202410695532.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-23
AI Technical Summary
In large-scale front-end projects based on micro-front-end architecture, each subsystem/sub-application has a separate code warehouse, which results in complex code management and high maintenance costs. In addition, version inconsistencies are prone to occur during deployment, resulting in reduced development efficiency.
Use Monorepo technology to build the main project structure, migrate the codes of each sub-application to the main project root directory, identify and delete duplicate dependencies and public business modules, store them in the main project root directory, and configure them in the main project configuration file Configure sub-application operation commands to execute multiple sub-applications in batches.
The sharing of code and resources is realized through Monorepo technology, which simplifies the management of components and tools in the financial business management system, improves the efficiency of testing, construction and deployment, and reduces code redundancy and maintenance costs.
Smart Images

Figure CN118535138A
Abstract
Description
Technical Field
[0001] This specification relates to the field of distributed technology, and in particular to application management methods, devices, and computer equipment based on a micro-frontend architecture. Background Art
[0002] In the financial field, a large-scale financial business management system is usually composed of many subsystems with relatively independent business functions. For example, the enterprise financial business system is composed of small loan business system, financial leasing system, financial guarantee system, factoring system, pawn business system, electronic letter of guarantee system and other subsystems. Each system has its own development team and technology stack, and these systems need to share and interact with each other. Micro front-end technology can make these subsystems more flexibly integrated.
[0003] However, in large front-end projects built based on micro-frontend technology, each subsystem / sub-application has a separate code repository, and each repository has its own version control and dependency management. Each repository needs to be maintained separately, resulting in complex code management and high maintenance costs. In addition, the project code of each sub-application needs to be deployed separately, which is prone to version inconsistency problems, and deployment requires a lot of time and manpower. The same functional module code is repeated in the sub-application, resulting in code redundancy. When developers modify multiple sub-application functional modules, they need to switch repositories frequently, reducing development efficiency. Summary of the invention
[0004] In order to solve the problems in the prior art that sub-applications are maintained and deployed separately, and that it is labor-intensive to modify functional modules, the embodiments of this specification provide an application management method, apparatus, and computer device based on a micro-frontend architecture.
[0005] An embodiment of the present specification provides an application management method based on a micro-frontend architecture, the method comprising: building a main project structure based on monorepo, the main project structure comprising: a main project root folder, a main project configuration file and a main project root directory file; obtaining the code of each sub-application respectively, and migrating the code of each sub-application to the main project root directory file in the main project root folder; identifying duplicate dependencies from the code of each sub-application in the main project root directory file and adding the duplicate dependencies to the root directory of the main project; identifying common business modules from the code of each sub-application in the main project root directory file, and storing the common business modules in the root directory of the main project; configuring sub-application operation commands in the main project configuration file to batch execute multiple sub-applications.
[0006] According to one aspect of an embodiment of the present specification, migrating the code of each sub-application to the main project root directory file of the main project root folder includes: constructing a corresponding configuration file for each sub-application in the main project root directory file; and migrating the code of each sub-application to the corresponding configuration file.
[0007] According to one aspect of an embodiment of the present specification, identifying duplicate dependencies and adding the duplicate dependencies to the root directory of a main project includes: searching the dependency configuration field of each sub-application for duplicate dependencies; if so, determining the duplicate dependencies as duplicate dependencies, and recording the sub-application with the duplicate dependencies, and treating the sub-application as the first sub-application; adding the duplicate dependencies to the main project configuration file, and deleting the duplicate dependencies from the code of the first sub-application.
[0008] According to one aspect of an embodiment of the present specification, after adding the repeated dependency to the main project configuration file, the method further includes: recording the relationship between the repeated dependency and the first sub-application in the main project configuration file; executing the repeated dependency installation command in the main project structure, and installing the repeated dependency into the main project node file at the same level as the main project configuration file; when executing the sub-application, searching for a dependency from the node file of the sub-application to determine whether the dependency exists in the code of the sub-application; if not, searching for the dependency from the main project node file.
[0009] According to one aspect of the embodiments of this specification, the method also includes: determining whether there are modules with the same business functions in each sub-application; if so, determining the module with the same business function as a common business module, and recording the sub-application with the common business module, and using the sub-application as a second sub-application; adding the common business module to a file in the root directory of the main project, and deleting the common business module from the code of the sub-application; in each second sub-application, establishing a soft link between the common business module and the second sub-application.
[0010] According to one aspect of an embodiment of the present specification, configuring sub-application operation commands in the main project configuration file to batch execute multiple sub-applications includes: executing the sub-application operation commands, entering the working directory of each sub-application respectively, and executing the build commands of each sub-application.
[0011] According to one aspect of the embodiments of the present specification, after executing the build commands of each sub-application, the method includes: storing the output of each sub-application in different sub-application files of the child file; configuring and building a dist folder belonging to the root directory of the main project according to the child file; uploading the dist folder to the web server; configuring the access path of each sub-application in the web service configuration file for accessing each sub-application.
[0012] The embodiment of the present specification also provides an application management device based on a micro-frontend architecture, the device comprising: a construction unit, used to construct a main project structure based on monorepo, the main project structure comprising: a main project root folder, a main project configuration file and a main project root directory file; a migration unit, used to obtain the code of each sub-application respectively, and migrate the code of each sub-application to the main project root directory file in the main project root folder; a dependency identification unit, used to identify duplicate dependencies from the code of each sub-application in the main project root directory file and add the duplicate dependencies to the root directory of the main project; a public business module identification unit, used to identify public business modules from the code of each sub-application in the main project root directory file, and store the public business modules in the root directory of the main project; a batch execution unit, used to configure sub-application operation commands in the main project configuration file to batch execute multiple sub-applications.
[0013] An embodiment of the present specification also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the application management method based on the micro-frontend architecture when executing the computer program.
[0014] An embodiment of the present specification also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the application management method based on the micro-frontend architecture is implemented.
[0015] This manual uses Monorepo technology to manage sub-applications, so that multiple sub-applications can share code and resources, making collaboration and integration easier. Monorepo makes it easier to manage shared components, libraries, and tools in the financial business management system, making testing, building, and deployment more convenient. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 The figure is a flow chart of an application management method based on a micro-frontend architecture according to an embodiment of the present specification;
[0018] Figure 2 The figure is a flow chart of a method for migrating sub-application codes according to an embodiment of the present specification;
[0019] Figure 3 The figure is a flow chart of a method for adding repeated dependencies according to an embodiment of the present specification;
[0020] Figure 4 The figure is a flow chart of a method for searching for dependencies according to an embodiment of the present specification;
[0021] Figure 5 The figure is a flow chart of a method for determining a public service module according to an embodiment of the present specification;
[0022] Figure 6 The figure shows a schematic diagram of the structure of an application management device based on a micro-frontend architecture according to an embodiment of the present specification;
[0023] Figure 7 The figure shows a schematic diagram of the structure of a micro-front-end main project structure according to an embodiment of this specification;
[0024] Figure 8 The diagram shows a directory structure of a dist folder in the root directory of a main project according to an embodiment of the present specification;
[0025] Fig. 9 The figure shows a schematic diagram of the structure of a computer device according to an embodiment of the present specification.
[0026] Description of the accompanying symbols:
[0027] 601, building unit;
[0028] 602, Migration Unit;
[0029] 603, dependency identification unit;
[0030] 604, public service module identification unit;
[0031] 605. Batch execution unit;
[0032] 902. Computer equipment;
[0033] 904, processor;
[0034] 906. Memory;
[0035] 908, driving mechanism;
[0036] 910, input / output module;
[0037] 912. Input device;
[0038] 914. Output device;
[0039] 916. Presentation equipment;
[0040] 918. Graphical user interface;
[0041] 920, network interface;
[0042] 922, communication link;
[0043] 924. Communication bus. DETAILED DESCRIPTION
[0044] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.
[0045] It should be noted that the terms "first", "second", etc. in the description and claims of this specification and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of this specification described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, device, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0046] This specification provides method operation steps as described in the embodiments or flow charts, but more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the system or device product is executed in practice, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel.
[0047] It should be noted that the application management method based on the micro-front-end architecture in this specification can be used in the field of distributed technology and in the field of financial technology. This specification does not limit the application field of the application management method, device and computer equipment based on the micro-front-end architecture.
[0048] Micro frontend is an architectural pattern. Microservice architecture splits a large backend application into multiple small, independent frontend applications. These small frontend applications (also called sub-applications) deployed in the micro frontend architecture can be combined into a whole through some technical means (such as routing forwarding, sandbox isolation, etc.), thus forming a complete frontend application. Among them, each sub-application is independent and can be independently developed, tested and deployed. The sub-application can run independently or be combined with other sub-applications to form a whole.
[0049] Figure 1 The flowchart of an application management method based on a micro-frontend architecture according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0050] Step 101: Build a main project structure based on monorepo, the main project structure includes: main project root folder, main project configuration file and main project root directory file. In this specification, Monorepo (Mono Repository) is a project code management method, which means a single repository and refers to a strategy for managing multiple modules / packages / projects in a single project repository. Figure 7 The main project code structure is established as shown in the figure, where MainProject is the root folder of the main project, which contains the main project configuration file package.json and the main project root directory file packages.
[0051] Furthermore, the main project structure also includes a monorepo project workspace configuration file, such as xxx-workspace.yaml. In this specification, if the pnpm tool is used to create a monorepo project, the xxx-workspace.yaml project workspace configuration file can be named pnpm-workspace.yaml, and the workspace defined in the file can be managed by pnpm as a soft link.
[0052] The main project configuration file package.json under MainProject mainly describes the detailed configuration information of the project, including but not limited to: project name, version number, project description, author, dependency configuration, project operation commands and project running environment.
[0053] In the embodiment of this specification, the main project structure may further include a sub-application configuration file appconfig.json, which configures sub-application information configuration items related to the micro-frontend architecture, and the sub-application configuration information items include but are not limited to: sub-application name, sub-application code storage directory, sub-application access port number and other information. As shown below:
[0054] "base":{
[0055] "name": "Base Application",
[0056] "packageName": "@package / base",
[0057] "port":8000
[0058] }
[0059] The code in the above sub-application configuration file appconfig.json indicates that the sub-application name is: base application; the sub-application code storage directory is package / base, and the sub-application access port number is 8000. During the application development process, configuration-related information required for function development, such as routing configuration, development and production environment configuration, menu configuration, etc., can be uniformly obtained from the sub-application configuration file appconfig.json.
[0060] This manual builds the main project structure based on monorepo, which helps to simplify the complexity of code sharing, version control, etc.
[0061] Step 102, respectively obtain the code of each sub-application, and migrate the code of each sub-application to the main project root directory file in the main project root folder.
[0062] In the embodiments of this specification, the sub-application may further include a base application, which can be regarded as a type of sub-application. The base application is a container carrier of other conventional sub-applications, responsible for the overall layout, configuration and scheduling of sub-applications, etc. The base application generally contains the common parts of each sub-application (such as the page frame layout, etc.). The sub-application is responsible for rendering its own business logic.
[0063] In this step, the code of the base application and each sub-application is migrated to the main project root directory file packages of the main project structure. Specifically, the main project root directory file includes sub-directory files corresponding to each sub-application. In the embodiment of this specification, each sub-directory file includes a sub-configuration file package.json corresponding to the sub-application.
[0064] For example, the code of the base application base is stored in the first sub-directory file under the root directory file of the main project: packages / base; the code of the sub-application app1 is stored in the second sub-directory file packages / app1 under the root directory file of the main project; the code of the sub-application app2 is stored in the third sub-directory file packages / app2 under the root directory file of the main project, and so on.
[0065] Step 103: Identify duplicate dependencies from the codes of each sub-application in the root directory file of the main project and add the duplicate dependencies to the root directory of the main project.
[0066] In the embodiments of this specification, in a microservice architecture, a large overall application is usually composed of multiple small, independent sub-applications. The same dependencies may exist in the codes of multiple sub-applications.
[0067] In this manual, the monorepo-based project manages dependencies by creating a virtual tree-like node module structure. When using pnpm to manage project dependency packages, first search for dependencies in the node_modules of the current project. If no dependencies are found, search for dependencies in the node_modules of the parent directory of the current project.
[0068] Each sub-application has a dependency configuration field in its package.json. For example, the dependency configuration field for the production environment is "dependencies":{}, and the dependency configuration field for the development environment is "devDependencies":{}. This manual does not limit the dependency configuration fields for the production environment and the development environment.
[0069] Step 104, identify the common business module from the code of each sub-application in the root directory file of the main project, and store the common business module in the root directory of the main project. In the embodiment of this specification, the common business module is a business module with the same function, including but not limited to: user management module, log management module, organization management module, etc. There may be overlapping and identical common business modules in each sub-application.
[0070] This step extracts the common business modules from each sub-application as separate modules in the main project structure, thereby streamlining the redundant codes in each sub-application.
[0071] Step 105, configuring sub-application operation commands in the main project configuration file to execute multiple sub-applications in batches.
[0072] In the embodiment of this specification, first install the batch script task executor npm-run-all in the main project, with the help of this tool, you can run multiple npm scripts at the same time. Further configure the unified build packaging command of each sub-application in the main project configuration file package.json, and build all sub-applications uniformly. The build command configuration in the main project configuration file package.json is as follows:
[0073] "build":"npm-run-all build:*",
[0074] "build:base":"cd packages / base&&npm-run-all build",
[0075] "build:base":"cd packages / base&&npm-run-all build",
[0076] "build:base":"cd packages / base&&npm-run-all build"
[0077] Among them, when executing the npm run build build command in the terminal, npm-run-all build:* will match all commands starting with build:, such as build:base, build:app1, and build:app2, and execute them in parallel. When the command is executed, it will enter the working directory of each sub-application respectively, and then execute the build command of each sub-application to achieve the purpose of unified construction. As described in the code above, the build command builds all unified sub-applications, the build:base command builds the base application, the build:app1 command builds the sub-application app1, and the build:app2 command builds the application app2.
[0078] Figure 2 The flowchart of a method for migrating sub-application codes according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0079] Step 201, in the main project root directory file, build a corresponding configuration file for each sub-application. As described in the previous steps, in the main project root directory file of the main project root folder, create a unique sub-directory file for each sub-application, record it as sub-directory files such as packages / base, packages / app1, packages / app2, and create a unique corresponding configuration file under the sub-directory file. For example, create a configuration file packages / base / package.json for the base application under the sub-directory file packages / base; create a configuration file packages / app1 / package.json for app1 under the sub-directory file packages / app1; create a configuration file packages / app2 / package.json for app2 under the sub-directory file packages / app2, and so on.
[0080] Step 202: Migrate the code of each sub-application to the corresponding configuration file.
[0081] In this step, the code of each sub-application is first obtained, and the code of each sub-application is migrated from the location where the code of each sub-application is originally stored to the configuration file corresponding to each sub-application under the main project root directory file of the main project architecture.
[0082] Figure 3 The flowchart of a method for adding repeated dependencies in an embodiment of the present specification is shown, which specifically includes the following steps:
[0083] Step 301, from the dependency configuration field of each sub-application, find whether there are repeated dependencies. In this step, the dependencies of the sub-application are searched from the dependency configuration field in the code of each sub-application. In this way, the dependencies of all sub-applications are searched, and the dependencies of all sub-applications are matched to determine whether there are repeated or identical dependencies.
[0084] Step 302: If so, determine the recurring dependency as a repeated dependency, record the sub-application with the repeated dependency, and use the sub-application as the first sub-application.
[0085] In this step, if the sub-application 1 packages / app1 / package.json dependency configuration has a gulp dependency of version 3.9.1, the configuration is as follows:
[0086] "dependencies":{
[0087] "gulp":"3.9.1",
[0088] }
[0089] By searching, it is determined that sub-application 2 also has gulp dependencies in the packages / app1 / package.json dependency configuration:
[0090] "dependencies":{
[0091] "gulp":"3.9.1",
[0092] }
[0093] It can be determined that sub-application 1 and sub-application 2 have the same dependency, and the dependency "gulp":"3.9.1" is determined as a duplicate dependency. Sub-application 1 and sub-application 2 having duplicate dependencies are determined as the first sub-application.
[0094] Step 303: Add the duplicate dependency to the main project configuration file, and delete the duplicate dependency from the code of the first sub-application.
[0095] In this step, delete the gulp dependency in packages / package.json of app1 and app2. After deleting, add the duplicate gulp dependency to the main project root directory MainProject / package.json:
[0096] "dependencies":{
[0097] "gulp":"3.9.1",
[0098] }
[0099] Figure 4 The flowchart of a method for searching for dependencies in an embodiment of the present specification is shown, which specifically includes the following steps:
[0100] Step 401, record the relationship between the repeated dependency and the first sub-application in the main project configuration file. Specifically, if the code of a sub-application includes a repeated dependency, the relationship or connection between the second sub-application and the repeated dependency is recorded in the main project configuration file package.json.
[0101] Step 402 , executing a repeated dependency installation command in the main project structure, and installing the repeated dependency into a main project node file having the same level as the main project configuration file.
[0102] Specifically, by executing the command to install duplicate dependencies in the main project structure, install the duplicate dependencies to Figure 7 The main project node file node_modules.
[0103] Step 403, when executing the sub-application, a dependency is searched from the node file of the sub-application to determine whether the dependency exists in the code of the sub-application. In this specification, the dependency is searched from the node_modules file in each sub-application and each base application to determine whether the dependency exists in the sub-application's own code.
[0104] Step 404: If not, search for the dependency from the main project node file. Specifically, the dependency may be searched in the parent directory node_modules of the current project. In the embodiment of this specification, the parent directory is the main project.
[0105] Figure 5 The flowchart of a method for determining a public service module according to an embodiment of the present specification specifically includes the following steps:
[0106] Step 501: determine whether there are modules with the same business functions in each sub-application.
[0107] In this step, multiple sub-applications of different types may use the same business functions. Different business models are required to support and implement the same business functions. For example, modules such as user management, log management, and organization management may be used in each sub-application. For example, the enterprise financial business system includes subsystems such as the micro-loan business system, the financial leasing system, and the financing guarantee system. These three subsystems need to obtain user identity and other information during operation, that is, the user management module will be used. Therefore, the user management module is a module with the same business functions in the three subsystems of the micro-loan business system, the financial leasing system, and the financing guarantee system.
[0108] Step 502: If it exists, determine the module with the same business function as a common business module, record the sub-application with the common business module, and use the sub-application as the second sub-application.
[0109] In the embodiment of this specification, if there are modules with the same business functions in each sub-application, these business modules are called common business modules, and the common business modules are business modules with common functions. At the same time, the numbers of the sub-applications with common business functions are recorded, and these sub-applications are determined to be the second sub-applications.
[0110] Step 503: Add the public service module to the file in the root directory of the main project, and delete the public service module from the code of the sub-application.
[0111] When each sub-application has a common functional module, extract the common business module as a separate module, separate it from each sub-application project, add it to the main project root directory file as a separate module, and simplify the redundant code in each sub-application. Specifically, create a new common business module folder packages / share under the main project root directory file packages of the main project structure, and create a configuration file package.json for the module. In the configuration file package.json, configure the name of the common business module as @mainproject / share, sort out the common business modules in each sub-application, store the code of the common business module in the packages / share folder, and delete the code of the common business module in each sub-application.
[0112] Step 504: In each second sub-application, a soft link between the common service module and the second sub-application is established.
[0113] By executing the pnpm add@mainproject / share command or the mklink command in each second sub-application project to establish a soft link of the public service module, the public service module is reintroduced into the sub-application in the form of a soft link for use.
[0114] Among them, the soft link can be understood as the index path of the file. The second sub-application establishes a soft link with the packages / share folder respectively. Specifically, in the second sub-application, the address of the packages / share folder is associated with the second sub-application, and the packages / share module content is stored in the node_modules of the second sub-application, but the node_modules of the second sub-application only contains the index address of the file, which points to the real physical folder of packages / share.
[0115] In some embodiments of the present specification, after executing the build command of each sub-application, the method includes: storing the output of each sub-application in different sub-application files of the child file; configuring and building a dist folder belonging to the root directory of the main project according to the child file; uploading the dist folder to the web server; configuring the access path of each sub-application in the web service configuration file for accessing each sub-application.
[0116] like Figure 6The figure shows a schematic diagram of the structure of an application management device based on a micro-frontend architecture according to an embodiment of the present specification. In this figure, the basic structure of the application management device based on the micro-frontend architecture is described. The functional units and modules therein can be implemented in software, or a general chip or a specific chip can be used to implement application management based on the micro-frontend architecture. The device specifically includes:
[0117] A construction unit 601 is used to construct a main project structure based on monorepo, wherein the main project structure includes: a main project root folder, a main project configuration file, and a main project root directory file;
[0118] Migration unit 602, used to obtain the code of each sub-application respectively, and migrate the code of each sub-application to the main project root directory file of the main project root folder;
[0119] A dependency identification unit 603 is used to identify duplicate dependencies from the codes of each sub-application in the root directory file of the main project and add the duplicate dependencies to the root directory of the main project;
[0120] A public service module identification unit 604 is used to identify public service modules from the codes of each sub-application in the root directory file of the main project, and store the public service modules in the root directory of the main project;
[0121] The batch execution unit 605 is used to configure sub-application operation commands in the main project configuration file to batch execute multiple sub-applications.
[0122] Figure 7 Shown is a structural schematic diagram of a micro-frontend main project structure of an embodiment of this specification, which shows the structure of the main project folder, the main project configuration file and the main project root directory file. Among them, MainProject is the main project root folder, package.json is the main project configuration file, and packages is the main project root directory file. Among them, the main project root directory file further includes sub-directory files of multiple sub-applications, for example, packages / base, packages / app1, packages / app2 and other sub-directory files. Furthermore, the main project structure also includes a monorepo project workspace configuration file, and the main project configuration file package.json, the main project root directory file packages and the project workspace configuration file are at the same level and are files of the same level.
[0123] Figure 8 The figure is a schematic diagram of the directory structure of the dist folder in the root directory of a main project according to an embodiment of the present specification.
[0124] The output of the base application base build is stored in the base folder, and the output of each sub-application build is stored in the child folder. When the main project build task is completed, the base application build output is stored in the base folder, and the output of each sub-application build is stored in the child folder. The final product is output to a unified directory and uploaded to the web server.
[0125] Upload the dist folder to the specified location in the web server through a file transfer tool, and create a base folder corresponding to the base application and files corresponding to the sub-applications in the web server. Configure the access path of each sub-application in the web service configuration file. After each sub-application is packaged and placed separately, obtain the access path and port number through the browser to access the sub-application. You can also implement reverse proxy and other configurations to achieve the purpose of unified deployment.
[0126] like Fig. 9 The diagram shows a schematic diagram of a computer device provided by an embodiment of the present specification. The application management method based on the micro-frontend architecture described in the present specification can be executed by the computer device. The computer device 902 may include one or more processors 904, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. The computer device 902 may also include any memory 906, which is used to store any kind of information such as code, settings, data, etc. Non-limitingly, for example, the memory 906 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 902. In one case, when the processor 904 executes an associated instruction stored in any memory or a combination of memories, the computer device 902 may perform any operation of the associated instruction. The computer device 902 also includes one or more drive mechanisms 908 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.
[0127] The computer device 902 may also include an input / output module 910 (I / O) for receiving various inputs (via input devices 912) and for providing various outputs (via output devices 914). A specific output mechanism may include a presentation device 916 and an associated graphical user interface (GUI) 918. In other embodiments, the input / output module 910 (I / O), the input device 912, and the output device 914 may not be included, and the computer device 902 may be used as a computer device in a network. The computer device 902 may also include one or more network interfaces 920 for exchanging data with other devices via one or more communication links 922. One or more communication buses 924 couple the components described above together.
[0128] The communication link 922 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 922 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.
[0129] Corresponds to Figures 1 to 5 The method in the embodiment of the present specification also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are executed.
[0130] The embodiment of the present specification also provides a computer-readable instruction, wherein when the processor executes the instruction, the program therein causes the processor to execute the following Figures 1 to 5 The method shown.
[0131] It should be understood that in the various embodiments of this specification, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this specification.
[0132] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this specification generally indicates that the associated objects before and after are in an "or" relationship.
[0133] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this specification.
[0134] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0135] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0136] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this specification.
[0137] In addition, each functional unit in each embodiment of this specification may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0138] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this specification is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of this specification. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0139] Specific embodiments are used in this specification to illustrate the principles and implementation methods of this specification. The description of the above embodiments is only used to help understand the methods and core ideas of this specification. At the same time, for those skilled in the art, according to the ideas of this specification, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on this specification.
Claims
1. An application management method based on micro-frontend architecture, characterized in that: The method comprises: Build a main project structure based on monorepo, the main project structure includes: a main project root folder, a main project configuration file and a main project root directory file; Obtain the code of each sub-application respectively, and migrate the code of each sub-application to the main project root directory file in the main project root folder; Identify duplicate dependencies from the code of each sub-application in the root directory file of the main project and add the duplicate dependencies to the root directory of the main project; Identify the common business module from the code of each sub-application in the root directory file of the main project, and store the common business module in the root directory of the main project; The sub-application operation commands are configured in the main project configuration file to execute multiple sub-applications in batches.
2. The application management method based on micro-frontend architecture according to claim 1 is characterized in that: The step of migrating the code of each sub-application to the main project root directory file of the main project root folder includes: In the main project root directory file, build a corresponding configuration file for each sub-application; Migrate the code of each sub-application to the corresponding configuration file.
3. The application management method based on micro-frontend architecture according to claim 2 is characterized in that: Identify duplicate dependencies and add them to the root directory of the main project including: Check the dependency configuration fields of each sub-application to see if there are repeated dependencies. If so, determining the recurring dependency as a repeated dependency, recording the sub-application having the repeated dependency, and taking the sub-application as the first sub-application; The duplicate dependency is added to the main project configuration file, and the duplicate dependency is deleted from the code of the first sub-application.
4. The application management method based on micro-frontend architecture according to claim 3 is characterized in that: After adding the repeated dependency to the main project configuration file, the method further includes: Recording the relationship between the repeated dependency and the first sub-application in a main project configuration file; Execute the command to install the duplicate dependencies in the main project structure to install the duplicate dependencies into the main project node file at the same level as the main project configuration file; When executing a sub-application, searching for a dependency item in a node file of the sub-application to determine whether the dependency item exists in the code of the sub-application; If not, search for the dependency from the main project node file.
5. The application management method based on micro-frontend architecture according to claim 4 is characterized in that: The method further comprises: Determine whether there are modules with the same business functions in each sub-application; If it exists, the module with the same business function is determined as a common business module, and the sub-application with the common business module is recorded, and the sub-application is used as the second sub-application; Add the common business module to the file in the root directory of the main project, and delete the common business module from the code of the sub-application; In each second sub-application, a soft link between the common service module and the second sub-application is established.
6. The application management method based on micro-frontend architecture according to claim 1 is characterized in that: Configuring sub-application operation commands in the main project configuration file to batch execute multiple sub-applications includes: Execute the sub-application operation command, enter the working directory of each sub-application respectively, and execute the build command of each sub-application.
7. The application management method based on micro-frontend architecture according to claim 6 is characterized in that: After executing the build command of each sub-application, the method includes: Store the output of each sub-application in different sub-application files of the child file; According to the child file, configure and build the dist folder belonging to the root directory of the main project; Upload the dist folder to the web server; Configure the access path of each sub-application in the web service configuration file to access each sub-application.
8. An application management device based on a micro-frontend architecture, characterized in that: The device comprises: A construction unit is used to build a main project structure based on monorepo, wherein the main project structure includes: a main project root folder, a main project configuration file, and a main project root directory file; A migration unit, used to obtain the code of each sub-application respectively, and migrate the code of each sub-application to the main project root directory file of the main project root folder; A dependency identification unit, used to identify duplicate dependencies from the code of each sub-application in the root directory file of the main project and add the duplicate dependencies to the root directory of the main project; A public service module identification unit, used to identify the public service module from the code of each sub-application in the root directory file of the main project, and store the public service module in the root directory of the main project; The batch execution unit is used to configure the sub-application operation commands in the main project configuration file to batch execute multiple sub-applications.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Front-end architecture construction method and device suitable for cross-end development, equipment and medium
CN120596083A
