Small program construction and operation method and device, storage medium and program product
By generating a tenant configuration list through the configuration center and combining it with preset mini-program templates, the system dynamically adapts to multi-tenant requirements, solving the problem of low efficiency in building multi-tenant mini-programs and achieving efficient multi-tenant mini-program building and operation and maintenance management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-10
AI Technical Summary
Existing multi-tenant mini-program building solutions suffer from problems such as lengthy and inefficient deployment chains, uncontrolled regression testing scope, and high operational and maintenance difficulties due to architectural coupling.
The configuration center generates a tenant configuration list, dynamically matches tenant configurations with tenant identifiers and runtime environment information, and builds multi-tenant mini-programs by combining preset mini-program templates, dynamically adapting to multi-tenant needs and separating the traditional build-phase difference management to runtime parsing.
It simplifies the deployment process of mini-programs, reduces the difficulty of building multi-tenant mini-programs, improves construction efficiency, and reduces operation and maintenance complexity.
Smart Images

Figure CN121635951A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, device, storage medium, and program product for building and running a small program. Background Technology
[0002] Existing multi-tenant mini-program building solutions rely heavily on differentiated processing during the mini-program code building phase. That is, development teams usually need to maintain independent functional branches for different tenants, or statically embed tenant-specific configurations and resources during mini-program building through conditional compilation directives.
[0003] However, this method of building mini-programs suffers from the drawback of a lengthy and inefficient mini-program deployment chain. Any configuration or resource change for a single tenant, even a minor one, requires triggering the entire mini-program's rebuild, testing, and deployment process.
[0004] Therefore, it is necessary to propose a method for building mini-programs to simplify the deployment process of multi-tenant mini-programs and improve the efficiency of building multi-tenant mini-programs.
[0005] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The main purpose of this application is to provide a method, device, storage medium, and program product for building and running mini-programs, aiming to solve the technical problem of how to improve the building efficiency of multi-tenant mini-programs.
[0007] To achieve the above objectives, this application proposes a method for building a mini-program, the method comprising:
[0008] Based on the configuration center, at least one tenant is configured via a mini-program to generate a tenant configuration list, which includes at least one tenant configuration.
[0009] When the mini-program is in the initialization phase, the corresponding tenant configuration is obtained from the tenant configuration list based on the tenant identifier and runtime environment information;
[0010] Based on the tenant configuration and the preset mini-program template, the mini-program corresponding to the tenant identifier is constructed.
[0011] In one embodiment, the step of configuring at least one tenant using a mini-program based on a configuration center to generate a tenant configuration list includes:
[0012] For any tenant, based on the configuration center, according to the parameter configuration item of the running environment and the preset applet template, the tenant configuration corresponding to the tenant is constructed, wherein the parameter configuration item at least includes network access configuration, application identity, third-party service authentication parameter, version information, and resource description information;
[0013] Taking the tenant identifier corresponding to the tenant as a key and the tenant configuration as a value, a key-value pair corresponding to the tenant is constructed;
[0014] The key-value pairs of at least one tenant are aggregated to generate a tenant configuration list, wherein the tenant configuration list is stored in a Map data structure.
[0015] In an embodiment, the preset applet template includes a plurality of business modules, and the step of constructing the applet corresponding to the tenant identifier according to the tenant configuration and the preset applet template includes:
[0016] injecting the tenant configuration into a global state variable in the preset applet template,
[0017] constructing the applet corresponding to the tenant identifier, and the business module consumes resource data corresponding to the tenant configuration based on a configuration reading interface.
[0018] In addition, to achieve the above-mentioned purpose, the application also provides an applet running method, which comprises:
[0019] In the case that the applet is in a running phase, a network request from a business module of the applet is received, and a target request path and a gateway address are determined according to the network request;
[0020] According to the target request path and the gateway address, a final request address is determined, and the network request is sent to the final request address, wherein the applet is constructed according to the applet construction scheme described above.
[0021] In an embodiment, the network request includes a first path, and the step of determining the target request path and the gateway address according to the network request includes:
[0022] The login state of the user is obtained by determining whether the network request includes a login token;
[0023] According to the login state and a preset path mapping rule, an interface relative path is determined;
[0024] The first path and the interface relative path are spliced to determine the target request path;
[0025] According to the global state variable of the applet, a gateway address corresponding to the running environment is determined.
[0026] In an embodiment, there are several versions of the applet, and the applet is version-isolated based on the environment identifier, and the applet running method further comprises:
[0027] When the network request is a user login request, the login token is determined according to the user login request, and the login token is uniquely associated with the environment identifier and the user identifier;
[0028] By determining whether the login token exists in the preset user database, it is confirmed whether the applet version requested to be logged in by the user is correct, so as to determine whether to perform login jump.
[0029] In an embodiment, the applet running method further comprises:
[0030] When the network request is completed, the monitoring data is spliced based on a preset hook function, and the monitoring data at least includes the context of the network request and the tenant identifier;
[0031] The monitoring data is reported to the server endpoint corresponding to the tenant identifier by using a preset alarm robot.
[0032] In addition, to achieve the above-mentioned purposes, the present application also proposes an electronic device, which comprises a transceiver, a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the applet construction method as described above, or the steps of the applet running method as described above.
[0033] In addition, to achieve the above-mentioned purposes, the present application also proposes a storage medium, which is a computer-readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a processor to implement the applet construction method as described above, or the steps of the applet running method as described above.
[0034] In addition, to achieve the above-mentioned purposes, the present application also proposes a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the applet construction method as described above, or the steps of the applet running method as described above.
[0035] The one or more technical solutions proposed in the present application have at least the following technical effects:
[0036] The application embodiment proposes a small program construction and running method, device, storage medium and program product, which specifically configures a small program for at least one tenant based on a configuration center, generates a tenant configuration list, and the tenant configuration list includes at least one tenant configuration; in the case that the small program is in an initialization stage, corresponding tenant configuration is obtained from the tenant configuration list according to the tenant identifier and the running environment information; and the small program corresponding to the tenant identifier is constructed according to the tenant configuration and a preset small program template.
[0037] The application configures a small program for multiple tenants through a configuration center to generate a tenant configuration list, and then dynamically matches tenant configuration from the tenant configuration list through a tenant identifier and running environment information in the case that the small program is in an initialization stage, and constructs the small program corresponding to the tenant identifier according to the tenant configuration and a preset small program template. The above method dynamically acquires tenant configuration in the running period of the small program to dynamically adapt to the needs of multiple tenants, and then uniformly adapts to multiple tenants by using a preset small program template, so as to realize the behavior polymorphism of the small program code unchanged, to separate the tenant difference management from the traditional construction period of the small program and transfer it to the running period for dynamic analysis, to simplify the release link of the small program, to reduce the difficulty of constructing the small program of multiple tenants, and to improve the construction efficiency of the small program of multiple tenants. BRIEF DESCRIPTION OF DRAWINGS
[0038] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the application.
[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.
[0040] Figure 1 The flowchart provided for the small program construction method embodiment one of the present application;
[0041] Figure 2 The flowchart provided for the small program construction method embodiment two of the present application;
[0042] Figure 3 The flowchart provided for the small program running method embodiment three of the present application;
[0043] Figure 4 The flowchart provided for the small program running method embodiment four of the present application;
[0044] Figure 5A device structure schematic diagram of a hardware running environment involved in an embodiment of the present application.
[0045] The purposes, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0046] It should be understood that the specific embodiments described herein are merely intended to explain the technical solutions of the present application, and are not intended to limit the present application.
[0047] In order to better understand the technical solutions of the present application, the specific embodiments will be described in detail below with reference to the accompanying drawings and the specific embodiments.
[0048] The main solution of the embodiment of the present application is: based on the configuration center, at least one tenant is configured, a tenant configuration list is generated, and the tenant configuration list includes at least one tenant configuration; in the case that the applet is in the initialization stage, according to the tenant identifier and the running environment information, the corresponding tenant configuration is obtained from the tenant configuration list; according to the tenant configuration and the preset applet template, the applet corresponding to the tenant identifier is constructed.
[0049] The existing applet construction scheme for multi-tenancy highly depends on the differentiated processing during the applet code construction period, or through conditional compilation instructions to statically embed tenant-specific configurations and resources during applet construction.
[0050] However, this applet construction method at least has the following defects:
[0051] Firstly, the applet release link is long and inefficient: any configuration or resource change for a single tenant, even a slight change, needs to trigger the entire applet reconstruction, testing and release process. This not only significantly increases the time cost and complexity of the release operation, but also makes it difficult to achieve rapid iteration.
[0052] Secondly, the regression test range of the applet is easy to get out of control: any code-level modification needs to perform comprehensive regression testing on all tenant-independent packages to ensure that no cross-tenant regression errors are introduced. This leads to a significant increase in testing cost and difficulty.
[0053] Thirdly, the architecture coupling increases the difficulty of operation and maintenance: the basic resources and business switches of different tenants are hard-coded or scattered and coupled in various business modules, rather than being centrally managed. This architecture coupling state dramatically increases the complexity of applet configuration maintenance and problem troubleshooting, and it is difficult to achieve strict runtime isolation, with a high risk of cross-tenant configuration or resource pollution.
[0054] Therefore, it is necessary to propose a method for building mini-programs, at least to solve the problem of the lengthy and inefficient release chain of multi-tenant mini-programs, and improve the efficiency of building multi-tenant mini-programs.
[0055] This application provides a solution that configures mini-programs for multiple tenants through a configuration center to generate a tenant configuration list. Then, while the mini-program is in the initialization phase, the tenant configuration is dynamically matched from the tenant configuration list using the tenant identifier and runtime environment information. Based on the tenant configuration and a preset mini-program template, the mini-program corresponding to the tenant identifier is constructed. This method dynamically obtains tenant configurations during the mini-program's runtime to adapt to multi-tenant requirements, and then uses a preset mini-program template to uniformly adapt to multiple tenants. This achieves polymorphic behavior while keeping the mini-program code unchanged, decoupling tenant difference management from the traditional mini-program build phase and transferring it to dynamic parsing at runtime. This simplifies the mini-program release process, reduces the difficulty of building multi-tenant mini-programs, and improves the efficiency of building multi-tenant mini-programs.
[0056] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or mini-program building device capable of performing the above functions. The following description uses a mini-program building device as an example to illustrate this embodiment and the subsequent embodiments.
[0057] Based on this, the embodiments of this application provide a method for building a mini-program, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the method for building a mini-program according to this application.
[0058] In this embodiment, the mini-program construction method includes steps S10 to S30:
[0059] Step S10: Based on the configuration center, configure at least one tenant using a mini-program to generate a tenant configuration list, which includes at least one tenant configuration.
[0060] It should be noted that the configuration center refers to a platform or system pre-set by the mini-program developers for centralized and unified management of configuration information for multiple tenant mini-programs. A tenant refers to a customer or business entity that needs to use the mini-program service independently.
[0061] Existing methods for building multi-tenant mini-programs often require code compilation and packaging for different tenants during the traditional mini-program build phase. This approach necessitates writing a dedicated mini-program code file for each tenant, leading to a lengthy and inefficient deployment process, uncontrolled regression testing, and increased operational complexity. Therefore, this application proposes a method for dynamically adapting multi-tenant requirements based on tenant configuration. This method achieves unified adaptation of multi-tenant mini-programs by matching tenant configurations with preset mini-program templates. First, in step S10, a configuration center is used to configure the tenant's mini-program based on its usage requirements. This involves setting a set of parameters that determine mini-program behavior, available resources, and connection information, generating the corresponding tenant configuration. By configuring at least one tenant, a tenant configuration list is generated, providing a data foundation for subsequent dynamic adaptation during runtime. Centralized configuration management allows for unified registration and storage of tenant configurations, separating tenant configurations from business code. This enables a single mini-program codebase to serve multiple tenants by loading different configurations, thereby improving the ease of mini-program operation and maintenance.
[0062] Step S20: When the mini-program is in the initialization phase, obtain the corresponding tenant configuration from the tenant configuration list based on the tenant identifier and runtime environment information;
[0063] It's important to note that the initialization phase of a mini-program refers to the preparation stage before the mini-program starts and is ready to run. This is also the lifecycle stage where the application logic begins execution, but the specific pages of the mini-program have not yet fully loaded, such as when the App.onLaunch event in a WeChat mini-program is triggered. A tenant identifier is information used to uniquely identify a tenant; it can be the tenant's ID, name, or other unique identifier.
[0064] Specifically, the mini-program building device can execute the application logic of the mini-program to put the mini-program into the initialization stage, and then match the corresponding tenant configuration from the tenant configuration list according to the tenant identifier and the runtime environment information of the mini-program (i.e., runtime environment information). The runtime environment information includes, but is not limited to, operating system, device type, network environment, etc.
[0065] In one implementation, when constructing the tenant configuration in step S10, there is configuration information for multiple operating environments in the tenant configuration. Therefore, the mini-program construction device first matches the tenant configuration from the tenant configuration list according to the tenant identifier, and then filters out the configuration information for the corresponding operating environment from the tenant configuration according to the operating environment information.
[0066] Step S30: Based on the tenant configuration and the preset mini-program template, construct the mini-program corresponding to the tenant identifier.
[0067] It should be noted that a preset mini-program template refers to a general mini-program source code framework that does not contain hard-coded information for specific tenants, and includes common logic and UI components for several business modules.
[0068] Specifically, by parsing the tenant configuration information obtained in step S20, the preset mini-program template is modified and adjusted accordingly based on the various configuration information obtained from the parsing, thereby constructing a mini-program running instance that is available to the current tenant, meets the tenant's needs, and is fully configured, thus realizing the rapid construction and personalized customization of mini-programs.
[0069] It should be understood that preset mini-program templates can include multiple different versions or types to adapt to the needs of different types of mini-programs.
[0070] Optionally, the tenant configuration is injected into the global state variables of the preset mini-program template to construct the mini-program corresponding to the tenant identifier. Specifically, the mini-program building device injects the tenant configuration into the global state variables of the preset mini-program template as a globally accessible data object. This allows the mini-program to access this global state variable during runtime to determine the set of parameters that determine the mini-program's behavior, available resources, and connection information, thereby constructing a mini-program that meets the tenant's needs.
[0071] Optionally, the preset mini-program template includes several business modules, which consume resource data corresponding to the tenant configuration based on a configuration reading interface. Specifically, the business modules read the tenant configuration from global state variables in read-only mode through the configuration reading interface, and run based on the tenant configuration to complete the differentiated behavior of the business modules. The above method achieves complete decoupling between business logic and tenant configuration. The business modules do not need to care about the current tenant; they only need to read the tenant configuration from a unified global state variable and consume the resource data corresponding to the tenant configuration.
[0072] This embodiment provides a method for building a mini-program. Through a configuration center, multiple tenants are configured to generate a tenant configuration list. Then, while the mini-program is in the initialization phase, tenant configurations are dynamically matched from the tenant configuration list using tenant identifiers and runtime environment information. Based on the tenant configurations and a preset mini-program template, the mini-program corresponding to the tenant identifier is built. This method dynamically obtains tenant configurations during the mini-program's runtime to adapt to multi-tenant requirements, and then uses a preset mini-program template to uniformly adapt to multiple tenants. This achieves polymorphic behavior while maintaining the same code for the mini-program. Tenant difference management is separated from the traditional mini-program build phase and transferred to runtime for dynamic parsing, simplifying the mini-program release process, reducing the difficulty of building multi-tenant mini-programs, and improving the efficiency of multi-tenant mini-program construction.
[0073] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 The step of configuring at least one tenant using a mini-program based on the configuration center to generate a tenant configuration list includes steps S210 to S230:
[0074] Step S210: For any tenant, based on the configuration center, construct the tenant configuration corresponding to the tenant according to the parameter configuration items of the operating environment and the preset mini-program template. The parameter configuration items include at least network access configuration, application identity identifier, third-party service authentication parameters, version information, and resource description information.
[0075] It should be noted that parameter configuration items refer to the set of variables or parameters in the preset mini-program template that need to be set differently according to different tenants or operating environments.
[0076] Specifically, during the generation of the tenant configuration list, for each tenant, the configuration center needs to configure the specific parameter values of multiple parameter configuration items under different operating environments according to the parameter configuration structure template corresponding to the preset mini-program template, and construct a tenant configuration that meets the tenant's needs. The operating environment can be a production environment, a testing environment, or a development environment.
[0077] Optionally, the parameter configuration items include at least network access configuration, application identity identifier, third-party service authentication parameters, version information, and resource description information. Specifically, the network access configuration defines the service gateway address mapping for tenants in different operating environments; the application identity identifier uniquely identifies tenant instances within the mini-program's operating platform; the third-party service authentication parameters integrate external service capabilities to achieve isolation between tenants, including but not limited to map keys (mapKey) and scan pipe identifiers (scanPipe), where map keys identify different maps and scan pipe identifiers identify different scan channels; version information controls the functional version of the mini-program; and resource description information controls the static resources of the mini-program.
[0078] Step S220: Construct a key-value pair corresponding to the tenant, using the tenant identifier corresponding to the tenant as the key and the tenant configuration as the value;
[0079] Step S230: Aggregate key-value pairs of at least one tenant to generate a tenant configuration list, wherein the tenant configuration list is stored in a Map data structure.
[0080] Specifically, to centrally manage tenant configurations, key-value pairs can be constructed, with the tenant identifier as the key and the corresponding tenant configuration as the value, establishing a mapping relationship between tenant identifiers and tenant configurations. Then, by aggregating key-value pairs from multiple tenants, a list of tenant configurations is obtained, and this list is stored using a Map data structure. The Map data structure stores key-value pairs, enabling fast value lookup through unique keys, and each key maps to at most one value, with no duplicates allowed.
[0081] This embodiment, through the above-described scheme, generates a complete and environmentally-oriented exclusive mini-program configuration for each independent tenant via a configuration center, achieving centralized and structured configuration information. Simultaneously, by constructing key-value pairs and generating a tenant configuration list, a centralized configuration information database is created. This enables rapid tenant configuration lookup based on tenant identifiers, ensuring accurate location of the current tenant's configuration during mini-program runtime. Tenant difference management is separated from the traditional mini-program build phase and transferred to dynamic parsing during runtime, simplifying the mini-program release process, reducing the difficulty of building multi-tenant mini-programs, and improving the efficiency of multi-tenant mini-program construction.
[0082] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or mini-program running device capable of the above functions. The following description uses a mini-program running device as an example to illustrate this embodiment and the subsequent embodiments.
[0083] Based on the above embodiments of this application, a method for running a mini-program is proposed in the third embodiment of this application, wherein the mini-program for running is constructed according to the mini-program construction scheme described in the foregoing embodiments. Based on this, please refer to... Figure 3 The method for running the mini-program includes steps S310 to S320:
[0084] Step S310: When the mini-program is running, receive network requests from the business modules of the mini-program, and determine the target request path and gateway address based on the network requests.
[0085] It should be noted that "mini-program in the running phase" means that the mini-program has completed initialization and is in the lifecycle state of responding to user interactions and executing business logic. A business module refers to a code unit that implements a specific function of the mini-program, such as user login, product ordering, map navigation, and product payment.
[0086] Specifically, when a mini-program is running, users trigger network requests by interacting with business modules. The business modules then initiate these network requests to interact with the mini-program's backend server. These network requests include, but are not limited to, information such as request paths, request parameters, and request methods.
[0087] To simplify the code of the business modules and improve code reusability, this embodiment decouples the business modules from complex network addressing logic. The business modules only need to care about the relative business interface paths; therefore, the request paths in network requests are usually relative request paths. Due to differences in operating environment, tenant, user login status, etc., the relative request paths of these network requests need to undergo mapping processing to determine the correct final request address.
[0088] Specifically, the device running the mini-program intercepts and maps network requests, dynamically selecting the server interface path (i.e., the target request path) and the server gateway address used for access based on the current request context.
[0089] In one feasible implementation, the network request includes a first path, and the step of determining the target request path and gateway address based on the network request may include steps A101 to A104:
[0090] Step A101: Determine whether the network request contains a login token to obtain the user's login status;
[0091] Step A102: Determine the relative path of the interface based on the login status and the preset path mapping rules;
[0092] It should be noted that a login token is a credential string used to identify a user's identity and the validity of a session. It is usually issued by the server after a user successfully logs in and is stored by the client. It is carried in subsequent requests to pass the server's authentication check.
[0093] Additionally, it should be noted that the preset path mapping rule refers to a predefined configuration rule used to map the original path requested by the business module to different actual interface paths. This configuration rule is usually represented as a mapping table structure, where the key is the general or relative path used by the business module, and the value is an array containing at least two elements, corresponding to the relative paths of the actual server interfaces to be accessed in the logged-out state and the logged-in state, respectively.
[0094] Specifically, the device running the mini-program determines the user's login status by checking if a login token is present in the network request. If a login token is present in the network request, the user is confirmed to be logged in; otherwise, the user is confirmed to be logged out.
[0095] Then, the relative paths of the interfaces that match the user's login status are determined from the preset path mapping rules. These relative paths include public interface paths accessed when the user is not logged in, and user interface paths accessed when the user is logged in.
[0096] Step A103: Concatenate the first path with the interface relative path to determine the target request path;
[0097] Step A104: Determine the gateway address corresponding to the runtime environment based on the global state variables of the mini-program.
[0098] Then, the first path in the network request is concatenated with the relative path of the interface to obtain the server interface path, which is the target request path. Since the tenant configuration is determined based on the tenant identifier and the runtime environment during the mini-program's runtime construction process, the device running the mini-program can determine the mini-program's runtime environment by querying the configuration information injected into the mini-program's global state variables, and then determine the corresponding gateway address based on the runtime environment.
[0099] Step S320: Determine the final request address based on the target request path and gateway address, and send the network request to the final request address.
[0100] Specifically, by concatenating the aforementioned target request path and gateway address, the final request address that can actually respond to the network request is obtained, and the received network request is sent to the final request address to obtain the response corresponding to the network request.
[0101] This embodiment provides a method for building a mini-program. While the mini-program is running, it receives network requests from the mini-program's business modules, determines the target request path and gateway address based on the network requests, determines the final request address based on the target request path and gateway address, and sends the network request to the final request address. This approach decouples the network addressing logic of the business modules from the network requests, improving the reusability of the business modules within the mini-program, supporting the configurability of the business modules, reducing the difficulty of building multi-tenant mini-programs, and improving the construction efficiency of multi-tenant mini-programs.
[0102] Based on the above embodiments of this application, in the fourth embodiment of this application, the same or similar content as the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 The mini-program has several versions, and the mini-program is isolated based on environment identifiers. The mini-program running method further includes steps S410 to S420:
[0103] Step S410: When the network request is a user login request, determine the login token based on the user login request. The login token is uniquely associated with the environment identifier and the user identifier.
[0104] Step S420: By determining whether the login token exists in the preset user database, and confirming whether the version of the mini-program requested by the user is correct, it is determined whether to perform a login redirect.
[0105] It should be noted that the release format of the same mini-program may change due to different stages or different uses. Therefore, there are multiple versions of mini-programs, including at least one of the following: development version, trial version (or test version) and official version.
[0106] The environment identifier is a string or enumeration value used to uniquely distinguish different versions. For example, in the WeChat Mini Program platform, the environment identifier can be obtained through the wx.getAccountInfoSync().miniProgram.envVersion interface, and its value may be develop (development version), trial (trial version), or release (release version).
[0107] Specifically, when the network request is a user login request, the user's identity is determined based on the login request. After successful user authentication on the mini-program backend, a credential string representing the user's session permissions is obtained, i.e., a login token. In this embodiment, the login token is uniquely associated with the environment identifier and the user identifier. That is to say, even for the same customer under different environment identifiers, the corresponding login token string will be completely different.
[0108] By determining whether the login token exists in the preset user database corresponding to the mini-program, it can be determined whether the user has permission to access the mini-program version and whether the mini-program version requested by the user is correct.
[0109] If the login token does not exist in the default user login database, it means the user does not have permission to access that version of the mini-program, and the user's requested login version is incorrect. The mini-program backend needs to reject this user's login request and execute the login redirection process, guiding the user to the login page of the correct mini-program version. If the login token exists in the default user login database, it means the user has permission to access that version of the mini-program, and the user's requested login version is correct. The mini-program backend needs to respond to this user's login request, allowing the user to log in to that version of the mini-program.
[0110] Furthermore, the method for running the mini-program also includes steps B01 to B02:
[0111] Step B01: After the network request is completed, monitoring data is obtained by concatenating the data based on a preset hook function. The monitoring data includes at least the context of the network request and the tenant identifier.
[0112] Step B02: The monitoring data is reported to the server corresponding to the tenant identifier using a preset alarm robot.
[0113] Specifically, during the operation of the mini-program, after each network request is processed by the mini-program's backend server, the device running the mini-program, according to a pre-set hook function, concatenates information such as the network request context, tenant identifier, mini-program version information, user identifier or name, and operating environment to obtain monitoring data. Simultaneously, through a pre-configured programmatic interface or service for automatically sending alarms or monitoring messages—namely, a pre-set alarm robot—the monitoring data related to the network request is uploaded to the server corresponding to the tenant identifier. This allows the tenant to view the operational status and anomaly information of the corresponding tenant's mini-program without data confusion with other tenants, thus supporting rapid identification of tenant-side issues and achieving refined operation and maintenance management.
[0114] This embodiment provides a method for building a mini-program. When the network request is a user login request, a login token is determined based on the user login request. The login token is uniquely associated with an environment identifier and a user identifier. By determining whether the login token exists in a preset user database, the method confirms whether the version of the mini-program requested by the user is correct, and then determines whether to perform a login redirect. This scheme verifies the version of the mini-program requested by the user. By uniquely associating the login token with the environment identifier, it ensures that the login token can only be used within the corresponding version of the mini-program, thereby strictly ensuring version isolation and preventing user data from being confused between multiple versions.
[0115] This application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute the applet construction method or applet running method described in the above embodiments.
[0116] The following is for reference. Figure 5 The diagram illustrates a structural schematic of an electronic device suitable for implementing embodiments of this application. The electronic devices in these embodiments may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0117] like Figure 5 As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. The communication device 1009 allows the electronic device to communicate wirelessly or wiredly with other devices to exchange data. Although the diagrams show electronic devices with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented alternatively.
[0118] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0119] The electronic device provided in this application, employing the mini-program construction method or mini-program running method in the above embodiments, can solve the technical problem of how to improve the construction efficiency of multi-tenant mini-programs. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the mini-program construction method or mini-program running method provided in the above embodiments, and other technical features in the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0120] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0121] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0122] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the applet construction method or applet running method in the above embodiments.
[0123] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0124] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.
[0125] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by an electronic device, the electronic device causes the following: Based on a configuration center, it configures at least one tenant for a mini-program and generates a tenant configuration list, the tenant configuration list including at least one tenant configuration; when the mini-program is in the initialization phase, it obtains the corresponding tenant configuration from the tenant configuration list according to the tenant identifier and runtime environment information; and constructs the mini-program corresponding to the tenant identifier according to the tenant configuration and a preset mini-program template.
[0126] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone 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 remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0128] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0129] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described mini-program building method or mini-program running method, and can solve the technical problem of how to improve the building efficiency of multi-tenant mini-programs. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the mini-program building method or mini-program running method provided in the above embodiments, and will not be repeated here.
[0130] This application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the applet construction method or applet running method described above.
[0131] The computer program product provided in this application can solve the technical problem of how to improve the construction efficiency of multi-tenant mini-programs. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiments of this application are the same as the beneficial effects of the mini-program construction method or mini-program running method provided in the above embodiments, and will not be repeated here.
[0132] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. An applet construction method, characterized by, The applet construction method comprises: Based on the configuration center, at least one tenant is configured, and a tenant configuration list is generated, the tenant configuration list comprising at least one tenant configuration; In the case where the applet is in the initialization stage, the corresponding tenant configuration is obtained from the tenant configuration list according to the tenant identifier and the running environment information; According to the tenant configuration and the preset applet template, the applet corresponding to the tenant identifier is constructed.
2. The applet construction method of claim 1, wherein, The step of configuring at least one tenant based on the configuration center to generate a tenant configuration list comprises: For any tenant, based on the configuration center, the tenant configuration corresponding to the tenant is constructed according to the running environment and the parameter configuration item of the preset applet template, wherein the parameter configuration item at least comprises network access configuration, application identity, third-party service authentication parameter, version information, and resource description information; The tenant identifier corresponding to the tenant is taken as the key, and the tenant configuration is taken as the value, to construct the key-value pair corresponding to the tenant; The key-value pairs of at least one tenant are aggregated to generate a tenant configuration list, wherein the tenant configuration list is stored in a Map data structure.
3. The applet construction method of claim 1, wherein The preset applet template comprises a plurality of business modules, and the step of constructing the applet corresponding to the tenant identifier according to the tenant configuration and the preset applet template comprises: The tenant configuration is injected into the global state variable in the preset applet template, The applet corresponding to the tenant identifier is constructed, and the business module consumes the resource data corresponding to the tenant configuration based on a configuration reading interface.
4. An applet execution method characterized by comprising: The applet running method comprises: In the case where the applet is in the running stage, a network request from the business module of the applet is received, and the target request path and the gateway address are determined according to the network request; The final request address is determined according to the target request path and the gateway address, and the network request is sent to the final request address, wherein the applet is constructed according to the applet construction method of any one of claims 1 to 3.
5. The applet execution method of claim 4, wherein, The network request comprises a first path, and the step of determining the target request path and the gateway address according to the network request comprises: The login state of the user is obtained by determining whether the network request has a login token; The interface relative path is determined according to the login state and a preset path mapping rule; The first path and the interface relative path are spliced to determine the target request path; The gateway address corresponding to the running environment is determined according to the global state variable of the applet.
6. The applet execution method of claim 5, wherein, The applet has a plurality of versions, and the applet is version-isolated based on the environment identifier, and the applet running method further comprises: When the network request is a user login request, the login token is determined according to the user login request, and the login token is uniquely associated with the environment identifier and the user identifier; Whether the applet version requested by the user to log in is correct is confirmed by determining whether the login token exists in a preset user database, so as to determine whether to perform login jump.
7. The applet execution method of claim 6, wherein, The applet running method further comprises: When the network request is completed, monitoring data is spliced based on a preset hook function, and the monitoring data at least includes a context of the network request and a tenant identifier; The monitoring data is reported to a server endpoint corresponding to the tenant identifier by using a preset alarm robot.
8. An electronic device, comprising: The electronic device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the applet construction method according to any one of claims 1 to 3 or the applet running method according to any one of claims 4 to 7.
9. A storage medium, characterized by The storage medium is a computer-readable storage medium, and the storage medium stores a computer program. When the computer program is executed by a processor, the steps of the applet construction method according to any one of claims 1 to 3 or the applet running method according to any one of claims 4 to 7 are implemented.
10. A computer program product, characterised in that, The computer program product includes a computer program. When the computer program is executed by a processor, the steps of the applet construction method according to any one of claims 1 to 3 or the applet running method according to any one of claims 4 to 7 are implemented.