Method and apparatus for creating an interface, storage medium, and electronic device

By creating a bridge object to provide an interface for target applications to call target components, the problem of low efficiency in the prior art is solved, and the effect of improving call efficiency and reducing maintenance costs is achieved.

CN114253533BActive Publication Date: 2025-06-27QINGDAO HAIER TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111425015.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-26
Publication Date
2025-06-27
Estimated Expiration
2041-11-26

AI Technical Summary

Technical Problem

In the prior art, it is less efficient to retrieve target components, and manually writing script files to retrieve components are prone to errors, resulting in increased maintenance costs.

Method used

By obtaining the interface creation request initiated by the interface calling module, a bridge object is created based on the carried target annotation information, and sent it to the interface calling module to provide an interface for the target application to call the target component.

Benefits of technology

Improve the efficiency of the target component to retrieve, avoid the inefficiency caused by manual scripting files and the problem of error-prone code, and reduce maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114253533B_ABST
    Figure CN114253533B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and apparatus for creating an interface, a storage medium, and an electronic device. Among them, the method includes: obtaining an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for calling application resources used on a target application; responding to the interface creation request, creating a bridging object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate, by means of annotation, one or more target components where the application resources used on the target application are located; sending the bridging object to the interface call module, where the bridging object is used to instruct the interface call module to provide an interface for calling one or more target components for the target application through the bridging object. By adopting the above technical solution, problems such as low efficiency in retrieving target components in the related art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular, to a method and apparatus for creating an interface, a storage medium, and an electronic device. Background Art

[0002] Now, with the rapid iteration of the version of the smart home APP and a short development cycle, although the smart home APP has now fully completed the migration process from the native technology stack to the Flutter technology stack, saving a lot of manpower and time in the development process, since many basic modules are still developed by the native technology, such as user information, logs, push, devices, etc. At this time, in order to implement the requirement of the top-level Flutter module to call the modules in the underlying native, the Flutter Plugin technology is often used. The Flutter Plugin just acts as a bridging object. The program creator manually creates a bridging object in the form of a Flutter Plugin for the native component to be called according to the need, and it is easy to make mistakes when creating. When solving the same problem, different developers will also adopt different technical solutions, resulting in a greatly increased maintenance cost.

[0003] In view of the problem of low efficiency in calling the target component in the related art, no effective solution has been proposed yet. Summary of the Invention

[0004] Embodiments of the present invention provide a method and apparatus for creating an interface, a storage medium, and an electronic device, so as to at least solve the problem of low efficiency in calling the target component in the related art.

[0005] According to an embodiment of the present invention, a method for creating an interface is provided, including: obtaining an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for a target application to call application resources used on the target application; responding to the interface creation request, creating a bridging object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located by means of annotation; and sending the bridging object to the interface call module, where the bridging object is used to instruct the interface call module to provide an interface for the target application to call the one or more target components through the bridging object.

[0006] Optionally, creating the bridging object according to the one or more target annotation information carried in the request created based on the interface includes: extracting the one or more target annotation information from the request for creating the interface; generating target script files corresponding to each of the one or more target annotation information, obtaining one or more target script files, wherein the target script files are used to record the code for implementing the invocation of the target components indicated by the corresponding target annotation information; creating the one or more target script files into the bridging object.

[0007] Optionally, creating the one or more target script files into a bridging object includes: concatenating the one or more target script files to obtain an intermediate file; performing format conversion on the intermediate file to obtain the bridging object in a target format, wherein the target format is a code format that allows to be loaded by the target application.

[0008] According to an embodiment of the present invention, there is provided a method for creating an interface, including: obtaining one or more target annotation information, wherein the one or more target annotation information is used to indicate, by way of annotation, one or more target components where the application resources used on the target application are located; generating an interface creation request carrying the one or more target annotation information, wherein the interface creation request is used to request to create an interface for invoking the application resources used on the target application for the target application; sending the interface creation request to an interface creation module; receiving a bridging object returned by the interface creation module in response to the interface creation request, wherein the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to invoke the one or more target components.

[0009] Optionally, obtaining the one or more target annotation information includes: creating an initial bridging object for the target application; obtaining an interface declaration class of the target application through the initial bridging object, wherein the interface declaration class is used to describe the one or more target components; adding annotations to the interface declaration class to obtain the one or more target annotation information.

[0010] Optionally, after receiving the bridging object returned by the interface creation module in response to the interface creation request, the method further includes: receiving a component invocation request sent by the target application, wherein the component invocation request is used to request to invoke a to-be-invoked component among the one or more target components; forwarding the component invocation request to the to-be-invoked component through the bridging object.

[0011] According to another embodiment of the embodiments of the present invention, there is also provided a device for creating an interface, including: a first acquisition module, configured to acquire an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for a target application to call application resources used on the target application; a creation module, configured to respond to the interface creation request and create a bridging object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; a sending module, configured to send the bridging object to the interface call module, where the bridging object is used to instruct the interface call module to provide an interface for the target application to call the one or more target components through the bridging object.

[0012] According to another embodiment of the embodiments of the present invention, there is also provided a device for creating an interface, including: a second acquisition module, configured to acquire one or more target annotation information, where the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; a generation module, configured to generate an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for the target application to call the application resources used on the target application; a sending module, configured to send the interface creation request to an interface creation module; a first receiving module, configured to receive a bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to call the one or more target components.

[0013] According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is configured to execute the above-mentioned interface creation method when running.

[0014] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the above-mentioned processor executes the above-mentioned interface creation method through the computer program.

[0015] In an embodiment of the present invention, an interface creation request initiated by an interface call module is obtained, where the interface creation request is used to request to create an interface for calling application resources used on a target application; in response to the interface creation request, a bridging object is created according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located through annotation; the bridging object is sent to the interface call module, where the bridging object is used to instruct the interface call module to provide an interface for calling the one or more target components for the target application through the bridging object, that is, annotation information is set for the components of the application resources used on the target application through annotation, different annotation information corresponds to different components, and the target components for which the interface needs to be called can be determined according to the target annotation information in the interface creation request, and then a bridging object for calling the interface of the target components is generated, so as to provide an interface for the target application to call the target components, avoiding problems such as low efficiency and easy code errors when manually writing a script file for calling components in the related art. By adopting the above technical solution, the problem of low efficiency in calling target components in the related art is solved, and the technical effect of improving the calling efficiency of target components is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present invention, and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0017] Figure 1 is a hardware structure block diagram of a computer terminal for a method of creating an interface according to an embodiment of the present invention;

[0018] Figure 2 is a flowchart of a method of creating an interface according to an embodiment of the present invention;

[0019] Figure 3 is a schematic diagram of an optionally generated bridging object according to an embodiment of the present application;

[0020] Figure 4 is an optionally component call timing diagram according to an embodiment of the present request;

[0021] Figure 5 is a structural diagram of an optionally created bridging object model according to an embodiment of the present application;

[0022] Figure 6 is a flowchart of a method of creating an interface according to an embodiment of the present invention;

[0023] Figure 7It is a structural block diagram of a device for creating an interface according to an embodiment of the present invention;

[0024] Figure 8 It is a structural block diagram of another device for creating an interface according to an embodiment of the present invention. Detailed implementation manners

[0025] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order different from those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0027] The method embodiments provided in the embodiments of the present application can be executed on a computer terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 It is a hardware structural block diagram of a computer terminal for a method of creating an interface according to an embodiment of the present invention. As Figure 1 shown, the computer terminal may include one or more ( Figure 1 only one is shown in Figure 1 a processor 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. In an exemplary embodiment, the above computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown in Figure 1 is only schematic and does not limit the structure of the above computer terminal. For example, the computer terminal may further include more or fewer components than Figure 1 shown in Figure 1Different configurations with more functions as shown.

[0028] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for creating an interface in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely provided with respect to the processor 102, and these remote memories can be connected to the computer terminal through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0029] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the computer terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 can be a radio frequency (Radio Frequency, abbreviated as RF) module, which is used to communicate with the Internet wirelessly.

[0030] In this embodiment, a method for creating an interface is provided, which is applied to the above computer terminal. Figure 2 It is a flowchart of the method for creating an interface according to an embodiment of the present invention, and this process includes the following steps:

[0031] Step S202, obtain an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for calling application resources used on a target application;

[0032] Step S204, in response to the interface creation request, create a bridge object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located in an annotation manner;

[0033] Step S206, send the bridge object to the interface call module, where the bridge object is used to instruct the interface call module to provide an interface for calling the one or more target components for the target application through the bridge object.

[0034] Through the above steps, annotation information is set for the components of the application resources used in the target application in the form of annotations. Different annotation information corresponds to different components. Based on the target annotation information in the interface creation request, the target components for which the interface needs to be invoked can be determined, and then a bridging object for invoking the target component interface can be generated, thereby providing an interface for the target application to call the target component, avoiding problems such as low efficiency and easy code errors in the related art when manually writing script files for invoking components. By adopting the above technical solution, the problems such as low efficiency in invoking the target component in the related art are solved, and the technical effect of improving the invocation efficiency of the target component is achieved.

[0035] In the technical solution provided in the above step S202, the target component is a component in a non-target application, and the target application cannot directly invoke the target component. For example, the target component can be a component in other applications or a component stored in a certain storage location (this storage location is not in the target application).

[0036] In the technical solution provided in the above step S204, the bridging object provides a channel for the target application to call the resources in the target component, and the bridging object does not limit the data content for the target application to call the target component.

[0037] Optionally, in this embodiment, the bridging object can be preset according to the component, or can be generated according to the annotation information and call template of the component.

[0038] In the technical solution provided in the above step S206, the bridging object can be sent to the interface call module in a direct sending form, or can be sent to the interface call module in an encrypted and compressed manner after being encrypted and compressed.

[0039] Figure 3 It is a schematic diagram of generating a bridging object according to an optional embodiment of the present application, which is used to generate a target bridging object for invoking the target component where the application resources used by the target application are located. This bridging object is used to provide an interface for the target application to call the target component, as Figure 3 shown:

[0040] S301, developers create the service class provided by the component and the corresponding interface declaration, and use the annotation model to add annotation information to the service class and interface declaration information to obtain the target annotation information of the service class and interface that the target application needs to call;

[0041] S302, generate a request for the Annotation analysis (annotation parsing library) to generate a target bridging object for invoking the target component according to the target annotation information;

[0042] 303, call the annotation parsing library to parse the target annotation information;

[0043] S304, the annotation parsing library performs parsing processing on the target annotation information, so as to match a target component that matches the target annotation information in the preset components in the annotation parsing library, and generate a bridging object for calling the target component according to the target script corresponding to the target component.

[0044] Figure 4 It is an optional component calling time sequence diagram according to the embodiment of the present request. By Figure 3 The embodiment generates a bridging object for calling the target component, providing a bridging object for calling the Native component for the Flutter project, such as Figure 4 shown:

[0045] S401, the operator starts the Flutter APP;

[0046] S402, when the Flutter APP needs to call a component in the Native, it will send a request to the Flutter Plugin to call the bridging object of the component generated by the Flutter Plugin.

[0047] S403, call the target component in the Native through the bridging object generated by the Flutter Plugin;

[0048] S404, return the calling result of the target component in the Native to the Flutter Plugin;

[0049] S405, provide the calling result of the target component to the Flutter project.

[0050] Figure 5 It is a structural diagram of an optional bridging object creation model according to the embodiment of the present application, which is used to generate a bridging object for calling a component according to the annotation information of the component that needs to be called by the target application, such as Figure 5As shown in the figure, the whole structure is divided into two parts. The main function of Flutter Plugin is to provide a bridge presentation for Native data and services to the upper layer. Annotation_analysis is mainly used to generate a bridge object for calling components according to the annotation information of the components that need to be called. During development, the required function code and business code in Flutter Plugin are first extracted to form templated code, which is used as the script code for calling the target component after parsing the annotation. Second, the function code of the components required for templated code generation except for the Plugin interface signature is listed, and these function codes are designed as annotation information and created in the annotation library. Third, in the annotation parsing library (annotation_generator), the annotation information and the annotated target information are obtained through the source_gen library to generate the script code described in the first step. Fourth, after the conditions for generating script code are met, the completed script code is truly converted into legal Dart code through the code_builder library, and the core step of generating bridge objects by annotation is completed. When used, Flutter Plugin sends the target annotation information of the target component that the target application needs to call to the annotation parsing library (annotation_generator), and uses the annotations in the above annotation library to parse the target annotation information. After completion, the console runs the command provided by the builder_runner library, which starts source_gen to analyze the target annotation information and generate the above script code. Finally, the code_builder library is used to generate legal Dart code and output it in the form of a file to obtain a bridge object.

[0051] In an exemplary embodiment, creating the bridge object according to the one or more target annotation information carried by the interface creation request includes:

[0052] Extracting the one or more target annotation information from the interface creation request;

[0053] Generate a target script file corresponding to each target annotation information in the one or more target annotation information to obtain one or more target script files, wherein the target script file is used to record the code for implementing the call of the target component indicated by the corresponding target annotation information;

[0054] The one or more target script files are created as the bridge object.

[0055] Optionally, in this embodiment, the present solution does not limit the programming language of the script file. For example, the script file can be, but is not limited to, code written in the Java language, code written in the C++ language, and so on.

[0056] Optionally, in this embodiment, the script file can be preset according to the component, or can be generated according to the annotation information and call template of the component.

[0057] In an exemplary embodiment, the creating the one or more target script files as a bridging object includes:

[0058] Concatenating the one or more target script files to obtain an intermediate file;

[0059] Performing format conversion on the intermediate file to obtain the bridging object in the target format, where the target format is a code format that allows to be loaded by the target application.

[0060] Optionally, in this embodiment, the format conversion can be obtained by processing the intermediate file using a radical conversion model.

[0061] Optionally, in this embodiment, the target format can include, but is not limited to, Dart format, CSS format, JSON format, and so on.

[0062] In this embodiment, a method for creating an interface is provided, which is applied to the above computer terminal. Figure 6 It is a flowchart of the method for creating an interface according to an embodiment of the present invention, and the process includes the following steps:

[0063] Step S602, obtaining one or more target annotation information, where the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located by means of annotations;

[0064] Step S604, generating an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for calling the application resources used on the target application;

[0065] Step S606, sending the interface creation request to an interface creation module;

[0066] Step S608, receiving the bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to call the one or more target components.

[0067] Optionally, in this embodiment, the interface creation request may be directly sent to the interface creation module, or the interface creation request may be compressed and then the compressed interface creation request is sent to the interface creation module.

[0068] In an exemplary embodiment, obtaining the one or more target annotation information includes:

[0069] Create an initial bridging object for the target application;

[0070] Obtain the interface declaration class of the target application through the initial bridging object, where the interface declaration class is used to describe the one or more target components;

[0071] Add annotations to the interface declaration class to obtain the one or more target annotation information.

[0072] Optionally, in this embodiment, the target annotation information may be obtained by annotating the interface declaration class using an annotation model, or may be determined according to a preset correspondence between the interface declaration class and the annotation information.

[0073] In an exemplary embodiment, after receiving the bridging object returned by the interface creation module in response to the interface creation request, the method further includes:

[0074] Receive a component call request sent by the target application, where the component call request is used to request to call a to-be-called component among the one or more target components;

[0075] Forward the component call request to the to-be-called component through the bridging object.

[0076] Optionally, in this embodiment, the target application realizes retrieving the content corresponding to the component call request in the target component through the bridging object.

[0077] Optionally, in this embodiment, the component call request may include, but is not limited to, application information of the target application, account information of the account logged in the target application, call content information, etc. For example, when the component only contains application information, the to-be-called component corresponding to the application can be retrieved; when the component only contains account information, the to-be-called component corresponding to the account information can be retrieved; when the component contains call content information, the to-be-called component corresponding to the call content information can be retrieved.

[0078] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution 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. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of the present invention.

[0079] Figure 7 is a structural block diagram of a device for creating an interface according to an embodiment of the present invention; as Figure 7 shown, it includes:

[0080] A first acquisition module 72, configured to acquire an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for calling application resources used on a target application;

[0081] A creation module 74, configured to respond to the interface creation request and create a bridging object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located by means of annotations;

[0082] A sending module 76, configured to send the bridging object to the interface call module, where the bridging object is used to instruct the interface call module to provide an interface for calling the one or more target components for the target application through the bridging object.

[0083] Optionally, the creation module includes: an extraction unit, configured to extract the one or more target annotation information from the interface creation request; a generation unit, configured to generate target script files corresponding to each of the one or more target annotation information to obtain one or more target script files, where the target script files are used to record code for implementing the call to the target components indicated by the corresponding target annotation information; a first creation unit, configured to create the one or more target script files into the bridging object.

[0084] Optionally, the first creation unit is configured to: splice the one or more target script files to obtain an intermediate file; perform format conversion on the intermediate file to obtain the bridging object in a target format, where the target format is a code format allowed to be loaded by the target application.

[0085] Figure 8 is a structural block diagram of another interface creation device according to an embodiment of the present invention; as Figure 8 shown, it includes:

[0086] A second acquisition module 82, configured to acquire one or more target annotation information, where the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where application resources used on a target application are located;

[0087] A generation module 84, configured to generate an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for calling application resources used on the target application for the target application;

[0088] A sending module 86, configured to send the interface creation request to an interface creation module;

[0089] A first receiving module 88, configured to receive a bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to call the one or more target components.

[0090] Optionally, the second acquisition module includes: a second creation unit, configured to create an initial bridging object for the target application; an acquisition unit, configured to acquire an interface declaration class of the target application through the initial bridging object, where the interface declaration class is used to describe the one or more target components; an adding unit, configured to add an annotation to the interface declaration class to obtain the one or more target annotation information.

[0091] Optionally, the device further includes: a second receiving module, configured to receive a component call request sent by the target application after receiving the bridging object returned by the interface creation module in response to the interface creation request, where the component call request is used to request to call a to-be-called component among the one or more target components; a forwarding module, configured to forward the component call request to the to-be-called component through the bridging object.

[0092] Through the above embodiments, annotation information is set for components of application resources used in a target application in an annotation manner. Different annotation information corresponds to different components. Based on the target annotation information in the interface creation request, the target component for which the interface needs to be invoked can be determined, and then a bridging object for invoking the interface of the target component is generated, thereby providing an interface for the target application to call the target component, avoiding problems such as low efficiency and easy code errors in the related art when manually writing a script file for invoking a component. By adopting the above technical solution, the problem of low efficiency in invoking a target component in the related art is solved, and the technical effect of improving the invocation efficiency of the target component is achieved.

[0093] An embodiment of the present invention further provides a storage medium, which includes a stored program. When the above program runs, it executes the method of any one of the above.

[0094] Optionally, in this embodiment, the above storage medium can be set to store program code for executing the following steps: obtaining an interface creation request initiated by an interface invocation module, where the interface creation request is used to request to create an interface for a target application to call application resources used in the target application; responding to the interface creation request, creating a bridging object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate one or more target components where application resources used in the target application are located in an annotation manner; sending the bridging object to the interface invocation module, where the bridging object is used to instruct the interface invocation module to provide an interface for the target application to call the one or more target components through the bridging object.

[0095] Optionally, in this embodiment, the above storage medium can be set to store program code for executing the following steps: obtaining one or more target annotation information, where the one or more target annotation information is used to indicate one or more target components where application resources used in the target application are located in an annotation manner; generating an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for the target application to call application resources used in the target application; sending the interface creation request to an interface creation module; receiving a bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to call the one or more target components.

[0096] An embodiment of the present invention further provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0097] Optionally, the above electronic device may further include a transmission device and an input / output device. The transmission device is connected to the above processor, and the input / output device is connected to the above processor.

[0098] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program: obtaining an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for calling application resources used on a target application; responding to the interface creation request, and creating a bridging object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information are used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; sending the bridging object to the interface call module, where the bridging object is used to instruct the interface call module to provide an interface for calling the one or more target components for the target application through the bridging object.

[0099] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program: obtaining one or more target annotation information, where the one or more target annotation information are used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; generating an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for calling the application resources used on the target application; sending the interface creation request to an interface creation module; receiving a bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for calling the one or more target components for the target application.

[0100] Optionally, in this embodiment, the above storage medium may include, but is not limited to: various media such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disc that can store program codes.

[0101] Optionally, for specific examples in this embodiment, reference may be made to the examples described in the above embodiments and optional implementation manners, and details thereof are not described herein again.

[0102] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a sequence different from that here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0103] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for creating an interface, characterized in that, Including: Obtain an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for calling application resources used on a target application; Respond to the interface creation request, and create a bridge object according to one or more target annotation information carried in the interface creation request, where the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; Send the bridge object to the interface call module, where the bridge object is used to instruct the interface call module to provide an interface for calling the one or more target components for the target application through the bridge object; Among them, creating a bridge object according to one or more target annotation information carried in the interface creation request includes: extracting the required function code and business code in Flutter Plugin to form templated code, and using it as the script code for calling the target component after parsing the annotation; listing the function codes of the components except the Plugin interface signature required for generating the templated code, designing these function codes as annotation information, and creating them in an annotation library; obtaining the annotation information and the annotated target information through the source_gen library to generate the script code; using the code_builder library to truly convert the script code into legal Dart code and output it in the form of a file to obtain the bridge object.

2. The method for creating an interface according to claim 1, wherein Creating the bridge object according to the one or more target annotation information carried in the interface creation request includes: Extract the one or more target annotation information from the interface creation request; Generate target script files corresponding to each of the one or more target annotation information, obtaining one or more target script files, where the target script files are used to record the code for implementing the call to the target components indicated by the corresponding target annotation information; Create the one or more target script files as the bridge object.

3. The method for creating an interface according to claim 2, wherein The creating the one or more target script files as the bridge object includes: Concatenate the one or more target script files to obtain an intermediate file; Convert the format of the intermediate file to obtain the bridge object in a target format, where the target format is a code format that allows the target application to load.

4. A method for creating an interface, characterized in that, Including: Obtain one or more target annotation information, where the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; Generate an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for calling the application resources used on the target application; Send the interface creation request to the interface creation module; Receive the bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to call the one or more target components; Among them, creating a bridging object according to the one or more target annotation information carried in the interface creation request includes: extracting the required functional code and business code in the Flutter Plugin to form templated code, which is used as the script code for calling the target component after parsing the annotation; listing the functional code of the components other than the Plugin interface signature required for generating the templated code, designing these functional codes as annotation information, and creating them in the annotation library; obtaining the annotation information and the target information annotated thereby through the source_gen library to generate the script code; and truly converting the script code into legal Dart code through the code_builder library and outputting it in the form of a file to obtain the bridging object.

5. The method for creating an interface according to claim 4, wherein Obtaining the one or more target annotation information includes: Create an initial bridging object for the target application; Obtain the interface declaration class of the target application through the initial bridging object, where the interface declaration class is used to describe the one or more target components; Add annotations to the interface declaration class to obtain the one or more target annotation information.

6. The method for creating an interface according to claim 4, wherein After receiving the bridging object returned by the interface creation module in response to the interface creation request, the method further includes: Receive a component call request sent by the target application, where the component call request is used to request to call a to-be-called component among the one or more target components; Forward the component call request to the to-be-called component through the bridging object.

7. An interface creation device, characterized in that, Includes: A first acquisition module, configured to acquire an interface creation request initiated by an interface call module, where the interface creation request is used to request to create an interface for a target application to call application resources used on the target application; A creation module, which is used to respond to the interface creation request and create a bridging object according to one or more target annotation information carried by the interface creation request. Wherein, the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located. Creating a bridging object according to the one or more target annotation information carried by the interface creation request includes: extracting the required functional code and business code in the Flutter Plugin to form templated code, which is used as the script code for invoking the target component after parsing the annotation; listing the functional code of the components except for the Plugin interface signature required for generating the templated code, designing these functional codes as annotation information, and creating them in the annotation library; obtaining the annotation information and the annotated target information through the source_gen library to generate the script code; using the code_builder library to truly convert the script code into legal Dart code and output it in the form of a file to obtain the bridging object; A sending module, which is used to send the bridging object to the interface calling module, where the bridging object is used to instruct the interface calling module to provide an interface for calling the one or more target components for the target application through the bridging object.

8. An interface creation device, characterized in that, including: A second acquisition module, which is used to acquire one or more target annotation information, where the one or more target annotation information is used to indicate, in an annotation manner, one or more target components where the application resources used on the target application are located; A generation module, which is used to generate an interface creation request carrying the one or more target annotation information, where the interface creation request is used to request to create an interface for calling the application resources used on the target application for the target application; A sending module, which is used to send the interface creation request to the interface creation module; The first receiving module is configured to receive the bridging object returned by the interface creation module in response to the interface creation request, where the bridging object is created by the interface creation module according to the one or more target annotation information carried in the interface creation request, and the bridging object is used to provide an interface for the target application to call the one or more target components. Creating a bridging object according to the one or more target annotation information carried in the interface creation request includes: extracting the required function code and business code in the Flutter Plugin to form templated code, which is used as the script code for calling the target component after parsing the annotation; listing the function codes of the components other than the Plugin interface signature required by the templated code, designing these function codes as annotation information, and creating them in the annotation library; obtaining the annotation information and the target information annotated thereby through the source_gen library to generate the script code; and converting the script code into legal Dart code through the code_builder library and outputting it in the form of a file to obtain the bridging object.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, where the program, when running, executes the method described in any one of claims 1 to 6 above.

10. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to execute the method described in any one of claims 1 to 6 through the computer program.

Citation Information

Patent Citations

  • Cross-process callback execution method and device, equipment and storage medium

    CN111880866A

  • Data calling method and device, storage medium and electronic device

    CN113110896A