An applet fusion method and device, electronic equipment and storage medium
By compiling and merging the source code packages of the main mini-program and sub-mini-programs, the frameworks and specifications of each mini-program are isolated, solving the problem of low development efficiency when merging multiple mini-programs, and achieving efficient integration and improved business experience.
Patent Information
- Application Number
- CN202211013165.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-23
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-08-23
AI Technical Summary
In existing technologies, multiple independently developed mini-programs affect each other in terms of framework, specifications, and compilation when they are integrated, resulting in low development efficiency.
By compiling the source code packages of the main mini-program and the sub-mini-program separately, a compiled code package is generated. The compiled code package of the sub-mini-program is then used as the target sub-package of the main mini-program for fusion processing, including entry point execution processing, isolated execution processing, communication processing, and routing processing, in order to isolate the framework and specifications of each mini-program.
It achieves isolation of the framework, specifications and compilation of multiple mini-programs, improves development efficiency, and enables multiple mini-programs that were developed separately to be integrated into a single target mini-program, thereby enhancing the business experience.
Smart Images

Figure CN115373684B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a method, apparatus, electronic device, and storage medium for integrating mini-programs. Background Technology
[0002] Mini-programs, as applications that can be used without downloading or installation, are widely used. With the continuous development of mini-programs, page sharing is common among multiple independently developed mini-programs. In this case, integrating the functions of multiple mini-programs into a single target mini-program can avoid page jumps between different mini-programs and improve the business experience. Additionally, when multiple teams collaborate on a target mini-program with many functions, each team typically develops a different mini-program independently, and then integrates the functions of these separately developed mini-programs into the target mini-program to ensure a unified business experience.
[0003] In related technologies, for multiple mini-programs with separate development, the Git submodule approach is usually used for merging. This requires multiple teams to maintain shared page code from the same code repository while developing these mini-programs separately, and they also need to obtain permissions to the same code repository. In addition, multiple mini-programs include a main mini-program and various sub-mini-programs. The source code of each sub-mini-program is usually compiled in the development environment of the main mini-program. Therefore, the main mini-program needs to be compatible with the framework, specifications, compilation, etc. of each sub-mini-program.
[0004] For the reasons mentioned above, it is impossible to isolate the development of multiple mini-programs to be integrated. Their frameworks, specifications, compilation, etc., affect each other, resulting in low development efficiency. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, and storage medium for merging multiple mini-programs that were developed separately, thereby avoiding mutual interference between their frameworks, specifications, compilation, etc., and improving development efficiency.
[0006] On the one hand, embodiments of this application provide a method for integrating mini-programs, including:
[0007] Obtain the source code packages of multiple independently developed mini-programs, compile the multiple source code packages separately to obtain the corresponding compiled code packages; wherein, the multiple mini-programs include: one main mini-program and at least one sub-mini-program;
[0008] The obtained multiple compiled code packages are merged to obtain an initial merged code package; wherein, in the initial merged code package, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program;
[0009] The initial fusion code package is subjected to preset processing to obtain the target fusion code package; wherein, the preset processing includes at least one of the following: entry running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, and routing processing of sub-mini-programs;
[0010] Based on the target fusion code package, the fused target mini-program is generated.
[0011] Optionally, the initial fusion code package is processed for entry point execution as a sub-mini-program, including:
[0012] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0013] Inject runtime code into a target sub-package; wherein the runtime code is used to execute the entry file of the corresponding sub-mini-program and the lifecycle of the corresponding sub-mini-program, as well as register application-level events;
[0014] Import the global style file in the target sub-package into the local style files of the corresponding sub-mini-program, and import the global configuration file in the target sub-package into the page configuration files of the corresponding sub-mini-program;
[0015] The global configuration files of the corresponding sub-mini-programs are merged into the global configuration file of the main mini-program, and the entry page path of the corresponding sub-mini-program is added to the directory information of the target sub-package before being registered in the global configuration file of the main mini-program.
[0016] Optionally, the initial fusion code package is subjected to isolated execution processing between mini-programs, including at least one of the following operations:
[0017] Each target sub-package in the initial fusion code package is isolated using a sandbox.
[0018] For each target sub-package in the initial fusion code package, page style isolation is performed respectively;
[0019] Storage isolation is performed on each target sub-package in the initial fusion code package.
[0020] Optionally, the step of performing sandbox isolation on each target sub-package in the initial fusion code package includes:
[0021] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0022] The sandbox proxy is used to proxy the first target object in a target subpackage and to locally define specified global variables in the target subpackage.
[0023] Shared code is injected into one of the target subpackages. This shared code is used to share the communication methods and custom information of the main mini-program by obtaining target global variables from the compiled code package of the main mini-program.
[0024] Optionally, page style isolation is performed on each target sub-package in the initial fusion code package, including:
[0025] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0026] In a target subpackage, each page's local style file imports the global style file, and both the global style file and the local style file adopt a specified style structure;
[0027] Isolation code is injected into one of the target sub-packages. The isolation code is used to indicate that the global style file of the main mini-program is invalid for the corresponding sub-mini-program.
[0028] Optionally, performing storage isolation on each target sub-package in the initial fusion code package includes:
[0029] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0030] By using a sandbox proxy, the storage method of the first target object in a target subpackage is used to add the directory information of the corresponding sub-program to the storage method.
[0031] Optionally, the initial fusion code package is processed for communication between mini-programs, including:
[0032] In the compilation code package of the main mini-program within the initial fusion code package, add a communication object;
[0033] In each target sub-package of the initial fusion code package, communication code is injected; wherein the communication code is used to return the communication object through a specified local variable in the corresponding target sub-package.
[0034] Optionally, the initial fusion code package is processed for sub-mini-program routing, including:
[0035] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0036] For internal redirection information in a target sub-package, the directory information of the target sub-package is added through the routing method corresponding to the internal redirection information by the second target object.
[0037] Optionally, the preset processing further includes specified processing, in which case specified processing is performed on the initial fusion code package, including:
[0038] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0039] Convert the root path information in a target subpackage to relative path information, or add the directory information of the target subpackage to the root path information;
[0040] Perform a preset transformation on the specified syntax and the corresponding injected code in the target subpackage.
[0041] On one hand, embodiments of this application provide a mini-program integration device, including:
[0042] The acquisition module is used to acquire the source code packages of multiple independently developed mini-programs, compile the multiple source code packages respectively, and obtain the corresponding compiled code packages; wherein, the multiple mini-programs include: one main mini-program and at least one sub-mini-program;
[0043] The fusion module is used to merge multiple compiled code packages to obtain an initial fused code package; wherein, in the initial fused code package, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program;
[0044] The processing module is used to perform preset processing on the initial fusion code package to obtain the target fusion code package; wherein, the preset processing includes at least one of the following: entry running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, and routing processing of sub-mini-programs;
[0045] The generation module is used to generate the fused target mini-program based on the target fusion code package.
[0046] Optionally, when performing entry point execution processing for the initial fusion code package into a sub-mini-program, the processing module is used to:
[0047] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0048] Inject runtime code into a target sub-package; wherein the runtime code is used to execute the entry file of the corresponding sub-mini-program and the lifecycle of the corresponding sub-mini-program, as well as register application-level events;
[0049] Import the global style file in the target sub-package into the local style files of the corresponding sub-mini-program, and import the global configuration file in the target sub-package into the page configuration files of the corresponding sub-mini-program;
[0050] The global configuration files of the corresponding sub-mini-programs are merged into the global configuration file of the main mini-program, and the entry page path of the corresponding sub-mini-program is added to the directory information of the target sub-package before being registered in the global configuration file of the main mini-program.
[0051] Optionally, when performing isolated execution processing between mini-programs on the initial fusion code package, the processing module is used to perform at least one of the following operations:
[0052] Each target sub-package in the initial fusion code package is isolated using a sandbox.
[0053] For each target sub-package in the initial fusion code package, page style isolation is performed respectively;
[0054] Storage isolation is performed on each target sub-package in the initial fusion code package.
[0055] Optionally, when performing sandbox isolation on each target sub-package in the initial fusion code package, the processing module is used to:
[0056] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0057] The sandbox proxy is used to proxy the first target object in a target subpackage and to locally define specified global variables in the target subpackage.
[0058] Shared code is injected into one of the target subpackages. This shared code is used to share the communication methods and custom information of the main mini-program by obtaining target global variables from the compiled code package of the main mini-program.
[0059] Optionally, when performing page style isolation on each target sub-package in the initial fusion code package, the processing module is used to:
[0060] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0061] In a target subpackage, each page's local style file imports the global style file, and both the global style file and the local style file adopt a specified style structure;
[0062] Isolation code is injected into one of the target sub-packages. The isolation code is used to indicate that the global style file of the main mini-program is invalid for the corresponding sub-mini-program.
[0063] Optionally, when performing storage isolation on each target sub-package in the initial fusion code package, the processing module is used to:
[0064] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0065] By using a sandbox proxy, the storage method of the first target object in a target subpackage is used to add the directory information of the corresponding sub-program to the storage method.
[0066] Optionally, when performing inter-mini-program communication processing on the initial fusion code package, the processing module is used to:
[0067] In the compilation code package of the main mini-program within the initial fusion code package, add a communication object;
[0068] In each target sub-package of the initial fusion code package, communication code is injected; wherein the communication code is used to return the communication object through a specified local variable in the corresponding target sub-package.
[0069] Optionally, when performing sub-mini-program routing processing on the initial fusion code package, the processing module is used to:
[0070] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0071] For internal redirection information in a target sub-package, the directory information of the target sub-package is added through the routing method corresponding to the internal redirection information by the second target object.
[0072] Optionally, the preset processing further includes specified processing. When performing specified processing on the initial fusion code package, the processing module is used to:
[0073] For each target subpackage in the initial fusion code package, perform the following operations respectively:
[0074] Convert the root path information in a target subpackage to relative path information, or add the directory information of the target subpackage to the root path information;
[0075] Perform a preset transformation on the specified syntax and the corresponding injected code in the target subpackage.
[0076] On one hand, embodiments of this application provide an electronic device, which includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the above-described applet fusion methods.
[0077] On one hand, embodiments of this application provide a computer storage medium including a computer program. When the computer program is run on an electronic device, the computer program is used to cause the electronic device to perform the steps of any of the above-described applet fusion methods.
[0078] On one hand, embodiments of this application provide a computer program product, which includes a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, causing the electronic device to perform the steps of any of the above-described applet fusion methods.
[0079] Since the embodiments of this application adopt the above-described technical solution, they have at least the following technical effects:
[0080] In the scheme of this application embodiment, the source code packages of the independently developed main mini-program and each sub-mini-program are compiled separately. Even if the development frameworks of the source code of each mini-program are different, they can be compiled separately. Then, their respective compiled code packages are merged, that is, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program. In this way, the main mini-program and each sub-mini-program, which are developed separately, can be merged to avoid mutual interference between their frameworks, specifications, compilation, etc. Furthermore, the obtained initial merged code package is subjected to at least one of the following processes: entry point running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, and routing processing of sub-mini-programs. This merges multiple mini-programs, which are developed separately and whose frameworks, specifications, compilation, etc. are isolated, into a single target mini-program. This can decompose the development of a large mini-program with many functions into multiple mini-programs with independent functions, thereby separating development and improving development efficiency.
[0081] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0082] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0083] Figure 1 A schematic diagram illustrating the integration process of a mini-program as provided in an embodiment of this application;
[0084] Figure 2 A flowchart illustrating a method for integrating mini-programs provided in this application embodiment;
[0085] Figure 3 A logical schematic diagram of a mini-program integration method provided in an embodiment of this application;
[0086] Figure 4 A logical schematic diagram of another applet fusion method provided in an embodiment of this application;
[0087] Figure 5 A schematic diagram illustrating the process of running the entry point of the mini-program provided in this embodiment of the application;
[0088] Figure 6 A schematic diagram illustrating the sandbox isolation process for a mini-program provided in this application embodiment;
[0089] Figure 7 A schematic diagram illustrating the style isolation process of a mini-program provided in this embodiment of the application;
[0090] Figure 8 A schematic diagram illustrating the storage isolation process for a mini-program provided in this application embodiment;
[0091] Figure 9 A schematic diagram illustrating the processing of mini-program communication provided in an embodiment of this application;
[0092] Figure 10 A schematic diagram illustrating the routing process for the mini-program provided in this application embodiment;
[0093] Figure 11 A structural block diagram of a mini-program fusion device provided in an embodiment of this application;
[0094] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0095] Figure 13 This is a schematic diagram of the structure of another electronic device in an embodiment of this application. Detailed Implementation
[0096] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0097] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.
[0098] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0099] In related technologies, for multiple mini-programs with separate development, the merging approach typically uses Git submodules. This requires multiple teams to maintain shared page code from the same code repository while developing these mini-programs separately, and they also need to obtain permissions to that same code repository. Furthermore, since multiple mini-programs include a main mini-program and various sub-mini-programs, the source code of each sub-mini-program is usually compiled within the main mini-program's development environment. Therefore, the main mini-program needs to be compatible with the framework, specifications, and compilation methods of each sub-mini-program. For these reasons, it is impossible to isolate the development of the multiple mini-programs to be merged; their frameworks, specifications, and compilation methods interfere with each other, resulting in low development efficiency.
[0100] To address the aforementioned issues, this application provides a method, apparatus, electronic device, and storage medium for merging multiple mini-programs that were developed separately into a single target mini-program. This avoids mutual interference between the frameworks, specifications, and compilation processes of the multiple mini-programs, thereby improving development efficiency. A detailed description is provided below with reference to the accompanying drawings.
[0101] First, please refer to Figure 1 , Figure 1 The process of generating the target mini-program is shown, which involves the main mini-program, sub-mini-programs, and the target mini-program.
[0102] The main mini-program, sub-mini-programs, and target mini-program can be WeChat mini-programs or other application mini-programs, and can be installed on terminal devices. Among them, there can be one or more sub-mini-programs.
[0103] Both the main mini-program and the sub-mini-programs contain source code packages. Compiling the source code packages of the main mini-program and the sub-mini-programs separately yields the compiled code packages of the main mini-program and the sub-mini-programs, respectively. These compiled code packages are then merged, with each sub-mini-program's compiled code package serving as a target sub-package for the main mini-program, resulting in an initial merged code package. Pre-processing this initial merged code package yields the target merged code package. The target mini-program can then be generated from this target merged code package.
[0104] The mini-program fusion method of this application embodiment can be executed by an electronic device, which can be a server or a terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, cloud functions, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The aforementioned terminal devices include, but are not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, and aircraft.
[0105] The technical solutions of this application embodiment can be based on Figure 1 The integration process of the mini-program is illustrated with a schematic diagram or deformation diagram to illustrate the specific implementation.
[0106] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0107] The specific implementation method of the mini-program integration method in this application is described below.
[0108] See Figure 2 , Figure 2 This application illustrates an embodiment of a method for integrating mini-programs, which can be executed by an electronic device and includes, but is not limited to, the following steps S201-S204:
[0109] Step S201: Obtain the source code packages of multiple independently developed mini-programs, compile the multiple source code packages respectively, and obtain the corresponding compiled code packages; wherein, the multiple mini-programs include: one main mini-program and at least one sub-mini-program.
[0110] Because each of the aforementioned mini-programs can be developed as an independent project, each mini-program has a corresponding source code package. A source code package is a file package containing source code (also called source program), which refers to a series of human-readable computer language instructions. In modern programming languages, source code can appear in the form of books or tapes, but the most common format is a text file, the typical format of which is used to compile computer programs.
[0111] Furthermore, the source code packages of each of the aforementioned mini-programs are compiled separately to obtain the compiled code packages for each mini-program. Each compiled code package contains compiled code, which translates human-readable text (source code) into binary instructions that a computer can execute.
[0112] Step S202: The obtained multiple compiled code packages are merged to obtain an initial merged code package; wherein, in the initial merged code package, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program.
[0113] Typically, each mini-program's code package includes a main package and sub-packages. The main package includes one or more sub-packages. When merging multiple compiled code packages, the compiled code package of each sub-mini-program is used as a target sub-package under the main package of the main mini-program to obtain the initial merged code package.
[0114] Step S203: Perform preset processing on the initial fusion code package to obtain the target fusion code package; wherein, the preset processing includes at least one of the following: entry running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, and routing processing of sub-mini-programs.
[0115] When the compiled code package of a sub-mini-program is used as the target sub-package of the main mini-program, the entry file of the sub-mini-program may not be executed automatically. Therefore, the initial fusion code package can be processed to run the entry point of the sub-mini-program. To provide each mini-program with an independent running environment, the initial fusion code package can be processed to run the mini-programs in an isolated manner.
[0116] Considering that communication may be required between mini-programs, inter-mini-program communication processing can be implemented in the initial fusion code package. To differentiate the target packages of each sub-mini-program, directory information can be added to the target package of each sub-mini-program, and the navigation information of the sub-mini-program can be routed according to the directory information to ensure normal navigation.
[0117] Step S204: Generate the merged target mini-program based on the target fusion code package.
[0118] Specifically, it can be understood that the fusion code package contains the compiled code package of the main mini-program and the compiled code package of the sub-mini-program. Therefore, the target mini-program generated based on the fusion code package includes the pages and functions of the main mini-program and the pages and functions of the sub-mini-program.
[0119] In the scheme of this application embodiment, the source code packages of the independently developed main mini-program and each sub-mini-program are compiled separately. Even if the development frameworks of the source code of each mini-program are different, they can be compiled separately. Then, their respective compiled code packages are merged, that is, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program. In this way, the main mini-program and each sub-mini-program, which are developed separately, can be merged to avoid mutual interference between their frameworks, specifications, compilation, etc. Furthermore, the obtained initial merged code package is subjected to the above-mentioned various processing, thereby merging multiple mini-programs that are developed separately and whose frameworks, specifications, compilation, etc. are isolated into a single target mini-program. This allows the development of a large mini-program with many functions to be broken down into multiple mini-programs with independent functions, thus separating development and improving development efficiency.
[0120] The following describes several aspects of the preset processing of the initial fusion code package in step S203 above.
[0121] In some embodiments, when performing the entry point execution process of the sub-program on the initial fusion code package in step S203 above, the following steps A1-A3 can be executed separately for each target sub-package in the initial fusion code package:
[0122] A1. Inject runtime code into a target sub-package; the runtime code is used to execute the entry file of the corresponding sub-program and the lifecycle of the corresponding sub-program, as well as register application-level events.
[0123] Specifically, the entry file for a sub-mini-program includes the app.js file, which is executed first when the mini-program runs. Considering that the sub-mini-program's compiled code package may not execute automatically after being used as the target sub-package of the main mini-program, runtime code is injected into the target sub-package to instruct the execution of the entry file. For example, injecting require app.js in the header of the entry page will execute app.js.
[0124] The above-mentioned code is also used to execute the lifecycle of the sub-program, such as the onLaunch and onShow methods. OnLaunch is triggered when the sub-program is initialized, and onShow refers to the display of the page. The onShow method is triggered after the page is loaded to display the page. It is called once every time the page is opened (for example, when the sub-program comes from the background to the foreground or when the page is re-entered).
[0125] The above code is also used to register application-level events, such as wx.onAppShow (to get the event when the mini-program switches to the foreground) and wx.onAppHide (to get the event when the mini-program switches to the background).
[0126] A2. Import the global style file in a target sub-package into the local style files of the corresponding sub-mini-program, and import the global configuration file in a target sub-package into the page configuration files of the corresponding sub-mini-program.
[0127] The global stylesheet file for the sub-mini-program takes effect across all pages. To ensure this, the global stylesheet file is included in the local stylesheet files of each page within the sub-mini-program. For example, the global stylesheet file for the mini-program includes app.wxss.
[0128] Meanwhile, the global configuration file is used to configure information for the sub-mini-program (it contains global information). To ensure that the global information in the sub-mini-program's global configuration file takes effect on all pages of the sub-mini-program, this global configuration file should be included in the configuration files of each page of the sub-mini-program. For example, the global configuration file for a mini-program includes app.json.
[0129] A3. Merge the global configuration files of the corresponding sub-mini-programs into the global configuration file of the main mini-program, and add the target sub-package directory information to the entry page path of the corresponding sub-mini-programs before registering them in the global configuration file of the main mini-program.
[0130] To ensure the global configuration files of the sub-mini-programs take effect, they are merged into the global configuration file of the main mini-program. As described in the previous embodiments, to differentiate the target sub-packages of each sub-mini-program, directory information is set for each sub-mini-program's target sub-package. To ensure the normal operation of the entry page of each sub-mini-program, the entry page path is added with the corresponding target sub-package's directory information and then registered in the main mini-program's global configuration file.
[0131] In some embodiments, the isolated execution process between applets in step S203 above may include one or more of the following steps B1-B3.
[0132] B1. Sandbox isolation is performed on each target sub-package in the initial fusion code package.
[0133] Optionally, for each target sub-package in the initial fusion code package, perform the following steps B11-B12 respectively:
[0134] B11. Proxy the first target object in a target subpackage through a sandbox and define a specified global variable in a target subpackage locally.
[0135] A sandbox allows a program to run in an isolated environment, without affecting other programs. By creating an independent working environment similar to a sandbox, programs running inside it cannot have a permanent impact on the hard drive.
[0136] Specifically, in order to provide an independent running environment for the sub-mini-program, the first target object in the target sub-package of the sub-mini-program is proxied through a sandbox; for example, the wx object is proxied through ProxySandbox. The Proxy object is used to create a proxy for an object, thereby realizing the interception and customization of basic operations. The wx object is the global object of the sub-mini-program and can be used anywhere.
[0137] Meanwhile, to ensure that specified global variables in the target sub-package of the sub-mini-program take effect within the sub-mini-program, these specified global variables are defined locally, that is, as local variables in the initial fusion code package. For example, specified global variables include global, getApp, App, globalThis, etc.
[0138] B12. Inject shared code into a target subpackage. The shared code is used to share the main mini-program's communication methods and custom information by obtaining the target global variables in the main mini-program's compiled code package.
[0139] Within the main mini-program, communication methods and custom information are mounted via a target global variable. Sub-mini-programs can then access these same communication methods and custom information by obtaining the target global variable from the main mini-program. For example, within the target sub-package of the sub-mini-program, the global variable `app` of the main mini-program can be obtained through the `getApp({allowDefault:true})` method, thus enabling sharing.
[0140] B2. Perform page style isolation on each target sub-package in the initial fusion code package.
[0141] Optionally, for each target sub-package in the initial fusion code package, perform the following steps B21-B22 respectively:
[0142] B21. In a target subpackage, each page's local style file imports the global style file, and both the global style file and the local style file use the specified style structure.
[0143] As mentioned above, when processing the entry point of a sub-mini-program, the global style file is imported into the local style files of each page. Therefore, each page of each sub-mini-program uses both global styles and local styles for that page. Furthermore, each component in each page uses a specified style structure to ensure style isolation. For example, the specified style structure is Shadow DOM, which uses predetermined styles to isolate the external environment and encapsulate components.
[0144] B22. Inject isolation code into a target sub-package. The isolation code is used to indicate that the global style file of the main mini-program is invalid for the corresponding sub-mini-program.
[0145] For example, the global style file of the main mini-program includes app.wxss, and setting app.wxss in isolated code has no effect on the target sub-package of the child mini-program.
[0146] B3. Perform storage isolation on each target sub-package in the initial fusion code package.
[0147] Optionally, for each target sub-package in the initial fusion code package, perform the following steps respectively: proxy the storage method of the first target object in a target sub-package through a sandbox, and add the directory information of the corresponding sub-mini-program in the storage method.
[0148] For example, by using Proxysandbox to proxy the storage-related methods of the wx object, the key of the storage method in the sub-mini-program is prefixed with the directory base of the target sub-package of the sub-mini-program to ensure storage isolation.
[0149] In some embodiments, the communication processing between applets in the initial fusion code package in step S203 above may include the following steps C1-C2:
[0150] C1. Add a communication object to the compilation code package of the main mini-program in the initial fusion code package.
[0151] In this embodiment, a communication object is defined and then mounted onto the global variable of the main mini-program. For example, the communication object based on props and the event publish / subscribe model is mounted onto the global variable `app` of the main mini-program, where `props` is the only interface for child components to access data from the parent component.
[0152] C2. Inject communication code into each target sub-package in the initial fusion code package; wherein, the communication code is used to return a communication object through a specified local variable in the corresponding target sub-package.
[0153] When a sub-mini-program needs to communicate with the main mini-program or other sub-mini-programs, it can achieve communication by specifying a local variable to obtain the communication object mounted in the main mini-program. For example, the sub-mini-program's local variable getApp returns the communication object on the main mini-program's global variable app.
[0154] In this embodiment of the application, the above-mentioned communication method between mini-programs enables native sharing of pages between sub-mini-programs instead of switching between mini-programs, thereby reducing user churn, optimizing user experience, and improving traffic conversion rate.
[0155] In some embodiments, when performing sub-program routing processing on the initial fusion code package in step S203 above, the following steps can be performed separately for each target sub-package in the initial fusion code package:
[0156] For internal redirection information in a target subpackage, add directory information of the target subpackage through the routing method corresponding to the internal redirection information of the second target object.
[0157] The second target object can be the same as the first target object, for example, the wx object proxied by Proxysandbox. Internal redirection information within the target sub-package is implemented through routing methods, such as navigateTo, reLaunch, and redirectTo methods, without limitation. To ensure the proper functioning of the sub-program's internal redirection information, the directory information of the sub-program's target sub-package is added to the routing method corresponding to that internal redirection information.
[0158] In addition, for external navigation information between main and sub-mini-programs, or between sub-mini-programs, it is usually possible to use parameters or exclude the target sub-package directory information of the sub-mini-program without adding it.
[0159] In some embodiments, considering the characteristics of mini-programs, in addition to performing the aforementioned processing on the initial fusion code package, specific processing can also be performed on the initial fusion code package. Specifically, for each target sub-package in the initial fusion code package, the following steps D1-D2 are executed respectively:
[0160] D1. Convert the root path information in a target subpackage to relative path information, or add the directory information of a target subpackage to the root path information.
[0161] Since the compiled code package of the sub-mini-program is used as the target sub-package, directory information is set for the target sub-package. Therefore, to ensure that the root path information in the target sub-package is referenced correctly, this root path information can be converted to relative path information or the directory information of the target sub-package can be added. Typically, the root path information is included in the page configuration file of the target sub-package of the sub-mini-program.
[0162] D2. Perform a preset transformation on the specified syntax and the corresponding injected code in a target subpackage.
[0163] To address syntax compatibility issues between mini-programs, a preset conversion can be performed on the specified syntax of the target sub-package of the sub-mini-program. For example, if the specified syntax is ES6, the preset conversion can be performed using the Babel compiler. Babel is a JavaScript compiler primarily used to convert ECMAScript 2015+ code into backward-compatible JavaScript syntax so that it can run in current and older browsers or other environments. Simultaneously, Babel conversion can also be performed on the code injected into the target sub-package of the sub-mini-program.
[0164] This application embodiment is based on the concept of mini-program micro-frontend, realizing the free integration of multiple mini-programs in a modular way. Multiple mini-programs that are isolated in terms of development, framework, compilation, and specifications can be integrated into one mini-program through mini-program micro-frontend. This can break down the development of large mini-programs with many functions into multiple mini-programs with independent functions, so as to separate development and facilitate multi-team collaboration. It can also enhance the sharing of pages among multiple mini-programs, making the functions of the main mini-program more complete and providing users with better and more comprehensive services.
[0165] The following is combined Figure 3 and Figure 4 The implementation logic of the mini-program fusion method in this application embodiment is described by way of example.
[0166] like Figure 3 As shown, assume team A independently develops the main mini-program, while teams B and C independently develop sub-mini-program one and sub-mini-program two, respectively. After independent development is completed, the source code packages of these three mini-programs are compiled separately to obtain compiled artifacts (containing the compiled code packages of these three mini-programs), as detailed below. Figure 4 As shown, the main mini-program's CI (Continuous Integration) pulls the main compiled code package of the main mini-program, the compiled code package one of sub-mini-program one, and the compiled code package two of sub-mini-program two. Compiled code package one is designated as sub-package one, and compiled code package two as sub-package two. Because the compiled code packages of the main and sub-mini-programs are merged, it is independent of the mini-program framework. Mini-program frameworks include, but are not limited to: uniapp, taro, kbone, mpvue, wepy, and native (naive) frameworks.
[0167] Based on the mini-program micro-frontend approach, code is injected into the compilation output (i.e., the preset processing in the above embodiments is executed) to provide an independent running environment for each mini-program, including entry point, isolation, communication, routing, and mini-program characteristics (i.e., the specified processing in the above embodiments). Specifically, such as... Figure 4 As shown, code is injected into the main compiled code package, sub-package one, and sub-package two of the main mini-program. Through compile-time fusion, the target fused code package of the target mini-program is obtained, which includes the main package and sub-packages, sub-package one, and sub-package two of the main mini-program.
[0168] The following is an exemplary introduction to the concept of WeChat Mini Program micro-frontend.
[0169] This application embodiment integrates the compiled code packages of multiple mini-programs into a single target mini-program by injecting processing code through a mini-program micro-frontend, truly achieving independence from the mini-program framework and separation of development. The technical architecture of the mini-program micro-frontend includes the following aspects: 1) Independent of the mini-program framework, using independent sub-packages of sub-mini-programs and merging compiled code packages; 2) Entry, loading entry-related content of sub-mini-programs; 3) Isolation - JS sandbox; 4) Isolation - style isolation; 5) Isolation - storage isolation; 6) Application communication; 7) Application routing; 8) Designated processing.
[0170] 1) Unrelated to the mini-program framework, the compilation artifacts are merged using instruction-based methods.
[0171] Each mini-program is developed separately, with each outputting its own compiled code package. Based on the mini-program micro-frontend approach, the compiled code packages of the main and sub-mini-programs are merged. Each sub-mini-program's compiled code package corresponds to an independent sub-package (i.e., the target sub-package mentioned above), forming a final target mini-program. Since it is a merging of compiled output code packages, it is independent of the mini-program framework.
[0172] 2) Entry
[0173] like Figure 5 As shown, for the entry file app.js of the sub-mini-program, you need to execute app.js to execute the sub-mini-program lifecycle: onLaunch and onShow, and register application-level events: wx.onAppShow (get the mini-program to the foreground event) and wx.onAppHide (get the mini-program to the foreground event).
[0174] To ensure the global style of the sub-mini-program, the app.wxss global style file is included in the local style files of each page of the sub-mini-program.
[0175] For the global configuration file app.json of the sub-mini-program, import app.json into the page configuration files of each page of the sub-mini-program. At the same time, add the base (directory information) of the independent sub-package of the sub-mini-program to the entry page path of the sub-mini-program, and then register it in the global configuration file app.json of the main mini-program.
[0176] 3) Isolation - JavaScript (JS) Sandbox
[0177] like Figure 6 As shown, sandbox isolation is implemented for the independent sub-packages of the sub-mini-program. The wx object is proxied through ProxySandbox. The wx object is the global object of the sub-mini-program and can be used anywhere. Global variables such as global, getApp, App, and globalThis are defined locally in the sub-mini-program, isolated from the main mini-program.
[0178] Sharing between the main and sub-mini-programs is achieved through the global variable 'app' of the main mini-program, including mini-program communication and sharing of custom JS; within the independent sub-package of the sub-mini-program, the global variable 'app' of the main mini-program is obtained through the getApp({allowDefault:true}) method of the main mini-program to achieve sharing.
[0179] 4) Isolation - Style Isolation
[0180] like Figure 7 As shown, the sub-mini-program's pages use both global styles (injected into the sub-mini-program's app.wxss file) and local styles. The component is a Shadow DOM element, ensuring style isolation. Furthermore, the main mini-program's global styles (app.wxss) have no effect on the sub-mini-program's independent sub-packages.
[0181] 5) Isolation - Storage Isolation
[0182] By using Proxysandbox to proxy the storage-related methods of the wx object, the storage key of the sub-mini-program is prefixed with the base (directory information) of the sub-mini-program's independent sub-package directory, ensuring storage isolation.
[0183] 6) Mini Program Communication
[0184] like Figure 8As shown, the props-based event publish / subscribe model is used as the communication object and is mounted on the global variable `app` of the main mini-program. Props are the only interface for child components to access data from the parent component, and include functions such as `setState`, `onStateChange`, `onceStateChange`, and `offStateChange`. Event publish / subscribe includes functions such as `emit`, `on`, `once`, and `off`.
[0185] The sub-mini-program's local variable getApp returns the communication object of the main mini-program's global variable app; specifically, when the sub-mini-program requests to obtain the communication object through its own local variable getApp, the main mini-program's global variable app is returned to the sub-mini-program.
[0186] 7) Sub-mini-program routing
[0187] like Figure 9 As shown, within the main mini-program, to facilitate the categorization and sub-packaging of sub-mini-programs and avoid duplicate files, a directory base is added to the independent sub-package of each sub-mini-program. For internal navigation information within sub-mini-programs, the wx object proxied by Proxysandbox adds a directory base to the corresponding routing methods. For external navigation information between main and sub-mini-programs, or between sub-mini-programs, which is implemented through parameters or not included in the sub-mini-program, no directory base is added.
[0188] 8) Specify processing
[0189] like Figure 10 As shown, for the root path reference of the sub-mini-program, since an independent sub-package has been added in the main mini-program, it is necessary to convert the root path to a relative path or add the independent sub-package name. At the same time, the ES6 syntax in the independent sub-package of the sub-mini-program and the code injected into the sub-mini-program are transformed using Babel.
[0190] In this embodiment, the native compilation artifacts are processed to reduce reliance on the framework, thus ensuring independence from the mini-program framework. For the entry point of the sub-mini-program, files such as app.js, app.wxss, and app.json are processed to simulate an independent running environment for the sub-mini-program. For mini-program isolation, JS isolation, style isolation, and storage isolation are implemented. For mini-program communication, props-based and event-based publish / subscribe models are used to meet the communication needs between mini-programs. For sub-mini-program routing, Proxysandbox is used within the sub-mini-program to proxy the routing methods of the wx object and automatically add the directory base. Through the solution of this embodiment, the compilation artifacts of multiple mini-programs are integrated using the mini-program micro-frontend concept, achieving independence from the mini-program framework, separation of development, autonomous development, and fusion into a single target mini-program, ensuring a unified user experience.
[0191] This application's embodiments are based on the concept of mini-program micro-frontends, requiring no modification to the source code of the main and sub-mini-programs. Separating the development of the main and sub-mini-programs improves development efficiency. By treating the compiled code packages of the sub-mini-programs as independent sub-packages, there is no impact on the main mini-program, and multiple mini-programs can be freely merged, offering high flexibility. Merging the main and sub-mini-programs into a single target mini-program increases the conversion rate of traffic from the main mini-program to the sub-mini-program and optimizes the user browsing experience.
[0192] Based on the same inventive concept as the above-described method embodiments, this application also provides a mini-program fusion device. The principle of this device in solving the problem is similar to that of the above-described method. Therefore, the implementation of this device can refer to the implementation of the above-described method, and repeated details will not be described again.
[0193] See Figure 11 As shown in the figure, this application embodiment provides a mini-program integration device, including:
[0194] The acquisition module 111 is used to acquire the source code packages of multiple independently developed mini-programs, compile the multiple source code packages, and obtain the corresponding compiled code packages; wherein, the multiple mini-programs include: one main mini-program and at least one sub-mini-program;
[0195] The fusion module 112 is used to fuse multiple obtained compiled code packages to obtain an initial fused code package; wherein, in the initial fused code package, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program;
[0196] The processing module 113 is used to perform preset processing on the initial fusion code package to obtain the target fusion code package; wherein, the preset processing includes at least one of the following: entry running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, and routing processing of sub-mini-programs;
[0197] The generation module 114 is used to generate the merged target mini-program based on the target fusion code package.
[0198] In the scheme of this application embodiment, the source code packages of the independently developed main mini-program and each sub-mini-program are compiled separately, and then their respective compiled code packages are merged, that is, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program. In this way, the main mini-program and each sub-mini-program, which are developed separately, can be merged to avoid mutual interference between their frameworks, specifications, compilation, etc. Furthermore, the obtained initial merged code package is subjected to the above-mentioned various processing, thereby merging multiple mini-programs that are developed separately and whose frameworks, specifications, compilation, etc. are isolated into a single target mini-program. This allows the development of a large mini-program with many functions to be broken down into multiple mini-programs with independent functions, thus separating development and improving development efficiency.
[0199] Optionally, when processing the initial fusion code package for the entry point of the sub-mini-program, the processing module 113 is used for:
[0200] For each target subpackage in the initial fusion code package, perform the following operations:
[0201] Inject runtime code into a target sub-package; the runtime code is used to execute the entry file of the corresponding sub-mini-program and the lifecycle of the corresponding sub-mini-program, as well as register application-level events;
[0202] Import the global style file in a target sub-package into the local style files of the corresponding sub-mini-program, and import the global configuration file in a target sub-package into the page configuration files of the corresponding sub-mini-program;
[0203] After merging the global configuration files of the corresponding sub-mini-programs into the global configuration file of the main mini-program, and adding the target sub-package directory information to the entry page path of the corresponding sub-mini-program, register it in the global configuration file of the main mini-program.
[0204] Optionally, when performing isolated execution processing between mini-programs on the initial fusion code package, the processing module 113 is used to perform at least one of the following operations:
[0205] Each target sub-package in the initial fusion code package is isolated using a sandbox.
[0206] For each target sub-package in the initial fusion code package, perform page style isolation separately;
[0207] Storage isolation is performed on each target sub-package in the initial fusion code package.
[0208] Optionally, when performing sandbox isolation on each target sub-package in the initial fusion code package, the processing module 113 is used to:
[0209] For each target subpackage in the initial fusion code package, perform the following operations:
[0210] The sandbox proxy proxies the first target object in a target subpackage and locally defines specified global variables in a target subpackage.
[0211] Inject shared code into a target subpackage. This shared code is used to share the main mini-program's communication methods and custom information by obtaining target global variables from the main mini-program's compiled code package.
[0212] Optionally, when performing page style isolation for each target sub-package in the initial fusion code package, the processing module 113 is used for:
[0213] For each target subpackage in the initial fusion code package, perform the following operations:
[0214] Within a target subpackage, each page's local style file imports the global style file, and both the global and local style files use a specified style structure.
[0215] Inject isolation code into a target sub-package. The isolation code is used to indicate that the global style file of the main mini-program is invalid for the corresponding sub-mini-program.
[0216] Optionally, when performing storage isolation on each target sub-package in the initial fusion code package, the processing module 113 is used to:
[0217] For each target subpackage in the initial fusion code package, perform the following operations:
[0218] By using a sandbox proxy, the storage method of the first target object in a target subpackage is used to add the directory information of the corresponding sub-program to the storage method.
[0219] Optionally, when performing inter-mini-program communication processing on the initial fusion code package, the processing module 113 is used for:
[0220] Add a communication object to the compiled code package of the main mini-program in the initial fusion code package;
[0221] In each target subpackage within the initial fusion code package, communication code is injected; this communication code is used to return a communication object via a specified local variable in the corresponding target subpackage.
[0222] Optionally, when performing sub-mini-program routing processing on the initial fusion code package, processing module 113 is used for:
[0223] For each target subpackage in the initial fusion code package, perform the following operations:
[0224] For internal redirection information in a target subpackage, add directory information of the target subpackage through the routing method corresponding to the internal redirection information of the second target object.
[0225] Optionally, the preset processing also includes specified processing. When performing specified processing on the initial fusion code package, the processing module 113 is used to:
[0226] For each target subpackage in the initial fusion code package, perform the following operations:
[0227] Convert the root path information in a target subpackage to relative path information, or add the directory information of a target subpackage to the root path information;
[0228] Perform a preset transformation on a specified syntax and the corresponding injected code in a target subpackage.
[0229] For ease of description, the above sections are divided into modules (or units) according to their functions and described separately. Of course, in implementing this application, the functions of each module (or unit) can be implemented in one or more software or hardware components.
[0230] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0231] Regarding the apparatus in the above embodiments, the specific execution methods of each module have been described in detail in the embodiments related to the method, and will not be elaborated here.
[0232] Based on the same inventive concept as the above-described method embodiments, this application also provides an electronic device. The principle of this electronic device in solving the problem is similar to that of the above-described method. Therefore, the implementation of this electronic device can refer to the implementation of the above-described method, and repeated details will not be described again.
[0233] See Figure 12 As shown, the electronic device 120 may include at least a processor 121 and a memory 122. The memory 122 stores a computer program, which, when executed by the processor 121, causes the processor 121 to perform the steps in any of the aforementioned applet fusion methods.
[0234] In an exemplary embodiment, this application also provides a storage medium including a computer program, such as a memory 122 including a computer program, which can be executed by a processor 121 of an electronic device 120 to complete the aforementioned applet fusion method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.
[0235] The following reference Figure 13 To describe an electronic device 130 according to this embodiment of the present application. Figure 13 The electronic device 130 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0236] like Figure 13 The electronic device 130 is manifested in the form of a general electronic device. The components of the electronic device 130 may include, but are not limited to: at least one processing unit 131, at least one storage unit 132, and a bus 133 connecting different system components (including storage unit 132 and processing unit 131).
[0237] Bus 133 represents one or more of several bus structures, including a memory bus or memory controller, peripheral bus, processor, or local bus using any of the various bus structures.
[0238] Storage unit 132 may include a readable medium in the form of volatile memory, such as random access memory (RAM) 1321 and / or cache memory 1322, and may further include read-only memory (ROM) 1323.
[0239] Storage unit 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, such program modules 1324 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0240] Electronic device 130 can also communicate with one or more external devices 134 (e.g., keyboard, pointing device, etc.), and with one or more devices that enable a user to interact with electronic device 130, and / or with any device that enables electronic device 130 to communicate with one or more other electronic devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 135. Furthermore, electronic device 130 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 136. As shown, network adapter 136 communicates with other modules used in electronic device 130 via bus 133. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0241] Based on the same inventive concept as the above-described method embodiments, this application provides a computer program product comprising a computer program stored in a computer-readable storage medium. The processor of an electronic device reads the computer program from the computer-readable storage medium and executes the computer program, causing the electronic device to perform the steps of any of the above-described applet fusion methods.
[0242] Computer program products may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0243] The computer program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on an electronic device. However, the computer program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.
[0244] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.
[0245] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0246] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0247] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for integrating mini-programs, characterized in that, include: Obtain the source code packages of multiple independently developed mini-programs, compile the multiple source code packages separately to obtain the corresponding compiled code packages; wherein, the multiple mini-programs include: one main mini-program and at least one sub-mini-program; The obtained multiple compiled code packages are merged to obtain an initial merged code package; wherein, in the initial merged code package, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program; The initial fusion code package is subjected to preset processing to obtain the target fusion code package; wherein, the preset processing includes: entry running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, routing processing of sub-mini-programs, and specification processing of sub-mini-programs; Based on the target fusion code package, generate the fused target mini-program; The initial fusion code package is used for inter-mini-program communication processing, including: In the compiled code package of the main mini-program within the initial fusion code package, a defined communication object is mounted onto the global variable of the main mini-program. This communication object is generated based on a unique interface for child components to access parent component data, and an event publishing and subscription model. Communication code is injected into each target sub-package within the initial fusion code package. This communication code is used to return the communication object through a specified local variable in the corresponding target sub-package. When a child mini-program communicates with the main mini-program or other child mini-programs, communication is achieved by obtaining the communication object mounted onto the global variable of the main mini-program through the specified local variable. The initial fusion code package is processed for isolated execution between mini-programs, including at least one of the following operations: For each target subpackage in the initial fusion code package, sandbox isolation is performed, specifically including: for each target subpackage in the initial fusion code package, the following operations are performed: proxying the first target object in a target subpackage through the sandbox, and locally defining a specified global variable in the target subpackage so that the specified global variable is used as a local variable in the initial fusion code package; injecting shared code into the target subpackage, the shared code being used to obtain the target global variable in the compiled code package of the main applet to share the communication method and custom information mounted on the target global variable; For each target sub-package in the initial fusion code package, page style isolation is performed respectively, specifically including: importing global style files into the local style files of each page in a target sub-package, wherein both the global style files and the local style files adopt a specified style structure; injecting isolation code into the target sub-package, wherein the isolation code is used to indicate that the global style files of the main mini-program are invalid for the corresponding sub-mini-programs; For each target sub-package in the initial fusion code package, storage isolation is performed respectively, specifically including: using a sandbox to proxy the storage method of the first target object in a target sub-package, and adding the directory information of the corresponding sub-mini-program to the storage method; wherein, the first target object is the global object of the sub-mini-program corresponding to the target sub-package; The initial fusion code package is processed to specify sub-mini-programs, including: For each target subpackage in the initial fusion code package, perform the following operations: convert the root path information in the page configuration file of a target subpackage into relative path information, or add the directory information of the target subpackage to the root path information; perform preset conversions on the specified syntax and the corresponding injected code in a target subpackage.
2. The method according to claim 1, characterized in that, The initial fusion code package is processed for entry point execution as a sub-mini-program, including: For each target subpackage in the initial fusion code package, perform the following operations respectively: Inject runtime code into a target sub-package; wherein the runtime code is used to execute the entry file of the corresponding sub-mini-program and the lifecycle of the corresponding sub-mini-program, as well as register application-level events; Import the global style file in the target sub-package into the local style files of the corresponding sub-mini-program, and import the global configuration file in the target sub-package into the page configuration files of the corresponding sub-mini-program; The global configuration files of the corresponding sub-mini-programs are merged into the global configuration file of the main mini-program, and the entry page path of the corresponding sub-mini-program is added to the directory information of the target sub-package before being registered in the global configuration file of the main mini-program.
3. The method according to claim 1, characterized in that, The initial fusion code package is used for sub-mini-program routing processing, including: For each target subpackage in the initial fusion code package, perform the following operations respectively: For internal redirection information in a target sub-package, the directory information of the target sub-package is added through the routing method corresponding to the internal redirection information by the second target object.
4. A mini-program integration device, characterized in that, include: The acquisition module is used to acquire the source code packages of multiple independently developed mini-programs, compile the multiple source code packages respectively, and obtain the corresponding compiled code packages; wherein, the multiple mini-programs include: one main mini-program and at least one sub-mini-program; The fusion module is used to merge multiple compiled code packages to obtain an initial fused code package; wherein, in the initial fused code package, the compiled code package of each sub-mini-program is used as a target sub-package of the main mini-program; The processing module is used to perform preset processing on the initial fusion code package to obtain the target fusion code package; wherein, the preset processing includes: entry running processing of sub-mini-programs, isolated running processing between mini-programs, communication processing between mini-programs, routing processing of sub-mini-programs, and specification processing of sub-mini-programs; The generation module is used to generate the fused target mini-program based on the target fusion code package; When the preset processing includes communication processing between mini-programs, the processing module is specifically used for: When performing inter-mini-program communication processing on the initial fusion code package, the processing module is used to: In the compiled code package of the main mini-program in the initial fusion code package, a communication object is added and the communication object is mounted to the global variable of the main mini-program; wherein, the communication object is generated based on the unique interface for child components to access parent component data, and the event publishing and subscription model; In each target sub-package of the initial fusion code package, communication code is injected; wherein, the communication code is used to return the communication object through a specified local variable in the corresponding target sub-package. When a sub-program communicates with the main sub-program or other sub-programs, the communication object mounted on the global variable of the main sub-program is obtained through the specified local variable to realize communication. When performing isolated execution between mini-programs on the initial fusion code package, the processing module is specifically used to perform at least one of the following operations: For each target subpackage in the initial fusion code package, sandbox isolation is performed, specifically including: for each target subpackage in the initial fusion code package, the following operations are performed: proxying the first target object in a target subpackage through the sandbox, and locally defining a specified global variable in the target subpackage so that the specified global variable is used as a local variable in the initial fusion code package; injecting shared code into the target subpackage, the shared code being used to obtain the target global variable in the compiled code package of the main applet to share the communication method and custom information mounted on the target global variable; For each target sub-package in the initial fusion code package, page style isolation is performed respectively, specifically including: importing global style files into the local style files of each page in a target sub-package, wherein both the global style files and the local style files adopt a specified style structure; injecting isolation code into the target sub-package, wherein the isolation code is used to indicate that the global style files of the main mini-program are invalid for the corresponding sub-mini-programs; For each target sub-package in the initial fusion code package, storage isolation is performed respectively, specifically including: using a sandbox to proxy the storage method of the first target object in a target sub-package, and adding the directory information of the corresponding sub-mini-program to the storage method; wherein, the first target object is the global object of the sub-mini-program corresponding to the target sub-package; When specifying sub-mini-programs for the initial fusion code package, the processing module is specifically used for: For each target subpackage in the initial fusion code package, perform the following operations: convert the root path information in the page configuration file of a target subpackage into relative path information, or add the directory information of the target subpackage to the root path information; perform preset conversions on the specified syntax and the corresponding injected code in a target subpackage.
5. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of any of the methods described in claims 1 to 3.
Citation Information
Patent Citations
Package combining method and device for applets, electronic equipment and medium
CN112052011A
Applet generation method and related device
CN112148389A
Application management method and system, medium and electronic terminal
CN113467817A
