Cross-application target function calling system and method, storage medium and program product
Patent Information
- Application Number
- CN202610799479.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-03
- Publication Date
- 2026-08-21
AI Technical Summary
[0004]本申请实施例提供了一种跨应用的目标功能的调用系统和方法、存储介质及程序产品,以至少解决现有技术中,现有网页应用调用不同App原生功能时,因各平台SDK接口不统一、适配逻辑分散且需硬编码,导致开发效率低、维护成本高、扩展性差的问题
[0013] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the broadcast scheduling method of the BLE gateway described above when running.
Smart Images

Figure CN122614601A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a system and method for invoking target functions across applications, a storage medium, and a program product. Background Technology
[0002] In web application development, to improve user experience, it is often necessary to call the native functions of the host app (such as taking photos, sharing, and location services). However, due to the differences in the underlying SDK interfaces of different apps, developers need to write adaptation code separately for each app. Furthermore, for applications on different platforms, their SDK interface definitions vary, requiring developers to write separate calling code for each platform. This makes it impossible to use a unified interface to complete cross-platform calls, resulting in low development efficiency, high maintenance costs, and poor scalability in web application development.
[0003] In response to the problems of low development efficiency, high maintenance costs, and poor scalability caused by inconsistent SDK interfaces, scattered adaptation logic, and the need for hard coding in the existing web applications when calling native functions of different apps, no effective solution has yet been proposed. Summary of the Invention
[0004] This application provides a cross-application target function invocation system and method, storage medium and program product, to at least solve the problems of low development efficiency, high maintenance cost and poor scalability in the prior art when existing web applications call native functions of different Apps, due to the inconsistent SDK interfaces of each platform, the scattered adaptation logic and the need for hard coding.
[0005] According to one embodiment of this application, a cross-application target function invocation system is provided, comprising: an environment detection module, configured to detect the environment information of the host application in which the web application resides when a function invocation instruction is received through a web application, and determine the type identifier of the host application based on the environment information; an adapter management module, connected to the web application environment detection module, configured to load a corresponding target adapter instance based on the type identifier; and a function invocation module, connected to the adapter management module, configured to send the function invocation instruction to the target adapter instance through a function invocation interface, so that the target adapter instance responds to the function invocation instruction and invokes the target function of the host application, wherein the function invocation interface is used to uniformly invoke the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
[0006] In an exemplary embodiment, the environment detection module is further configured to parse the target string to determine whether the target string contains a target identifier field corresponding to the type identifier; and / or detect the global object injected by the host application to determine whether the global object contains a target object corresponding to the type identifier, wherein the environment information includes: the target string and / or the global object.
[0007] In an exemplary embodiment, the environment detection module is further configured to, when determining that the target string contains the target identifier field and / or the global object contains the target object, determine the type identifier based on the target identifier field and / or the target object; and when the number of first type identifiers indicated by the target identifier field and / or the target object is multiple, determine the type identifier from multiple first type identifiers based on the priority of the multiple first type identifiers.
[0008] In an exemplary embodiment, the environment detection module is further configured to send a prompt message to the web application when the target string does not contain the target identifier field and the global object does not contain the target object, wherein the prompt message is used to indicate that the environment information does not support calling the target function.
[0009] In an exemplary embodiment, the adapter management module is further configured to create one-to-one corresponding adapter instances for each of the multiple host applications, thereby obtaining multiple adapter instances; establish a mapping relationship between the type identifiers of the multiple host applications and the multiple adapter instances; and store the multiple adapter instances and the mapping relationship.
[0010] In an exemplary embodiment, the adapter management module is further configured to match the target adapter instance according to the mapping relationship and the type identifier; if the target adapter instance is successfully matched, determine whether the target adapter instance has been loaded into the cache; if it is determined that the target adapter instance has not been loaded into the cache, obtain the adapter classpath of the target adapter instance from the configuration file, and load the target adapter instance into the cache based on the adapter classpath, wherein the configuration file includes the mapping relationship.
[0011] In an exemplary embodiment, the adapter management module is further configured to: create the target adapter instance based on the type identifier if the target adapter instance fails to match; determine the adapter classpath of the target adapter instance and update the mapping relationship based on the type identifier and the adapter classpath; and re-match the target adapter instance based on the updated mapping relationship.
[0012] According to another embodiment of this application, a method for invoking a target function across applications is also provided, applied to the aforementioned system for invoking a target function across applications. The method includes: upon receiving a function invoking instruction through a web application, detecting the environment information of the host application in which the web application resides, and determining the type identifier of the host application based on the environment information; loading a corresponding target adapter instance based on the type identifier; and sending the function invoking instruction to the target adapter instance through a function invoking interface, so that the target adapter instance responds to the function invoking instruction and invoking the target function of the host application. The function invoking interface is used to uniformly invoke adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
[0013] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the broadcast scheduling method of the BLE gateway described above when running.
[0014] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the steps of the methods described in various embodiments of this application.
[0015] This application addresses the following: After receiving a function call instruction through a web application, the environment detection module detects the environment information of the host application on which the web application resides, and determines the type identifier of the host application based on the obtained environment information. Then, the adapter management module loads the corresponding target adapter instance according to the type identifier. Finally, the function call module sends the function call instruction to the target adapter instance through a unified function call interface. The target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module. By constructing an adaptation layer architecture of automatic environment identification, unified interface call, and dynamic adapter loading, this application enables web applications to call the native functions of any host application with a single interface, completely shielding platform differences and supporting dynamic expansion with zero code modification. This solves the problems of low development efficiency, high maintenance costs, and poor scalability in existing technologies where web applications call the native functions of different apps due to inconsistent SDK interfaces across platforms, scattered adaptation logic, and the need for hard coding. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a hardware structure block diagram of a computer terminal for an optional cross-application target function invocation method according to an embodiment of this application;
[0019] Figure 2 This is a structural block diagram of an optional cross-application target function invocation system according to an embodiment of this application;
[0020] Figure 3 This is a system architecture diagram of an optional cross-application target function invocation system according to an embodiment of this application;
[0021] Figure 4 This is a flowchart illustrating an optional target function call according to an embodiment of this application;
[0022] Figure 5 This is a flowchart of an optional cross-application target function invocation method according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] The methods and embodiments provided in this application can be executed on a computer terminal or similar computing device. Taking running on a computer terminal as an example, Figure 1 This is a hardware structure block diagram of a computer terminal according to an embodiment of this application. Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor (MCU) or a programmable gate array (FPGA)) and a memory 104 for storing data are also shown. The computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0026] Memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the cross-application target function invocation method in this embodiment. Processor 102 executes various functional applications and data processing by running the computer programs stored in memory 104, thus implementing the above-described method. Memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, memory 104 may further include memory remotely located relative to processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0027] The computer terminal uses a wireless network provided by a communications provider. In one example, transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0028] This embodiment provides a cross-application target function invocation system. Figure 2This is a structural block diagram of a cross-application target function invocation system according to an embodiment of this application, such as... Figure 2 As shown, the system includes:
[0029] The environment detection module 22 is used to detect the environment information of the host application in which the web application is located when a function call instruction is received through the web application, and to determine the type identifier of the host application based on the environment information.
[0030] It should be noted that the aforementioned web applications may include, but are not limited to, H5 pages, PWAs (Progressive Web Apps), and single-page applications (SPAs).
[0031] The adapter management module 24 is connected to the environment detection module and is used to load the corresponding target adapter instance according to the type identifier.
[0032] The function call module 26 is connected to the adapter management module and is used to send the function call instruction to the target adapter instance through the function call interface, so that the target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
[0033] The aforementioned system, upon receiving a function call instruction through a web application, uses an environment detection module to detect the environment information of the host application on which the web application resides, and determines the type identifier of the host application based on the obtained environment information. Then, the adapter management module loads the corresponding target adapter instance according to the type identifier. Finally, the function call module sends the function call instruction to the target adapter instance through a unified function call interface, and the target adapter instance responds to the function call instruction to call the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module. By adopting the above scheme, this application, through constructing an adaptation layer architecture of automatic environment identification, unified interface call, and dynamic adapter loading, enables web applications to call the native functions of any host application with a single interface, completely shielding platform differences and supporting dynamic expansion with zero code modification. This solves the problems of low development efficiency, high maintenance costs, and poor scalability in existing technologies where web applications call the native functions of different apps due to inconsistent SDK interfaces of various platforms, scattered adaptation logic, and the need for hard coding.
[0034] Optionally, the environment detection module is further configured to: parse the target string to determine whether the target string contains a target identifier field corresponding to the type identifier; and / or detect the global object injected by the host application to determine whether the global object contains a target object corresponding to the type identifier, wherein the environment information includes: the target string and / or the global object.
[0035] The environment detection module parses the User-Agent string (i.e., the target string mentioned above) passed by the host APP to determine whether it contains a unique identifier field that matches the target APP type. For example, "MicroMessenger" corresponds to WeChat, and "AlipayClient" corresponds to Taobao. At the same time, it detects global JavaScript objects in the page's runtime environment to confirm the existence of specific objects such as wx, alipay, and dd, which are actively injected by the native layer of each APP. These objects are the iconic entry points for the platform to provide interface capabilities for H5. Their existence directly proves that the current application is running in the WebView container of this platform, thereby achieving dual verification and avoiding misjudgments caused by string tampering or version differences due to single detection methods, thus improving the accuracy and robustness of environment recognition.
[0036] This embodiment combines string features with global object dual-dimensional verification, enabling the adaptation layer to remain stable and accurately identify the host application in complex and ever-changing APP embedding environments, thus providing a reliable basis for the correct loading of subsequent adapters.
[0037] Optionally, the environment detection module is further configured to: determine the type identifier based on the target identifier field and / or the target object when it is determined that the target string contains the target identifier field and / or the target object contains the target object; and determine the type identifier from the multiple first type identifiers based on the priority of the multiple first type identifiers when the number of first type identifiers indicated by the target identifier field and / or the target object is multiple.
[0038] When the environment detection module identifies that the User-Agent contains multiple platform feature fields such as MicroMessenger and AlipayClient, or simultaneously detects multiple global injection objects such as wx and alipay, it selects the final host identity from multiple candidate type identifiers according to preset priority rules. The priority is determined by the platform usage scenario. For example, in enterprise applications, DingTalk takes precedence over WeChat, and in public scenarios, WeChat takes precedence over other platforms. This ensures that even in complex environments with cross-injection across multiple platforms, the host type that best matches the business logic can still be accurately identified, avoiding adapter misloading due to overlapping environmental features.
[0039] This mechanism eliminates the uncertainty caused by multiple identifier conflicts through a priority adjudication mechanism, ensuring the stability and decision-making consistency of the adaptation layer in a hybrid environment.
[0040] Optionally, the environment detection module is further configured to: send a prompt message to the web application when the target string does not contain the target identifier field and the global object does not contain the target object, wherein the prompt message is used to indicate that the environment information does not support calling the target function.
[0041] When the environment detection module fails to identify any preset platform identifier field in the User-Agent string, and no native objects injected by host applications such as WeChat or Taobao are found in the global scope of the page, the system determines that the current running environment does not belong to any supported APP container. At this time, it directly returns a clear environment incompatibility prompt to the web application. This prompt serves as front-end interactive feedback, guiding developers or users to switch to a compliant platform to use the function, avoiding interface errors or function failures caused by accidentally triggering native calls in unsupported environments such as ordinary browsers or unadapted APPs.
[0042] This mechanism reduces the risk of system anomalies by proactively intercepting illegal call scenarios, and improves the robustness of applications in unexpected environments and the consistency of user experience.
[0043] Optionally, the adapter management module is further configured to: create one-to-one corresponding adapter instances for each of the multiple host applications, thereby obtaining multiple adapter instances; establish a mapping relationship between the type identifiers of the multiple host applications and the multiple adapter instances; and store the multiple adapter instances and the mapping relationship.
[0044] The adapter management module initializes independent adapter instances for each supported host application, such as WeChat, Alipay, and DingTalk. Each instance encapsulates the platform-specific parameter conversion logic and native calling methods. Then, a unique mapping relationship is established between the platform type identifier, such as WeChat or Alipay, and the corresponding adapter instance, and stored in the content cache. This forms a reusable, searchable, and scalable adapter registry, ensuring that any subsequent call can quickly locate the accurate adaptation implementation through the type identifier, avoiding duplicate creation and logical confusion.
[0045] This mechanism achieves modular accumulation of adaptation capabilities through pre-construction and centralized management, significantly improving call efficiency and system maintainability.
[0046] Optionally, the adapter management module: matches the target adapter instance according to the mapping relationship and the type identifier; if the target adapter instance is successfully matched, determines whether the target adapter instance has been loaded into the cache; if it is determined that the target adapter instance has not been loaded into the cache, obtains the adapter classpath of the target adapter instance from the configuration file, and loads the target adapter instance into the cache based on the adapter classpath, wherein the configuration file includes the mapping relationship.
[0047] The adapter management module searches for the corresponding target adapter instance from the preset mapping relationship based on the type identifier returned by the environment detection. If a match is found and the instance does not exist in the memory cache, its full path is read from the configuration file. This path points to the independently compiled adapter implementation module. The system dynamically loads and instantiates the adapter accordingly, and then stores it in the cache for subsequent repeated calls, avoiding re-initialization for each request and ensuring that the loading process is triggered on demand, takes effect once, and is reused globally.
[0048] This mechanism enables lazy loading and cache reuse of the adapter, balancing system startup speed and running performance, reducing resource consumption, and supporting hot-swappable platform expansion.
[0049] Optionally, the adapter management module is further configured to: create the target adapter instance according to the type identifier if the target adapter instance fails to match; determine the adapter classpath of the target adapter instance and update the mapping relationship based on the type identifier and the adapter classpath; and re-match the target adapter instance based on the updated mapping relationship.
[0050] When the adapter management module fails to find a matching adapter instance in the existing mapping relationship based on the type identifier, the system will dynamically create a new adapter instance according to the identifier and automatically deduce its corresponding class path, which points to the adapter implementation class pre-written by the developer. Then, the type and path of the new instance are written to the configuration file, and the internal mapping relationship is updated synchronously, so that the system can directly hit the registered adapter in the next call without repeated creation, realizing runtime self-registration and adaptive expansion.
[0051] This mechanism empowers the system to automatically identify and register new platforms in unknown environments without requiring restarts or pre-installed code, truly achieving dynamic adaptation capabilities with zero intervention.
[0052] In an optional embodiment, this application combines Figure 3This paper introduces the system architecture of the cross-application target function invocation system. This embodiment designs a general adaptation layer to encapsulate the invocation logic for different APP SDKs (Software Development Kits). The adaptation layer adopts a modular design, and its core architecture is as follows: Figure 3 As shown, the core modules of this adaptation layer include:
[0053] Environment detection module: Detects the app environment in which the current web application resides, identifying the type and version information of the host app (i.e., the aforementioned host application). The detection process includes:
[0054] Step 1: Identify the current operating environment by analyzing the User-Agent string. The User-Agent usually contains information such as the APP name and version number. Regular expression matching can be used to initially determine the type of the host APP.
[0055] Step 2: Detect global objects or specific identifiers injected by the app. Different apps typically inject specific JavaScript objects (such as wx, alipay, etc.) into the WebView. Detecting the existence of these global objects can further confirm the app type.
[0056] Step 3: Based on the detection results, return the corresponding adapter instance identifier. If multiple features are detected, return the most matching adapter type according to priority.
[0057] Step 4: If the environment cannot be recognized, return the default adapter or throw an exception to inform the developer that the current environment is not supported.
[0058] Adapter Management Module: Loads the corresponding adapter based on the detection results and centrally manages adapter instances from different apps. The adapters are designed using a factory pattern, supporting dynamic registration and loading. The main functions of the adapter management module include:
[0059] (1) Adapter registration: Provides the register Adapter(appType, adapter) method to register a new APP adapter. During registration, the adapter instance is mapped to the APP type.
[0060] (2) Adapter Acquisition: The getAdapter(appType) method is provided to obtain the corresponding adapter instance based on the APP type. If the adapter is not loaded, it will be automatically recorded and initialized from the configuration.
[0061] (3) Adapter caching: Adapter instances are cached to avoid duplicate creation and improve performance. The cache adopts a singleton pattern to ensure that only one adapter instance exists for the same APP type.
[0062] (4) Configuration loading: Supports dynamically loading adapter mapping relationships from configuration files. The configuration file adopts JSON format and defines the mapping between APP type and adapter classpath.
[0063] Function Invocation Module: This module invokes specific functions within the adapter through a unified interface, shielding it from underlying SDK differences. All native function calls are completed through the unified `invode(method, params, callback)` interface. The invocation flow is as follows: Figure 4 As shown:
[0064] Step 4.1: The web application calls the unified interface of the adaptation layer, passing in the method name and parameters. The method name is a string type, representing the native function to be called (such as "takePhoto", "share", etc.).
[0065] Step 4.2: The adaptation layer routes to the corresponding adapter based on the current environment. The APP type returned by the environment detection module is used to determine which adapter to use.
[0066] Step 4.3: The adapter converts the uniform parameters into the format required by the specific APP SDK. The parameter formats of different SDKs may differ, and the adapter is responsible for the format conversion.
[0067] Step 4.4: Call the native SDK interface to execute specific functions. The adapter communicates with the native code through JSBridge or a similar mechanism, passing the method name and the converted parameters.
[0068] Step 4.5: Receive the results returned by the native SDK and convert them into a unified format. The data structure returned by the native SDK may be different; the adapter converts it into a unified response format.
[0069] Step 4.6: Return the result to the web application through a callback function. The callback function is asynchronous and supports both success and failure callbacks.
[0070] Configuration Management Module: Manages adapter mapping configurations, supporting dynamic loading and updating.
[0071] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0072] Figure 5 This is a flowchart of an optional cross-application target function invocation method according to an embodiment of this application; the cross-application target function invocation method is applied to the aforementioned cross-application target function invocation system, such as... Figure 5 As shown, the method includes the following steps:
[0073] Step S502: When a function call instruction is received through a web application, the environment information of the host application in which the web application is located is detected, and the type identifier of the host application is determined based on the environment information.
[0074] Step S504: Load the corresponding target adapter instance according to the type identifier;
[0075] Step S506: Send the function call instruction to the target adapter instance through the function call interface, so that the target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
[0076] This solution, upon receiving a function call instruction through a web application, detects the environment information of the host application on which the web application resides, and determines the type identifier of the host application based on the obtained environment information. Then, it loads the corresponding target adapter instance based on the type identifier. Finally, it sends the function call instruction to the target adapter instance through a unified function call interface, and the target adapter instance responds to the function call instruction to call the target function of the host application. The function call interface is used to uniformly call the adapter instance of the adapter management module. By constructing an adaptation layer architecture of automatic environment identification, unified interface call, and dynamic adapter loading, this application enables web applications to call the native functions of any host application with a single interface, completely shielding platform differences and supporting dynamic expansion with zero code modification. This solves the problems of low development efficiency, high maintenance costs, and poor scalability in existing technologies where web applications call the native functions of different apps due to inconsistent SDK interfaces of various platforms, scattered adaptation logic, and the need for hard coding.
[0077] Optionally, the method further includes: parsing the target string to determine whether the target string contains a target identifier field corresponding to the type identifier; and / or detecting the global object injected by the host application to determine whether the global object contains a target object corresponding to the type identifier, wherein the environment information includes: the target string and / or the global object.
[0078] Optionally, the method further includes: if the target string contains the target identifier field and / or the global object contains the target object, determining the type identifier based on the target identifier field and / or the target object; if the number of first type identifiers indicated by the target identifier field and / or the target object is multiple, determining the type identifier from multiple first type identifiers based on the priority of the multiple first type identifiers.
[0079] Optionally, the method further includes: sending a prompt message to the web application when the target string does not contain the target identifier field and the global object does not contain the target object, wherein the prompt message is used to indicate that the environment information does not support calling the target function.
[0080] Optionally, the method further includes: creating one-to-one corresponding adapter instances for each of the multiple host applications to obtain multiple adapter instances; establishing a mapping relationship between the type identifiers of the multiple host applications and the multiple adapter instances; and storing the multiple adapter instances and the mapping relationship.
[0081] Optionally, the method further includes: matching the target adapter instance according to the mapping relationship and the type identifier; if the target adapter instance is successfully matched, determining whether the target adapter instance has been loaded into the cache; if it is determined that the target adapter instance has not been loaded into the cache, obtaining the adapter class path of the target adapter instance from the configuration file, and loading the target adapter instance into the cache based on the adapter class path, wherein the configuration file includes the mapping relationship.
[0082] Optionally, the method further includes: if the target adapter instance fails to match, creating the target adapter instance based on the type identifier; determining the adapter classpath of the target adapter instance, and updating the mapping relationship based on the type identifier and the adapter classpath; and re-matching the target adapter instance based on the updated mapping relationship.
[0083] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the methods described above when it is run.
[0084] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0085] S1, when a function call instruction is received through a web application, the environment information of the host application in which the web application is located is detected, and the type identifier of the host application is determined based on the environment information;
[0086] S2, Load the corresponding target adapter instance according to the type identifier;
[0087] S3, the function call instruction is sent to the target adapter instance through the function call interface, so that the target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
[0088] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0089] Embodiments of this application also provide a computer program product, including a non-volatile computer-readable storage medium storing the computer program product, wherein the computer program, when executed by a processor, implements the steps of the methods described in various embodiments of this application.
[0090] Optionally, in this embodiment, the computer program described above can be configured to perform the following steps when executed by the processor:
[0091] S1, when a function call instruction is received through a web application, the environment information of the host application in which the web application is located is detected, and the type identifier of the host application is determined based on the environment information;
[0092] S2, Load the corresponding target adapter instance according to the type identifier;
[0093] S3, the function call instruction is sent to the target adapter instance through the function call interface, so that the target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
[0094] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0095] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0096] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A cross-application target function invocation system, characterized in that, include: The environment detection module is used to detect the environment information of the host application in which the web application is located when a function call instruction is received through the web application, and to determine the type identifier of the host application based on the environment information. The adapter management module, connected to the environment detection module, is used to load the corresponding target adapter instance according to the type identifier; A function call module, connected to the adapter management module, is used to send the function call instruction to the target adapter instance through a function call interface, so that the target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
2. The cross-application target function invocation system according to claim 1, characterized in that, The environmental detection module is also used for: The target string is parsed to determine whether it contains a target identifier field corresponding to the type identifier; and / or Detect the global object injected by the host application, and determine whether the global object contains the target object corresponding to the type identifier, wherein the environment information includes: the target string and / or the global object.
3. The cross-application target function invocation system according to claim 2, characterized in that, The environmental detection module is also used for: If it is determined that the target string contains the target identifier field, and / or the global object contains the target object, the type identifier is determined based on the target identifier field and / or the target object; When there are multiple first type identifiers indicated by the target identifier field and / or the target object, the type identifier is determined from the multiple first type identifiers according to the priority of the multiple first type identifiers.
4. The cross-application target function invocation system according to claim 2, characterized in that, The environmental detection module is also used for: If the target string does not contain the target identifier field and the global object does not contain the target object, a prompt message is sent to the web application, wherein the prompt message is used to indicate that the environment information does not support calling the target function.
5. The cross-application target function invocation system according to claim 1, characterized in that, The adapter management module is also used for: For each of the aforementioned host applications, a corresponding adapter instance is created, resulting in multiple adapter instances; Establish a mapping relationship between the type identifiers of the multiple host applications and the multiple adapter instances; Store the multiple adapter instances and the mapping relationship.
6. The cross-application target function invocation system according to claim 5, characterized in that, The adapter management module: Match the target adapter instance according to the mapping relationship and the type identifier; If the target adapter instance is successfully matched, determine whether the target adapter instance has been loaded into the cache. If it is determined that the target adapter instance is not loaded into the cache, the adapter classpath of the target adapter instance is obtained from the configuration file, and the target adapter instance is loaded into the cache based on the adapter classpath, wherein the configuration file includes the mapping relationship.
7. The cross-application target function invocation system according to claim 6, characterized in that, The adapter management module is also used for: If the target adapter instance fails to match, the target adapter instance is created based on the type identifier; Determine the adapter classpath of the target adapter instance, and update the mapping relationship based on the type identifier and the adapter classpath; The target adapter instance is re-matched based on the updated mapping.
8. A method for invoking a target function across applications, characterized in that, A cross-application target function invocation system applicable to any one of claims 1 to 7, comprising: When a function call instruction is received through a web application, the environment information of the host application in which the web application resides is detected, and the type identifier of the host application is determined based on the environment information. Load the corresponding target adapter instance based on the type identifier; The function call instruction is sent to the target adapter instance through the function call interface, so that the target adapter instance responds to the function call instruction and calls the target function of the host application. The function call interface is used to uniformly call the adapter instances in the adapter management module, and the adapter instances include the target adapter instance.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method of claim 8.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method of claim 8.