Component library updating method, device, electronic device and readable storage medium
By creating new sub-applications in the micro front-end system and exporting and importing component libraries, the problem of incompatible updates of large versions of the component library is solved, seamless upgrades and multi-version coexistence of the component library are achieved, and costs and risks are reduced.
Patent Information
- Application Number
- CN202110303244.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-22
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-03-22
AI Technical Summary
In the existing technology, the front-end system cannot be directly upgraded when the component library undergoes a large-version incompatible update, resulting in system unavailability, high reconstruction costs, and easy introduction of vulnerabilities. Official code analysis tools may damage the business code when modified.
Create a second sub-application in the micro front-end system, install the second version of the component library, and implement component library version updates between multiple sub-applications by exporting and importing the component library to ensure that the old version code is compatible without modifying the old code. Avoid introducing vulnerabilities.
It achieves seamless upgrade of the component library and allows multiple versions to coexist, reducing the development cycle and cost and ensuring the safety and reliability of version upgrades.
Smart Images

Figure CN112965733B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a component library updating method, device, electronic device and readable storage medium. Background Art
[0002] In the prior art, software systems all have common functional modules, and there is a common component library for the front-end system. However, when the dependent component library undergoes a major version incompatible update, the front-end system cannot directly upgrade the component library because it is incompatible, which will cause the system to be unavailable.
[0003] In the prior art, when a new version of a component library is used to refactor the software and modify the business code to meet the usage rules of the new version for component upgrade, the cost is extremely high and the system cannot be reused when the system is large and complex. When a major version is updated again, it is necessary to retest and refactor, which is also prone to introduce vulnerabilities. If the official code analysis tool is used to automatically modify the code, and then the unmodifiable parts are manually adjusted, there is a problem that although the cost is low, manual changes are still required. If the official code analysis tool is not powerful enough, the business code may be messed up, and there is still the problem of introducing vulnerabilities. Summary of the invention
[0004] The embodiments of the present invention provide a component library updating method, device, electronic device and readable storage medium to solve the problem of system compatibility when a component library is updated with a large version incompatible in the prior art.
[0005] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0006] In a first aspect, an embodiment of the present invention provides a component library update method, which is applied to a micro-frontend system composed of multiple sub-applications, and the method includes:
[0007] Create a new second sub-application, wherein the second sub-application has a second version of a first component library installed; the first component library includes a plurality of components;
[0008] Exporting the first component library of the second version to the first target path of the second sub-application;
[0009] According to the first target path, at least one target component is obtained from the first component library of the second version, and the target component is exported to a target sub-application among the multiple sub-applications.
[0010] Optionally, the target sub-application is a first sub-application, and the first sub-application has a first component library of a first version installed.
[0011] Optionally, the target sub-application is a third sub-application, and the first component library is not installed in the third sub-application.
[0012] Optionally, also include:
[0013] Exporting a first component library of a first version from the first sub-application to a second target path of the first sub-application;
[0014] If the second sub-application needs to use the first version of the component, the method further includes:
[0015] According to the second target path, at least one target component is obtained from the first component library of the first version, and the target component is imported into the second sub-application for use.
[0016] In a second aspect, an embodiment of the present invention further provides a component library updating device, comprising:
[0017] A component library module, used for creating a new second sub-application, wherein the second sub-application is installed with a second version of a first component library; the first component library includes a plurality of components;
[0018] An execution module, configured to export the first component library of the second version to a first target path of the second sub-application;
[0019] An export module is used to obtain at least one target component from the first component library of the second version according to the first target path, and export the target component to a target sub-application in a plurality of sub-applications.
[0020] Optionally, the target sub-application is a first sub-application, and the first sub-application has a first component library of a first version installed.
[0021] Optionally, the target sub-application is a third sub-application, and the first component library is not installed in the third sub-application.
[0022] Optionally, also include importing modules;
[0023] The execution module is further used to export the first component library of the first version from the first sub-application to the second target path of the first sub-application;
[0024] If the second sub-application needs to use the components of the first version, the import module is used to obtain at least one target component from the first component library of the first version according to the second target path, and import the target component into the second sub-application.
[0025] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the steps of the component library updating method as described in any one of the first aspects are implemented.
[0026] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium, on which a program is stored, and when the program is executed by a processor, the steps of the component library updating method as described in any one of the first aspects are implemented.
[0027] In an embodiment of the present invention, a micro-front-end system includes multiple sub-applications. By creating a new second sub-application and installing the second version of the first component library into the second sub-application, exporting the second version of the first component library to the first target path, obtaining at least one target component from the second version of the first component library according to the first target path, and exporting the target component to the target sub-application, the component library of the sub-application containing the components of the first component library in the micro-front-end system is updated to the second version; according to the component library update method implemented in this scheme, the micro-front-end system can be fully compatible with the old version code, realize the coexistence of multiple versions of the first component library of the same micro-front-end system, and can realize the upgrade of the component library without any modification to the old code, and no vulnerabilities will be introduced before and after the version upgrade, the development cycle is short, the real-time cost is low, and the component library upgrade is fast. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0029] Figure 1 One of the flowcharts of the component library updating method provided in the embodiment of the present invention;
[0030] Figure 2 A second flowchart of a component library updating method provided by an embodiment of the present invention;
[0031] Figure 3 One of the structural schematic diagrams of the component library updating device provided by an embodiment of the present invention;
[0032] Figure 4 This is one of the structural schematic diagrams of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0034] Please refer to Figure 1 , Figure 1 One of the flowcharts of the component library updating method provided in the embodiment of the present invention;
[0035] An embodiment of the present invention provides a component library update method, which is applied to a micro-frontend system composed of multiple sub-applications, and the method includes:
[0036] Step 11: Create a second sub-application, wherein the second sub-application is installed with a second version of the first component library; the first component library includes a plurality of components;
[0037] Step 12: Export the first component library of the second version to the first target path of the second sub-application;
[0038] Step 13: According to the first target path, obtain at least one target component from the first component library of the second version, and export the target component to a target sub-application among the multiple sub-applications.
[0039] In an embodiment of the present invention, a micro-front-end system includes multiple sub-applications. By creating a new second sub-application and installing the second version of the first component library into the second sub-application, exporting the second version of the first component library to the first target path, obtaining at least one target component from the second version of the first component library according to the first target path, and exporting the target component to the target sub-application, the component library of the sub-application containing the components of the first component library in the micro-front-end system is updated to the second version; according to the component library update method implemented in this scheme, the micro-front-end system can be fully compatible with the old version code, realize the coexistence of multiple versions of the first component library of the same micro-front-end system, and can realize the upgrade of the component library without any modification to the old code, and no vulnerabilities will be introduced before and after the version upgrade, the development cycle is short, the real-time cost is low, and the component library upgrade is fast.
[0040] In some embodiments of the present invention, optionally, each sub-application is installed with multiple component libraries.
[0041] In some embodiments of the present invention, optionally, software of a non-micro-frontend system architecture can be converted into a micro-frontend system architecture, and then the component library can be updated according to this method.
[0042] In an embodiment of the present invention, there are multiple component libraries that need to be upgraded in the micro-frontend system. The target component is obtained by obtaining the target path of the component library, and the target component is exported to the target sub-application to implement the version upgrade of the second component library of the target sub-application.
[0043] In some embodiments of the present invention, optionally, there are multiple versions of the first component library in the micro-frontend system, and each target sub-application can obtain and import the corresponding version of the component according to the target path exported by the second sub-application with a different version of the component library installed, so as to implement the component upgrade of a specific version of a specific sub-application.
[0044] In some embodiments of the present invention, optionally, the target sub-application is a first sub-application, and the first sub-application has a first component library of a first version installed.
[0045] In an embodiment of the present invention, when a target sub-application is installed with a first sub-application of a first component library of a first version, the first sub-application can obtain the target component from the first component library of a second version and import it to implement the functional use of the second version component; when the first sub-application needs to use a component in the first component library of the first version, it can be implemented by calling its own component library, and when it needs to use a component in the first component library of the second version, it can be implemented by importing the target component or target component package from the second sub-application that has the second version of the first component library installed; full compatibility of multi-version components on the same sub-application is achieved, and component libraries of different versions are isolated in different sub-applications, so that seamless switching from the first version to the second version can be achieved without modifying any first version business code; no vulnerabilities will be introduced before and after version upgrades, the development cycle is short, the real-time cost is low, and the component library is upgraded quickly.
[0046] In some embodiments of the present invention, optionally, the target sub-application is a third sub-application, and the third sub-application does not have the first component library of the first version installed.
[0047] In an embodiment of the present invention, when the target sub-application is a third sub-application that does not have the first component library installed, the target component can be directly obtained and imported from the first component library of the second version through the first target path to implement the application of the second version component on the third sub-application.
[0048] In some embodiments of the present invention, optionally, the method further includes:
[0049] Exporting a first component library of a first version from the first sub-application to a second target path of the first sub-application;
[0050] If the second sub-application needs to use the first version of the component, the method further includes:
[0051] According to the second target path, at least one target component is obtained from the first component library of the first version, and the target component is imported into the second sub-application for use.
[0052] Specifically, when the old version of the component library is installed into the newly created second sub-application, the use of the new version of the component in the second sub-application can be realized by obtaining the second target path of the first sub-application and importing it into the second sub-application, wherein the first sub-application has the new version of the component library installed. At this time, if the second sub-application needs to use the old version of the component, it can call the component in the old version of the component library installed by itself.
[0053] In an embodiment of the present invention, when a target sub-application is installed with a first sub-application of a first component library of a first version, a second sub-application can obtain a target component from the first component library of the first version and import it to implement functional usage of the first version component; when the second sub-application needs to use a component in the second version of the first component library, it can be implemented by calling its own component library, and when it needs to use a component in the first version of the first component library, it can be implemented by importing the target component or target component package from the first sub-application that has the first version of the first component library installed; full compatibility of multi-version components on the same sub-application is achieved, and component libraries of different versions are isolated in different sub-applications, so that seamless switching from the first version to the second version can be achieved without modifying any first version business code; no vulnerabilities will be introduced before and after version upgrades, the development cycle is short, the real-time cost is low, and the component library is upgraded quickly.
[0054] In some embodiments of the present invention, optionally, acquiring at least one target component from the first component library of the second version according to the first target path, and importing the target component into the target sub-application of the multiple sub-applications includes:
[0055] According to the first target path, multiple target components are obtained from the first component library of the second version to form a target component package, and the target component package is imported into a target sub-application among the multiple sub-applications.
[0056] In an embodiment of the present invention, multiple sub-applications of a micro-front-end system can import exported component packages from each other. The target sub-application obtains multiple components from the first component library of the second version through the first target path shared by the second sub-application to form a target component package, and imports the target component package to implement component version update of the target sub-application. No modification of the old code is required, and no vulnerabilities will be introduced before and after the version upgrade. The development cycle is short, the real-time cost is low, and the component library is quickly upgraded.
[0057] Specifically, please refer to Figure 2 , Figure 2The second flow chart of the component library updating method provided for the embodiment of the present invention; the first component library is the antd component library (a set of enterprise-level interactive design languages and react component libraries, full name AntDesign), the second sub-application is the antdv4-app sub-application, on which a sub-application of the Ant Design component library is installed, the versions of the Ant Design component library include v1-v4 versions, antd v4 version is the first component library 211 of the second version, and antd v3 version is the first component library 221 of the first version.
[0058] The micro front-end system 20 is composed of multiple sub-applications, including a second sub-application 21 and a target sub-application 22;
[0059] The second sub-application 21 has a first component library 211 of a second version installed therein; and the target sub-application 22 has a first component library 221 of a second version installed therein.
[0060] Each sub-application can import each other's exported component packages.
[0061] When the second sub-application 21 needs to call the first component of the first version, execute step 202: export the first component library of the first version from the first sub-application to the second target path of the first sub-application; according to the second target path, obtain at least one target component from the first component library of the first version, and import the target component into the second sub-application for use.
[0062] When the first sub-application 22 needs to call the first component of the second version, execute step 201: export the first component library of the second version from the second sub-application to the first target path of the second sub-application; according to the first target path, obtain at least one target component from the first component library of the second version, and export the target component to the first sub-application for use.
[0063] In the embodiment of the present invention, when using the new version, the v4 version of AntDesign exported by antdv4-app is directly imported and used directly. For the original code of the business sub-application that uses the v3 version of Ant Design, no modification is required, and the original antdv3 version is still used, ultimately achieving the coexistence of multiple versions of the component library v3 v4, and the same method can be used to achieve the coexistence of multiple versions of v3 v4 v5 when there is an incompatible upgrade to the next v5 version.
[0064] In some embodiments of the present invention, the old version of the component library installed on the second sub-application may be uninstalled first, and then the new version of the component library may be installed in the second sub-application. At this time, the use of the old version of the component in the second sub-application is achieved by importing the old version of the target component obtained from other sub-applications that have the old version of the component library installed (i.e., modifying the reference path of all references to the old version of the component).
[0065] Please refer to Figure 3 , Figure 3 One of the structural schematic diagrams of the component library updating device provided in the embodiment of the present invention; the embodiment of the present invention also provides a component library updating device, including:
[0066] A component library module 31 is used to create a second sub-application, wherein the second sub-application is installed with a second version of a first component library; the first component library includes a plurality of components;
[0067] An execution module 32, configured to export the first component library of the second version to a first target path of the second sub-application;
[0068] The export module 33 is used to obtain at least one target component from the first component library of the second version according to the first target path, and export the target component to a target sub-application in the plurality of sub-applications.
[0069] In an embodiment of the present invention, a component library updating device creates a new second sub-application, installs the second version of the first component library into the second sub-application, exports the second version of the first component library to the first target path, obtains at least one target component from the second version of the first component library according to the first target path, and exports the target component to the target sub-application, thereby updating the component library of the sub-application containing the components of the first component library in the micro-front-end system to the second version; according to the component library updating method implemented in this scheme, the micro-front-end system can be fully compatible with the old version code, realize the coexistence of multiple versions of the first component library of the same micro-front-end system, and can realize the upgrade of the component library without any modification to the old code, and no vulnerabilities will be introduced before and after the version upgrade, the development cycle is short, the real-time cost is low, and the component library upgrade is fast.
[0070] In some embodiments of the present invention, optionally, the target sub-application is a first sub-application, and the first sub-application has a first component library of a first version installed.
[0071] In an embodiment of the present invention, when a target sub-application is installed with a first sub-application of a first component library of a first version, the first sub-application can obtain the target component from the first component library of a second version and import it to implement the functional use of the second version component; when the first sub-application needs to use a component in the first component library of the first version, it can be implemented by calling its own component library, and when it needs to use a component in the first component library of the second version, it can be implemented by importing the target component or target component package from the second sub-application that has the second version of the first component library installed; full compatibility of multi-version components on the same sub-application is achieved, and component libraries of different versions are isolated in different sub-applications, so that seamless switching from the first version to the second version can be achieved without modifying any first version business code; no vulnerabilities will be introduced before and after version upgrades, the development cycle is short, the real-time cost is low, and the component library is upgraded quickly.
[0072] In some embodiments of the present invention, optionally, the target sub-application is a third sub-application, and the third sub-application does not have the first component library of the first version installed.
[0073] In an embodiment of the present invention, when the target sub-application is a third sub-application that does not have the first component library installed, the target component can be directly obtained and imported from the first component library of the second version through the first target path to implement the application of the second version component on the third sub-application.
[0074] In some embodiments of the present invention, optionally, an import module 34 is also included;
[0075] The execution module 32 is further configured to export the first component library of the first version from the first sub-application to the second target path of the first sub-application;
[0076] If the second sub-application needs to use a component of the first version, the import module 34 is used to obtain at least one target component from the first component library of the first version according to the second target path, and import the target component into the second sub-application.
[0077] Specifically, when the old version of the component library is installed in the newly created second sub-application, the use of the new version of the component in the second sub-application can be realized by obtaining the second target path of the first sub-application and importing it into the second sub-application, wherein the first sub-application is installed with the new version of the component library. At this time, if the second sub-application needs to use the old version of the component, it can call the component in the old version of the component library installed by itself. In the embodiment of the present invention, in the component library updating device, when the target sub-application is installed with the first sub-application of the first version of the first component library, the second sub-application can obtain the target component from the first component library of the first version and import it to realize the functional use of the first version of the component; when the second sub-application needs to use the component in the second version of the first component library, it can be realized by calling its own component library, and when it needs to use the component in the first version of the first component library, it can be realized by importing the target component or target component package from the first sub-application installed with the first version of the first component library; it realizes full compatibility of multi-version components on the same sub-application, and also isolates different versions of component libraries in different sub-applications, and realizes seamless switching from the first version to the second version without modifying any first version business code; no vulnerabilities will be introduced before and after the version upgrade, the development cycle is short, the real-time cost is low, and the component library is upgraded quickly.
[0078] The present invention also provides an electronic device, please refer to Figure 4 , Figure 4 This is one of the structural schematic diagrams of an electronic device provided by an embodiment of the present invention.
[0079] The electronic device 40 includes: a processor 41, a memory 42, and a program stored in the memory 42 and executable on the processor 41. When the program is executed by the processor 41, the various processes of the embodiment of the component library updating method described in any of the above-mentioned embodiments are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0080] An embodiment of the present invention further provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of any of the above-mentioned component library update method embodiments are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0081] The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0082] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A component library updating method, characterized in that: Applied to a micro-frontend system consisting of multiple sub-applications, the method includes: Create a new second sub-application, wherein the second sub-application has a second version of a first component library installed; the first component library includes a plurality of components; Exporting the first component library of the second version to the first target path of the second sub-application; According to the first target path, obtaining at least one target component from the first component library of the second version, and exporting the target component to a target sub-application among the multiple sub-applications; Among them, when the target sub-application is installed with the first sub-application of the first component library of the first version, the first sub-application can obtain the target component from the first component library of the second version and import it to implement the functional use of the second version component; when the first sub-application needs to use the component in the first component library of the first version, it calls its own component library to implement it, and when it needs to use the component in the first component library of the second version, it imports the target component or target component package from the second sub-application installed with the second version of the first component library; The second sub-application can obtain the target component from the first component library of the first version and import it to implement the functional use of the first version component; when the second sub-application needs to use the component in the first component library of the second version, it calls its own component library to implement it, and when it needs to use the component in the first component library of the first version, it imports the target component or target component package from the first sub-application that has the first version of the first component library installed.
2. The component library updating method according to claim 1, characterized in that: The target sub-application is a first sub-application, and the first sub-application has a first component library of a first version installed.
3. The component library updating method according to claim 1, characterized in that: The target sub-application is a third sub-application, and the first component library is not installed in the third sub-application.
4. The component library updating method according to claim 2, characterized in that: Also includes: Exporting a first component library of a first version from the first sub-application to a second target path of the first sub-application; If the second sub-application needs to use the first version of the component, the method further includes: According to the second target path, at least one target component is obtained from the first component library of the first version, and the target component is imported into the second sub-application for use.
5. A component library updating device, characterized in that: include: A component library module, used for creating a new second sub-application, wherein the second sub-application is installed with a second version of a first component library; the first component library includes a plurality of components; An execution module, configured to export the first component library of the second version to a first target path of the second sub-application; An export module, configured to obtain at least one target component from the first component library of the second version according to the first target path, and export the target component to a target sub-application among the plurality of sub-applications; Wherein, when the target sub-application is installed with the first sub-application of the first component library of the first version, the first sub-application can obtain the target component from the first component library of the second version and import it to implement the functional use of the second version component; when the first sub-application needs to use the component in the first component library of the first version, it calls its own component library to implement it, and when it needs to use the component in the first component library of the second version, it imports the target component or target component package from the second sub-application installed with the second version of the first component library; The second sub-application can obtain the target component from the first component library of the first version and import it to implement the functional use of the first version component; when the second sub-application needs to use the component in the first component library of the second version, it calls its own component library to implement it, and when it needs to use the component in the first component library of the first version, it imports the target component or target component package from the first sub-application that has the first version of the first component library installed.
6. The component library updating device according to claim 5, characterized in that: The target sub-application is a first sub-application, and the first sub-application has a first component library of a first version installed.
7. The component library updating device according to claim 5, characterized in that: The target sub-application is a third sub-application, and the first component library is not installed in the third sub-application.
8. The component library updating device according to claim 6, characterized in that: It also includes import modules; The execution module is further used to export the first component library of the first version from the first sub-application to the second target path of the first sub-application; If the second sub-application needs to use the components of the first version, the import module is used to obtain at least one target component from the first component library of the first version according to the second target path, and import the target component into the second sub-application.
9. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the component library updating method according to any one of claims 1 to 4.
10. A readable storage medium, characterized in that: The readable storage medium stores a program, and when the program is executed by a processor, the steps of the component library updating method according to any one of claims 1 to 4 are implemented.
