Method and device for executing application function, equipment and storage medium
By introducing an event transmission policy between the main application and the third-party application and using client events for data transmission, the problem of low security in the existing technology of executing application functions is solved, and higher security and leakage prevention effects are achieved.
Patent Information
- Application Number
- CN202311574813.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-22
- Publication Date
- 2025-05-23
Smart Images

Figure CN120034341A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for executing application functions. Background Art
[0002] With the continuous development of technology, more and more devices can nest and present multiple micro-frontend applications on the client side. That is, in the process of presenting the main application, the page content of the third-party application is nested and displayed, so that the functions in the third-party application can be executed through the main application on the client side, enriching the functions of the main application. There is no need to jump back and forth between the main application and the third-party application, which improves the user experience of the main application.
[0003] For example, the main application is a shopping application and the third-party application is a logistics query application. Then, in response to a logistics view operation triggered for a shopping order in the shopping application, the logistics information of the shopping order found in the logistics query application can be nested and displayed in the shopping application.
[0004] In the related art, an inline frame is usually used to implement the process of executing the functions of a third-party application through a main application. The method of executing the application function is to insert an inline frame tag in the front-end code of the main application, and indicate the address link corresponding to the page content of the third-party application to be embedded, and the processing parameters required to be used when the third-party application executes the function through the inline frame tag. Therefore, the page in the third-party application can be determined through the address link, and the display content in the page can be determined through the processing parameters, so as to obtain the page content of the third-party application, present the page content of the third-party application in the main application, and complete the process of executing the function in the third-party application through the main application.
[0005] However, the above-mentioned process of executing application functions can only realize displaying the page content of the third-party application in the main application. If this one-time process of executing application functions is to interact with the third-party application in the process of presenting the page content of the third-party application to realize the process of interactive execution of application functions, it is necessary to integrate the related functions of the main application and the third-party application together for development when developing the main application and the third-party application. In this case, not only the main application and the third-party application cannot be used independently, but there is also a risk that the code data of the main application can be improperly obtained through the third-party application, which makes there a greater security risk when running the main application.
[0006] It can be seen that the security of executing application functions under related technologies is low. Summary of the invention
[0007] Embodiments of the present application provide a method, apparatus, device, and storage medium for executing application functions, which are used to solve the problem of low security in executing application functions.
[0008] In a first aspect, a method for executing an application function is provided, which is applied to a main application running on a client, wherein a third-party application is nested and running in the main application, including:
[0009] Importing an event transmission strategy; wherein the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers;
[0010] When a target event is detected, a function execution instruction sent by the third-party application using the target event as a carrier is obtained, and the main application function in the main application indicated by the function execution instruction is executed to obtain a main execution result; wherein the target event is: a client event called by the third-party application according to the event transmission strategy in response to a selection operation triggered by a third-party function in the third-party application;
[0011] According to the event transmission strategy, the callback event associated with the target event is called, and the main execution result is returned to the third application using the callback event as a carrier, so that the third-party application determines the third-party execution result of the third-party function based on the main execution result.
[0012] In a second aspect, a method for executing an application function is applied to a third-party application nested and running in a main application, wherein the main application runs on a client, including:
[0013] Importing an event transmission strategy; wherein the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers;
[0014] In response to a selection operation triggered on a third-party function in the third-party application, calling a target event according to the event transmission strategy, so that when the main application detects the target event, it obtains a function execution instruction sent with the target event as a carrier, and executes the main application function in the main application indicated by the function execution instruction to obtain a main execution result; and, calling a callback event associated with the target event according to the event transmission strategy, and returning the main execution result to the third application with the callback event as a carrier;
[0015] After obtaining the main execution result, a third-party execution result of the third-party function is determined based on the main execution result.
[0016] In a third aspect, a device for executing an application function is provided, which is applied to run a main application, wherein a third-party application is nested and run in the main application, including:
[0017] Import module: used to import event transmission strategy; wherein, the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers;
[0018] Processing module: used for obtaining, when a target event is detected, a function execution instruction sent by the third-party application using the target event as a carrier, and executing the main application function in the main application indicated by the function execution instruction to obtain a main execution result; wherein the target event is: a client event called by the third-party application according to the event transmission strategy in response to a selection operation triggered by a third-party function in the third-party application;
[0019] The processing module is also used to: call the callback event associated with the target event according to the event transmission strategy, and return the main execution result to the third application using the callback event as a carrier, so that the third-party application determines the third-party execution result of the third-party function based on the main execution result.
[0020] Optionally, the processing module is specifically used for:
[0021] When it is detected that a target trigger function for a target event is run in the third-party application, the target name of the target event is used as the function execution instruction sent by the third-party application;
[0022] In the main application, a function function named with the target name is run to execute the main application function in the main application indicated by the function execution instruction to obtain a main execution result.
[0023] Optionally, the callback event is: a client event registered based on a target name of the target event according to the event transmission strategy, and the callback name of the callback event includes the target name;
[0024] The processing module is specifically used for:
[0025] According to the event transmission strategy, based on the target name and the callback name, determine the callback trigger function of the callback event associated with the target event, and run the callback trigger function to call the callback event;
[0026] The main execution result is used as the running result of the callback trigger function, so that after the third-party application detects the callback event, it receives the running result to obtain the main execution result.
[0027] Optionally, the target event is associated with a target identifier, which is configured for the target event according to the event transmission policy when the third-party application calls the target event, and the target identifier is used to uniquely characterize the target event; and the callback event is associated with a callback identifier, which is configured for the callback event based on the target identifier of the target event according to the event transmission policy when registering the callback event;
[0028] The processing module is specifically used for:
[0029] Determine the target identifier of the target event, and when it matches the callback identifier of the callback event, use the main execution result as the running result of the callback trigger function, so that when the third-party application detects that the callback trigger function is running in the main application, it runs the result receiving function for the callback event, receives the running result of the callback trigger function, and obtains the main execution result.
[0030] Optionally, the processing module is further used for:
[0031] Before obtaining the function execution instruction sent by the third-party application using the target event as a carrier when the target event is detected,
[0032] In response to a page rendering operation of the third-party application triggered by the main page content presented by the main application, loading the third-party page content of the third-party application through the third-party routing address of the third-party application;
[0033] The third-party page content is presented on top of the main page content in the form of a pop-up window.
[0034] Optionally, the processing module is specifically used for:
[0035] In response to the running operation triggered for the main application, the main page content of the main application is loaded from the main routing address of the main application configured according to the hash routing strategy; wherein the hash routing strategy represents: a routing method of linking to a corresponding routing address by splicing each hash value through an address template;
[0036] In response to the page rendering operation of the third-party application triggered by the main page content, the third-party page content of the third-party application is loaded through the third-party routing address of the third-party application configured according to the hash routing policy.
[0037] Optionally, each page content in the third-party application is associated with a corresponding page identifier, and the page identifier is used to uniquely represent the corresponding page content in the third-party application;
[0038] The processing module is specifically used for:
[0039] In response to the page presentation operation of the third-party application triggered by the main page content, a pop-up window opening instruction is obtained; wherein the pop-up window opening instruction includes a page identifier of the third-party page content in the third-party application;
[0040] Determining the third-party routing address based on the page identifier of the third-party page content;
[0041] The third-party page content is loaded from the third-party routing address.
[0042] Optionally, the processing module is specifically used for:
[0043] Determine the page hash value corresponding to the page identifier of the third-party page content based on the pre-stored mapping relationship between each page identifier and each hash value;
[0044] The designated location in the main routing address of the main page content is updated to the page hash value to obtain the third-party routing address.
[0045] In a fourth aspect, a device for executing an application function is provided, which is applied to run a third-party application, wherein the third-party application is nested and runs in a main application, including:
[0046] Import module: used to import event transmission strategy; wherein, the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers;
[0047] Processing module: used for, in response to a selection operation triggered by a third-party function in the third-party application, calling a target event according to the event transmission strategy, so that when the main application detects the target event, it obtains a function execution instruction sent with the target event as a carrier, and executes the main application function in the main application indicated by the function execution instruction to obtain a main execution result; and, according to the event transmission strategy, calling a callback event associated with the target event, and returning the main execution result to the third application with the callback event as a carrier;
[0048] The processing module is further configured to: after obtaining the main execution result, determine the third-party execution result of the third-party function based on the main execution result.
[0049] Optionally, the callback event is: a client event registered based on a target name of the target event according to the event transmission strategy, and the callback name of the callback event includes the target name;
[0050] The processing module is specifically used for:
[0051] It is detected that a callback trigger function for a callback event named by the callback name is executed, and according to the event transmission strategy, the main execution result returned with the callback event as a carrier is obtained.
[0052] Optionally, the target event is associated with a target identifier, which is configured for the target event according to the event transmission policy when the third-party application calls the target event, and is used to uniquely characterize the target event; and the callback event is associated with a callback identifier, which is configured for the callback event according to the event transmission policy and based on the target identifier of the target event when registering the callback event;
[0053] The processing module is specifically used for:
[0054] Detecting that a callback trigger function for a callback event named by the callback name is executed, and obtaining a callback identifier of the callback event;
[0055] Determine the target identifier of the target event, and when it matches the callback identifier of the callback event, run the result receiving function for the callback event, receive the running result of the callback trigger function, and obtain the main execution result carried by the running result.
[0056] According to a fifth aspect, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the method described in the first aspect or the second aspect.
[0057] A sixth aspect provides a computer device, including:
[0058] A memory for storing program instructions;
[0059] The processor is used to call the program instructions stored in the memory and execute the method as described in the first aspect or the second aspect according to the obtained program instructions.
[0060] In a seventh aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method as described in the first aspect or the second aspect.
[0061] In an embodiment of the present application, the main application and the third-party application are two independently developed applications. For example, the main application and the third-party application are both micro-front-end applications. When the third-party application responds to a selection operation triggered by a third-party function in the third-party application, if the third-party application needs to obtain the third-party execution result of the third-party function based on the main execution result obtained by executing the main application function in the main application, then when the event transmission strategy is imported into both the main application and the third-party application, the main application and the third-party application are transmitted data through the event transmission strategy using client events as the carrier, so that the main application can execute the main application function indicated by the third-party application through the target event, and the third-party application can obtain the third-party execution result of the third-party function based on the main execution result returned by the main application.
[0062] Therefore, the two applications do not need to be integrated for business cooperation, and the two applications can be used independently. Furthermore, since only instruction data and result data can be transmitted through the event transmission strategy, the specific details of the application operation are shielded from each other. Therefore, the code data of the main application cannot be improperly obtained through a third-party application, avoiding the risk of code data leakage, improving the security of running the main application, and greatly improving the security of executing application functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1A A schematic diagram of an interface for a method of executing an application function in the related art;
[0064] Figure 1B A schematic diagram of a method for executing an application function in the related art;
[0065] Figure 1C An application scenario of the method for executing application functions provided in an embodiment of the present application;
[0066] Figure 2 A flowchart of a method for executing an application function provided in an embodiment of the present application is shown in FIG1 ;
[0067] Figure 3A A schematic diagram of a method for executing an application function provided in an embodiment of the present application;
[0068] Figure 3B A schematic diagram of a method for executing an application function provided in an embodiment of the present application Figure 2 ;
[0069] Figure 4A A schematic diagram of an interface of a method for executing an application function provided in an embodiment of the present application;
[0070] Figure 4BAn interface diagram of a method for executing an application function provided in an embodiment of the present application Figure 2 ;
[0071] Figure 5 A third schematic diagram of a method for executing an application function provided in an embodiment of the present application;
[0072] Figure 6 A flow chart of a method for executing an application function provided in an embodiment of the present application Figure 2 ;
[0073] Fig. 7A An interactive schematic diagram of a method for executing an application function provided in an embodiment of the present application;
[0074] Figure 7B A flowchart diagram of a method for executing an application function provided in an embodiment of the present application is shown in FIG3;
[0075] Fig. 8A A structural schematic diagram 1 of a device for executing application functions provided in an embodiment of the present application;
[0076] Figure 8B A schematic diagram of a structure of a device for executing application functions provided in an embodiment of the present application Figure 2 ;
[0077] Fig. 9 A schematic diagram of a structure of a device for executing application functions provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION
[0078] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0079] Some of the terms used in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.
[0080] (1) Micro Frontends:
[0081] Micro frontends are an architectural style that aims to split front-end applications into smaller, more manageable parts, each of which can be developed, deployed, and scaled independently. The goal of micro frontends is to achieve better maintainability and scalability by dividing the front-end application into multiple independent modules so that it can be developed and deployed independently, each of which can use different technology stacks and frameworks.
[0082] (2) JavaScript Software Development Kit (JSSDK):
[0083] JSSDK is used to provide JavaScript interfaces and tools for specific services or functions. JSSDK can contain functions and classes for accessing service APIs, processing data, and implementing specific functions. JSSDK enables developers to integrate and use services more easily, and simplifies interaction and operation with services by providing high-level abstraction and encapsulation.
[0084] (3) Routing:
[0085] In a single-page application, routing refers to the method of loading different components or views according to different paths of the Uniform Resource Locator (URL). It allows users to navigate to different pages or views in the application without refreshing the entire page. Routing is usually supported by front-end frameworks or libraries, such as ReactRouter, Vue Router, etc.
[0086] The embodiments of the present application relate to artificial intelligence (AI) technology and cloud computing. Artificial intelligence technology and cloud computing can be applied to multiple fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, smart transportation, assisted driving, vehicle terminals, aircraft, digital twins, virtual humans, robots, artificial intelligence generated content (AIGC), conversational interaction, smart medical care, smart customer service, game AI, etc. It is believed that with the development of technology, artificial intelligence technology and cloud computing will be applied in more fields and play an increasingly important role.
[0087] Artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0088] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, mechatronics, etc. Among them, pre-trained models are also called large models and basic models. After fine-tuning, they can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0089] Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network that provides resources is called a "cloud". From the user's perspective, the resources in the "cloud" are infinitely scalable and can be accessed at any time, used on demand, expanded at any time, and paid for as needed.
[0090] As a cloud computing basic capability provider, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an Infrastructure as a Service (IaaS) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0091] According to the logical function division, the Platform as a Service (PaaS) layer can be deployed on the Infrastructure as a Service (IaaS) layer, and the Software as a Service (SaaS) layer can be deployed on the PaaS layer. SaaS can also be deployed directly on IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is a variety of business software, such as web portals, SMS mass senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
[0092] It should be noted that in the embodiments of the present application, operations related to obtaining data such as importing event transmission strategies are involved. When the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0093] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0094] The following is a brief introduction to the application fields of the method for executing application functions provided in the embodiments of the present application.
[0095] With the continuous development of technology, more and more devices can nest and present multiple micro-frontend applications on the client side. That is, in the process of presenting the main application, the page content of the third-party application is nested and displayed, so that the functions in the third-party application can be executed through the main application on the client side, enriching the functions of the main application. There is no need to jump back and forth between the main application and the third-party application, which improves the user experience of the main application.
[0096] For example, see Figure 1A , which is a video account e-commerce scenario. The main application is a shopping application, and the third-party application is a logistics query application. Then, in response to a logistics viewing operation triggered for a shopping order in the shopping application, the logistics information of the shopping order found in the logistics query application can be nested and displayed in the shopping application.
[0097] In the related art, an inline frame is usually used to implement the process of executing the functions of a third-party application through a main application. The method of executing the application function is to insert an inline frame tag in the front-end code of the main application, and indicate the address link corresponding to the page content of the third-party application to be embedded, and the processing parameters required to be used when the third-party application executes the function through the inline frame tag. Therefore, the page in the third-party application can be determined through the address link, and the display content in the page can be determined through the processing parameters, so as to obtain the page content of the third-party application, present the page content of the third-party application in the main application, and complete the process of executing the function in the third-party application through the main application.
[0098] Please refer to Figure 1B In response to the selection of the "Logistics Information" button for an order presented in the shopping application, an inline frame tag is inserted into the front-end code of the main application, such as <iframe src="url?param=value”>, where "url" is the address link corresponding to the page content of the logistics query application, and "param=value" indicates the logistics order number to be queried. Through the inline frame tag, link to the logistics query application, and search for the corresponding logistics information according to the logistics order number, and present the queried logistics information in the specified location associated with a certain order in the shopping application, completing the process of executing the functions in the logistics query application through the shopping application.
[0099] However, the above-mentioned process of executing application functions can only realize the display of the page content of the third-party application in the main application. If this one-time process of executing application functions is to interact with the third-party application in the process of presenting the page content of the third-party application to realize the process of interactive execution of application functions, it is necessary to integrate the related functions of the main application and the third-party application together for development when developing the main application and the third-party application. In this case, not only the main application and the third-party application cannot be used independently, but there is also a risk that the code data of the main application can be improperly obtained through the third-party application, which makes there a greater security risk when running the main application.
[0100] It can be seen that the security of executing application functions under the relevant technology is low.
[0101] In order to solve the problem of low security in executing application functions, the present application proposes a method for executing application functions. In the method, an event transmission strategy is introduced; wherein the event transmission strategy represents: a data transmission method between a main application and a third-party application using a client event as a carrier. When a target event is detected, a function execution instruction sent by a third-party application using the target event as a carrier is obtained, and the main application function in the main application indicated by the function execution instruction is executed to obtain a main execution result; wherein the target event is: a client event called by the third-party application in accordance with the event transmission strategy in response to a selection operation triggered for a third-party function in the third-party application. According to the event transmission strategy, a callback event associated with the target event is called, and the main execution result is returned to the third application using the callback event as a carrier, so that the third-party application determines the third-party execution result of the third-party function based on the main execution result.
[0102] Among them, the main application is the application currently running on the client. Before the third-party application is nested and run, the main application runs independently. After the third-party application is nested and run, the page content of the third-party application can be accessed in the page content of the main application without perception.
[0103] The third-party application is an application that runs nested during the execution of the main application in response to a third-party presentation operation triggered for the main application.After running a third-party application in nested mode, the page content of the third-party application is seamlessly integrated into the page content of the main application; when the third-party application responds to an end-presentation operation triggered for the third-party application, the third-party application stops running and the main application runs independently.
[0104] The main application and the third-party application can be large-scale applications or micro-frontend applications, etc., without specific limitations.
[0105] In the embodiments of the present application, the main application and the third-party application are two independently developed applications. For example, both the main application and the third-party application are micro-frontend applications. When the third-party application responds to a selection operation triggered for a third-party function in the third-party application, if the third-party application needs to obtain the third-party execution result of the third-party function based on the main execution result obtained by executing the main application function in the main application, then when the event transmission strategy is imported into both the main application and the third-party application, data is transmitted between the main application and the third-party application through the event transmission strategy with client events as the carrier, so that the main application can execute the main application function indicated by the third-party application through the target event, and the third-party application can obtain the third-party execution result of the third-party function based on the main execution result returned by the main application received.
[0106] Thus, the two applications can achieve business cooperation between them without the need for integrated development, and the two applications can also be used independently. Further, since only instruction data and result data can be transmitted through the event transmission strategy, the specific details of the application operation are mutually shielded. Therefore, the code data of the main application cannot be obtained improperly through the third-party application, avoiding the risk of code data leakage, improving the security of running the main application, and greatly enhancing the security of executing the application function.
[0107] The application scenarios of the method for executing application functions provided by the present application will be described below.
[0108] Please refer to Figure 1C, which is a schematic diagram of an application scenario of the method for executing application functions provided by the present application. This application scenario includes a client 101 and a server 102. Taking the browser as an example for the client 101, communication can be carried out between the client 101 and the server 102.The communication method can be wired communication technology for communication. For example, communication can be carried out by connecting a network cable or a serial port cable; it can also be wireless communication technology for communication. For example, communication can be carried out through technologies such as Bluetooth or wireless fidelity (WIFI), etc., and there is no specific limitation.
[0109] The client 101 generally refers to devices that can run applications, etc. For example, terminal devices, third-party application programs that can be accessed by terminal devices, or web pages that can be accessed by terminal devices, etc. Terminal devices include but are not limited to mobile phones, computers, intelligent medical devices, intelligent household appliances, vehicle-mounted terminals, or aircraft, etc. The server 102 generally refers to devices that can assist the client 101 in processing data, etc. For example, terminal devices or servers, etc. Servers include but are not limited to cloud servers, local servers, or associated third-party servers, etc. Both the client 101 and the server 102 can adopt cloud computing to reduce the occupation of local computing resources; similarly, cloud storage can also be adopted to reduce the occupation of local storage resources.
[0110] As an embodiment, the client 101 and the server 102 can be the same device, or can be different devices respectively, and there is no specific limitation.
[0111] Next, based on Figure 1C, the method for executing application functions provided by the embodiments of the present application will be specifically introduced. From the perspective of the main application running on the client, please refer to Figure 2, which is a schematic flowchart of the method for executing application functions provided by the embodiments of the present application.
[0112] S201, import the event transmission policy.
[0113] The event transmission policy represents: a data transmission method with client events as the carrier between the main application and the third-party application. The event transmission policy is imported into the main application, so that the main application can use the data transmission method provided by the event transmission policy to send data.
[0114] The event transmission strategy is only used to transmit data, and does not perform any functional processing on the data. For example, the event transmission strategy does not contain content related to the business logic of any application, and does not contain implementation details related to the functions of any application. Therefore, the main application and the third-party application cannot obtain the business logic or function implementation details of the other party through the event transmission strategy, which prevents information leakage and improves the security of executing application functions.
[0115] The event transmission strategy can also be set to support calling asynchronous events, so that events can be called in parallel, improving the efficiency of executing application functions.
[0116] The event transmission strategy can be encapsulated in the form of a module, such as a software development kit (Software Development Kit, SDK) or a JavaScript software development kit (JavaScript Software Development Kit, JSSDK). When the main application or a third-party application needs to import the event transmission strategy, the event transmission strategy can be imported based on the development language of the main application or the third-party application, thereby simplifying the process of writing the event transmission strategy in each application and reducing the storage resource usage of the main application and the third-party application.
[0117] S202, when a target event is detected, a function execution instruction sent by a third-party application using the target event as a carrier is obtained, and a main application function in a main application indicated by the function execution instruction is executed to obtain a main execution result.
[0118] The main application can detect the client event according to the event transmission strategy to obtain data sent to the main application by other applications using the client event as a carrier according to the event transmission strategy. When the main application detects the target event, it obtains the function execution instruction sent by the third-party application using the target event as a carrier, and executes the main application function in the main application indicated by the function execution instruction to obtain the main execution result. The target event is: the client event called by the third-party application according to the event transmission strategy in response to the selection operation triggered by the third-party function in the third-party application.
[0119] Since the third-party application is nested and runs in the main application, when the third-party application responds to the selection operation triggered by the third-party function in the third-party application, the execution of the third-party function may require the participation of data in the main application. For example, when the logistics query application responds to the selection operation triggered by the close function of the logistics query application, the logistics query application may need to receive the data result that the shopping application has hidden and displayed the logistics query application before ending the operation of the logistics query application and releasing the running content to execute the close function of the logistics query application.
[0120] Then, in response to a selection operation triggered by a third-party function in the third-party application, the third-party application can call the target event according to the event transmission strategy, and send a function execution instruction to the main application using the target event as a carrier. When the main application detects the target event, it obtains the function execution instruction sent by the third-party application using the target event as a carrier, thereby realizing the process of the third-party application sending data to the main application according to the event transmission strategy.
[0121] Thus, according to the event transmission strategy, the third-party application sends a function execution instruction to the main application, and the main application cannot obtain the specific implementation details of the third-party application, thereby ensuring the security of the application execution function. As an embodiment , the method that the main application detects the target event may be implemented by detecting that a target trigger function for the target event is run in a third-party application. When the target trigger function for the target event is run in the third-party application, if a detection function for the target trigger function that has been run is written in any application, it can be determined that the target event is detected. When the main application detects that a target trigger function for a target event is run in a third-party application, the target name of the target event is used as a function execution instruction sent by the third-party application. In the main application, a function named with the target name is run to execute the main application function in the main application indicated by the function execution instruction to obtain a main execution result.
[0124] For example, taking the client as a browser, the target trigger function in the third-party application can be implemented by using the browser's dispatch function, such as window.dispatch (target name of the target event). When the main application detects whether the target trigger function is running in the third-party application, it can be implemented by using the browser's event detection function, such as window.addEventListener (target name of the target event, {main application function}).
[0125] Please refer to Figure 3A. In the main application, an event detection function window.addEventListener(target event name, {main application function}) is run. In the {main application function} of this event detection function, code for hiding the third-party application can be written, continuously detecting whether the target trigger function for the target event is running until the dispatch function window.dispatch(target event name) is run in the third-party application. Then the main application determines that the target trigger function is detected to be running. Thus, the code for hiding the third-party application written in the event detection function is run, that is, the main application function is executed.
[0126] As an embodiment, the function template of the target trigger function can be written in the event transmission strategy. When the third-party application needs to run the target trigger function for the target event, the third-party application can directly build the target trigger function for the target event based on the function template written in the event transmission strategy to run the target trigger function. Thus, there is no need to write the function code for each trigger function in the third-party application, reducing the storage resource occupancy of the third-party application.
[0127] For example, taking the client as a browser, please refer to Figure 3B. The function template in the event transmission strategy includes two parts: creating an event and dispatching an event. Creating an event is achieved, for example, through const event = new CustomEvent(event name, {event content}), and dispatching an event is achieved, for example, through window.dispatch(event).
[0128] Then, taking channelsSdk as an example of the event transmission strategy, building the target trigger function for the target event based on the function template written in the event transmission strategy in the third-party application is achieved, for example, by running await channelsSdk.invoke('target event name', {event content of the target event}).Thus, in the event transmission strategy, actually run const event = new CustomEvent('the target name of the target event', {the event content of the target event}), and window.dispatch(event) to complete the operation of the target trigger function for the target event.
[0129] As an example, when detecting the target event and before obtaining the function execution instruction sent by the third-party application with the target event as the carrier, the main application can respond to the page presentation operation of the third-party application triggered by the main page content presented by the main application, and load the third-party page content of the third-party application through the third-party routing address of the third-party application. After obtaining the third-party page content, the main application presents the third-party page content in the form of a pop-up window above the main page content.
[0130] When the third-party page content is displayed in the form of a pop-up window above the main page content, since the pop-up window can be moved, the main page content can still be presented completely by moving the pop-up window. Therefore, both the main page content and the third-party page content can respond to the operations of the client, that is, using the objects of the client, one can operate both the main page content and the third-party page content, enriching the executable functions of the main application, without the need for frequent jumps between applications, and breaking the limitations of executing applications.
[0131] For example, please refer to Figure 4A. The main application is a shopping application, and the third-party application is a logistics query application. The shopping application responds to the selection operation triggered by the "Logistics Information" button corresponding to a certain order, so as to trigger the page presentation operation for the logistics query application. In the shopping application, the logistics information page content in the logistics query application can be presented in the form of a pop-up window above the order management page content in the shopping application. Please refer to Figure 4B. The presented logistics information page content can be dragged to any position with an operation device such as a mouse, so that the logistics information page content does not block the presentation of the order management page content.
[0132] As an embodiment, each main page content included in the main application and each third-party page content included in the third-party application are configured with routing addresses according to the hash routing strategy, and the hash routing strategy is characterized by splicing each hash value through an address template and linking to a corresponding routing address. The hash routing strategy does not require the server to configure the routing address, the hash value will not be sent to the server, and the routing logic is processed at the front end. It is suitable for static browser websites or browser environments where server configuration cannot be performed, has good compatibility, and supports most browsers.
[0133] For example, the routing address is http: / / xxxxxxx.com / # / home , where http: / / xxxxxxx.com / # is the address template and " / home" is the hash value. By splicing different hash values for the address template, different routing addresses can be linked. The default value of the hash value can be a null value or other preset values.
[0134] Then, loading the third-party page content of the third-party application through the third-party routing address of the third-party application can be, in response to the running operation triggered for the main application, after loading the main page content of the main application from the main routing address of the main application configured according to the hash routing policy, it can be in response to the page presentation operation of the third-party application triggered for the main page content, and load the third-party page content of the third-party application through the third-party routing address of the third-party application configured according to the hash routing policy.
[0135] As an embodiment, taking the client as a browser as an example, when the main page content is presented in the browser, the address bar of the browser can display the main routing address of the main page content; after loading the third-party page content, the address bar of the browser can be updated to the third-party routing address of the third-party application; when canceling the presentation of the third-party page content, the address bar of the browser can be restored to the main routing address of the main page content, so that the third-party routing address and the third-party page content can be presented at the same time, and the presentation can be canceled at the same time, so as to achieve a visually unified display effect.
[0136] As an embodiment, each page content in the third-party application is associated with a corresponding page identifier, and the page identifier is used to uniquely characterize the corresponding page content in the third-party application. The page identifier can be in digital form, such as pageid; it can also be in character form, such as pagename, etc., without specific limitation. Then, loading the third-party page content of the third-party application can be, in response to the page presentation operation of the third-party application triggered by the main page content, obtaining a pop-up window opening instruction, and the pop-up window opening instruction includes the page identifier of the third-party page content in the third-party application.Based on the page identifier of the third-party page content, the third-party routing address is determined. From the third-party routing address, the third-party page content is loaded.
[0137] For example, a pop-up window opening function is written in the main application. In response to the page presentation operation of the third-party application triggered by the main page content, the corresponding pop-up window opening function can be run. An opening detection function for the pop-up window opening function can also be written in the main application. If it is detected that the opening detection function has been run, it is determined that the corresponding pop-up window opening function has been run, that is, the pop-up window opening instruction has been obtained.
[0138] The start detection function is, for example, computed((pageid), {determine the third-party routing address based on the pageid of the third-party page content}), then in response to the page presentation operation of the third-party application triggered by the main page content, obtain the page identifier, update the pageid with the obtained page identifier, and the start detection function computed determines that the value of pageid has changed, then execute {determine the third-party routing address based on the pageid of the third-party page content}. Therefore, whenever the pageid changes, it will be detected by the start detection function.
[0139] As an embodiment, in the client or in the storage unit associated with the main application, the mapping relationship between each page identifier and each hash value can be pre-stored. The mapping relationship between the page identifier and the hash value is stored, which is equivalent to registering the corresponding page content. Then, when determining the third-party routing address based on the page identifier of the third-party page content, the page hash value corresponding to the page identifier of the third-party page content can be determined based on the mapping relationship between each pre-stored page identifier and each hash value. The specified position in the main routing address of the main page content is updated to the page hash value to obtain the third-party routing address.
[0140] Since the main routing address is also configured according to the hash routing strategy, updating the specified location in the main routing address with the page hash value is equivalent to the process of splicing the address template and the page hash value.
[0141] Please refer to Table 1, which is a mapping relationship between each page identifier and each hash value.Table 1
[0143] Page Identification Hash value Description index Null Value front page home / home Home
[0144] Among them, two page identifiers are included, and there is a mapping relationship between the page identifier "index" and the hash value "", that is, the routing address of the home page is the address template itself, and no content needs to be spliced; there is a mapping relationship between the page identifier "home" and the hash value " / home", that is, the routing address of the home page is the address template spliced " / home".
[0145] As an embodiment, after updating the specified position in the main routing address of the main page content to the page hash value, the query parameters can be further spliced to obtain the third-party routing address. The query parameter is a parameter passed by the main application to the third-party application when presenting the third-party page content of the third-party application. For example, the main application is a shopping application and the third-party application is a logistics query application. Then the third-party routing address can be " http: / / xxxxxxx.xxxxxxx.xxx / xxx / xxxx / xxxx / # / xxxx? query parameter = 5 ", and the query parameter can indicate several logistics data among the multiple logistics data queried and displayed in the third-party page content.
[0146] S203, according to the event transmission strategy, call the callback event associated with the target event, and return the main execution result to the third application using the callback event as a carrier.
[0147] After the main application obtains the main execution result, it needs to send the main execution result to the third-party application for use by the third-party application. Then the main application can call the callback event associated with the target event according to the event transmission strategy, and return the main execution result to the third application using the callback event as a carrier, so that the third-party application can determine the third-party execution result of the third-party function based on the main execution result.
[0148] Thus, according to the event transmission strategy, the main application sends the main execution result to the third-party application, and the third-party application cannot obtain the specific implementation details of the main application, thereby ensuring the security of the application execution function.
[0149] As an embodiment, the callback event is: according to the event transmission strategy, a client event is registered based on the target name of the target event, and the callback name of the callback event includes the target name. Then according to the event transmission strategy, the callback event associated with the target event is called, and the main execution result is returned to the third application using the callback event as a carrier. According to the event transmission strategy, based on the target name and the callback name, the callback trigger function of the callback event associated with the target event is determined, and the callback trigger function is run to call the callback event. The main execution result is used as the running result of the callback trigger function, so that after the third-party application detects the callback event, it receives the running result to obtain the main execution result.
[0150] For example, when the async await function is used to create a target event with a target name, a promise function will be registered with a callback name as the return result of the target event. The promise function can be used as a callback trigger function for a callback event associated with the target event. If the target name of the target event is "xxxx", then the callback name of the callback event can be "xxxx_cb". When the callback trigger function is run, the callback event is called. The main execution result obtained can be used as the running result of the callback trigger function through the promise function. Thus, after the third-party application detects the callback event, it receives the running result of the callback trigger function and can obtain the main execution result.
[0151] As an embodiment, the function template for registering the callback trigger function can be written in the event transmission strategy. When the main application executes the main application function, the callback trigger function for the callback event can be asynchronously registered based on the function template written in the event transmission strategy to run the callback trigger function. Thus, there is no need to write the function code for each trigger function in the main application, which reduces the storage resource usage of the main application.
[0152] For example, taking the client as a browser, please refer to Figure 5. The function template in the event transmission policy includes two parts: a registration event function and a return event result function. The registration event function is implemented, for example, by const resultPromise = new Promise(event name, {event content}), and the return event result function is implemented, for example, by const data = await resultPromise, and return data.
[0153] Then, based on the example in Figure 3B, after the main application detects that the third-party application has run const event = newCustomEvent(target name of the target event, {event content of the target event}), and runs window.dispatch(event) to achieve the purpose of running the target trigger function for the target event, the main application can register the callback trigger function of the callback event associated with the target event based on the function template written in the event transmission policy. For example, it is implemented by running const resultPromise = new Promise(target name_cb, {event content of the callback event}), where target name_cb is the callback name of the callback event. At the same time, the main application can asynchronously process to obtain the main execution result. After obtaining the main execution result, it runs const data = await resultPromise, and return data, and carries the main execution result in the event content of the callback event as the running result of the callback trigger function, so that when the third-party application detects that the callback trigger function is running in the main application, it runs the result receiving function for the callback event to receive the running result of the callback trigger function and obtain the main execution result.
[0154] As an embodiment, the target event is associated with a target identifier, which is configured for the target event according to the event transmission policy when the third-party application calls the target event, and the target identifier is used to uniquely represent the target event.The target identifier can be a digital id, a character name, or a combination of numbers and characters, such as name_id, etc., without specific restrictions. The callback event is associated with a callback identifier, which is configured for the callback event based on the target identifier of the target event according to the event transmission strategy when registering the callback event. For example, if the target identifier is "close_12", then the callback identifier can also be "close_12", or it can be "close_cb_12", etc., without specific restrictions. Then , when the main execution result is used as the operation result of the callback trigger function, the target identifier of the target event can be determined first, and whether it matches the callback identifier of the callback event. For example, if the callback identifier is the same as the target identifier, that is, the target identifier is "close_12", and the callback identifier is "close_12", it is considered to match, and if the callback identifier is different from the target identifier, it is considered not to match; for another example, if the callback identifier includes the target identifier, that is, the target identifier is "close_12", and the callback identifier is "close_cb_12", it is considered to match, and if the callback identifier does not include the target identifier, it is considered not to match, etc., it can be specifically set according to the configuration strategy of the configuration callback identifier. If it matches , it means that the callback event is a client event associated with the target event, and the main execution result can be used as the running result of the callback trigger function, so that when the third-party application detects that the callback trigger function is running in the main application, it runs the result receiving function for the callback event, receives the running result of the callback trigger function, and obtains the main execution result; if it does not match, it means that the callback event is not a client event associated with the target event, so the main execution result obtained by the target event will not be used as the running result of the callback trigger function of the callback event. Through the target identifier and the callback identifier, the situation of data return error and the like can be avoided when the data is processed asynchronously, and the accuracy of executing the application function is improved.
[0157] As an embodiment, the process of determining whether the target identifier of the target event matches the callback identifier of the callback event can be written in the event transmission strategy. Then, when the callback event is called according to the event transmission strategy, if the target identifier of the target event matches the callback identifier of the callback event, the running result of the callback trigger function will be sent to the third-party application. Otherwise, an asynchronous error will be returned and the callback event will be called again.
[0158] Continuing below based on Figure 1C, a method for executing an application function provided by an embodiment of the present application will be specifically introduced. From the perspective of a third-party application nested and running in the main application, please refer to Figure 6, which is a schematic flowchart of a method for executing an application function provided by an embodiment of the present application.
[0159] S601, import an event transmission policy.
[0160] The event transmission policy represents a data transmission method with client events as the carrier between the main application and the third-party application. For specific details, please refer to the previous introduction and will not be elaborated here. The event transmission policy is imported into the third-party application, so that the third-party application can use the data transmission method provided by the event transmission policy to send data.
[0161] S602, in response to a selection operation triggered for a third-party function in the third-party application, call a target event according to the event transmission policy.
[0162] The third-party application can detect client events according to the event transmission policy to obtain data sent by other applications to the third-party application with client events as the carrier according to the event transmission policy. When the third-party application has been nested and running in the main application, it can respond to a selection operation triggered for a third-party function in the third-party application. For example, respond to a close operation triggered for the third-party page content presented by the third-party application to cancel the display of the third-party page content.
[0163] In response to a selection operation triggered for a third-party function in the third-party application, the third-party application can call a target event according to the event transmission policy, so that when the main application detects the target event, it can obtain a function execution instruction sent with the target event as the carrier, and execute the main application function in the main application indicated by the function execution instruction to obtain a main execution result; and, enable the main application to call a callback event associated with the target event according to the event transmission policy, and return the main execution result to the third application with the callback event as the carrier; for specific details, please refer to the previous introduction and will not be elaborated here.
[0164] S603, after obtaining the main execution result, determine the third-party execution result of the third-party function based on the main execution result.
[0165] After obtaining the main execution result, the third-party application can determine the third-party execution result of the third-party function based on the main execution result. For example, the third-party function is a close function, which is used to cancel the display of the third-party page content of the third-party application in the form of a pop-up window on the main page content of the main application. Then, the main execution result can indicate that the main application has hidden the pop-up window for presenting the third-party page content of the third-party application. Then, based on the main execution result, the third-party application can determine that the third-party execution result of the third-party function is to release the operating resources of the third-party application to end the nested operation of this third-party application.
[0166] As an embodiment, the callback event may be: a client event registered based on the target name of the target event according to the event transmission strategy, and the callback name of the callback event includes the target name. For details, please refer to the previous introduction and will not be repeated here.
[0167] Then the method for the third-party application to obtain the main execution result can be that when it detects that the callback trigger function of the callback event named by the callback name has been run, it obtains the main execution result returned with the callback event as the carrier according to the event transmission strategy. For details, please refer to the previous introduction and will not be repeated here.
[0168] As an embodiment, a target event is associated with a target identifier, which is configured for the target event according to an event transmission strategy when a third-party application calls the target event, and is used to uniquely characterize the target event; and a callback event is associated with a callback identifier, which is configured for the callback event based on the target identifier of the target event according to the event transmission strategy when registering the callback event; for details, please refer to the previous introduction, which will not be repeated here.
[0169] Then, the method for obtaining the main execution result can be to detect that the callback trigger function of the callback event named for the callback name has been run, and obtain the callback identifier of the callback event. When the third-party application determines the target identifier of the target event and matches the callback identifier of the callback event, it runs the result receiving function for the callback event, receives the operation result of the callback trigger function, and obtains the main execution result carried by the operation result. When the third-party application determines that the target identifier matches the callback identifier, it will receive the main execution result, avoid the situation of data return errors caused by asynchronous operations, and improve the accuracy of executing application functions.
[0170] The process of determining whether the target identifier matches the callback identifier can also be determined through the event transmission policy. For specific details, please refer to the foregoing description. For other specific implementation processes, please refer to the foregoing description and will not be elaborated herein.
[0171] Taking the client as a browser, the main application as a shopping application, the third-party application as a logistics query application, and the third-party function as a close function as an example, the method for executing the application function provided in the embodiments of the present application will be introduced by way of example. Please refer to Figure 7A, where both the shopping application and the logistics query application are default imported with the event transmission policy.
[0172] S701, in response to a running operation triggered for the shopping application, load the order management page content of the shopping application according to the hash routing policy.
[0173] In response to a running operation triggered for the shopping application, the browser can start the shopping application and load the order management page content of the shopping application from the main routing address of the shopping application configured according to the hash routing policy. At this time, the order management page content of the shopping application is presented as the main page content in the browser.
[0174] S702, in response to a logistics query operation for a certain order triggered for the order management page content, load the logistics information page content of the logistics query application.
[0175] Please refer to Figure 7B, which is a schematic flowchart for loading the logistics information page content of the logistics query application.
[0176] S7001, in response to a logistics query operation for a certain order triggered for the order management page content, obtain the page identifier of the logistics information page content.
[0177] Responding to a logistics query operation for a certain order triggered for the order management page content is equivalent to obtaining a query request for the logistics information of a certain order, and is also equivalent to obtaining a pop-up window opening instruction for opening a pop-up window in the main application.The browser can nest and run the logistics query application. The shopping application indicates the logistics information page content in the logistics query application to be loaded through the page identifier. The logistics information page content is used to present the logistics information of a certain order.
[0178] S7002, based on the pre-stored mapping relationship between each page identifier and each hash value, determine the page hash value corresponding to the page identifier of the logistics information page content.
[0179] S7003, update the hash value position in the main routing address of the order management page content to the page hash value to obtain the third-party routing address.
[0180] The third-party routing address includes a URL address for linking to a logistics query page in a logistics query application, and may also include query parameters for querying logistics information of a certain order, such as a logistics order number, etc.
[0181] S7004, load the logistics information page content of the logistics query application from the third-party routing address of the logistics query application.
[0182] After loading the logistics information page content according to the third-party routing address, in the browser, the logistics information page content can be presented above the order management page content in the form of a pop-up window.
[0183] S703, the logistics query application responds to the close operation triggered by the content of the logistics information page, creates and dispatches a target event based on the function template provided by the event transmission strategy, and calls the target event to achieve the purpose of sending function execution instructions to the shopping application using the target event as a carrier.
[0184] The function template provides a creation function and a dispatch function, and can create and dispatch a target event according to the target name of the corresponding "closedialog" of the closing operation. When creating a target event, a target identifier is set for the target event association, such as "close_1".
[0185] After executing S703, S704 to S705 and S706 may be executed asynchronously, and then S707 to S710 may be executed.
[0186] S704, the shopping application detects that the logistics query application runs the dispatch function, that is, the target trigger function, and obtains the target name of the target event, "closedialog".
[0187] The shopping application can use the event detection function provided by the browser to detect whether the logistics query application has run the dispatch function.
[0188] S705, the shopping application runs a function named with a target name "closedialog" to execute a pop-up window closing function in the shopping application and obtain a main execution result.
[0189] The main execution result can represent a pop-up window used to present the content of the logistics information page, which has been hidden.
[0190] S706, the logistics query application registers the callback event associated with the target event based on the function template provided by the event transmission strategy.
[0191] After the shopping application obtains the main execution result, it can call a callback event and use the callback event as a carrier to return the main execution result to the logistics query application.
[0192] The function template registers an event function and a return event result function, registers a callback event according to the target name "closedialog", the callback name of the callback event can be "closedialog_cb", and the callback identifier can be "close_1". After the shopping application asynchronously obtains the main execution result, the return event result function returns the main execution result to the logistics query application.
[0193] S707, after the shopping application obtains the main execution result, it calls the callback event associated with the target event, and returns the main execution result to the logistics query application using the callback event as a carrier.
[0194] S708, the logistics query application detects that the shopping application runs the return event result function and obtains the callback identifier "close_1".
[0195] S709, the logistics query application determines the callback identifier "close_1" through the event transmission strategy, matches it with the target identifier "close_1", and receives the main execution result returned by the return event result function.
[0196] S710, the logistics query application determines the third-party execution result of the closed function based on the main execution result.
[0197] The third-party execution result can indicate that the logistics query application has released the running resources and ended the operation.
[0198] In the embodiment of the present application, the third-party application is embedded and run in the main application in the form of a micro front-end, which solves the scroll bar problem that exists when the traditional iframe mode presents the third-party page content and the problem that the iframe cannot affect the document structure of the outer application.Interact using the event transmission strategy, shielding the specific implementation details of the respective functions in the main application and the third-party application, solving the security problem and preventing the leakage of code information. By means of the strategy of routing to different routing addresses through different hash values, the problem that the routing address of the third-party application affects the routing address of the main application is solved.
[0199] Based on the same inventive concept, an embodiment of the present application provides a device for executing application functions, which can implement the functions corresponding to the foregoing method for executing application functions. Please refer to Figure 8A. The device includes an import module 801 and a processing module 802, where:
[0200] The import module 801: is used to import the event transmission strategy; wherein, the event transmission strategy represents: a data transmission method with client events as the carrier between the main application and the third-party application;
[0201] The processing module 802: is used to obtain a function execution instruction sent by the third-party application with the target event as the carrier when detecting the target event, and execute the main application function in the main application indicated by the function execution instruction to obtain the main execution result; wherein, the target event is: the client event called by the third-party application in response to the selection operation triggered for the third-party function in the third-party application;
[0202] The processing module 802 is further used to: call the callback event associated with the target event according to the event transmission strategy, and return the main execution result to the third application with the callback event as the carrier, so that the third-party application can determine the third-party execution result of the third-party function based on the main execution result.
[0203] In a possible embodiment, the processing module 802 is specifically used for:
[0204] When it is detected that a target trigger function for the target event is running in the third-party application, use the target name of the target event as the function execution instruction sent by the third-party application;
[0205] In the main application, run the function function named with the target name to execute the main application function in the main application indicated by the function execution instruction to obtain the main execution result.
[0206] In a possible embodiment, the callback event is: a client event registered based on the target name of the target event according to the event transmission strategy, and the callback name of the callback event includes the target name; The processing module 802 is specifically used for:
[0208] According to the event transmission strategy, based on the target name and the callback name, determine the callback trigger function of the callback event associated with the target event, and run the callback trigger function to call the callback event;
[0209] The main execution result is used as the running result of the callback trigger function, so that after the third-party application detects the callback event, it receives the running result to obtain the main execution result.
[0210] In a possible embodiment, the target event is associated with a target identifier, which is configured for the target event according to the event transmission strategy when the third-party application calls the target event, and the target identifier is used to uniquely characterize the target event; and the callback event is associated with a callback identifier, which is configured for the callback event based on the target identifier of the target event according to the event transmission strategy when registering the callback event; The processing module 802 is specifically used for:
[0212] Determine the target identifier of the target event. When it matches the callback identifier of the callback event, use the main execution result as the running result of the callback trigger function, so that when the third-party application detects that the callback trigger function is running in the main application, it runs the result receiving function for the callback event, receives the running result of the callback trigger function, and obtains the main execution result.
[0213] In a possible embodiment, the processing module 802 is further used to:
[0214] When a target event is detected, before obtaining a function execution instruction sent by a third-party application using the target event as a carrier,
[0215] In response to a page rendering operation of a third-party application triggered by the main page content presented by the main application, loading the third-party page content of the third-party application through the third-party routing address of the third-party application;
[0216] The third-party page content is presented above the main page content in the form of a pop-up window.
[0217] In a possible embodiment, the processing module 802 is specifically used for:
[0218] In response to the run operation triggered for the main application, the main page content of the main application is loaded from the main routing address of the main application configured according to the hash routing strategy; wherein the hash routing strategy represents: a routing method of linking each hash value to a corresponding routing address through an address template;
[0219] In response to the page rendering operation of the third-party application triggered by the main page content, the third-party page content of the third-party application is loaded through the third-party routing address of the third-party application configured according to the hash routing strategy.
[0220] In a possible embodiment, each page content in the third-party application is associated with a corresponding page identifier, and the page identifier is used to uniquely represent the corresponding page content in the third-party application; The processing module 802 is specifically used for:
[0222] in response to a page presentation operation of a third-party application triggered by the main page content, obtaining a pop-up window opening instruction; wherein the pop-up window opening instruction includes a page identifier of the third-party page content in the third-party application;
[0223] Determining a third-party routing address based on a page identifier of the third-party page content;
[0224] Load third-party page content from a third-party routing address.
[0225] In a possible embodiment, the processing module 802 is specifically used for:
[0226] Based on the pre-stored mapping relationship between each page identifier and each hash value, determine the page hash value corresponding to the page identifier of the third-party page content;
[0227] Update the specified location in the main routing address of the main page content to the page hash value to obtain the third-party routing address.
[0228] Based on the same inventive concept, an embodiment of the present application provides a device for executing application functions, which can implement the functions corresponding to the aforementioned method for executing application functions.Please refer to Figure 8B. The device includes an import module 8001 and a processing module 8002, where:
[0229] The import module 8001: is used to import an event transmission policy; wherein, the event transmission policy characterizes: a data transmission method with client events as the carrier between the main application and the third-party application;
[0230] The processing module 8002: is used to, in response to a selection operation triggered for a third-party function in the third-party application, call a target event according to the event transmission policy, so that when the main application detects the target event, obtain a function execution instruction sent with the target event as the carrier, and execute the main application function in the main application indicated by the function execution instruction to obtain a main execution result; and, according to the event transmission policy, call a callback event associated with the target event, and return the main execution result to the third application with the callback event as the carrier;
[0231] The processing module 8002 is further used to: after obtaining the main execution result, determine the third-party execution result of the third-party function based on the main execution result.
[0232] In a possible embodiment, the callback event is: a client event registered according to the event transmission policy based on the target name of the target event, and the callback name of the callback event includes the target name;
[0233] The processing module 8002 is specifically used to:
[0234] Detect that a callback trigger function for the callback event named after the callback name is running, and obtain the main execution result returned with the callback event as the carrier according to the event transmission policy.
[0235] In a possible embodiment, a target event is associated with a target identifier, which is configured for the target event according to an event transmission policy when a third-party application invokes the target event, and the target identifier is used to uniquely represent the target event; and, a callback event is associated with a callback identifier, which is configured for the callback event according to the event transmission policy based on the target identifier of the target event when registering the callback event;
[0236] The processing module 8002 is specifically configured to:
[0237] Detect that a callback trigger function for a callback event named after a callback name is run, and obtain the callback identifier of the callback event;
[0238] When it is determined that the target identifier of the target event matches the callback identifier of the callback event, run a result receiving function for the callback event, receive the running result of the callback trigger function, and obtain the main execution result carried by the running result.
[0239] Please refer to Figure 9, which is a computer device 900 provided by an embodiment of the present application. The computer device 900 may be, for example, the terminal device 101 or the server 102 in Figure 1B. The current version and historical versions of the data storage program and the application software corresponding to the data storage program may be installed on the computer device 900, and the computer device 900 includes a processor 980 and a memory 920. In some embodiments, the computer device 900 may include a display unit 940, and the display unit 940 includes a display panel 941 for displaying a user interaction operation interface, etc.
[0240] In a possible embodiment, the display panel 941 may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED), etc.
[0241] The processor 980 is used to read the computer program and then execute the method defined by the computer program. For example, the processor 980 reads the data storage program or file, etc., so as to run the data storage program on the computer device 900 and display the corresponding interface on the display unit 940. The processor 980 may include one or more general-purpose processors and may also include one or more DSPs (Digital Signal Processors) to perform related operations to implement the technical solutions provided in the embodiments of the present application.
[0242] The memory 920 generally includes a memory and an external memory, and the memory may be a random access memory (RAM), a read-only memory (ROM), and a cache (CACHE), etc. The external memory may be a hard disk, an optical disk, a USB disk, a floppy disk, or a tape drive, etc. The memory 920 is used to store computer programs and other data, and the computer program includes the application programs corresponding to each client, etc. Other data may include the data generated after the operating system or the application program is run, and the data include system data (such as configuration parameters of the operating system) and user data. In the embodiment of the present application, the computer program is stored in the memory 920, and the processor 980 executes the computer program in the memory 920 to implement any method discussed in the preceding figure.
[0243] The display unit 940 is used to receive input digital information, character information or contact touch operation / contactless gesture, and generate signal input related to user settings and function control of the computer device 900. Specifically, in the embodiment of the present application, the display unit 940 may include a display panel 941. The display panel 941 is, for example, a touch screen, which can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, a stylus, etc. on or on the display panel 941), and drive the corresponding connection device according to a pre-set program.
[0244] In a possible embodiment, the display panel 941 may include two parts: a touch detection device and a touch controller. The touch detection device detects the touch position of the player, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 980, and can receive and execute the command sent by the processor 980.
[0245] Among them, the display panel 941 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave.In addition to the display unit 940, in some embodiments, the computer device 900 may further include an input unit 930. The input unit 930 may include an image input device 931 and other input devices 932. The other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0246] In addition to the above, the computer device 900 may further include a power supply 990 for powering other modules, an audio circuit 960, a near field communication module 970, and an RF circuit 910. The computer device 900 may further include one or more sensors 950, such as an acceleration sensor, a light sensor, a pressure sensor, etc. The audio circuit 960 specifically includes a speaker 961 and a microphone 962, etc. For example, the computer device 900 may collect the user's voice through the microphone 962 and perform corresponding operations, etc.
[0247] As an embodiment, the number of processors 980 may be one or more. The processor 980 and the memory 920 may be coupled or relatively independent.
[0248] As an embodiment, the processor 980 in Figure 9 may be used to implement the functions of the import module 801 and the processing module 802 in Figure 8A; it may also be used to implement the functions of the import module 8001 and the processing module 8002 in Figure 8B.
[0249] As an embodiment, the processor 980 in Figure 9 may be used to implement the functions corresponding to the server or terminal device described above.
[0250] Those of ordinary skill in the art will understand that all or part of the steps of implementing the above method embodiments can be completed by a computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the computer program is executed, it performs the steps including those of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs, etc., which are various media that can store program codes.
[0251] Alternatively, if the above integrated units of the present invention are implemented in the form of software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. For example, it is embodied through a computer program product. The computer program product is stored in a storage medium and includes a computer program for causing a computer device to execute all or part of the methods described in the various embodiments of the present invention. And the aforementioned storage medium includes: mobile storage devices, ROM, RAM, magnetic disks, or optical discs, etc., which are various media that can store program codes.
[0252] Obviously, those skilled in the art can make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application also intends to include these changes and modifications.< / iframe>
Claims
1. A method for executing an application function, It is characterized in that The method is applied to a main application running on a client, wherein a third-party application is nested and running in the main application, and includes: Importing an event transmission strategy; wherein the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers; When a target event is detected, a function execution instruction sent by the third-party application using the target event as a carrier is obtained, and the main application function in the main application indicated by the function execution instruction is executed to obtain a main execution result; wherein the target event is: a client event called by the third-party application according to the event transmission strategy in response to a selection operation triggered by a third-party function in the third-party application; According to the event transmission strategy, the callback event associated with the target event is called, and the main execution result is returned to the third application using the callback event as a carrier, so that the third-party application determines the third-party execution result of the third-party function based on the main execution result.
2. The method according to claim 1, It is characterized in that The method of obtaining, when detecting a target event, a function execution instruction sent by the third-party application using the target event as a carrier, and executing a main application function in the main application indicated by the function execution instruction to obtain a main execution result includes: When it is detected that a target trigger function for a target event is run in the third-party application, the target name of the target event is used as the function execution instruction sent by the third-party application; In the main application, a function function named with the target name is run to execute the main application function in the main application indicated by the function execution instruction to obtain a main execution result.
3. The method according to claim 1, It is characterized in that The callback event is: a client event registered based on the target name of the target event according to the event transmission strategy, and the callback name of the callback event includes the target name; The calling the callback event associated with the target event according to the event transmission strategy, and returning the main execution result to the third application using the callback event as a carrier, includes: According to the event transmission strategy, based on the target name and the callback name, determine the callback trigger function of the callback event associated with the target event, and run the callback trigger function to call the callback event; The main execution result is used as the running result of the callback trigger function, so that after the third-party application detects the callback event, it receives the running result to obtain the main execution result.
4. The method according to claim 3, It is characterized in that The target event is associated with a target identifier, and the target identifier is configured for the target event according to the event transmission strategy when the third-party application calls the target event, and the target identifier is used to uniquely characterize the target event; And, the callback event is associated with a callback identifier, and the callback identifier is configured for the callback event based on the target identifier of the target event according to the event transmission strategy when registering the callback event; The taking the main execution result as the operation result of the callback trigger function includes: Determine the target identifier of the target event, and when it matches the callback identifier of the callback event, use the main execution result as the running result of the callback trigger function, so that when the third-party application detects that the callback trigger function is running in the main application, it runs the result receiving function for the callback event, receives the running result of the callback trigger function, and obtains the main execution result.
5. The method according to any one of claims 1 to 4, It is characterized in that Before obtaining the function execution instruction sent by the third-party application using the target event as a carrier when the target event is detected, the method further includes: In response to a page rendering operation of the third-party application triggered by the main page content rendered by the main application, loading the third-party page content of the third-party application through the third-party routing address of the third-party application; The third-party page content is presented on top of the main page content in the form of a pop-up window.
6. The method according to claim 5, It is characterized in that The step of loading the third-party page content of the third-party application through the third-party routing address of the third-party application in response to the page rendering operation of the third-party application triggered by the main page content rendered by the main application includes: In response to the running operation triggered for the main application, the main page content of the main application is loaded from the main routing address of the main application configured according to the hash routing strategy; wherein the hash routing strategy represents: a routing method of linking to a corresponding routing address by splicing each hash value through an address template; In response to the page rendering operation of the third-party application triggered by the main page content, the third-party page content of the third-party application is loaded through the third-party routing address of the third-party application configured according to the hash routing policy.
7. The method according to claim 6, It is characterized in that Each page content in the third-party application is associated with a corresponding page identifier, and the page identifier is used to uniquely represent the corresponding page content in the third-party application; The step of loading the third-party page content of the third-party application by the third-party routing address of the third-party application configured according to the hash routing strategy in response to the page rendering operation of the third-party application triggered by the main page content includes: In response to the page presentation operation of the third-party application triggered by the main page content, a pop-up window opening instruction is obtained; wherein the pop-up window opening instruction includes a page identifier of the third-party page content in the third-party application; Determining the third-party routing address based on the page identifier of the third-party page content; The third-party page content is loaded from the third-party routing address.
8. The method according to claim 7, It is characterized in that The determining the third-party routing address based on the page identifier of the third-party page content includes: Determine the page hash value corresponding to the page identifier of the third-party page content based on the pre-stored mapping relationship between each page identifier and each hash value; The designated location in the main routing address of the main page content is updated to the page hash value to obtain the third-party routing address.
9. A method for executing an application function, It is characterized in that Applied to a third-party application nested and running in a main application, the main application running on a client, the method comprising: Importing an event transmission strategy; wherein the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers; In response to a selection operation triggered on a third-party function in the third-party application, calling a target event according to the event transmission strategy, so that when the main application detects the target event, it obtains a function execution instruction sent with the target event as a carrier, and executes the main application function in the main application indicated by the function execution instruction to obtain a main execution result; and, calling a callback event associated with the target event according to the event transmission strategy, and returning the main execution result to the third application with the callback event as a carrier; After obtaining the main execution result, a third-party execution result of the third-party function is determined based on the main execution result.
10. The method according to claim 9, It is characterized in that The callback event is: a client event registered based on the target name of the target event according to the event transmission strategy, and the callback name of the callback event includes the target name; The obtaining of the main execution result includes: It is detected that a callback trigger function for a callback event named by the callback name is executed, and according to the event transmission strategy, the main execution result returned with the callback event as a carrier is obtained.
11. The method according to claim 10, It is characterized in that The target event is associated with a target identifier, which is configured for the target event according to the event transmission strategy when the third-party application calls the target event, and is used to uniquely characterize the target event; And, the callback event is associated with a callback identifier, and the callback identifier is configured for the callback event according to the event transmission strategy and based on the target identifier of the target event when registering the callback event; The detecting that a callback trigger function for a callback event named by the callback name is running, and obtaining the main execution result returned with the callback event as a carrier according to the event transmission strategy, includes: Detecting that a callback trigger function for a callback event named by the callback name is executed, and obtaining a callback identifier of the callback event; Determine the target identifier of the target event, and when it matches the callback identifier of the callback event, run the result receiving function for the callback event, receive the running result of the callback trigger function, and obtain the main execution result carried by the running result.
12. A device for executing an application function, It is characterized in that The device is applied to run a main application, wherein a third-party application is embedded in the main application, and the device includes: Import module: used to import event transmission strategy; wherein, the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers; Processing module: used for obtaining, when a target event is detected, a function execution instruction sent by the third-party application using the target event as a carrier, and executing the main application function in the main application indicated by the function execution instruction to obtain a main execution result; wherein the target event is: a client event called by the third-party application according to the event transmission strategy in response to a selection operation triggered by a third-party function in the third-party application; The processing module is also used to: call the callback event associated with the target event according to the event transmission strategy, and return the main execution result to the third application using the callback event as a carrier, so that the third-party application determines the third-party execution result of the third-party function based on the main execution result.
13. A device for executing an application function, It is characterized in that The device is applied to run a third-party application, wherein the third-party application is nested and runs in a main application, and the device includes: Import module: used to import event transmission strategy; wherein, the event transmission strategy represents: a data transmission method between the main application and the third-party application using client events as carriers; Processing module: used for, in response to a selection operation triggered by a third-party function in the third-party application, calling a target event according to the event transmission strategy, so that when the main application detects the target event, it obtains a function execution instruction sent with the target event as a carrier, and executes the main application function in the main application indicated by the function execution instruction to obtain a main execution result; and, according to the event transmission strategy, calling a callback event associated with the target event, and returning the main execution result to the third application with the callback event as a carrier; The processing module is further configured to: after obtaining the main execution result, determine the third-party execution result of the third-party function based on the main execution result.
14. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
15. A computer device, It is characterized in that include: A memory for storing program instructions; The processor is used to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 11 according to the obtained program instructions.
16. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method according to any one of claims 1 to 11.