Application program updating method and device, electronic equipment and storage medium

文档序号:1963481 发布日期:2021-12-14 浏览:26次 中文

阅读说明:本技术 一种应用程序更新方法、装置、电子设备及存储介质 (Application program updating method and device, electronic equipment and storage medium ) 是由 单鹏涛 李�昊 于 2021-08-18 设计创作,主要内容包括:本发明提供了一种应用程序更新方法、装置、电子设备及存储介质。该方法包括:从服务端下载用于对Flutter的界面进行逻辑更新的JS文件;确定响应监听到的界面的事件所需执行的JS文件中的JS函数,以及在操作系统携带的JS引擎的辅助下执行JS函数得到JS函数的执行结果并返回Flutter,以响应事件。如此,只需应用程序自动从服务端下载用于对Flutter的界面进行逻辑更新的JS文件,而无需用户重新手动下载和安装新版本的应用程序(具有用于对Flutter的界面进行逻辑更新的JS文件的新版本的应用程序),就可以实现界面的逻辑的更新,也即实现了界面的逻辑的动态化更新,非常方便。(The invention provides an application program updating method and device, electronic equipment and a storage medium. The method comprises the following steps: downloading a JS file for logically updating an interface of the Flutter from a server; and determining a JS function in the JS file which needs to be executed in response to the monitored event of the interface, executing the JS function under the assistance of a JS engine carried by the operating system to obtain an execution result of the JS function, and returning to Flutter to respond to the event. Therefore, only the JS file used for carrying out logic updating on the interface of the Flutter is automatically downloaded by the application program from the server side, and the user does not need to manually download and install the application program of the new version (the application program of the new version of the JS file used for carrying out logic updating on the interface of the Flutter) again, so that the logic updating of the interface can be realized, namely, the dynamic updating of the logic of the interface is realized, and the method is very convenient.)

1. An application program update method, comprising:

downloading a JS file for logically updating an interface of the Flutter from a server;

and determining a JS function in the JS file which needs to be executed in response to the monitored event of the interface, and executing the JS function under the assistance of a JS engine carried by an operating system to obtain an execution result of the JS function and return to Flutter so as to respond to the event.

2. The method according to claim 1, wherein the determining a JS function in the JS file that needs to be executed in response to the monitored event of the interface, and executing the JS function with the assistance of a JS engine carried by an operating system results in an execution result of the JS function and returns Flutter, comprises:

in a user-defined first bridge, determining the name of a JS function in the JS file which needs to be executed in response to the monitored event of the interface and the parameters needed for calling the JS function, and transmitting the name into a user-defined second bridge;

in the second bridge, calling the JS function in the JS file injected into the execution context of the JS engine based on the transmitted name of the JS function and the parameter for calling the JS function, and returning the execution result of the JS function to the first bridge;

and in the first bridge connection, returning the execution result of the JS function to Flutter.

3. The method of claim 2, further comprising, prior to said invoking the JS function in the JS file that has been injected into the execution context of the JS engine based on the incoming name of the JS function and the parameter invoking the JS function:

injecting a first custom function into a JS execution context of the JS engine;

based on afferent the name of JS function and calling the parameter of JS function, call and injected into in the execution context of the JS engine in the JS file the JS function, include:

through the first custom function, based on the incoming name of the JS function and the calling of the parameter of the JS function, the calling has been injected into the execution context of the JS engine among the JS files.

4. The method of claim 2, further comprising:

initializing the second bridge in application program starting initialization;

in the initialization process of the second bridge, injecting a second custom function into the JS execution context of the JS engine;

sending the execution result of the JS function to the first bridge, including:

and returning the execution result of the JS function to the first bridge through the second custom function.

5. The method according to any one of claims 1 to 4, wherein the JS file is obtained by conversion of an abstract syntax tree generated at the time of code compilation of the interface of Flutter rewritten in the programming language of Flutter.

6. An application program update apparatus, comprising:

the downloading module is used for downloading the JS file for logically updating the interface of the Flutter from the server;

and the execution module is used for determining a JS function in the JS file required to be executed by the event of the interface monitored by the response monitoring and executing the JS function under the assistance of a JS engine carried by the operating system to obtain the execution result of the JS function and return Flutter so as to respond to the event.

7. The apparatus of claim 6, wherein the execution module is specifically configured to:

in a user-defined first bridge, determining the name of a JS function in the JS file which needs to be executed in response to the monitored event of the interface and the parameters needed for calling the JS function, and transmitting the name into a user-defined second bridge;

in the second bridge, calling the JS function in the JS file injected into the execution context of the JS engine based on the transmitted name of the JS function and the parameter for calling the JS function, and returning the execution result of the JS function to the first bridge;

and in the first bridge connection, returning the execution result of the JS function to Flutter.

8. The apparatus according to claim 7, wherein said execution module is specifically configured to inject a first custom function into the JS execution context of the JS engine before said invoking of the JS function in the JS file that has been injected into the JS engine's execution context based on the incoming name of the JS function and the parameter invoking the JS function; through the first custom function, based on the incoming name of the JS function and the calling of the parameter of the JS function, the calling has been injected into the execution context of the JS engine among the JS files.

9. The apparatus of claim 7, wherein the execution module is specifically configured to:

initializing the second bridge in application program starting initialization; in the initialization process of the second bridge, injecting a second custom function into the JS execution context of the JS engine;

and returning the execution result of the JS function to the first bridge through the second custom function.

10. The apparatus according to any one of claims 6 to 9, wherein the JS file is transformed from an abstract syntax tree generated at the time of code compilation of the Flutter's interface rewritten in the Flutter's programming language.

11. An electronic device, comprising: processor, memory and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the application update method according to any of claims 1 to 5.

12. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the steps of the application update method according to any one of claims 1 to 5.

Technical Field

The present invention relates to the field of computer technologies, and in particular, to an application updating method and apparatus, an electronic device, and a storage medium.

Background

As an emerging mobile UI framework, Flutter can build a high-quality user interface suitable for iOS. However, in the implementation scheme in the related art, Flutter does not support the dynamization of the logic corresponding to the iOS user interface of the application program, and when the logic corresponding to the iOS user interface needs to be updated, a user needs to manually download and install a new version of the application program again, which causes inconvenience in use.

Disclosure of Invention

The embodiment of the invention provides an application program updating method and device, electronic equipment and a storage medium, and aims to solve the problems in the related art.

The purpose of the invention is realized by the following technical scheme:

in a first aspect, an embodiment of the present invention provides an application program updating method, including:

downloading a JS file for logically updating an interface of the Flutter from a server, wherein the JS file is obtained by code conversion of the Flutter interface rewritten by a programming language of the Flutter;

and determining a JS function in the JS file which needs to be executed in response to the monitored event of the interface, and executing the JS function under the assistance of a JS engine carried by an operating system to obtain an execution result of the JS function and return to Flutter so as to respond to the event.

In a possible implementation, the determining that the JS function in the JS file needs to be executed in response to the monitored event of the interface, and executing the JS function with the assistance of a JS engine carried by an operating system obtains an execution result of the JS function and returns Flutter includes:

in a user-defined first bridge, determining the name of a JS function in the JS file which needs to be executed in response to the monitored event of the interface and the parameters needed for calling the JS function, and transmitting the name into a user-defined second bridge;

in the second bridge, calling the JS function in the JS file injected into the execution context of the JS engine based on the transmitted name of the JS function and the parameter for calling the JS function, and returning the execution result of the JS function to the first bridge;

and in the first bridge connection, returning the execution result of the JS function to Flutter.

In one possible embodiment, before the calling the JS function in the JS file that has been injected into the execution context of the JS engine, based on the incoming name of the JS function and the calling of the parameter of the JS function, the method further includes:

injecting a first custom function into a JS execution context of the JS engine;

based on afferent the name of JS function and calling the parameter of JS function, call and injected into in the execution context of the JS engine in the JS file the JS function, include:

through the first custom function, based on the incoming name of the JS function and the calling of the parameter of the JS function, the calling has been injected into the execution context of the JS engine among the JS files.

In one possible embodiment, the method further comprises:

initializing the second bridge in application program starting initialization;

in the initialization process of the second bridge, injecting a second custom function into the JS execution context of the JS engine;

sending the execution result of the JS function to the first bridge, including:

and returning the execution result of the JS function to the first bridge through the second custom function.

In a possible implementation, the JS file is converted from an abstract syntax tree generated during code compilation of the interface of Flutter rewritten in the Flutter programming language.

In a second aspect, an embodiment of the present invention provides an application updating apparatus, including:

the downloading module is used for downloading the JS file for logically updating the interface of the Flutter from the server;

and the execution module is used for determining a JS function in the JS file required to be executed by the event of the interface monitored by the response monitoring and executing the JS function under the assistance of a JS engine carried by the operating system to obtain the execution result of the JS function and return Flutter so as to respond to the event.

In a possible implementation manner, the execution module is specifically configured to:

in a user-defined first bridge, determining the name of a JS function in the JS file which needs to be executed in response to the monitored event of the interface and the parameters needed for calling the JS function, and transmitting the name into a user-defined second bridge;

in the second bridge, calling the JS function in the JS file injected into the execution context of the JS engine based on the transmitted name of the JS function and the parameter for calling the JS function, and returning the execution result of the JS function to the first bridge;

and in the first bridge connection, returning the execution result of the JS function to Flutter.

In a possible embodiment, the execution module is specifically configured to inject a first custom function into the JS execution context of the JS engine before the JS function in the JS file that has been injected into the JS engine execution context is called based on the incoming name of the JS function and the parameter that calls the JS function; through the first custom function, based on the incoming name of the JS function and the calling of the parameter of the JS function, the calling has been injected into the execution context of the JS engine among the JS files.

In a possible implementation manner, the execution module is specifically configured to:

initializing the second bridge in application program starting initialization; in the initialization process of the second bridge, injecting a second custom function into the JS execution context of the JS engine;

and returning the execution result of the JS function to the first bridge through the second custom function.

In a possible implementation, the JS file is converted from an abstract syntax tree generated during code compilation of the interface of Flutter rewritten in the Flutter programming language.

In a third aspect, an embodiment of the present invention provides an electronic device, including: a processor, a memory and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the application update method according to any one of the first aspect.

In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the application program updating method according to any one of the first aspect.

The advantages or beneficial effects in the above technical solution at least include: the JS file used for logically updating the interface of the Flutter can be downloaded from the server side, the JS function in the JS file which needs to be executed can be determined as responding to the monitored event for the monitored event of the interface, at this time, the JS function which needs to be executed can be executed under the assistance of the JS engine carried by the operating system of the terminal, and the execution result is returned to the Flutter, so that the Flutter can respond to the monitored event. The response of the interface event is realized based on the JS file after the logic update, but not based on the original logic, so that the logic update of the interface is realized, and the logic update of the interface can be realized only by automatically downloading the JS file for carrying out the logic update on the interface of the Flutter from the server side by the application program and without manually downloading and installing a new version of the application program (the application program with the new version of the JS file for carrying out the logic update on the interface of the Flutter) again by a user, namely, the dynamic update of the logic of the interface is realized, and the method is very convenient.

The foregoing summary is provided for the purpose of description only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the present invention will be readily apparent by reference to the drawings and following detailed description.

Drawings

Fig. 1 is an exemplary hardware system architecture diagram provided by an embodiment of the present invention.

Fig. 2 is a flowchart of an exemplary application program updating method according to an embodiment of the present invention.

Fig. 3 is a flowchart of an exemplary application program updating method according to an embodiment of the present invention.

Fig. 4 is a flowchart of an exemplary application program updating method according to an embodiment of the present invention.

Fig. 5 is a schematic structural diagram of an exemplary application updating apparatus according to an embodiment of the present invention.

Fig. 6 is a schematic structural diagram of an exemplary electronic device according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Fig. 1 is a diagram of an exemplary hardware system architecture provided by an embodiment of the present invention, as shown in fig. 1, the hardware system architecture includes a server 101 and a terminal 102. The terminal 102 may download and install the application from the server 101. The interface of the application program is the interface of the Flutter. When the logic of the interface needs to be updated, a developer can rewrite the code of the interface based on the programming language of Flutter, and then update the logic of the interface of the Flutter of the application program of the terminal based on the application program updating method provided by the embodiment of the invention. The following describes the application program updating method provided by the embodiment of the present invention in detail.

Fig. 2 is a flowchart of an exemplary application program updating method according to an embodiment of the present invention. As shown in fig. 2, the application program updating method at least includes the following steps:

and step 201, downloading a JS file for logically updating the interface of the Flutter from the server.

In practical applications, when the logic of the interface needs to be updated, a developer may rewrite the code of the interface of Flutter based on a programming language of Flutter, such as Dart language, where the code includes a user interface and logic corresponding to the user interface. For example, if a clickable button is included in the user interface, then, after the button is clicked, the function to be implemented needs logic code to be implemented, before the update, the function a can be implemented, for example, the function becomes red after clicking, and after the update, the function b can be implemented, for example, the function becomes green after clicking. And then, converting the code of the rewritten interface of the Flutter to obtain a JS file for logically updating the interface of the Flutter.

Step 202, determining a JS function in the JS file which needs to be executed in response to the monitored event of the interface, executing the JS function under the assistance of a JS engine carried by an operating system to obtain an execution result of the JS function and returning to Flutter so as to respond to the event.

In practical applications, the operating system, i.e., the native operating system of the terminal, may be an iOS operating system or the like. The JS engine (JavaScriptCore) may be carried in the native operating system. JavaScriptCore is an open-source framework that is part of WebKit (cross-platform browser engine) and provides JS code's ability to interact with native code.

The event of the interface may be an event triggered by user input, such as a button click or the like, or a preset event triggered automatically, such as a notification, a reminder, or the like. In response to the event, the interface may be rendered based on the execution result of the JS function.

In this embodiment, the JS file used for logically updating the interface of Flutter may be downloaded from the server, and for the monitored event of the interface, it may be determined that the JS function in the JS file needs to be executed in response to the monitored event, at this time, the JS function needs to be executed may be executed with the assistance of the JS engine carried by the operating system of the terminal, and the execution result is returned to Flutter, so that Flutter may respond to the monitored event. The response of the interface event is realized based on the JS file after the logic update, but not based on the original logic, so that the logic update of the interface is realized, and the logic update of the interface can be realized only by automatically downloading the JS file for carrying out the logic update on the interface of the Flutter from the server side by the application program and without manually downloading and installing a new version of the application program (the application program with the new version of the JS file for carrying out the logic update on the interface of the Flutter) again by a user, namely, the dynamic update of the logic of the interface is realized, and the method is very convenient.

In an exemplary embodiment, the JS file may be converted from an abstract syntax tree generated when the code of the interface of Flutter is compiled again by the programming language of Flutter. In this embodiment, the JS file is obtained by code conversion of the interface of Flutter rewritten in the Flutter programming language, that is, codes before and after the interface update are all written in Flutter, which is a language, and thus implementation is simpler.

Illustratively, the interface of the rewritten Flutter may be transcoded based on Fair. Fair is a dynamic open source framework designed for Flutter.

In practical applications, in Fair, an abstract syntax tree generated when the code of the interface of Flutter in Dart Language is compiled may be intercepted, and then a Domain Specific Language (DSL) file and a corresponding JS file are generated based on the intercepted abstract syntax tree. The DSL file is a file for describing the layout of the interface. The JS file is a file for describing the logic of the interface. During compiling, a pre-run (AOT) compiling mode may be adopted. Illustratively, in Fair, interception during AOT compilation is implemented by build _ runner and Analyzer component libraries of Dart to get an abstract syntax tree. Here, build _ runner and Analyzer of Dart are two component libraries of Fluter. The ability of Fair to borrow 2 component libraries inserts some description and annotation during compilation (for later parsing purposes) resulting in the compilation product, i.e., the DSL file and the corresponding JS file, after compilation is complete is performed by Flutter.

The build _ runner provides some general commands for generating files, some of the commands can be used for testing the generated files, some of the commands can be used for externally providing the generated files and source codes thereof, and the class member variables, the constructors, all parent classes, comments and the like in each dart file can be scanned out. Analyzer is used for code analysis, and can directly scan the whole item, and analyze the syntax tree scanned by each dart file.

In implementation, on the terminal side, in Fair, interface layout can be dynamically changed by ruttime of Dart based on DSL files. runtime, i.e., running time, refers to a state in which a program is running. Specifically, in Fair, the interface of flute can be generated by parsing the DSL file into a recognizable syntax of Dart, and then executing the recognizable syntax through runtime of Dart, so that the user interface is dynamic.

In an exemplary embodiment, the determining, in response to the monitored event of the interface, a JS function in the JS file that needs to be executed, and executing the JS function with the assistance of a JS engine carried by an operating system to obtain an execution result of the JS function and return Flutter may include, as shown in fig. 3, a specific implementation manner of the JS function:

step 301, in the first bridge of the user-defined, determining the name of the JS function in the JS file which needs to be executed in response to the monitored event of the interface, calling the parameters needed by the JS function, and introducing the parameters into the second bridge of the user-defined.

Flutter itself has a variety of communication channels, such as fluttermodechannel, fluttbasicmessagechannel, etc. for communicating with the native operating system. Here, a channel that Flutter uses to communicate with the native operating system may be used as a channel that Flutter communicates with the first bridge. In this step, the fact that the response is monitored through a channel which is provided by Flutter and used for communicating with the native operating system is determined, the name of the JS function in the JS file is required to be executed and called by the event of the interface, and the parameter required by the JS function is introduced into the user-defined second bridge. That is, Flutter can be through the passageway with native operating system communication, will the required execution of event at interface the name of the JS function in the JS file with call the required parameter of JS function is introduced into first bridge, and based on this, in first bridge, can confirm that the response is listened the required execution of event at interface the name of the JS function in the JS file with call the required parameter of JS function.

Step 302, in the second bridge, based on the incoming name of the JS function and the calling of the parameter of the JS function, calling the JS function in the JS file which is injected into the execution context (JSContext) of the JS engine, and returning the execution result of the JS function to the first bridge.

And step 303, in the first bridging, returning the execution result of the JS function to Flutter.

Similarly, the execution result of the JS function can be returned to Flutter through a channel provided by Flutter for communicating with the Native of the operating system.

In this embodiment, two self-defined bridges, namely the first bridge and the second bridge, are provided to realize interaction between Flutter and the JS engine, so as to monitor an event on an interface of Flutter, call a JS function of a JS file, which is injected into the JS engine, that needs to be executed by the monitored event, and return an execution result.

In an exemplary embodiment, after downloading, from the server, a JS file for logically updating an interface of Flutter, and before determining a JS function in the JS file that needs to be executed in response to a monitored event of the interface, the application updating method may further include: and injecting the JS file into the JS execution context of the JS engine so as to execute the JS function in the JS file. Specifically, the JS file to be downloaded can be sent to the first bridge through a channel communicating with the native operating system in Flutter, and the JS file is transmitted into the second bridge in the first bridge, and the JS file is injected into the JS execution context of the JS engine in the second bridge.

In an exemplary embodiment, before said invoking said JS function in said JS file that has been injected into the execution context of said JS engine based on said incoming name of said JS function and said invoking said parameter of said JS function, further comprises: injecting a first custom function into a JS execution context of the JS engine; based on afferent the name of JS function and calling the parameter of JS function, the call has been injected into in the execution context of the JS engine among the JS file, concrete implementation can include: through the first custom function, based on the incoming name of the JS function and the calling of the parameter of the JS function, the calling has been injected into the execution context of the JS engine among the JS files.

In this embodiment, a first custom function for calling the JS function, which is injected into the execution context of the JS engine, in the JS file based on the incoming name of the JS function and the call of the parameter of the JS function is provided. In implementation, the first custom function may be carried in an installation package of the application. The first custom function is also a JS function. Therefore, the first custom function can be timely injected into the JS execution context of the JS engine before the JS function in the JS file, which is injected into the execution context of the JS engine, is called for the subsequent time.

In implementation, a custom JS file can be carried in an installation package of an application, and the custom JS file contains a plurality of custom functions for realizing the custom function, for example, a first custom function. The method comprises the steps that a user-defined JS file is sent to a first bridge through a channel communicated with a native operating system in Flutter, the user-defined JS file is transmitted into a second bridge in the first bridge, and the user-defined JS file is injected into the JS execution context of a JS engine in the second bridge. Therefore, the corresponding function can be realized by executing the custom function in the custom JS file.

In an exemplary embodiment, the application program updating method may further include: initializing the second bridge in application program starting initialization; in the initialization process of the second bridge, injecting a second custom function into the JS execution context of the JS engine; sending the execution result of the JS function to the first bridge, where the specific implementation manner of the JS function may include: and returning the execution result of the JS function to the first bridge through the second custom function.

In this embodiment, in the process of starting initialization of the application program, the second bridge is initialized more timely. And providing a second custom function for returning the execution result of the JS function to the first bridge. In implementation, the second custom function may be carried in an installation package of the application. The second custom function is also a JS function. Therefore, the second custom function can be injected into the JS execution context of the JS engine in time during the initialization of the second bridge, so as to be called when the execution result of the JS function in the JS file is subsequently returned.

In an exemplary embodiment, the application program updating method may further include: and when the exit interface is detected, cleaning the JS file corresponding to the interface injected into the JS engine. Specifically, the name of the exit interface may be transferred to the first bridge in Flutter, the name of the exit interface may be transferred to the second bridge in the first bridge, and the JS file corresponding to the name of the exit interface may be set to be null in the second bridge. In implementation, the JS file corresponding to the name of the quit interface can be set to be null by customizing a third custom function in the JS file. Therefore, the memory can be recycled in time, and the occupation of the memory is reduced.

In an exemplary embodiment, the application program updating method may further include: JS executes the injected function in a context on a different thread than Flutter. That is, the thread where the function injected in the JS execution context is located (JS thread for short) is separated from the thread of Flutter, so that the interface jamming caused by the influence on the thread of Flutter is avoided.

It should be noted that the application program updating method according to the embodiment of the present invention may be carried in the installation package of the application program in the form of a component library. After the application program is installed, each time the application program is started, the component library can be initialized and the application program updating process can be started.

Illustratively, the component library may include three parts: a first bridge (Flutterbridge), a process manager (FairProcessManager), and a second bridge (JSbridge). The FairProcessManager can be used as an entrance and manages the whole application program updating process.

This is explained in more detail below with specific application scenarios.

in the iOS operating system, when an application based on Flutter is started, a start entry didfinishLanch may be called, a Flutter engine is registered in the didfinishLanch, and a component library (FairPlugin) for implementing the application update method provided by the embodiment of the present invention is initialized through Generated PluginRegistration (static registration), and the component library is implemented based on Fair. As shown in fig. 4, during initialization, the process manager is initialized first, and the entire process is started. The flow manager then initializes the first bridge and the second bridge. During the second bridge initialization, JScontext may be initialized, setData (i.e., the second custom function) may be injected, and the JS thread may be initialized.

In addition, a custom JS file (baseJS) is carried in the installation package of the application, and the custom JS file contains a plurality of custom functions, such as a first custom function.

When the logic of the interface needs to be updated, the code of the interface can be rewritten by adopting the programming language Dart of the Flutter, then the interception during the code AOT compilation is realized through the build _ runner + Analyzer component library of Dart based on Fair, and the intercepted product is generated into a DSL file and a corresponding JS file. And the server side issues the DSL file and the JS file to an application program of the iOS terminal.

And at the iOS terminal, realizing the dynamization of the interface and the corresponding logic of the Flutter based on the DSL file and the JS file. The dynamization of the user interface is achieved by parsing the DSL file into a recognizable grammar by Dart, which can then be executed by the runtime of Dart to generate the interface of Flutter. The logic dynamic corresponding to the user interface is realized as follows:

in the first bridge, a baseJS incoming flow manager to which Flutter is delivered through fluttrmethodchanel, and a JS file to which Flutter is delivered through fluttemethodchanel are transmitted into the flow manager.

And in the flow manager, based on a preset first bridging protocol, transmitting the baseJS and JS files into a second bridge.

In the second bridge, the baseJS and JS files are injected into JSContext.

In the first bridge connection, the name of the JS function in the JS file which is required to be executed by responding to the monitored interface event and is transmitted by the Flutter through the Flutter basicmessagechannel and the parameter required by calling the JS function are obtained, and the name and the parameter of the JS function are transmitted to the flow manager.

And in the flow manager, based on a preset first bridging protocol, transmitting the name and the parameters of the JS function into a second bridging interface so as to call the second bridging interface.

In the second bridge connection, the JS function injected in the JSCContext is called through the first custom function based on the name and the parameter of the JS function, the execution result of the JS function is transmitted into the second custom function to call the second custom function, and the second custom function returns the execution result of the JS function to the flow manager.

In the flow manager, based on a preset second bridge protocol, the first bridge interface is called to return the execution result of the JS Function to Flutter through fluttter basic message channel or FFI (external Function interface). Wherein the flutterbacicmessagechannel returns Flutter asynchronously. FFI is returned to Flutter in a synchronized manner.

The scheme supports the realization of the interface logic dynamic of the Flutter at the iOS terminal through the Fair component library, and the iOS developer accessing the Fair needs not to consider interaction scheme and logic, does not have extra adaptation work when developing the page through the Flutter, and only needs normal Flutter development because the Fair component library is realized, so that the use is convenient.

Fig. 5 is a schematic structural diagram of an exemplary application updating apparatus according to an embodiment of the present invention.

As shown in fig. 5, an application updating apparatus 500 according to an embodiment of the present invention includes:

a downloading module 501, configured to download, from a server, a JS file for performing logic update on the interface of Flutter;

the execution module 502 is configured to determine that the response is monitored, the JS function in the JS file needs to be executed in the event of the interface, and execute the JS function with the assistance of a JS engine carried by the operating system, where the JS function obtains an execution result of the JS function and returns Flutter to respond to the event.

In a possible implementation manner, the execution module is specifically configured to:

in a user-defined first bridge, determining the name of a JS function in the JS file which needs to be executed in response to the monitored event of the interface and the parameters needed for calling the JS function, and transmitting the name into a user-defined second bridge;

in the second bridge, calling the JS function in the JS file injected into the execution context of the JS engine based on the transmitted name of the JS function and the parameter for calling the JS function, and returning the execution result of the JS function to the first bridge;

and in the first bridge connection, returning the execution result of the JS function to Flutter.

In a possible embodiment, the execution module is specifically configured to inject a first custom function into the JS execution context of the JS engine before the JS function in the JS file that has been injected into the JS engine execution context is called based on the incoming name of the JS function and the parameter that calls the JS function; through the first custom function, based on the incoming name of the JS function and the calling of the parameter of the JS function, the calling has been injected into the execution context of the JS engine among the JS files.

In a possible implementation manner, the execution module is specifically configured to:

initializing the second bridge in application program starting initialization; in the initialization process of the second bridge, injecting a second custom function into the JS execution context of the JS engine;

and returning the execution result of the JS function to the first bridge through the second custom function.

In a possible implementation, the JS file is converted from an abstract syntax tree generated during code compilation of the interface of Flutter rewritten in the Flutter programming language.

The functions of each module in each device in the embodiments of the present invention may refer to the corresponding description in the above embodiment of the application program updating method, and are not described herein again.

Preferably, an embodiment of the present invention further provides an electronic device, including: the processor, the memory, and the computer program stored in the memory and capable of running on the processor, when executed by the processor, implement each process of the above-mentioned application program updating method embodiment, and can achieve the same technical effect, and are not described herein again to avoid repetition.

Fig. 6 is a schematic structural diagram of an exemplary electronic device provided in an embodiment of the present application. As shown in fig. 6, the electronic device may include: the system comprises a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602 and the memory 603 are communicated with each other through the communication bus 604. The processor 601 may call a computer program in the memory 603 to perform the application update method in any of the above embodiments.

The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when being executed by a processor, the computer program implements each process of the above-mentioned embodiment of the application program updating method, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.

While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.

In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.

The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于自然语言理解与转化的业务逻辑无代码开发方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!