Application management method and device based on CDN, equipment, medium and product
By disassembling large applications into multiple modules and hosting them on CDN, the problem that micro front-end technology does not support Bundleless in production environments is solved, efficient development and release efficiency is achieved, and operation and maintenance risks are reduced.
Patent Information
- Application Number
- CN202411018110.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-12-20
AI Technical Summary
The existing micro front-end technology does not support Bundleless in a production environment, resulting in low efficiency and inability to effectively improve development and release efficiency.
By disassembling large applications into multiple modules in a decoupled state, building a single repository, and hosting the module's compiled files to the CDN, configuring the domain name root directory to point to the CDN address of the main application, and mounting the CDN address of the sub-application to Mainly apply global objects, realize online rendering and display, and support Bundleless in production environments.
It improves development and release efficiency, reduces application management complexity and operation and maintenance risks, and supports public code maintenance and sharing between master applications under micro front-end technology.
Smart Images

Figure CN119166196A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a CDN-based application management method, device, equipment, medium, and product. Background Art
[0002] For some applications, such as a service platform, in order to better meet user needs, the application needs to be continuously updated to improve or increase the services it provides, so that the application can better serve users. However, the size of the application will gradually increase with the iterations, such as the number of codes in the application will gradually increase with the iterations, which will cause some defects in the application, such as it takes a long time to publish minor changes. Summary of the invention
[0003] In order to solve the above technical problems, the present application provides a CDN-based application management method, device, equipment, medium, and product.
[0004] In order to achieve the above objectives, the technical solutions provided by this application are as follows:
[0005] The present application provides a CDN-based application management method, the method comprising:
[0006] Disassembling the target application to obtain a disassembly result, where the disassembly result is used to describe multiple modules in a decoupled state, where the multiple modules include a main application and at least one sub-application;
[0007] According to the disassembly result, a single repository is constructed, wherein the single repository includes a common folder and folders corresponding to each module, wherein the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes a code file of the module;
[0008] For any of the modules, the shared folder and the folder corresponding to the module are packaged and compiled to obtain a compiled file of the module, and the entry file address in the compiled file of the module is hosted on a content distribution network CDN to obtain a CDN address of the module;
[0009] The root directory of the domain name of the target application is configured to point to the CDN address of the main application, and for any of the sub-applications, the CDN address of the sub-application is mounted to the global object of the main application.
[0010] In a possible implementation manner, the shared folder includes a menu bar of the target application.
[0011] In a possible implementation manner, after configuring the root directory of the domain name of the target application to point to the CDN address of the main application, the method further includes:
[0012] In response to a query request triggered for the root directory, obtaining a CDN address of the main application according to the root directory;
[0013] Obtain the compiled file of the main application according to the CDN address of the main application;
[0014] The main application is rendered and displayed according to the compiled file of the main application.
[0015] In a possible implementation manner, after mounting the CDN address of the sub-application to the global object of the main application, the method further includes:
[0016] When the main application is in a display state, in response to a display request triggered for the sub-application, a CDN address of the sub-application is obtained from a global object of the main application;
[0017] Obtain the compiled file of the sub-application according to the CDN address of the sub-application;
[0018] Render and display the sub-application based on the compiled file of the sub-application.
[0019] In a possible implementation manner, the target application is implemented by relying on third-party resources;
[0020] The method further comprises:
[0021] Mount the third-party resource to the CDN to obtain the CDN address of the third-party resource;
[0022] Constructing an input mapping file according to the CDN address of the third-party resource;
[0023] According to the input mapping file, a configuration file of each module is constructed, and the input mapping file is introduced into the entry file in the compiled file of the main application.
[0024] In a possible implementation manner, after constructing the configuration files of each module, the method further includes:
[0025] Analyze the configuration files of the multiple modules to obtain common configuration items, the input mapping file includes the common configuration items, and configuration files of at least two modules among the multiple modules include the common configuration items;
[0026] The introducing the input mapping file into the entry file in the compiled file of the main application comprises:
[0027] The common configuration items are introduced into the entry file in the compiled file of the main application.
[0028] The present application provides an application management device based on CDN, including:
[0029] A disassembly unit, used to disassemble the target application to obtain a disassembly result, wherein the disassembly result is used to describe multiple modules in a decoupled state, wherein the multiple modules include a main application and at least one sub-application;
[0030] A construction unit, configured to construct a single repository according to the disassembly result, wherein the single repository includes a common folder and folders corresponding to each module, wherein the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes a code file of the module;
[0031] A compiling unit, for packaging and compiling the common folder and the folder corresponding to the module for any of the modules, to obtain a compiled file of the module, and to host the entry file address in the compiled file of the module to a content distribution network CDN, to obtain a CDN address of the module;
[0032] The processing unit is used to configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any of the sub-applications, mount the CDN address of the sub-application to the global object of the main application.
[0033] The present application provides an electronic device, the device comprising: a processor and a memory;
[0034] The memory is used to store instructions or computer programs;
[0035] The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the CDN-based application management method provided in the present application.
[0036] The present application provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes the CDN-based application management method provided by the present application.
[0037] The present application provides a computer program product, characterized in that it includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the CDN-based application management method provided by the present application.
[0038] Compared with the related art, this application has at least the following advantages:
[0039] In the technical solution provided by the present application, for a large target application, the target application is first disassembled to obtain a disassembly result, so that the disassembly result is used to describe multiple modules in a decoupled state, and the multiple modules include a main application and at least one sub-application; then, based on the disassembly result, a single repository is constructed, so that the single repository includes a common folder and a folder corresponding to each module, the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes the code file of the module, thereby supporting bundleless in the development environment; then, for any module, the common folder and the folder corresponding to the module are packaged and compiled to obtain a compiled file of the module, and the entry file address in the compiled file of the module is hosted to a content delivery network (Content Delivery Network) The CDN address of the module is obtained by using a CDN (CDN) to configure the root directory of the domain name of the target application to point to the CDN address of the main application. For any sub-application, the CDN address of the sub-application is mounted to the global object of the main application to register the sub-application in the main application. This allows the main application and sub-applications to be rendered and displayed online with the help of CDN, such as using the CDN address of the sub-application obtained from the global object to render and display the sub-application. This is conducive to achieving Bundleless in a production environment, thereby effectively improving efficiency, such as development efficiency and release efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 A flowchart of a CDN-based application management method provided in an embodiment of the present application;
[0042] Figure 2 A schematic diagram of a single storage library provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of local startup and online deployment provided in an embodiment of the present application;
[0044] Figure 4 A schematic diagram of third-party resource dependency provided for an embodiment of the present application;
[0045] Figure 5A schematic diagram of a content-dependent method provided in an embodiment of the present application;
[0046] Figure 6 A schematic diagram of the structure of a CDN-based application management device provided in an embodiment of the present application;
[0047] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] Research has found that in some scenarios, micro-frontend technology can be used to solve the defects of large applications. However, some implementations of micro-frontend technology have the following defects: these implementations do not support Bundleless, especially in production environments, which leads to low efficiency of these implementations.
[0049] Based on the above research, in order to better improve efficiency, the present application provides an application management method based on CDN, which includes: firstly, disassembling a large target application to obtain a disassembly result, so that the disassembly result is used to describe multiple modules in a decoupled state, and the multiple modules include a main application and at least one sub-application; then, based on the disassembly result, building a single repository, so that the single repository includes a common folder and a folder corresponding to each module, the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes the code file of the module, thereby supporting Bundleless in the development environment; then, for any module, the common folder and the folder corresponding to the module are The package compilation process is performed to obtain the compiled file of the module, and the entry file address in the compiled file of the module is hosted to the CDN to obtain the CDN address of the module, so as to subsequently configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any sub-application, the CDN address of the sub-application is mounted to the global object of the main application to register the sub-application in the main application, so as to subsequently realize the online rendering and display of the main application and each sub-application with the help of CDN, such as using the CDN address of the sub-application obtained from the global object to realize the rendering and display processing for the sub-application, etc. This is conducive to realizing Bundleless in the production environment, thereby effectively improving efficiency, such as development efficiency and release efficiency.
[0050] In addition, the present application does not limit the execution subject of the CDN-based application management method provided in the embodiment of the present application. For example, the CDN-based application management method provided in the embodiment of the present application can be applied to a terminal device or a server. For another example, the CDN-based application management method provided in the embodiment of the present application can also be implemented with the help of the data interaction process between the terminal device and the server. Among them, the terminal device can be a smart phone, a computer, a personal digital assistant (PDA), a tablet computer, etc. The server can be an independent server, a cluster server or a cloud server.
[0051] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0052] In order to better understand the technical solution provided by the present application, the CDN-based application management method provided by the present application is described below with reference to some drawings. Figure 1 As shown, the CDN-based application management method provided in the embodiment of the present application includes the following S1-S4. Figure 1 A flowchart of a CDN-based application management method provided in an embodiment of the present application.
[0053] S1: Disassemble the target application to obtain a disassembly result, where the disassembly result is used to describe multiple modules in a decoupled state, where the multiple modules include a main application and at least one sub-application.
[0054] Among them, the target application refers to a large application, that is, an application with a relatively large volume, such as Figure 2 The large-scale applications shown or large-scale and comprehensive service platforms, etc.
[0055] The disassembly result is obtained by disassembling the target application so that the disassembly result can describe multiple modules in a decoupled state, such as a main application and at least one sub-application, so that each module can be subsequently processed as a single application, such as development, deployment, and management. This can effectively reduce the size of a single application, reduce the difficulty of managing a single application, and reduce the operation and maintenance risks.
[0056] It should be noted that the present application does not limit the implementation method of disassembly. For example, the disassembly may be implemented by means of manual interaction to disassemble the target application according to user needs. For another example, the disassembly may be automatically implemented using pre-built disassembly strategies and disassembly rules. For another example, the disassembly may be implemented by means of a pre-built machine learning model with the function of disassembling large applications.
[0057] In addition, the present application does not limit the implementation method of the disassembly result. For example, when the disassembly result is used to describe K modules, the disassembly result may include at least the code file of the kth module, where k is a positive integer, k≤K, K is a positive integer, and K represents the number of modules in the above multiple modules. The code file of the kth module is used to implement the kth module.
[0058] For another example, the above disassembly result may also include the dependent content of the kth module, where k is a positive integer, k≤K. The dependent content of the kth module refers to the content required to be relied upon when implementing the kth module based on the code file of the kth module, such as third-party resources, and common content provided by R&D personnel for the target application (e.g., content similar to menu bars used with @components, content similar to hooks, utils, config, etc. used with @common, etc.).
[0059] In addition, the present application does not limit the implementation of S1 above. For example, it can be implemented with the help of any micro-frontend technology, such as Single-spa. It can be seen that in one possible implementation, S1 can specifically be: based on a pre-set micro-frontend technology (such as Single-spa), the target application is disassembled to decouple the modules in the target application to obtain multiple modules that are decoupled from each other, so that each module can be processed separately as a single application later.
[0060] Based on the relevant content of S1 above, it can be known that in some scenarios, for large target applications, a pre-set micro-frontend technology can be used to disassemble the target application to decouple the modules in the target application and obtain the main application and at least one sub-application, so that each application can be processed separately in the future, such as development, release and deployment, etc. This can effectively reduce the size of a single application, reduce the management difficulty of a single application, and reduce the operation and maintenance risks, thereby effectively overcoming some defects of large applications themselves, such as the time-consuming release of minor changes, which is conducive to improving application management effects.
[0061] S2: Based on the disassembly results, a single repository is constructed, which includes a common folder and folders corresponding to each module. The common folder includes common content between at least two modules. For any module, the folder corresponding to the module includes the code file of the module.
[0062] Among them, a single repository is used for multiple modules above (such as Figure 2 , Figure 3 , Figure 4 or Figure 5 The main application and N sub-applications shown in the figure provide storage services so that the storage content in the single storage repository can be used to complete the relevant processing for each module, such as development and deployment. Wherein, N is a positive integer.
[0063] In addition, a single repository can satisfy the following constraints: the single repository includes a common folder and folders corresponding to each module; the common folder includes common content between at least two modules; and for any module, the folder corresponding to the module includes the code file of the module, so that subsequent related processing for the kth module can be completed with the help of the common folder in the first repository and the folder corresponding to the kth module, such as local startup, online deployment, etc., k is a positive integer, k≤K.
[0064] It can be seen that under a possible implementation mode, the local startup solution provided by the present application is: in response to triggering a local startup request for the kth module, first read the content recorded in the common folder and the content recorded in the folder corresponding to the kth module from the first storage library; then render and display the kth module locally based on the read content so that the user can view the full picture of the kth module. It should be noted that if the dependent content of the kth module also includes third-party resources, the third-party resources can be downloaded to the local in advance so as to be available for use during local startup; or, when the third-party resources have been mounted to the CDN, the third-party resources can be obtained in real time during the local startup with the help of the CDN, which is conducive to saving local storage space.
[0065] A shared folder is a folder created in a single repository that is completely independent of the folders corresponding to each module and is used to provide dependent content for some or all modules. For example Figure 2 or Figure 5 The shared folder shown is used to provide some dependent content for the display process of each module, such as common code between the main application and at least one sub-application.
[0066] In addition, the shared folder can be used to record the shared content between at least two of the multiple modules above, such as common components such as menu bars, so that the shared folder can provide the multiple modules with the required dependent content. The shared content refers to the content that needs to be relied upon when implementing at least two modules; and this application does not limit the implementation method of the shared content. For example, the shared content may include content provided by R&D personnel for the target application and relied upon by at least two modules, such as common code between the main and sub-applications.
[0067] It can be seen that in one possible implementation mode, the content in the shared folder can be used to provide other dependencies for some or all of the multiple modules above in addition to third-party resources, such as common codes provided by R&D personnel for some or all of the modules, such as menu bars, so that subsequent users can change the dependent content of some or all modules by changing the content of the shared folder, which is conducive to improving efficiency.
[0068] Based on the content of the previous paragraph, it can be known that under a possible implementation method, the shared folder can include the menu bar of the target application. It can be seen that because the complete menu bar of the target application is no longer placed in the main application, but is stored in the shared folder as a public component, it can be subsequently rendered by each sub-application with the assistance of the shared folder, so that each sub-application only needs to start the sub-application when developing locally, without starting the main application. This can effectively overcome the defects that exist when viewing the full picture of the sub-application by starting the sub-application and the main application at the same time in the case of local development, such as the communication cost between the main and sub-applications and the reduction of local development efficiency. Also, because the menu bar is no longer placed in the main application, there is no need to republish the main application in the production environment when the menu bar is modified, which is conducive to improving the application management effect.
[0069] Furthermore, the present application does not limit the implementation method of the content in the shared folder. For example, it may include at least one shared content, such as Figure 5 The common content 1 to the common content M shown, M is a positive integer, so that the shared folder can provide some dependent content to the main application and each sub-application, such as @common dependency, @components dependency, etc. It should be noted that this application does not limit the at least one common content. For example, the at least one common content may include common code between all main and sub-applications, such as code used with the help of @common, code used with the help of @components, etc.
[0070] For the kth module among the multiple modules above, such as the main application or any sub-application, the folder corresponding to the kth module refers to a completely independent folder created for the kth module in a single repository and used to record the content that belongs exclusively to the kth module (such as the code files of the kth module). Figure 2 The folder of application 1, the folder of application 2, ..., or the folder of application N, etc. are shown, so that the rendering and display processing of the kth module can be completed with the help of the folder later, where k is a positive integer, k≤K.
[0071] In addition, the present application does not limit the implementation method of the folder corresponding to the kth module. For example, the folder corresponding to the kth module may at least include the code file of the kth module.
[0072] For another example, the folder corresponding to the kth module may also include the dependent configuration of the kth module, such as the package file of the kth module (such as Figure 5 json file shown in the package.json file), so that the dependency content of the k-th module can be obtained based on the dependency configuration during local startup or online rendering, and the rendering display process for the k-th module can be completed with the assistance of the dependency content.
[0073] It should be noted that the present application does not limit the implementation method of the dependency configuration of the kth module above. For example, it may include dependency configuration for third-party resources (such as Figure 4 Dependency configuration for third-party resources as described in the vite.config.json file shown in the figure) and / or dependency configuration for shared folders (such as for Figure 5 The dependency configuration of common content 1 to common content M is shown, where M is a positive integer).
[0074] In addition, the present application does not limit the implementation method of S2 above. For example, when S1 above is implemented using micro-frontend technology, S2 can be implemented using Monorepo to solve the problem that common code between master and sub-applications is difficult to maintain under micro-frontend technology.
[0075] It should be noted that this application does not limit the implementation method of the above paragraph. For example, when the package tool used in this application is PNPM, since PNPM has built-in support for a single repository, a pnpm-workspace.yaml file can be created in the root directory to generate a workspace (Workspace), so that the dependency on @common (or @components) appearing in the package.json of all subsequent sub-applications can be adaptively modified to workspace:@common (or workspace:@components), so that PNPM can link it to the @common (or @components) content in the shared folder in the workspace.
[0076] Based on the relevant content of S2 above, for some scenarios, after using micro-frontend technology to decompose the target application into multiple decoupled modules, such as the main application and at least one sub-application, you can use Monorepo technology to build a single repository, such as Figure 2 The single repository shown in the figure includes a common folder and folders corresponding to each module. The common folder includes common content between at least two modules, and the folders corresponding to each module include code files of the corresponding module. In this way, the problem of difficulty in maintaining common code between main and sub-applications under micro-frontend technology can be solved by combining Monorepo on the basis of micro-frontend. In addition, since the common folder can take effect after local debugging and modification, there is no need to send a package, so that the main application and each sub-application do not need to manually upgrade the package, which can better solve the problem of difficulty in maintaining common code between main and sub-applications under micro-frontend technology.
[0077] S3: For any module, the common folder and the folder corresponding to the module are packaged and compiled to obtain the compiled file of the module, and the entry file address in the compiled file of the module is hosted to CDN to obtain the CDN address of the module.
[0078] Among them, the compiled file of the kth module is obtained by packaging and compiling the common folder and the folder corresponding to the kth module, so that the online deployment processing of the kth module can be completed with the help of the compiled file later, k is a positive integer, k≤K.
[0079] It should be noted that the present application does not limit the implementation method of the packaging and compilation process in the above paragraph. For example, it can be implemented by any method that can implement packaging and compilation. For another example, in order to better implement Bundleless, the packaging and compilation process can be implemented with the help of a tool with packaging and compilation processing function, such as a build tool similar to Vite.
[0080] Based on the relevant content of S3 above, it can be known that in some scenarios, for the kth module, the common folder and the folder corresponding to the kth module can be packaged and compiled to obtain the compiled file of the kth module, so that the compiled file can provide the content required to implement the kth module, so that after the separate release and deployment of the kth module is completed according to the compiled file, the address of the entry file (such as index.html) in the compiled file of the kth module is hosted to the CDN to obtain the CDN address of the kth module, so that the compiled file of the kth module can be obtained based on the CDN address in the future, where k is a positive integer, k≤K.
[0081] S4: Configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any sub-application, mount the CDN address of the sub-application to the global object of the main application.
[0082] In the present application, after obtaining the CDN address of the main application, a mapping relationship can be established between the root directory of the domain name of the target application and the CDN address of the main application, so that the mapping relationship can indicate that the root directory points to the CDN address of the main application, so that the CDN address of the main application can be determined from the mapping relationship based on the root directory, and the online rendering and display processing of the main application can be completed with the help of the CDN address of the main application.
[0083] In addition, after obtaining the CDN address of the nth sub-application, the CDN address of the nth sub-application can be mounted on the global object of the main application (such as the window object), so that the main application can subsequently obtain the CDN address of the nth sub-application from the global object to register the sub-application in the main application, thereby completing the entire micro-frontend architecture, where n is a positive integer, n≤N, N is a positive integer, and N represents the number of sub-applications in at least one of the above sub-applications.
[0084] It should be noted that the present application does not limit the content mounted in the above paragraph. For example, it may also include the application name and / or at least one application ancillary information. It can be seen that, under one possible implementation, the above S4 may at least include: for any sub-application, the application information of the sub-application is mounted to the global object of the main application, wherein the application information is used to describe the characteristics of the sub-application; and the present application does not limit the implementation method of the application information. For example, the application information may specifically include at least the CDN address of the sub-application. For another example, the application information may also include the application name of the sub-application and one or more of at least one application ancillary information. Among them, the application name is used to uniquely identify the sub-application. The application ancillary information is used to describe other characteristics of the sub-application, such as the display position of the application name of the sub-application on the main application.
[0085] It should also be noted that the present application does not limit the representation method of the above application information. For example, it can be represented in the form of key-value pairs, so that the CDN address of the sub-application can be found later with the help of the application name of the sub-application.
[0086] Based on the relevant contents of S1 to S4 above, it can be known that for a large target application, the target application is first disassembled to obtain a disassembly result, so that the disassembly result is used to describe multiple modules in a decoupled state, and the multiple modules include a main application and at least one sub-application; then, based on the disassembly result, a single repository is constructed, so that the single repository includes a common folder and a folder corresponding to each module, the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes the code file of the module, thereby supporting Bundleless in the development environment; then, for any module, the common folder and the folder corresponding to the module are packaged and compiled. Get the compiled file of the module, and host the entry file address in the compiled file of the module to CDN, and get the CDN address of the module, so as to subsequently configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any of the sub-applications, mount the CDN address of the sub-application to the global object of the main application to register the sub-application in the main application, so as to subsequently realize online rendering and display of the main application and each sub-application with the help of CDN, such as using the CDN address of the sub-application obtained from the global object to realize rendering and display processing for the sub-application, etc. This is conducive to realizing Bundleless in the production environment, thereby effectively improving efficiency, such as development efficiency and release efficiency.
[0087] Through research, it is found that in some scenarios, the target application may rely on third-party resources to be implemented, so that the dependency content of each module split from the target application may also include third-party resources. Therefore, in order to ensure that each module can be rendered and displayed smoothly, for any module, the third-party resources required by the module can be packaged into the compiled file of the module to ensure that the module can be smoothly rendered and displayed online later.
[0088] Research has also found that for any module, after the third-party resources required by the module are packaged into the compiled file of the module, the size of the compiled file increases dramatically, which affects the efficiency. Therefore, in order to better improve the efficiency, the present application provides a possible implementation method of the above-mentioned CDN-based application management method. Under this method, when the target application is implemented by relying on third-party resources, the CDN-based application management method can at least include the following steps 11-13.
[0089] Step 11: Mount the third-party resource to CDN and obtain the CDN address of the third-party resource.
[0090] Among them, third-party resources refer to the content provided by a third party that is required to implement the target application, such as plug-ins.
[0091] In addition, the present application does not limit the method of obtaining the third-party resource, for example, it can be specified in advance by relevant personnel for the target application. For another example, the third-party resource can be obtained by analyzing the target application.
[0092] Research has found that in some scenarios, third-party resources cannot be directly mounted on the CDN because they do not meet the CDN mounting requirements.
[0093] In order to overcome the problem shown in the previous paragraph, the present application also provides a possible implementation of step 11 above. In this way, when the third-party resource does not meet the CDN mounting conditions, step 11 can be specifically as follows: first process the third-party resource to obtain a third-party service, so that the third service meets the CDN mounting conditions, and enables the third service to describe the service described by the third-party resource in accordance with the preset format corresponding to the CDN; then, mount the third-party service to the CDN to obtain the CDN address of the third-party resource. The preset format refers to the format that the service that can be mounted on the CDN needs to meet; and the present application does not limit the preset format.
[0094] In addition, the present application does not limit the execution time of step 11, and it is necessary to ensure that the execution time of step 11 is later than the acquisition time of the third resource.
[0095] Step 12: Build an input mapping file, such as the import_map.json file, based on the CDN address of the third-party resource.
[0096] The input mapping file is at least used to store the CDN addresses of all third-party resources.
[0097] In addition, the input mapping file is also used to store the package names of all third-party resource packages, where the package name is used to uniquely identify the package.
[0098] In addition, the input map file is used to store packages for all third-party resources.
[0099] Based on the relevant content of step 12 above, it can be known that in one possible implementation mode, all third-party resource packages, the package names of all third-party resource packages, and the CDN addresses of all third-party resources can be stored in the import_map.json file, so that the reference to the third-party resource can be completed with the help of the import_map.json file later.
[0100] Step 13: Based on the input mapping file, build the configuration files of each module, and introduce the input mapping file into the entry file in the compilation file of the main application.
[0101] Among them, the configuration file of the kth module is used to describe the configuration information for the kth module, such as the dependency configuration for the third resource, etc., and this application does not limit the configuration file, such as it can include the vite.config.json file, k is a positive integer, k≤K.
[0102] It should be noted that the present application does not limit the implementation method of the vite.config.json file in the above paragraph. For example, in vite.config.json, rollupOptions.external is configured to be the package name array in the import_map.json file to ensure that the packages of these third-party resources are not packaged into the product, such as the compiled files of each module, so as to ensure that the third-party resources can be obtained with the help of CDN when rendering and displaying each module online. This can effectively overcome the defects caused by packaging the third-party resources into the product, such as low efficiency.
[0103] In addition, the present application does not limit the implementation method of the above step of "introducing the input mapping file into the entry file of the compiled file of the main application". For example, it can be specifically: in the index.html of the main application, <script type="importmap-shim"src=" import_map.json">< / script>The import_map.json file is introduced in this way, so that the global modules in the browser can be supported with the help of the shim mode of es-module-shims in the future, so that users can import and reference third-party resource packages in the browser just like in the node environment, so as to obtain third-party resources from the CDN when rendering and displaying the main application. This helps to ensure that various applications that rely on these third-party resources can be rendered and displayed normally.
[0104] After research, it was found that some third-party resources are commonly dependent on multiple modules, but some third-party resources are dependent on a certain module alone. Therefore, in order to better improve efficiency, only these commonly dependent third-party resources can be introduced into the index.html of the main application. This will help reduce the pressure when rendering and displaying the main application.
[0105] In order to achieve the requirements shown in the previous paragraph, the present application also provides a possible implementation method of the above step 13. In this method, the step 13 may specifically include the following steps 131 to 133.
[0106] Step 131: Based on the input mapping file, construct the configuration files of each module, such as Figure 4 The vite.config.json file shown.
[0107] Step 132: Analyze the configuration files of the above multiple modules to obtain common configuration items, such as Figure 4 In the content of the vite.baseconfig.json file shown, the input mapping file includes the common configuration item, and the configuration files of at least two modules among the multiple modules include the common configuration item.
[0108] The common configuration item refers to a configuration item that appears in the configuration files of at least two modules, so that the common configuration item can represent the third-party resource that exists in the above input mapping file and is relied upon by at least two modules.
[0109] It can be seen that the common configuration item can satisfy the following constraints: the above input mapping file includes the common configuration item, and configuration files of at least two modules among the above multiple modules include the common configuration item.
[0110] Step 133: Introduce the above common configuration items into the entry file in the compiled file of the main application.
[0111] Based on the relevant contents of steps 131 to 133 above, it can be known that in some scenarios, for the configuration file of any module, there may be some configuration items configured separately for the module, and there may also be some configuration items configured for multiple modules. Therefore, in order to better improve efficiency, these "configuration items configured for multiple modules" can be introduced into the index.html of the main application, so that when the main application is subsequently rendered and displayed, these "configuration items configured for multiple modules" can be referenced and loaded with the help of es-module-shims; in addition, these "configuration items configured separately for the module" are directly introduced into the vite.config.json file of the module, so that when the module, such as each sub-application, is subsequently rendered and displayed, these "configuration items configured separately for the module" are referenced and loaded, which is conducive to improving efficiency.
[0112] Based on the relevant contents of steps 11 to 13 above, it can be seen that in some scenarios, such as Figure 2 In the scenario shown, when this application uses Vite, a construction tool, to implement Bundleless, all third-party resource packages that the target application depends on and their corresponding CDN addresses can be stored in the import_map.json file, and rollupOptions.external can be configured in the vite.config.json file of each module as the package name array in the import_map.json file to ensure that these third-party resource packages are not packaged into the product, such as the compiled files of each module, thereby overcoming the defects caused when the third-party resource packages are packaged into the product, such as the sharp increase in the size of the compiled file and the reduction in efficiency in the production environment. At the same time, in the index.html of the main application, <script type="importmap-shim"src=" import_map.json">< / script> The import_map.json file is introduced in this way, so that the global modules in the browser can be supported with the help of the shim mode of es-module-shims in the future, so that users can import and reference third-party resource packages in the browser just like in the node environment. In this way, third-party resources are not packaged into the editing files of each module without affecting the online rendering and display of each module, thereby reducing the size of the editing files of each module without affecting the online rendering and display of each module, and thus better supporting Bundleless in the production environment.
[0113] In addition, the present application also provides an online usage logic of a main application, which may at least include the following steps 21 to 23.
[0114] Step 21: In response to a query request triggered by the root directory of the domain name of the target application, the CDN address of the main application is obtained according to the root directory.
[0115] The query request is used to query the root directory of the domain name of the target application; and the query request at least carries the root directory.
[0116] In addition, the present application does not limit the implementation method of step 21 above. For example, it can specifically be: in response to a query request triggered by the root directory of the domain name of the target application, based on the root directory carried by the query request, searching for a CDN address that has a mapping relationship with the root directory as the CDN address of the main application.
[0117] Step 22: Obtain the compiled file of the main application according to the CDN address of the main application.
[0118] In the present application, after obtaining the CDN address of the main application, the compiled file of the main application can be found with the help of CDN according to the CDN address of the main application.
[0119] Step 23: Render and display the main application based on the compiled file of the main application.
[0120] In this application, after obtaining the compiled file of the main application, autonomous rendering is performed according to the compiled file to obtain and display the main application.
[0121] Based on the relevant contents of steps 21 to 23 above, it can be known that for some scenarios, after configuring the root directory of the domain name of the target application to point to the CDN address of the main application, if a query request triggered for the root directory is detected, the CDN address pointed to by the root directory is first used as the CDN address of the main application; then, according to the CDN address, the compiled file of the main application is obtained; then, the compiled file is autonomously rendered to obtain and display the main application, so that the display process for the main application can be completed with the help of CDN. Among them, because the code files and dependent content of the main application can be obtained with the help of CDN, this is conducive to improving efficiency.
[0122] In addition, the present application also provides an online usage logic for the nth sub-application, which may at least include the following steps 31 to 33.
[0123] Step 31: When the main application is in a display state, such as the display state after executing step 23 above, in response to a display request triggered for the nth sub-application, the CDN address of the nth sub-application is obtained from the global object of the main application, where n is a positive integer, n≤N.
[0124] Among them, the display request triggered for the nth sub-application is used to request rendering and display for the nth sub-application; and the present application does not limit the implementation method of the display request. For example, when the key-value pair of <application name of the nth sub-application, CDN address of the nth sub-application> is recorded in the global object of the main application, the display request can carry the application name of the nth sub-application.
[0125] In addition, the present application does not limit the triggering method of the above display request. For example, when the application name of the nth sub-application is displayed on the main application, the display request can be a trigger operation by the user on the application name of the nth sub-application displayed by the main application, such as triggered by a selection operation.
[0126] Step 32: According to the CDN address of the nth sub-application, obtain the compiled file of the nth sub-application, where n is a positive integer, n≤N.
[0127] In the present application, after obtaining the CDN address of the nth sub-application, the compiled file of the nth sub-application can be found with the help of CDN according to the CDN address of the nth sub-application, where n is a positive integer, n≤N.
[0128] Step 33: Display the nth sub-application according to the compiled file of the nth sub-application, where n is a positive integer, n≤N.
[0129] Based on the relevant contents of steps 31 to 32 above, it can be known that for the nth sub-application, after the CDN address of the nth sub-application is mounted on the global object of the main application, when the main application is in the display state, if a display request triggered for the nth sub-application is detected, first, according to the content carried by the display request, such as the application name of the nth sub-application, the CDN address corresponding to the application name is searched from the global object of the main application as the CDN address of the nth sub-application; then, the compiled file of the nth sub-application is obtained according to the CDN address; then, the compiled file is autonomously rendered to obtain and display the nth sub-application, where n is a positive integer, n≤N, so that the display process for any sub-application can be realized. Among them, because the code files and dependent content of the nth sub-application can be obtained with the help of CDN, this is conducive to improving efficiency.
[0130] Based on the above content, it can be seen that the present application provides a solution based on the three technologies of Single-spa, Monorepo and Bundleless, and the solution has the characteristics shown in ①-⑥ below.
[0131] ① For large applications, they are split into multiple sub-applications and a main application in a module decoupling manner, so that the split applications are packaged and released separately, the addresses of the entry files of these applications are hosted on the CDN, and the application information of each sub-application is mounted on the window object of the main application, so as to register the sub-application in the main application. Among them, when developing locally, the public components similar to the menu bar that the sub-application needs to rely on to start are no longer placed on the main application, so this application only needs to start the sub-application separately for local development, and there is no need to start the main application again, which is conducive to improving efficiency.
[0132] ② This application uses Vite to implement Bundleless in local and production environments, and the reasons for implementing Bundleless in the production environment at least include: hosting the packages of third-party resources on CDN, so that the main application and each sub-application can reference the third-party resources through CDN introduction, which is conducive to improving efficiency.
[0133] ③This application uses PNPM's workspace to implement Monorepo, which solves the problem of reuse of common codes between the main application and sub-applications, and the solution is: first place the relevant files of the main application, the relevant files of each sub-application, and these common codes in the same warehouse; then, use folders to distinguish different applications, and when referencing the common code in the folder corresponding to each application, you only need to directly link to the folder in the warehouse that is used to store the common code separately. This makes code sharing easier, so that after changing the common code, it is easier to build and test all applications that rely on the common code, thereby improving the convenience and consistency of maintenance.
[0134] ④Through the technical solution provided by this application, large applications with hundreds of thousands of lines can be split to decouple each module, and obtain independent main applications and multiple sub-applications, which can greatly reduce the size of a single application. In addition, because each module is used as a single independent application, each application only needs to rely on the library it needs, so that the dependency is reduced a lot, which can greatly reduce the complexity of management. In addition, because it is only necessary to package and publish the applications involved in the change situation (such as iterative update) separately, the time consumption of the entire change process is reduced, and the scope of change is reduced, which is conducive to reducing the operation and maintenance risks. In addition, because each module exists as a separate application, each module can adopt a different framework and technology stack without affecting each other. Furthermore, because only a single sub-application needs to be started during local development, the full picture can be seen without starting the main application and the sub-application at the same time, and there is no communication problem between the main application and the sub-application, so that there is almost no need to frequently release the main application during the update iteration process.
[0135] ⑤ The present invention combines the Bundleless technology on the basis of the micro front-end. When developing locally, there is no need to go through dependency analysis, code translation and packaging after modification, so as to achieve instant local hot update and local startup in seconds. At the same time, it can also achieve compilation in seconds during online deployment, greatly improving efficiency.
[0136] ⑥ The present invention combines the micro front-end with Monorepo, so that the public code can be modified and take effect during local debugging without the need for packaging. The main application or sub-application does not need to upgrade the package during local debugging or release, solving the problems of code sharing, duplication and consistency.
[0137] Based on the CDN-based application management method provided in the embodiment of the present application, the embodiment of the present application also provides a CDN-based application management device. Figure 6 Explain and illustrate. Figure 6 This is a schematic diagram of the structure of a CDN-based application management device provided in an embodiment of the present application. It should be noted that for the technical details of the CDN-based application management device provided in an embodiment of the present application, please refer to the relevant content of the CDN-based application management method above.
[0138] like Figure 6 As shown, the CDN-based application management device 600 provided in the embodiment of the present application includes:
[0139] A disassembly unit 601 is used to disassemble the target application to obtain a disassembly result, where the disassembly result is used to describe multiple modules in a decoupled state, where the multiple modules include a main application and at least one sub-application;
[0140] A construction unit 602 is used to construct a single repository according to the disassembly result, wherein the single repository includes a common folder and folders corresponding to each module, wherein the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes a code file of the module;
[0141] The compiling unit 603 is used to package and compile the common folder and the folder corresponding to the module for any of the modules to obtain a compiled file of the module, and to host the entry file address in the compiled file of the module to a content distribution network CDN to obtain a CDN address of the module;
[0142] The processing unit 604 is used to configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any of the sub-applications, mount the CDN address of the sub-application to the global object of the main application.
[0143] In a possible implementation manner, the shared folder includes a menu bar of the target application.
[0144] In a possible implementation manner, the CDN-based application management device 600 further includes:
[0145] A first acquisition unit, configured to acquire a CDN address of the main application according to the root directory in response to a query request triggered for the root directory;
[0146] A second acquisition unit, configured to acquire a compiled file of the main application according to the CDN address of the main application;
[0147] The first display unit is used to render and display the main application according to the compiled file of the main application.
[0148] In a possible implementation manner, the CDN-based application management device 600 further includes:
[0149] A third acquisition unit, configured to, when the main application is in a display state, in response to a display request triggered for the sub-application, acquire a CDN address of the sub-application from a global object of the main application;
[0150] A fourth acquisition unit, configured to acquire a compiled file of the sub-application according to the CDN address of the sub-application;
[0151] The second display unit is used to render and display the sub-application according to the compiled file of the sub-application.
[0152] In a possible implementation manner, the target application is implemented by relying on third-party resources;
[0153] The CDN-based application management device 600 further includes:
[0154] A fifth acquisition unit, configured to mount the third-party resource to the CDN to obtain a CDN address of the third-party resource;
[0155] A sixth acquisition unit, configured to construct an input mapping file according to the CDN address of the third-party resource;
[0156] The seventh acquisition unit is used to construct a configuration file of each module according to the input mapping file, and introduce the input mapping file into an entry file in the compiled file of the main application.
[0157] In one possible implementation, the seventh acquisition unit is specifically used to: construct a configuration file for each of the modules based on the input mapping file; analyze the configuration files of the multiple modules to obtain common configuration items, the input mapping file includes the common configuration items, and the configuration files of at least two modules among the multiple modules include the common configuration items; and introduce the common configuration items into the entry file in the compiled file of the main application.
[0158] Based on the above-mentioned relevant contents of the CDN-based application management device 600, it can be known that the working principle of the CDN-based application management device 600 provided in the present application includes: firstly, a large target application is disassembled to obtain a disassembly result, so that the disassembly result is used to describe multiple modules in a decoupled state, and the multiple modules include a main application and at least one sub-application; then, based on the disassembly result, a single repository is constructed, so that the single repository includes a common folder and a folder corresponding to each module, the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes the code file of the module, thereby realizing support for Bundleless in the development environment; then, for any module, the common folder and the folder corresponding to the module are The corresponding folder is packaged and compiled to obtain the compiled file of the module, and the entry file address in the compiled file of the module is hosted to CDN to obtain the CDN address of the module, so as to subsequently configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any sub-application, the CDN address of the sub-application is mounted to the global object of the main application to register the sub-application in the main application, so that the main application and each sub-application can be rendered and displayed online with the help of CDN, such as using the CDN address of the sub-application obtained from the global object to implement rendering and display processing for the sub-application, etc. This is conducive to realizing Bundleless in the production environment, thereby effectively improving efficiency, such as development efficiency and release efficiency.
[0159] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation of the CDN-based application management method provided in the embodiment of the present application.
[0160] See also Figure 7, which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0161] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0162] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0163] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0164] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0165] The embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes any implementation of the CDN-based application management method provided in the embodiment of the present application.
[0166] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0167] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0168] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0169] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.
[0170] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0171] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0172] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.
[0173] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0174] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0175] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0176] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0177] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0178] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0179] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A CDN-based application management method, characterized in that: The method comprises: Disassembling the target application to obtain a disassembly result, where the disassembly result is used to describe multiple modules in a decoupled state, where the multiple modules include a main application and at least one sub-application; According to the disassembly result, a single repository is constructed, wherein the single repository includes a common folder and folders corresponding to each module, wherein the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes a code file of the module; For any of the modules, the shared folder and the folder corresponding to the module are packaged and compiled to obtain a compiled file of the module, and the entry file address in the compiled file of the module is hosted on a content distribution network CDN to obtain a CDN address of the module; The root directory of the domain name of the target application is configured to point to the CDN address of the main application, and for any of the sub-applications, the CDN address of the sub-application is mounted to the global object of the main application.
2. The method according to claim 1, characterized in that: The shared folder includes a menu bar of the target application.
3. The method according to claim 1, characterized in that After configuring the root directory of the domain name of the target application to point to the CDN address of the main application, the method further includes: In response to a query request triggered for the root directory, obtaining a CDN address of the main application according to the root directory; Obtain the compiled file of the main application according to the CDN address of the main application; The main application is rendered and displayed according to the compiled file of the main application.
4. The method according to claim 1, characterized in that: After mounting the CDN address of the sub-application to the global object of the main application, the method further includes: When the main application is in a display state, in response to a display request triggered for the sub-application, a CDN address of the sub-application is obtained from a global object of the main application; Obtain the compiled file of the sub-application according to the CDN address of the sub-application; Render and display the sub-application based on the compiled file of the sub-application.
5. The method according to claim 1, characterized in that The target application is implemented by relying on third-party resources; The method further comprises: Mount the third-party resource to the CDN to obtain the CDN address of the third-party resource; Constructing an input mapping file according to the CDN address of the third-party resource; According to the input mapping file, a configuration file of each module is constructed, and the input mapping file is introduced into the entry file in the compiled file of the main application.
6. The method according to claim 5, characterized in that After constructing the configuration files of each module, the method further comprises: Analyze the configuration files of the multiple modules to obtain common configuration items, the input mapping file includes the common configuration items, and configuration files of at least two modules among the multiple modules include the common configuration items; The introducing the input mapping file into the entry file in the compiled file of the main application comprises: The common configuration items are introduced into the entry file in the compiled file of the main application.
7. A CDN-based application management device, characterized in that: include: A disassembly unit, used to disassemble the target application to obtain a disassembly result, wherein the disassembly result is used to describe multiple modules in a decoupled state, wherein the multiple modules include a main application and at least one sub-application; A construction unit, configured to construct a single repository according to the disassembly result, wherein the single repository includes a common folder and folders corresponding to each module, wherein the common folder includes common content between at least two modules, and for any module, the folder corresponding to the module includes a code file of the module; A compiling unit, for packaging and compiling the common folder and the folder corresponding to the module for any of the modules, to obtain a compiled file of the module, and to host the entry file address in the compiled file of the module to a content distribution network CDN, to obtain a CDN address of the module; The processing unit is used to configure the root directory of the domain name of the target application to point to the CDN address of the main application, and for any of the sub-applications, mount the CDN address of the sub-application to the global object of the main application.
8. An electronic device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the method according to any one of claims 1 to 6.
9. A computer-readable medium, characterized in that The computer-readable medium stores instructions or computer programs, and when the instructions or computer programs are executed on a device, the device is enabled to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that It comprises a computer program carried on a non-transitory computer-readable medium, the computer program comprising a program code for executing the method according to any one of claims 1 to 6.
