Interface dynamic rendering method and device

文档序号:1904704 发布日期:2021-11-30 浏览:13次 中文

阅读说明:本技术 一种界面动态渲染方法及装置 (Interface dynamic rendering method and device ) 是由 甘泉 于 2021-09-08 设计创作,主要内容包括:本发明实施例提供了一种界面动态渲染方法及装置。其中,所述方法包括:获取界面代码,所述界面代码用于描述界面;若界面代码中包含脚本字符串,则执行所述脚本字符串,以在用于渲染界面的预设引擎中加载所述脚本字符串所表示的组件,得到加载有所述组件的预设引擎,其中,所述脚本字符串用于表示实现指定功能的组件;利用加载有所述组件的预设引擎渲染所述界面代码所描述的界面。可以使得用户能够根据实际需求对引擎进行定制,进而使用经过定制的引擎渲染得到符合不同需求的界面,使得界面渲染不再受限制于引擎,有效提高了引擎的适用性。(The embodiment of the invention provides a method and a device for dynamically rendering an interface. Wherein the method comprises the following steps: acquiring an interface code, wherein the interface code is used for describing an interface; if the interface code contains the script character string, executing the script character string to load the component represented by the script character string in a preset engine for rendering the interface to obtain the preset engine loaded with the component, wherein the script character string is used for representing the component for realizing the specified function; and rendering the interface described by the interface code by utilizing the preset engine loaded with the component. The engine can be customized according to actual requirements by a user, and then interfaces meeting different requirements are rendered by using the customized engine, so that the interface rendering is not limited by the engine any more, and the applicability of the engine is effectively improved.)

1. A method for dynamically rendering an interface, the method comprising:

acquiring an interface code, wherein the interface code is used for describing an interface;

if the interface code contains the script character string, executing the script character string to load the component represented by the script character string in a preset engine for rendering the interface to obtain the preset engine loaded with the component, wherein the script character string is used for representing the component for realizing the specified function;

and rendering the interface described by the interface code by utilizing the preset engine loaded with the component.

2. The method according to claim 1, wherein the interface code contains nesting information, and the nesting information is used for representing nesting relations between interface elements in the interface described by the interface code;

the rendering, by the update engine, the interface described by the interface code includes:

determining each interface element contained in the interface described by the interface code according to the interface code;

establishing nesting relations among all interface elements contained in the interface according to the nesting relations represented by the nesting information through a preset engine loaded with the components to obtain an interface template;

and loading each interface element contained in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code.

3. The method according to claim 2, wherein the interface code includes configuration information, the configuration information is used to indicate a loading manner of configured interface elements, and the configured interface elements are at least one interface element in the interface elements;

the obtaining the interface described by the interface code by loading each interface element included in the interface to the interface template by using the preset engine loaded with the component includes:

for each configured interface element, loading the configured interface element according to the loading mode of the configured interface element represented by the configuration information;

and for each unconfigured interface element, loading the unconfigured interface element according to the loading mode of a superior interface element of the unconfigured interface element, wherein the unconfigured interface element is an interface element which is not a configured interface element in each interface element, and the superior interface element is an interface element nested with the unconfigured interface element.

4. The method of claim 1, wherein prior to rendering the interface described by the interface code using the preset engine loaded with the component, the method further comprises:

carrying out hot updating on a preset engine;

the rendering the interface described by the interface code by using the preset engine loaded with the component comprises the following steps:

rendering the interface described by the interface code by using the preset engine loaded with the component and subjected to the hot update.

5. The method of claim 1, wherein an object declared in the script string is declared as a global object in the preset engine loaded with the component.

6. An apparatus for dynamically rendering an interface, the apparatus comprising:

the data acquisition module is used for acquiring an interface code, and the interface code is used for describing an interface;

the script execution module is used for executing the script character string if the interface code contains the script character string so as to load the component represented by the script character string in a preset engine used for rendering an interface to obtain the preset engine loaded with the component, wherein the script character string is used for representing the component for realizing a specified function;

and the interface rendering module is used for rendering the interface described by the interface code by utilizing the preset engine loaded with the component.

7. The apparatus according to claim 7, wherein the interface code includes nesting information, and the nesting information is used to represent nesting relationships between objects in the interface described by the interface code;

the interface rendering module renders the interface described by the interface code by using the update engine, and comprises:

determining each interface element contained in the interface described by the interface code according to the interface code;

establishing nesting relations among all interface elements contained in the interface according to the nesting relations represented by the nesting information through a preset engine loaded with the components to obtain an interface template;

and loading each interface element contained in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code.

8. The apparatus according to claim 7, wherein the interface code includes configuration information, the configuration information is used to indicate a loading manner of a configured interface element in each interface element, and the configured interface element is at least one interface element in each interface element;

the interface rendering module loads each interface element included in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code, and the method includes:

for each configured interface element, loading the configured interface element according to the loading mode of the configured interface element represented by the configuration information;

and for each unconfigured interface element, loading the unconfigured interface element according to the loading mode of a superior interface element of the unconfigured interface element, wherein the unconfigured interface element is an interface element which is not a configured interface element in each interface element, and the superior interface element is an interface element nested with the unconfigured interface element.

9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;

a memory for storing a computer program;

a processor for implementing the method steps of any one of claims 1 to 5 when executing a program stored in the memory.

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

Technical Field

The invention relates to the technical field of interface rendering, in particular to a method and a device for dynamically rendering an interface.

Background

The application program may need to set different interfaces according to different actual requirements, for example, an application program for viewing videos needs to set different User interfaces (User interfaces, hereinafter simply referred to as interfaces) according to the videos recommended to be viewed because the videos recommended to be viewed at different periods are different.

In the related art, a developer can develop different interfaces according to different requirements based on an engine for interface rendering, but on one hand, functions which can be provided by the engine are often limited, and various different actual requirements cannot be met. On the other hand, if the engine provides a large number of functions, the development and operation and maintenance costs of the engine are high.

Therefore, the rendered interface may be difficult to meet the actual requirements due to the limitation of the engine in the related art.

Disclosure of Invention

The embodiment of the invention aims to provide a method and a device for dynamically rendering an interface so as to improve the applicability of an engine. The specific technical scheme is as follows:

in a first aspect of the present invention, there is provided a method for dynamically rendering an interface, the method including:

acquiring an interface code, wherein the interface code is used for describing an interface;

if the interface code contains the script character string, executing the script character string to load the component represented by the script character string in a preset engine for rendering the interface to obtain the preset engine loaded with the component, wherein the script character string is used for representing the component for realizing the specified function;

and rendering the interface described by the interface code by utilizing the preset engine loaded with the component.

In a possible embodiment, the interface code includes nesting information, and the nesting information is used for representing nesting relations among interface elements in an interface described by the interface code;

the rendering, by the update engine, the interface described by the interface code includes:

determining each interface element contained in the interface described by the interface code according to the interface code;

establishing nesting relations among all interface elements contained in the interface according to the nesting relations represented by the nesting information through a preset engine loaded with the components to obtain an interface template;

and loading each interface element contained in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code.

In a possible embodiment, the interface code includes configuration information, where the configuration information is used to indicate a loading manner of a configured interface element, and the configured interface element is at least one interface element in each interface element;

the obtaining the interface described by the interface code by loading each interface element included in the interface to the interface template by using the preset engine loaded with the component includes:

for each configured interface element, loading the configured interface element according to the loading mode of the configured interface element represented by the configuration information;

and for each unconfigured interface element, loading the unconfigured interface element according to the loading mode of a superior interface element of the unconfigured interface element, wherein the unconfigured interface element is an interface element which is not a configured interface element in each interface element, and the superior interface element is an interface element nested with the unconfigured interface element.

In a possible embodiment, the rendering, with the component, the interface described by the interface code includes:

and rendering the interface described by the interface code by using a preset engine loaded with the component, wherein the preset engine is an interface rendering engine of a real Native framework.

In a possible embodiment, before the rendering the interface described by the interface code by using the preset engine loaded with the component, the method further includes:

carrying out hot updating on a preset engine;

the rendering the interface described by the interface code by using the preset engine loaded with the component comprises the following steps:

rendering the interface described by the interface code by using the preset engine loaded with the component and subjected to the hot update.

In a possible embodiment, the object declared in the script string is declared as a global object in the preset engine loaded with the component. .

In a second aspect of the present invention, there is also provided an interface dynamic rendering apparatus, including:

the data acquisition module is used for acquiring an interface code, and the interface code is used for describing an interface;

the script execution module is used for executing the script character string if the interface code contains the script character string so as to load the component represented by the script character string in a preset engine used for rendering an interface to obtain the preset engine loaded with the component, wherein the script character string is used for representing the component for realizing a specified function;

and the interface rendering module is used for rendering the interface described by the interface code by utilizing the preset engine loaded with the component.

In a possible embodiment, the interface code includes nesting information, where the nesting information is used to represent a nesting relationship between objects in an interface described by the interface code;

the interface rendering module renders the interface described by the interface code by using the update engine, and comprises:

determining each interface element contained in the interface described by the interface code according to the interface code;

establishing nesting relations among all interface elements contained in the interface according to the nesting relations represented by the nesting information through a preset engine loaded with the components to obtain an interface template;

and loading each interface element contained in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code.

In a possible embodiment, the interface code includes configuration information, where the configuration information is used to indicate a loading manner of a configured interface element in each interface element, and the configured interface element is at least one interface element in each interface element;

the interface rendering module loads each interface element included in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code, and the method includes:

for each configured interface element, loading the configured interface element according to the loading mode of the configured interface element represented by the configuration information;

and for each unconfigured interface element, loading the unconfigured interface element according to the loading mode of a superior interface element of the unconfigured interface element, wherein the unconfigured interface element is an interface element which is not a configured interface element in each interface element, and the superior interface element is an interface element nested with the unconfigured interface element.

In a possible embodiment, the apparatus further includes a hot update module, configured to perform hot update on the preset engine;

the rendering the interface described by the interface code by using the preset engine loaded with the component comprises the following steps:

rendering the interface described by the interface code by using the preset engine loaded with the component and subjected to the hot update.

In a possible embodiment, the object declared in the script string is declared as a global object in the preset engine loaded with the component.

In yet another aspect of the present invention, there is further provided a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements any one of the above-mentioned interface dynamic rendering methods.

In yet another aspect of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the above described methods for dynamic rendering of an interface.

According to the interface dynamic rendering method and device provided by the embodiment of the invention, the components represented by the script character strings are loaded in the preset engine for rendering the interface in a mode that the script character strings are carried in the interface codes, so that the components in the engine can be dynamically adjusted in the interface rendering process, a user can customize the engine according to actual requirements, and then the customized engine is used for rendering to obtain the interface meeting different requirements, so that the interface rendering is not limited by the engine any more, and the applicability of the engine is effectively improved.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.

Fig. 1 is a schematic flowchart of a method for dynamically rendering an interface according to an embodiment of the present invention;

FIG. 2 is a flow chart illustrating an engine hot-update method according to an embodiment of the present invention;

fig. 3 is a schematic diagram of a system architecture of a default engine according to an embodiment of the present invention;

fig. 4 is a schematic structural diagram of an interface dynamic rendering apparatus according to an embodiment of the present invention;

fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.

Referring to fig. 1, fig. 1 is a schematic flow chart of a method for dynamically rendering an interface according to an embodiment of the present invention, which may include:

and S101, acquiring an interface code.

And S102, if the interface code contains the script character string, executing the script character string to load the component represented by the script character string in a preset engine for rendering the interface to obtain the preset engine loaded with the component.

And S103, rendering the interface described by the interface code by using the preset engine loaded with the component.

By adopting the embodiment, the components represented by the script character strings are loaded in the preset engine for rendering the interface in a mode of carrying the script character strings in the interface codes, so that the components in the engine can be dynamically adjusted in the interface rendering process, a user can customize the engine according to actual requirements, and then the customized engine is used for rendering to obtain the interfaces meeting different requirements, so that the interface rendering is not limited by the engine any more, and the applicability of the engine is effectively improved.

For example, assuming that an engine a is used to render a user interface in a 1.0 version of an application, and as a user requirement expands, a function supported by the engine a gradually fails to meet the user requirement, in the related art, a developer may upgrade the engine a, assume that the upgraded engine is an engine B, and use the engine B to render the user interface in a 2.0 version of the application.

If the application provider needs to adaptively update the user interface of the user according to the developed activities, the developer can write interface codes for describing the updated user interface, the interface codes are pushed to the user terminal provided with the application through the server, and the user terminal analyzes and executes the interface codes through an engine in the application to render the interface described by the interface codes, so that the user interface is updated.

However, because of the difference between engine a and engine B, the same interface code cannot be applied to engine a and engine B. And part of users may use the application of version 1.0, and another part of users may use the application of version 2.0, so developers need to write interface codes for engine a and engine B separately, resulting in high cost.

If the interface dynamic rendering method provided by the embodiment of the invention is selected, if the functions supported by the engine A can not meet the requirements of the user, the user can add script character strings in the written interface code, and the user terminal can load the components represented by the script character strings into the engine a according to the script character strings when receiving the interface code, so as to obtain the engine a (hereinafter referred to as engine C) loaded with the components, since engine C is additionally loaded with new components, compared to engine a, engine C has more functions than engine a, thereby meeting the actual requirements of users, even along with the expansion of the requirements of users, developers do not need to upgrade the engine A, that is, the engine a can still be applied to the 2.0 version of the application, so that the high cost caused by the fact that developers write interface codes respectively for different engines can be avoided.

Moreover, even in a scenario where the 1.0 version of the application uses the engine a and the 2.0 version of the application uses the engine B, the developer may add the script string based on the interface code written for the engine B, so that after the user terminal receives the interface code, the user terminal may load the components represented by the script string in the engine a according to the script string, and the components are used to enable the engine a to have the capability of normally parsing and running the interface code, so that the developer does not need to rewrite the interface code for the engine a, and can reuse the interface code written for the engine B to the greatest extent, thereby reducing the cost.

In S101, the interface code is used to describe an interface, and according to different application scenarios, the interface code may be a code written in different languages that can be used to describe the interface, and for example, the interface code may be a code written in any one of the following languages, including but not limited to: JSON, XML, HTML. And the voice used by the interface code should be a language supported by the preset engine for rendering the interface, and for example, the preset engine for rendering the interface supports an XML language, the interface code may be a code written by using the XML language.

The interface code contains script character strings which are used for expressing components for realizing specified functions. The interface code may or may not include a script string. The language used for the script string may be any scripting language, and the scripting language used for the script should theoretically be consistent with the programming language used by the preset engine used for rendering the interface. For example, the programming language used by the engine may be JavaScript, and then the script string may be a string written using the JavaScript language, and for example, the programming language used by the engine may be PHP, and then the script string may be a string written using the PHP language.

The interface code may be read from a preset storage medium by the execution main body, or may be sent to the execution main body by a device other than the execution main body. For example, taking the execution subject as the user end device as an example, the user end device may read the interface code from a preset storage medium, such as a usb disk accessed to the user end device, a hard disk disposed in the user end device, and the like, and the user end device may also receive the interface code sent by the server end device through the network.

The component represented by the script string may be one or more, and the set of the function implemented by the component and the function possessed by the preset engine should include all the functions required for rendering the interface described by the interface code, for example, if the preset engine does not have a function of rendering an entry having complex interaction and business logic and the interface described by the interface code includes the entry, the component may at least implement the function of rendering the entry. For another example, assuming that the preset engine does not have the capability to render the entry, and the interface described by the interface code does not include the entry, the component may not have the function to render the entry.

The framework on which the components represented by the script strings are based should be theoretically the same as the framework on which the engine is based, and for convenience of description, the script strings may be used to represent the components written based on the real Native framework, assuming that the engine is an engine based on the real Native framework. The script string can be a simplified JavaScript code generated by a packaging tool of real Native and obtained by character escape, so that the script string can be contained in a double quotation mark without generating JSON syntax errors.

In S102, the script character string may be parsed from the interface code, and the parsed script character string may be executed. For example, the eval function execution script string may be called, and in other possible embodiments, other function execution script strings having the capability of executing the script string may be called.

Executing the script string loads the component represented by the script string in a preset engine for rendering the interface. The component may be composed of one or more functional functions, and the engine may implement the function that the component is configured to implement by calling the functional functions when rendering the interface, for example, assuming that the component is configured to render a specific style of window in the interface and the interface code describes the interface including the specific style of window, and the engine may call the functions that compose the component to render the specific style of window when rendering the interface described by the interface code.

It will be appreciated that a function needs to be declared before it is called, and that a component is made up of function functions and therefore needs to be declared before it is used. In one possible embodiment, components may be declared in local objects, as well as in global objects. The scope of a component will vary depending on the manner in which the component is declared, but whether the component is declared in a local object or in a global object, the scope of the component should contain the code scope that the component is to be called upon.

In one possible embodiment, to maximize the scope of the components represented by the script string, the components represented by the script string may be declared in a specified global object. Illustratively, this may be shown in the following code:

export DemoCard component after module, export DemoCard/script string execution

global [ '_ qyrn _ js _ card _' ], { … global [ '_ qyrn _ js _ card _' ], DemoCard }/the component DemoCard is declared in the global object qyrn _ js _ card.

In S103, in the process of rendering the interface described by the interface code, the components represented by the script string may be called, so as to render the interface described by the interface code through the functions that the components are configured to implement.

Because the components can be loaded for the preset engine in the interface rendering process in a mode of carrying the script character strings in the interface codes, the engine can have the functions which are configured and realized by the components, namely, the components with different functions can be dynamically loaded for the engine in the rendering process according to the actual requirements, so that the limitation of the engine function is avoided, and the interface meeting different actual requirements can be rendered.

In order to more clearly describe the interface dynamic rendering method provided by the embodiment of the present invention, the following description will be made on an interface code:

in a possible embodiment, the interface code may further include a nesting relationship, and the nesting relationship is used for representing the nesting relationship between interface elements in the interface described by the interface code.

The nested relationship between the interface elements can be regarded as a membership relationship between the interface elements, for example, assuming that the interface element "window 1" is a child window in the interface element "window 2", the interface element "window 1" is nested in the interface element "window 2".

The representation form of the nested relationship may be different according to different application scenarios, for example, in one possible embodiment, the nested relationship may be represented in a tree structure, each node in the tree structure is used to represent an interface element, and the interface element represented by any node in the tree structure is nested in the interface element represented by the parent node of the node. For example, suppose node a, node B, and node C are included in the tree structure, and node a represents interface element a, node B represents interface element B, and node C represents interface element C, if node B is a child node of node a and node C is a child node of node B in the tree structure, the tree structure represents that interface element B is nested in interface element a, and interface element C is nested in interface element B.

When the interface described by the interface code is rendered by using the preset engine loaded with the component, each interface element included in the interface described by the interface code may be determined according to the interface code, and the nesting relationship between each interface element included in the interface is established according to the nesting relationship indicated by the nesting information by using the preset engine loaded with the component, so as to obtain the interface template. And loading each interface element contained in the interface to the interface template by using the preset engine loaded with the component to obtain the interface described by the interface code.

It can be understood that the interface template only includes the nesting relationship between the interface elements and does not include the interface elements, and therefore after the interface template is obtained, each interface element included in the interface needs to be loaded to the interface template by using the preset engine loaded with the component, the obtained interface includes each interface element, and the nesting relationship between each included interface element is the same as the relationship in the interface template.

By adopting the embodiment, all objects in the interface can be freely combined according to actual requirements through the nesting relation among the objects, so that the interface style is enriched, and developers can flexibly design the interface according to the actual requirements.

In another possible embodiment, the interface code may further include configuration information, where the configuration information is used to indicate a loading manner of the configured interface element, and the configured interface element is at least one interface element in each interface element.

When each interface element included in the interface is loaded to the interface template by using the preset engine loaded with the component to obtain the interface described by the interface code, the configured interface element can be loaded according to the loading mode of the configured interface element represented by the configured information for each configured interface element.

And for each unconfigured interface element, loading the unconfigured interface element according to the loading mode of a superior interface element of the unconfigured interface element, wherein the unconfigured interface element is an interface element which is not a configured interface element in each interface element, and the superior interface element is an interface element nested with the unconfigured interface element.

The configured interface element may be one interface element in the interface described by the interface code, or may be multiple interface elements in the interface, and the configured interface element may be a part of elements in the interface, or may be all elements in the interface.

For example, if the interface includes 3 interface elements, which are respectively denoted as interface element a, interface element B, and interface element C, if the configured interface element only includes interface element a, interface element B, and interface element C, interface element B and interface element C are unconfigured interface elements. Moreover, in the embodiment of the present invention, if an interface element is not nested in other interface elements, the configured interface element should at least include the interface element, and for example, assuming that the interface element B is nested in the interface element a, the interface element C is nested in the interface element B, and the interface element a is not nested in other elements, the configured interface element should at least include the interface element a.

For a configured interface element, since the configuration information already indicates the loading manner of the configured interface element, it may be considered that the user wishes to load the configured interface element according to the loading manner configured by the user, that is, the configured interface element is described according to the loading manner of the configured interface element indicated by the configuration information.

For an unconfigured interface element, since the configuration information does not indicate the loading mode of the unconfigured interface element, it can be considered that the user does not configure the loading mode for the unconfigured interface element, and therefore the unconfigured interface element can be loaded along with the loading mode of the superior interface element of the unconfigured interface element.

For example, assuming that the interface described by the interface code includes three interface elements in total, which are respectively denoted as an interface element a, an interface element B, and an interface element C, and the interface element B is nested in the interface element a, and the interface element C is nested in the interface element B, then the interface element a is an upper interface element of the interface element B in this example, and the interface element B is an upper interface element of the interface element C.

Assume that the interface element a and the interface element B are configured interface elements, the interface element C is not configured interface element C, the loading mode of the interface element a indicated by the configuration information is loading mode 1, and the loading mode of the interface element B indicated by the configuration information is loading mode 2.

Loading the interface element A according to the loading mode 1, loading the interface element B according to the loading mode 2, and loading the interface element C according to the loading mode 2. It is understood that, because the interface element a and the interface element B are loaded in different manners, in one possible embodiment, the interface element a and the interface element B may be loaded separately. In another possible embodiment, the interface element a and the interface element B may also be loaded according to the loading mode 1, and then the interface element B is adjusted according to the difference between the loading mode 1 and the loading mode 2, so as to implement loading of the interface element B according to the loading mode 2.

By adopting the embodiment, inheritance (such as the interface element B and the interface element C) and coverage (such as the interface element A and the interface element B) of configuration information can be realized, and a loading mode is flexibly multiplexed among the interface elements, so that the data volume of interface codes is effectively reduced.

In the interface dynamic rendering method provided by the embodiment of the invention, the preset engine used for rendering the interface may be different according to different application scenes, and may be, for example, an interface rendering engine based on a real Native framework.

The fact Native framework is a framework based on JavaScript language, and the IOS system and the Android system are provided with JavaScript language interfaces, so that the preset engine based on the fact Native framework can be applied to the IOS system and the Android system, different engines do not need to be developed for the IOS system and the Android system, the applicability of the engine is further improved, and the development, operation and maintenance cost of the engine is reduced.

Moreover, it can be understood that the component represented by loading the script string in the preset engine may be regarded as updating the preset engine, and in some application scenarios, the preset engine needs to be restarted after being updated, so that the preset engine is updated by the application, that is, the preset engine is updated in the application scenarios in a cold update manner. Cold updates will result in a reduction in the efficiency of interface rendering due to the time it takes to restart the engine.

And if the preset engine is an engine based on the real Native framework, the JavaScript language based on the real Native framework does not need to be compiled, is interpreted and executed, and can dynamically load and execute the JS codes during running, so that the preset engine developed based on the JavaScript language and the real Native framework can be updated thermally, and in other possible embodiments, the preset engine is loaded. The principle of thermal update may be referred to fig. 2, and fig. 2 is a schematic flow chart of a thermal update method provided by an embodiment of the present invention, which may include:

s201, starting the application program.

The application program is an application program that needs interface rendering, and the application program may refer to different application programs according to different application scenes, such as an application program for watching videos, an application program for reading books, and the like.

S202, the application program requests a hot update interface from the interface server.

S203, the interface server sends the RN Patch list to the application.

The RN Patch list comprises one or more RN patches, and each RN Patch is a data packet obtained by packaging part of the code of the engine. And, each RN Patch corresponds to a version number for indicating an engine version of an engine to which the code contained in the RN Patch belongs.

And S204, the application program determines the RN Patch which needs to be updated according to the RN Patch list and the preset engine loaded by the application program.

The RN Patch list with the version number consistent with the version of the preset engine loaded in the application program may be screened out from the RN Patch list according to the version of the preset engine loaded in the application program and the version number corresponding to each RN Patch in the RN Patch list, and the remaining RN patches may be used as the RN patches required to be updated.

S205, the application downloads the RN Patch that needs to be updated from the content distribution network.

In one possible embodiment, to reduce the time taken to download, the application may be a multi-threaded concurrent download of the RN Patch that needs to be updated.

S206, the content distribution network returns the RN Patch which needs to be updated to the application program.

It should be understood that fig. 2 is only a flowchart of an engine hot update method provided in an embodiment of the present invention, and in other possible embodiments, the RN Patch that needs to be updated may not be stored in the content distribution network, which is not limited in this embodiment.

And S207, the application program performs signature verification on the RN Patch returned by the content distribution network, if the RN Patch passes the signature verification, S209 is executed, and if the RN Patch does not pass the signature verification, S208 is executed.

The signature may be obtained by encrypting the digest of the RN Patch with the first key of the interface server described above before being distributed to the content distribution network, and the application may encrypt the digest of the RN Patch with a second key local to the application, and if the encrypted ciphertext matches the signature of the RN Patch, it is confirmed that the RN Patch passes the signature check, and if the encrypted ciphertext does not match the signature of the RN Patch, it is confirmed that the RN Patch does not pass the signature check. The first key and the second key are the same key, or may be both keys in a pair of asymmetric keys.

S208, the application program deletes the RN Patch.

If the RN Patch fails the signature check, the RN Patch may be considered to be less secure and may be deleted.

S209, the application program decompresses the RN Patch to the temporary directory of the application program

In this embodiment, to ensure that the complete file is obtained by decompression, the RN Patch may be first decompressed to a preset temporary directory.

S210, the application transfers the decompressed RN Patch from the temporary directory to the final directory.

After the RN Patch is determined to be completely decompressed, the decompressed files in the temporary directory are transferred to the final directory, so that the final directory is ensured to have the complete files.

S211, the application program stores the corresponding relation of the latest jsbundle version in each service aspect in user preference in a persistent mode.

The corresponding relation is stored persistently, so that when the checking and updating are started again, the jsbundle version of the local cache can be conveniently and quickly inquired from user preferences according to the corresponding relation so as to judge whether the updating is needed.

By adopting the embodiment, the hot update of the preset engine can be realized, so that the engine is restarted with time consumption, and the interface rendering efficiency can be effectively improved.

In some application scenarios, an application may be used to implement multiple different services, so that a preset engine in the application undertakes multiple different services, for example, referring to fig. 3, fig. 3 is a schematic diagram of a system architecture of the preset engine provided in the embodiment of the present invention, and it can be seen from fig. 3 that the preset engine undertakes multiple services such as a special page service, a channel page service, and a single page playing service.

The implementation of different services may depend on each other, for example, the implementation of a special page service may depend on the implementation of a channel page service, and if the implementation of the channel page service needs to be changed, the implementation of the special page service needs to be adaptively modified, that is, the implementation of one service among a plurality of services needs to be changed, and the implementation of other services may need to be adaptively modified, which makes it difficult to customize the implementation of a specific service.

Based on this, in one possible embodiment, the implementation of each Service in the preset engine may be injected into the global object, for example, in one possible embodiment, the preset engine may abstract the core class into pages, items, elements, components and services 5 categories, each category allows one or more implementations to be registered below and gives a unique name, the preset engine, when starting, injects the implementation required by each Service into a globally-referenceable object, and the mutual reference between the implementations needs to be obtained through the globally-referenceable object and the name of the implementation, so that the decoupling between the classes is realized, and the specific implementation classes under each category may be multiplexed, replaced or clipped.

By adopting the embodiment, on one hand, the decoupling among the services is realized, developers can highly customize and change specific services according to actual requirements, on the other hand, codes can be repeatedly multiplexed among the services, and the data volume of the preset engine is reduced.

Referring to fig. 4, fig. 4 is a schematic structural diagram of an interface dynamic rendering apparatus according to an embodiment of the present invention, which may include:

a data obtaining module 401, configured to obtain an interface code, where the interface code is used to describe an interface;

a script execution module 402, configured to execute a script character string if the interface code includes the script character string, so as to load a component represented by the script character string in a preset engine for rendering an interface, to obtain the preset engine loaded with the component, where the script character string is used to represent a component for implementing a specified function;

and an interface rendering module 403, configured to render the interface described by the interface code by using the preset engine loaded with the component.

In a possible embodiment, the interface code includes nesting information, where the nesting information is used to represent a nesting relationship between objects in an interface described by the interface code;

the interface rendering module 403 renders the interface described by the interface code by using the update engine, including:

determining each interface element contained in the interface described by the interface code according to the interface code;

establishing nesting relations among all interface elements contained in the interface according to the nesting relations represented by the nesting information through a preset engine loaded with the components to obtain an interface template;

and loading each interface element contained in the interface to the interface template by using a preset engine loaded with the component to obtain the interface described by the interface code.

In a possible embodiment, the interface code includes configuration information, where the configuration information is used to indicate a loading manner of a configured interface element in each interface element, and the configured interface element is at least one interface element in each interface element;

the interface rendering module 403 loads each interface element included in the interface to the interface template by using the preset engine loaded with the component, to obtain the interface described by the interface code, where the interface includes:

for each configured interface element, loading the configured interface element according to the loading mode of the configured interface element represented by the configuration information;

and for each unconfigured interface element, loading the unconfigured interface element according to the loading mode of a superior interface element of the unconfigured interface element, wherein the unconfigured interface element is an interface element which is not a configured interface element in each interface element, and the superior interface element is an interface element nested with the unconfigured interface element.

In a possible embodiment, the apparatus further includes a hot update module, configured to perform hot update on the preset engine;

the rendering the interface described by the interface code by using the preset engine loaded with the component comprises the following steps:

rendering the interface described by the interface code by using the preset engine loaded with the component and subjected to the hot update.

In a possible embodiment, the object declared in the script string is declared as a global object in the preset engine loaded with the component.

An embodiment of the present invention further provides an electronic device, as shown in fig. 5, which includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, where the processor 501, the communication interface 502 and the memory 503 complete mutual communication through the communication bus 504,

a memory 503 for storing a computer program;

the processor 501, when executing the program stored in the memory 503, implements the following steps:

acquiring an interface code, wherein the interface code is used for describing an interface; if the interface code contains the script character string, executing the script character string to load the component represented by the script character string in a preset engine for rendering the interface to obtain the preset engine loaded with the component, wherein the script character string is used for representing the component for realizing the specified function; and rendering the interface described by the interface code by utilizing the preset engine loaded with the component.

The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.

The communication interface is used for communication between the terminal and other equipment.

The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.

The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.

In another embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the interface dynamic rendering method described in any of the above embodiments.

In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method for dynamically rendering an interface as described in any of the above embodiments.

In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.

It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 identical elements in a process, method, article, or apparatus that comprises the element.

All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the apparatus, the electronic device, the computer-readable storage medium, and the computer program product, since they are substantially similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.

The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

17页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:视频分类方法、装置、电子设备及存储介质

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!