A method and device for progressive decoupling of a large web project
Patent Information
- Application Number
- CN202611008011.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-07
- Publication Date
- 2026-10-13
AI Technical Summary
[0005]有鉴于此,本公开提供了一种大型WEB项目的渐进式解耦方法和装置,以解决现有SPA模块化开发方案拆分粒度仅停留于代码与组件层面,各业务模块在构建、部署及技术演进上强制绑定,无法支持大型Web项目渐进式独立迭代的问题,从而实现各业务模块迁移进度的独立推进、构建与发布周期的相互解耦,以及存量模块与已迁移模块在系统不中断运行前提下的稳定共存
[0011]在本公开上述实施例的大型WEB项目的渐进式解耦方法和装置中,首先,通过在配置信息中为各业务模块设置独立的加载方式标识并在主应用初始化时从服务端动态获取,将原本静态耦合的模块加载策略转化为可按模块粒度独立配置的动态控制机制,从而避免了单体架构下模块迁移策略须全局同步调整的强绑定缺陷,使各业务模块的解耦迁移进度得以独立推进。其次,通过依据加载方式标识将待迁移业务模块注册为独立构建与部署的子应用,使各业务模块的构建与发布周期相互解耦,消除了多团队共同维护单一代码仓库所引发的全量构建等待与代码合并冲突问题。最后,通过将当前访问路由与已注册子应用的激活路由规则进行匹配并依据匹配结果在子应用模式与基座模式间动态选择加载路径,实现了已迁移模块与存量模块在同一主应用内的稳定共存,确保了系统在渐进迁移过程中无需中断运行,保障了解耦迁移阶段的系统连续性。
Smart Images

Figure CN122902968A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of front-end architecture design technology, specifically to a progressive decoupling method and apparatus for large-scale web projects. Background Technology
[0002] With the continuous expansion of enterprise-level web applications and the widespread adoption of multi-team parallel collaboration models, modular development of Single-Page Applications (SPAs) based on component encapsulation and modular specifications has become the mainstream architectural model for front-end engineering teams to manage code complexity and improve collaboration efficiency.
[0003] However, in related technologies, the existing SPA modular development solutions only decompose at the code and component level, lacking application-level independent decoupling capabilities. This results in each business module being forcibly bound in terms of construction, deployment, and technological evolution, making it unable to support the gradual independent iteration of large-scale web projects.
[0004] Therefore, there is an urgent need for a progressive decoupling method for web projects that supports configuration-driven, incremental switching of loading strategies at the business module level, independent construction and deployment of each business module, and smooth decoupling and migration of existing modules without interrupting the operation of the existing system. Summary of the Invention
[0005] In view of this, this disclosure provides a progressive decoupling method and apparatus for large-scale web projects to solve the problem that the granularity of existing SPA modular development solutions is limited to the code and component level, and that each business module is forcibly bound in terms of construction, deployment and technical evolution, which cannot support the progressive independent iteration of large-scale web projects. This enables the independent advancement of the migration progress of each business module, the mutual decoupling of the construction and release cycles, and the stable coexistence of existing modules and migrated modules without interrupting the operation of the system.
[0006] On the one hand, this disclosure provides a progressive decoupling method for large-scale web projects, the method including: Obtain module loading configuration information from the server. The module loading configuration information includes the loading method identifier for each business module. The loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode. Based on the module loading configuration information, business modules whose loading mode is identified as sub-application mode are registered as sub-applications, and the sub-applications are built and deployed independently of the main application; In response to a user access request, the current access route is matched with the active route rules of the registered sub-applications. If the match is successful, the corresponding sub-application is loaded; if the match fails, the business module corresponding to the current route is loaded in the main application.
[0007] On the other hand, this disclosure also provides a progressive decoupling device for large-scale web projects, the device comprising: The configuration acquisition unit is used to obtain module loading configuration information from the server. The module loading configuration information includes the loading method identifier corresponding to each business module. The loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode. The registration unit is used to register business modules whose loading mode is identified as sub-application mode as sub-applications based on the module loading configuration information. Sub-applications are built and deployed independently of the main application. The loading unit is used to respond to user access requests by matching the current access route with the active route rules of the registered sub-applications. If the match is successful, the corresponding sub-application is loaded; if the match fails, the business module corresponding to the current route is loaded in the main application.
[0008] On the other hand, this disclosure also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the progressive decoupling method of any of the above-described large-scale web projects when executing the computer program.
[0009] On the other hand, this disclosure also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described progressive decoupling methods for large-scale web projects.
[0010] On the other hand, this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described progressive decoupling methods for large-scale web projects.
[0011] In the progressive decoupling method and apparatus for large-scale web projects disclosed in the above embodiments, firstly, by setting independent loading method identifiers for each business module in the configuration information and dynamically obtaining them from the server during the initialization of the main application, the originally statically coupled module loading strategy is transformed into a dynamic control mechanism that can be independently configured at the module granularity. This avoids the strong binding defect of the module migration strategy requiring global synchronous adjustment under a monolithic architecture, allowing the decoupling migration progress of each business module to proceed independently. Secondly, by registering the business modules to be migrated as independently built and deployed sub-applications based on the loading method identifiers, the build and release cycles of each business module are decoupled, eliminating the full build waiting and code merging conflicts caused by multiple teams jointly maintaining a single code repository. Finally, by matching the current access route with the activation route rules of the registered sub-applications and dynamically selecting the loading path between the sub-application mode and the base mode based on the matching results, stable coexistence of migrated modules and existing modules within the same main application is achieved, ensuring that the system does not need to be interrupted during the progressive migration process and guaranteeing the system continuity during the decoupling migration phase. Attached Figure Description
[0012] To more clearly illustrate the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A flowchart illustrating a progressive decoupling method for a large-scale web project provided in this embodiment of the disclosure; Figure 2 A schematic diagram of the structure of a progressive decoupling device for a large-scale web project provided in an embodiment of this disclosure; Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Detailed Implementation
[0014] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this disclosure.
[0015] With the continuous expansion of enterprise-level web applications and the widespread adoption of multi-team parallel collaboration models, SPA modular development based on component encapsulation and modular specifications (such as CommonJS, ECMAScript Module, ESM) has become the mainstream architectural model for front-end engineering teams to manage code complexity and improve collaboration efficiency.
[0016] However, the modular development solution for SPAs in related technologies is limited by the granularity of decomposition and the engineering system. It can only achieve logical decomposition at the code and component levels and cannot support the independent construction and deployment of business modules at the application level. Each module shares a global scope and style namespace, making it difficult to effectively isolate style conflicts and side effect pollution between modules. Moreover, the entire application is constrained by a unified technology stack, and the independent technical evolution of different modules must be promoted in a globally synchronized manner. Existing code and new code are deeply coupled, resulting in high migration risks and continuous accumulation of technical debt. When multiple teams jointly maintain the same code repository, the release of any module must trigger a full build and deployment process, leading to frequent code merge conflicts and long release waiting cycles, which seriously restricts the iteration efficiency and system stability of large projects.
[0017] Therefore, there is an urgent need for a progressive decoupling method for web projects that can progressively switch loading strategies at the granularity of business modules in a configuration-driven manner, support the independent construction and deployment of each business module, and achieve smooth decoupling and migration of existing modules without interrupting the operation of the existing system. This would effectively eliminate the collaboration bottleneck under the monolithic application architecture and achieve a dynamic balance between the independent evolution of multiple modules and the overall system stability.
[0018] To address the aforementioned issues, this disclosure provides a progressive decoupling method for large-scale web projects. The method includes: obtaining module loading configuration information from a server, wherein the module loading configuration information includes a loading method identifier corresponding to each business module, and the loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode; registering the business module with the loading method identifier of sub-application mode as a sub-application based on the module loading configuration information, wherein the sub-application is built and deployed independently of the main application; and responding to a user access request, matching the current access route with the activation route rules of the registered sub-applications, wherein if the match is successful, the corresponding sub-application is loaded, and if the match fails, the business module corresponding to the current route is loaded in the main application.
[0019] It should be noted that, in the description of this disclosure, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this disclosure are used to distinguish similar objects and are not used to describe a particular order or sequence.
[0020] To enable those skilled in the art to better understand the present disclosure, the present disclosure will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0021] Please refer to Figure 1 , Figure 1 A flowchart illustrating a progressive decoupling method for a large-scale web project provided in this disclosure embodiment is shown below. Figure 1 As shown, the method may include the following steps: Step S101: Obtain module loading configuration information from the server. The module loading configuration information includes the loading method identifier corresponding to each business module. The loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode.
[0022] In this embodiment, the module loading configuration information can be configuration data uniformly managed by the server. Each business module uses a unique identifier as the key-value pair to store its own loading method identifier. The loading method identifier indicates whether the corresponding business module should be loaded in sub-application mode or base mode at runtime: sub-application mode means that the corresponding business module is dynamically loaded as an independently deployed sub-application; base mode means that the corresponding business module is kept in the main application and loaded in the original way. By centrally managing the loading method identifiers of each module on the server, the loading strategy of each module can be changed instantly by adjusting the server configuration without redeploying the application, thereby achieving dynamic control over the migration progress of each module.
[0023] Specifically, during the initialization phase, the main application sends a configuration information request to the server to obtain the loading method identifiers of each business module. The obtained module loading configuration information serves as a unified basis for subsequent sub-application registration and module loading decisions, and is used in steps S102 and S103.
[0024] It should be noted that the configuration granularity of the loading method identifier is a single business module. The loading method identifiers of each module are independent of each other, allowing some modules to switch to sub-application mode while the rest remain in base mode, thus supporting a gradual decoupling scenario where multiple modules coexist at different migration stages.
[0025] Step S102: Based on the module loading configuration information, register the business modules whose loading mode is identified as sub-application mode as sub-applications. The sub-applications are built and deployed independently of the main application.
[0026] In this embodiment, a sub-application can refer to a front-end application unit that is split from the original monolithic web application and can be built and deployed independently. During runtime, the sub-application dynamically connects to the main application through the loading interface provided by the micro-frontend framework, and its construction and deployment processes are independent of the main application and other sub-applications. Registering a business module as a sub-application means registering the basic information of the corresponding sub-application with the micro-frontend framework, including the sub-application's entry resource address, activation routing rules, and mounting container information, so that the micro-frontend framework can identify and load the corresponding sub-application according to the rules when users access it subsequently.
[0027] Specifically, based on the module loading configuration information obtained in step S101, for business modules whose loading method is identified as sub-application mode, their corresponding sub-application configuration information is extracted, and the sub-application registration interface of the micro-frontend framework is called to complete the registration; business modules whose loading method is identified as base mode do not participate in the registration process and remain running in the main application in the original way.
[0028] Furthermore, each sub-application independently executes its own build process during the build phase, generating independent build artifacts and deploying them to its respective server. The build and release operations of each sub-application are independent of each other, and the release of any sub-application does not trigger the rebuild of the main application or other sub-applications, thereby decoupling the iterative release cycles of each business module.
[0029] Step S103: In response to the user access request, the current access route is matched with the active route rules of the registered sub-applications. If the match is successful, the corresponding sub-application is loaded. If the match fails, the business module corresponding to the current route is loaded in the main application.
[0030] In this embodiment, the activation routing rules for registered sub-applications can refer to the routing matching rules configured for each sub-application during the registration phase, which describe which access paths should trigger the loading of the corresponding sub-application. When a user initiates an access request, the micro-frontend framework matches the current access route with the activation routing rules of each registered sub-application one by one.
[0031] Specifically, if the current access route matches the activation route rule of a registered sub-application, the micro-frontend framework dynamically loads the corresponding sub-application from the deployment address of that sub-application and mounts it into the preset container element in the main application to complete the rendering; if the current access route does not match the activation route rule of any registered sub-application, the main application directly renders the business module corresponding to the current route in base mode, maintaining the same loading behavior as the original monolithic application.
[0032] Through the aforementioned dual-path loading mechanism, business modules that have completed sub-application transformation and existing modules that have not yet been migrated can run concurrently within the same main application. The user access experience is not affected by the current migration progress, and the system does not need to wait for all modules to be migrated before performing an overall switch.
[0033] In the progressive decoupling method and apparatus for large-scale web projects disclosed in the above embodiments, firstly, by setting independent loading method identifiers for each business module in the configuration information and dynamically obtaining them from the server during the initialization of the main application, the originally statically coupled module loading strategy is transformed into a dynamic control mechanism that can be independently configured at the module granularity. This avoids the strong binding defect of the module migration strategy requiring global synchronous adjustment under a monolithic architecture, allowing the decoupling migration progress of each business module to proceed independently. Secondly, by registering the business modules to be migrated as independently built and deployed sub-applications based on the loading method identifiers, the build and release cycles of each business module are decoupled, eliminating the full build waiting and code merging conflicts caused by multiple teams jointly maintaining a single code repository. Finally, by matching the current access route with the activation route rules of the registered sub-applications and dynamically selecting the loading path between the sub-application mode and the base mode based on the matching results, stable coexistence of migrated modules and existing modules within the same main application is achieved, ensuring that the system does not need to be interrupted during the progressive migration process and guaranteeing the system continuity during the decoupling migration phase.
[0034] In one possible implementation of step S102 above, registering a business module whose loading mode is identified as a sub-application mode as a sub-application includes: obtaining the permission information of the currently logged-in user; filtering out business modules that the current user has access to from the module loading configuration information based on the permission information; and registering the business modules whose loading mode is identified as a sub-application mode among the filtered business modules as sub-applications.
[0035] In this embodiment, different users have different resource access permissions within the system, and some business modules are only open to users with specific roles or permissions. Registering all users with the entire quantum application would not only cause users to load sub-application resources they are not authorized to access, but could also lead to the risk of access control failure. Therefore, this embodiment introduces a user permission-based filtering mechanism during the sub-application registration phase.
[0036] Specifically, after a user completes login authentication, the main application obtains the permission information of the currently logged-in user, which includes a list of business modules that the user has access to. Based on the permission information, the application filters out the business modules that the user has access to from the module loading configuration information obtained in step S101. Then, it extracts the business modules whose loading method is identified as sub-application mode from the filtering results, calls the sub-application registration interface to complete the registration, and other business modules do not participate in the registration process.
[0037] By chaining permission filtering with loading method identification filtering, it ensures that only business modules that the current user has the right to access and have been switched to sub-application mode are registered. This reduces unnecessary sub-application resource loading and achieves precise consistency between the sub-application registration scope and the user permission scope.
[0038] In the progressive decoupling method and apparatus for large-scale WEB projects disclosed in the above embodiments, by filtering the module loading configuration information based on the current user permission information during the sub-application registration stage, the scope of sub-application registration is precisely limited to the business modules that the current user has the right to access. This avoids the pre-registration and loading of unauthorized sub-application resources, thereby reducing the resource overhead during the main application initialization stage while ensuring the effectiveness of permission control.
[0039] In one possible implementation of step S103 above, after matching the current access route with the activation route rules of the registered sub-applications in response to the user access request, the method further includes: after the module corresponding to the current access route has been loaded, preloading other registered sub-applications that were not matched by the current access route when the system is idle.
[0040] In this embodiment, after accessing the current page, users often navigate to other sub-application pages within a short period. If sub-application resource loading is initiated only when the user actually initiates navigation, network request latency will be introduced, affecting the smoothness of page switching. Therefore, this embodiment loads the resources of other registered sub-applications in advance during system idle periods after the module corresponding to the current access route has been loaded.
[0041] Specifically, after the module corresponding to the current access route completes loading and rendering, the system enters an idle state. At this time, a preloading operation is triggered for other registered sub-applications that are not matched by the current access route, and resources are pulled from the deployment address of each sub-application in advance and cached locally. When the user subsequently navigates to the corresponding sub-application, the required resources are already available locally and can be directly mounted, significantly shortening the loading waiting time perceived by the user.
[0042] It should be noted that the preloading operation is triggered when the system is idle, does not occupy the critical path resources of the current page rendering, and does not affect the normal loading and interactive response of the module corresponding to the current access route.
[0043] In the progressive decoupling method and apparatus for large-scale web projects disclosed in the above embodiments, by performing preloading on the remaining registered sub-applications when the system is idle after the current module has finished loading, the sub-application resource retrieval operation is moved from the actual user navigation time to the idle time, effectively reducing the loading delay when the user navigates across sub-applications without affecting the performance of the current page.
[0044] In one possible implementation of the above embodiments, the method further includes: creating a publish-subscriber instance in the main application and passing the publish-subscriber instance to the sub-application when loading the sub-application; and communicating data between the main application and the sub-application through the publish-subscriber instance.
[0045] In this embodiment, the main application and each sub-application are isolated from each other at runtime, and the sub-applications cannot directly access the internal state of the main application. However, in real-world business scenarios, there is often a need for data sharing and event notification between the main and sub-applications. For example, the main application needs to pass user information to the sub-application after a user logs in, or the sub-application needs to notify the main application of specific business events. If the above communication is implemented through global variables or direct function calls, it will break the runtime isolation of the sub-applications and introduce implicit module dependencies. Therefore, this embodiment adopts a publish-subscribe pattern to achieve decoupled communication between the main and sub-applications.
[0046] Specifically, during the initialization phase, the main application creates a publish-subscriber instance, which serves as the sole shared channel for communication between the main application and all sub-applications. When a sub-application is loaded, the publish-subscriber instance is passed to that sub-application as an initialization parameter. Both the main application and the sub-applications publish and subscribe to messages through the publish-subscriber instance, enabling cross-application data transfer and event notification without directly holding references to each other's modules.
[0047] In the progressive decoupling method and apparatus for large-scale web projects disclosed in the above embodiments, a standardized decoupling communication channel between the main application and the sub-application is established by creating a unified publish-subscriber instance in the main application and passing it to the corresponding sub-application when loading the sub-application. This satisfies the business needs of cross-application data sharing and event notification while maintaining the isolation of the sub-applications during runtime.
[0048] In one possible implementation of the above embodiments, the sub-application is built and deployed independently of the main application, including: A unique version identifier is generated during the build process, and the sub-application configuration information containing the version identifier is uploaded to the server. During the system release and deployment phase, the sub-application configuration information is injected into the global object of the main application through a configuration synchronization mechanism. When the main application loads a sub-application, it retrieves the corresponding version of the sub-application resources based on the version identifier.
[0049] In this embodiment, sub-applications are built and deployed independently. Each resource file generated during a build must be distinguished by a unique identifier to ensure the main application accurately obtains the latest version of resources and avoids cached version inconsistencies. Meanwhile, in cases of network anomalies, the main application may be unable to obtain the latest sub-application configuration information from the server, necessitating a local backup source to ensure the reliability of the sub-application loading process.
[0050] Specifically, during each build, the sub-application generates a unique version identifier based on the build execution time. It then uploads its configuration information, including the version identifier and the sub-application's entry resource address, to the server for the main application to query during loading. During system deployment, the sub-application configuration information is injected into the global object of the main application's entry point via a configuration synchronization mechanism, serving as a local static backup data source in case of server-side configuration dynamic retrieval failure. When the main application loads a sub-application, it retrieves the corresponding version of the sub-application resources from the server based on the version identifier, ensuring that each load uses resource files consistent with the currently released version.
[0051] Furthermore, the configuration synchronization mechanism is executed during the system release and deployment phase, and is independent of the sub-application's own build process, without disrupting the physical decoupling relationship between the main and sub-application build pipelines; the main application does not need to actively detect version changes of each sub-application at runtime, and the version information is automatically synchronized to the main application's global object along with the deployment process.
[0052] In the progressive decoupling method and apparatus for large-scale WEB projects disclosed in the above embodiments, by generating a unique version identifier when building the sub-application and injecting the configuration information into the global object of the main application through a configuration synchronization mechanism during the deployment phase, the version information is automatically managed along with the release process, ensuring the accuracy of resource versions when the main application loads the sub-application; by injecting the sub-application configuration information into the global object of the main application in a static manner as a backup data source, a reliable local data foundation is provided for degraded loading when the server configuration is unreachable.
[0053] In one possible implementation of the above embodiment, if a match is successful, the corresponding sub-application is loaded. If the sub-application fails to load, the sub-application configuration information stored in the global object of the main application is read, and the system switches to base mode to load the business module corresponding to the current access route.
[0054] In this embodiment, the sub-application is hosted on the server in an independent deployment manner, and its loading process depends on network connectivity. In the event of network anomalies, invalid resource addresses, or other situations, the sub-application resources may fail to load normally. If not handled properly, the corresponding page will fail to render, affecting normal user access. Therefore, this embodiment provides an automatic degradation mechanism when the sub-application fails to load.
[0055] Specifically, during the loading of the corresponding business module in sub-application mode, the loading result of the sub-application is monitored in real time. If the loading of the sub-application fails, the loading of the sub-application is abandoned, and the sub-application configuration information stored in the global object statically injected into the main application entry is read. Based on the configuration information, the system switches to base mode, calls the original existing code of the business module retained in the main application code package, and loads the business module corresponding to the current access route in the main application to ensure that the user access request is responded to normally.
[0056] It should be noted that during the gradual decoupling migration phase, the main application code package still retains the original existing code copies of the business modules that have been converted into sub-applications as the source of code for downgrade loading; the aforementioned existing code copies can only be removed from the main application after the corresponding business modules have completed a full and stable migration.
[0057] In addition, the sub-application configuration information used for downgrade loading comes from the statically injected data of the main application's global object. Compared with the server-side configuration that needs to be obtained through network requests, it has higher availability in network anomaly scenarios, thus ensuring the reliable execution of the downgrade process.
[0058] In the progressive decoupling method and apparatus for large-scale WEB projects disclosed in the above embodiments, when a sub-application fails to load, the sub-application configuration information stored in the global object of the main application is automatically read and the original existing code retained in the main application is called to load the corresponding business module in the base mode. This realizes automatic fault tolerance and degradation between the sub-application mode and the base mode, and ensures the normal rendering of the corresponding page and the continuity of user access in extreme scenarios such as network anomalies.
[0059] In one embodiment, a progressive decoupling device for large-scale web projects is provided, which corresponds one-to-one with the progressive decoupling methods for large-scale web projects described in the above embodiments. For example... Figure 2 As shown, it includes: The configuration acquisition unit 21 is used to obtain module loading configuration information from the server. The module loading configuration information includes the loading method identifier corresponding to each business module. The loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode. Registration unit 22 is used to register business modules whose loading mode is identified as sub-application mode as sub-applications based on module loading configuration information. Sub-applications are built and deployed independently of the main application. Loading unit 23 is used to respond to user access requests by matching the current access route with the active route rules of the registered sub-applications. If the match is successful, the corresponding sub-application is loaded; if the match fails, the business module corresponding to the current route is loaded in the main application.
[0060] In one embodiment, the registration unit 22 is specifically used to obtain the permission information of the currently logged-in user; Based on permission information, filter out the business modules that the current user has permission to access from the module loading configuration information; Register the business modules whose loading method is identified as sub-application mode among the filtered business modules as sub-applications.
[0061] In one embodiment, the loading unit 23 is further configured to preload other registered sub-applications that are not matched by the current access route when the system is idle, after the module corresponding to the current access route has been loaded.
[0062] In one embodiment, the apparatus further includes: The communication unit is used to create a publish-subscriber instance in the main application and pass the publish-subscriber instance to the sub-application when it is loaded; the main application and the sub-application communicate data through the publish-subscriber instance.
[0063] In one embodiment, the apparatus further includes: The version management unit is used to generate a unique version identifier when the sub-application is built, upload the sub-application configuration information containing the version identifier to the server, and inject the sub-application configuration information into the global object of the main application through the configuration synchronization mechanism during the system release and deployment phase. When the main application loads a sub-application, it retrieves the corresponding version of the sub-application resources based on the version identifier.
[0064] In one embodiment, the loading unit 23 is further configured to, during the process of loading the corresponding sub-application if the matching is successful, if the sub-application fails to load, read the sub-application configuration information stored in the global object statically injected into the main application entry, switch to base mode, call the original existing code of the business module retained in the main application code package, and load the business module corresponding to the current access route in the main application.
[0065] It should be noted that the progressive decoupling device for large-scale web projects provided in the above embodiments is only illustrated by the division of the above-described program modules when implementing the corresponding progressive decoupling method for large-scale web projects. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the above device can be divided into different program modules to complete all or part of the processing described above. In addition, the system provided in the above embodiments and the corresponding Figure 1 The embodiments of the methods shown belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0066] This disclosure also provides an electronic device having the above-described features. Figure 2 The progressive decoupling device shown is for a large web project.
[0067] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure.
[0068] The following is a detailed reference. Figure 3The diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present disclosure. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 301, which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 302 or a program loaded from memory 308 into random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the electronic device. The processor 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0069] Typically, the following devices can be connected to I / O interface 305: input devices 306 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 307 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 308 including, for example, magnetic tapes, hard disks, etc.; and communication devices 309. Communication device 309 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 3 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0070] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 309, or installed from memory 308, or installed from ROM 302. When the computer program is executed by processor 301, it performs the functions defined in the progressive decoupling method for large web projects according to embodiments of this disclosure.
[0071] Figure 3 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0072] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the progressive decoupling method for large-scale web projects shown in the above embodiments.
[0073] A portion of this disclosure can be applied to computer program products, such as computer program instructions, which, when executed by a computer, can invoke or provide methods and / or technical solutions according to this disclosure through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, and installation package files. Accordingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions; the computer compiling the instructions and then executing the corresponding compiled program; the computer reading and executing the instructions; or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0074] Although embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A progressive decoupling method for large-scale web projects, characterized in that, The method includes: Obtain module loading configuration information from the server. The module loading configuration information includes the loading method identifier corresponding to each business module. The loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode. Based on the module loading configuration information, business modules whose loading mode is identified as sub-application mode are registered as sub-applications, and the sub-applications are built and deployed independently of the main application; In response to a user access request, the current access route is matched with the active route rules of the registered sub-applications. If the match is successful, the corresponding sub-application is loaded; if the match fails, the business module corresponding to the current route is loaded in the main application.
2. The method according to claim 1, characterized in that, The process of registering a business module whose loading mode is identified as a sub-application mode as a sub-application includes: Get the permission information of the currently logged-in user; Based on the permission information, select the business modules that the current user has access to from the module loading configuration information; Register the business modules whose loading method is identified as sub-application mode among the filtered business modules as sub-applications.
3. The method according to claim 1, characterized in that, After responding to a user access request and matching the current access route with the activation route rules of the registered sub-applications, the method further includes: After the module corresponding to the current access route is loaded, other registered sub-applications that are not matched by the current access route will be preloaded when the system is idle.
4. The method according to claim 1, characterized in that, The method further includes: Create a publish-subscriber instance in the main application and pass the publish-subscriber instance to the sub-application when it is loaded; The main application and the sub-application communicate with each other through the publish-subscriber instance.
5. The method according to claim 1, characterized in that, The sub-applications are built and deployed independently of the main application, including: A unique version identifier is generated during the build process, and the sub-application configuration information containing the version identifier is uploaded to the server. During the system release and deployment phase, the sub-application configuration information is injected into the global object of the main application through a configuration synchronization mechanism. When the main application loads the sub-application, it obtains the corresponding version of the sub-application resources based on the version identifier.
6. The method according to claim 5, characterized in that, If a match is successful, the corresponding sub-application is loaded. If the sub-application fails to load, the sub-application configuration information stored in the global object of the main application is read, and the system switches to base mode to load the business module corresponding to the current access route.
7. A progressive decoupling device for a large-scale web project, characterized in that, The device includes: The configuration acquisition unit is used to acquire module loading configuration information from the server. The module loading configuration information includes the loading method identifier corresponding to each business module. The loading method identifier is used to indicate whether the corresponding business module is loaded in sub-application mode or base mode. The registration unit is used to register business modules whose loading mode is identified as sub-application mode as sub-applications based on the module loading configuration information. The sub-applications are built and deployed independently of the main application. The loading unit is used to respond to user access requests by matching the current access route with the active route rules of the registered sub-applications. If the match is successful, the corresponding sub-application is loaded; if the match fails, the business module corresponding to the current route is loaded in the main application.
8. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the progressive decoupling method for large-scale web projects as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the progressive decoupling method for a large web project as described in any one of claims 1-6.
10. A computer program product, characterized in that, Includes computer instructions for causing a computer to execute the progressive decoupling method for a large web project as described in any one of claims 1-6.