CN113961279A - Page rendering method, device, server and storage medium - Google Patents

Page rendering method, device, server and storage medium Download PDF

Info

Publication number
CN113961279A
CN113961279A CN202010697457.8A CN202010697457A CN113961279A CN 113961279 A CN113961279 A CN 113961279A CN 202010697457 A CN202010697457 A CN 202010697457A CN 113961279 A CN113961279 A CN 113961279A
Authority
CN
China
Prior art keywords
component
page
target
rendering
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010697457.8A
Other languages
Chinese (zh)
Inventor
杨子聪
曾庆宇
梁沁
张裕钦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010697457.8A priority Critical patent/CN113961279A/en
Publication of CN113961279A publication Critical patent/CN113961279A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis

Abstract

The disclosure provides a page rendering method, a page rendering device, a server and a storage medium, and belongs to the technical field of software development. The method comprises the following steps: determining a target rendering frame and a first page component corresponding to a target page to be rendered; converting the first page component into a second page component through a grammar interpreter corresponding to the target rendering frame, wherein the second page component is a page component which can be run by the target rendering frame; determining an interface protocol of the target rendering framework, wherein the interface protocol is used for recording a component interface of a basic component used by the target rendering framework; and operating the second page component according to the interface protocol to obtain a target page, and generating the page component of the version corresponding to the rendering frame only by converting the first page component through the syntax interpreter, so that the page component does not need to be rewritten for the target rendering frame, the workload of page developers is reduced, and the development efficiency is improved.

Description

Page rendering method, device, server and storage medium
Technical Field
The present disclosure relates to the field of software development technologies, and in particular, to a page rendering method, an apparatus, a server, and a storage medium.
Background
With the development of software development technology, various applications are developed endlessly, and pages containing different information can be rendered in the applications, so that different information is presented to users. With the continuous development of the application programs, developers of the application programs generally use a self-selected rendering framework for page rendering.
In the related technology, when a developer develops a page, the developer needs to write a page component library corresponding to a rendering frame according to the selected rendering frame, so that when the page is rendered, page components in the page component library corresponding to the rendering frame can be referred to realize page rendering, and a target page is obtained.
In the related art, because different rendering frames use different development languages, when a page containing the same information needs to be rendered in multiple application programs, a set of page components corresponding to the page needs to be written for the rendering frames corresponding to the different application programs, which is tedious to operate and results in a long development period of the application programs.
Disclosure of Invention
The embodiment of the disclosure provides a page rendering method, a page rendering device, a server and a storage medium, which can simplify the page development process and shorten the development period of an application program. The technical scheme is as follows:
in one aspect, a method for rendering a page is provided, and the method includes:
determining a target rendering frame corresponding to a target page to be rendered, and determining a first page component of the target page to be rendered, wherein the first page component is a page component written by a specified development language;
converting the first page component into a second page component through a grammar interpreter corresponding to the target rendering frame, wherein the second page component is a page component which can be run by the target rendering frame;
determining an interface protocol of the target rendering framework, wherein the interface protocol is used for recording a component interface of a basic component used by the target rendering framework;
and operating the second page component according to the interface protocol to obtain the target page.
In one possible implementation, the converting, by the syntax interpreter corresponding to the target rendering frame, the first page component into a second page component includes:
converting, by the grammar interpreter, the first page component into a grammar tree object, the first page component including a plurality of first base components;
modifying the component attribute and the style text of each first basic component in the syntax tree object through the syntax interpreter to obtain a plurality of second basic components;
and composing the plurality of second base components into the second page component.
In another possible implementation manner, the modifying, by the syntax interpreter, the component attribute and the style text of each first base component in the syntax tree object to obtain a plurality of second base components includes:
for each first base component in a syntax tree object, converting, by the syntax interpreter, a first component attribute of the first base component into a second component attribute, and converting a first style text of the first base component into a second style text, where the second component attribute is a component attribute readable by the target rendering frame, and the second style text is a style text readable by the target rendering frame;
and generating the second basic component according to the second component attribute and the second style text.
In another possible implementation manner, the converting, by the grammar interpreter, the first component attribute of the first base component into the second component attribute, and the converting the first style text of the first base component into the second style text includes:
calling a first corresponding relation between a first component attribute and a second component attribute of a base component in the grammar interpreter; converting the first component attribute of the first base component into the second component attribute according to the first corresponding relation and the first component attribute of the first base component;
calling a second corresponding relation between the first style text and the second style text of the base component in the grammar interpreter; and converting the first style text of the first base component into the second style text according to the second corresponding relation and the first style text of the first base component.
In another possible implementation manner, the operating the second page component according to the interface protocol to obtain the target page includes:
determining each second base component that the second page component comprises;
calling a component interface of each second basic component according to the interface protocol;
rendering a page display effect corresponding to each second basic component according to the component interface of each second basic component;
and rendering each second basic component based on the page display effect corresponding to each second basic component to obtain the target page.
In another possible implementation manner, the invoking the component interface of each second base component according to the interface protocol includes:
determining a component interface of each second base component from a component adaptation layer according to the interface protocol; calling the component interface; the component adaptation layer comprises a corresponding relation between a component interface of a third basic component and a component interface adapted to the target rendering framework, and the third basic component is a basic component in a basic component library based on a specified development language.
In another possible implementation manner, before determining the component interface of each second base component from the component adaptation layer according to the interface protocol, the method further includes:
determining the basic component library;
for each appointed rendering frame, determining a component interface of each third basic component in the basic component library under the rendering frame according to the development language of the rendering frame;
determining the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame according to the component interface adapted to each rendering frame and the component interface of the third basic component in the component library respectively;
and generating a component adaptation layer of the rendering frame according to the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame.
In another aspect, an apparatus for rendering a page is provided, the apparatus including:
the system comprises a first determining module, a second determining module and a display module, wherein the first determining module is used for determining a target rendering frame corresponding to a target page to be rendered and determining a first page component of the target page to be rendered, and the first page component is a page component written by a specified development language;
the conversion module is used for converting the first page component into a second page component through a grammar interpreter corresponding to the target rendering frame, and the second page component is a page component which can be run by the target rendering frame;
a second determining module, configured to determine an interface protocol of the target rendering framework, where the interface protocol is used to record a component interface of a base component used by the target rendering framework;
and the operation module is used for operating the second page component according to the interface protocol to obtain the target page.
In one possible implementation, the conversion module includes:
a conversion unit, configured to convert, by the syntax interpreter, the first page component into a syntax tree object, where the first page component includes a plurality of first base components;
the modification unit is used for modifying the component attribute and the style text of each first basic component in the syntax tree object through the syntax interpreter to obtain a plurality of second basic components;
a composing unit configured to compose the plurality of second base components into the second page component.
In another possible implementation manner, the modifying unit includes:
the transformation module is used for transforming the first component attribute of the first basic component into a second component attribute through the grammar interpreter and transforming the first style text of the first basic component into a second style text for each first basic component in a grammar tree object, wherein the second component attribute is a component attribute which can be read by the target rendering frame, and the second style text is a style text which can be read by the target rendering frame;
and the generating subunit is used for generating the second basic component according to the second component attribute and the second style text.
In another possible implementation manner, the transformation subunit is configured to invoke a first correspondence between a first component attribute and a second component attribute of a base component in the syntax interpreter; converting the first component attribute of the first base component into the second component attribute according to the first corresponding relation and the first component attribute of the first base component; calling a second corresponding relation between the first style text and the second style text of the base component in the grammar interpreter; and converting the first style text of the first base component into the second style text according to the second corresponding relation and the first style text of the first base component.
In another possible implementation manner, the execution module includes:
a determining unit, configured to determine each second base component included in the second page component;
the calling unit is used for calling the component interface of each second basic component according to the interface protocol;
the rendering unit is used for rendering the page display effect corresponding to each second basic component according to the component interface of each second basic component; and rendering each second basic component based on the page display effect corresponding to each second basic component to obtain the target page.
In another possible implementation manner, the invoking unit is configured to determine, according to the interface protocol, a component interface of each second base component from a component adaptation layer; calling the component interface; the component adaptation layer comprises a corresponding relation between a component interface of a third basic component and a component interface adapted to the target rendering framework, and the third basic component is a basic component in a basic component library based on a specified development language.
In another possible implementation manner, the apparatus further includes:
a third determination module for determining the base component library;
a fourth determining module, configured to determine, for each specified rendering frame, a component interface of each third basic component in the basic component library under the rendering frame according to a development language of the rendering frame;
a fifth determining module, configured to determine, according to the component interface adapted to each rendering frame and the component interface of the third basic component in the component library, a corresponding relationship between the component interface of the third basic component and the component interface adapted to the target rendering frame;
and the generating module is used for generating a component adaptation layer of the rendering frame according to the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame.
In another aspect, a server is provided, which includes a processor and a memory, where at least one program code is stored in the memory, and the program code is loaded and executed by the processor to implement the operations performed in the page rendering method.
In another aspect, a computer-readable storage medium is provided, in which at least one program code is stored, the program code being loaded and executed by a processor to implement the operations performed in the above-described page rendering method.
In another aspect, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer program code, the computer program code being stored in a computer-readable storage medium, the computer program code being read by a processor of a computer device from the computer-readable storage medium, the computer program code being executed by the processor to cause the computer device to perform the operations performed in the above-mentioned page rendering method.
The technical scheme provided by the embodiment of the disclosure has the following beneficial effects:
in the embodiment of the disclosure, in response to rendering a target page under a target rendering frame, only a first page component of the target page which is written in advance needs to be obtained, and the first page component is converted through a syntax interpreter, so that the page component which can be rendered under the target rendering frame can be obtained, and therefore, the page component does not need to be rewritten for the target rendering frame, the workload of page developers is reduced, and the development efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
FIG. 1 is an implementation environment of a page rendering method provided according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a page rendering method flow provided in accordance with an exemplary embodiment;
FIG. 3 is a schematic diagram of a page rendering method flow provided in accordance with an exemplary embodiment;
FIG. 4 is a schematic diagram of a page rendering method flow provided in accordance with an exemplary embodiment;
FIG. 5 is a schematic diagram of a page rendering method flow provided in accordance with an exemplary embodiment;
FIG. 6 is a schematic illustration of a destination page provided in accordance with an exemplary embodiment;
FIG. 7 is a schematic illustration of a destination page provided in accordance with an exemplary embodiment;
FIG. 8 is a schematic illustration of a page rendering method flow provided in accordance with an exemplary embodiment;
FIG. 9 is a block diagram of a page rendering apparatus provided according to an embodiment of the present disclosure;
fig. 10 is a block diagram of a page rendering apparatus provided according to an embodiment of the present disclosure;
fig. 11 is a schematic structural diagram of a server provided according to an embodiment of the present disclosure.
Detailed Description
To make the objects, technical solutions and advantages of the present disclosure more apparent, embodiments of the present disclosure will be described in detail with reference to the accompanying drawings.
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a schematic diagram illustrating an implementation environment involved in a page rendering method according to an exemplary embodiment of the present disclosure. Referring to fig. 1, the implementation environment includes the system architecture diagram including a first terminal 101, a second terminal 102, and a server 103. Wherein, the first terminal 101 and the second terminal 102 can be connected with the server 103 through a wireless network.
The first terminal 101 is a terminal used by a page developer. The developer designs a development target page through the first terminal 101, sends a page component of the target page to the server 103, and the server 103 renders the target page according to the page component of the target page and sends the rendered page to the second terminal 102. The second terminal 102 receives the rendered target page and displays the target page on the display screen.
The second terminal 102 may have a plurality of applications installed therein, where the plurality of applications may be applications with different functions, and the same page content may be displayed in the plurality of applications. For example, the second terminal 102 may have a first application and a second application installed therein, where the first application is a browser application, the second application is a social application, both the first application and the second application may display a target page, and the target page may include information such as news information.
The first terminal 101 and the second terminal 102 may be the same terminal or different terminals, and both the first terminal 101 and the second terminal 102 may be a mobile phone, a computer, a tablet computer, or a wearable device. The server 103 may be one server 103, a server 103 cluster composed of a plurality of servers 103, a cloud server 103, or the like. In the embodiments of the present disclosure, this is not particularly limited.
Fig. 2 is a flowchart of a page rendering method according to an exemplary embodiment. As shown in fig. 2, the method comprises the steps of:
step 201: determining a target rendering frame corresponding to a target page to be rendered, and determining a first page component of the target page to be rendered, wherein the first page component is a page component written by a specified development language.
Step 202: and converting the first page component into a second page component through a grammar interpreter corresponding to the target rendering frame, wherein the second page component is a page component which can be run by the target rendering frame.
Step 203: determining an interface protocol of the target rendering framework, wherein the interface protocol is used for recording component interfaces of basic components used by the target rendering framework.
Step 204: and operating the second page component according to the interface protocol to obtain the target page.
In one possible implementation, the converting the first page component into a second page component by a syntax interpreter corresponding to the target rendering framework includes:
converting, by the grammar interpreter, the first page component into a grammar tree object, the first page component including a plurality of first base components;
modifying the component attribute and the style text of each first basic component in the syntax tree object through the syntax interpreter to obtain a plurality of second basic components;
and forming the plurality of second basic components into the second page component.
In another possible implementation manner, the modifying, by the syntax interpreter, the component attribute and the style text of each first base component in the syntax tree object to obtain a plurality of second base components includes:
for each first base component in a syntax tree object, converting the first component attribute of the first base component into a second component attribute through the syntax interpreter, and converting the first style text of the first base component into a second style text, wherein the second component attribute is a component attribute readable by the target rendering frame, and the second style text is a style text readable by the target rendering frame;
and generating the second basic component according to the second component attribute and the second style text.
In another possible implementation manner, the converting, by the grammar interpreter, the first component attribute of the first base component into the second component attribute, and the converting the first style text of the first base component into the second style text includes:
calling a first corresponding relation between a first component attribute and a second component attribute of a base component in the grammar interpreter; converting the first component attribute of the first basic component into the second component attribute according to the first corresponding relation and the first component attribute of the first basic component;
calling a second corresponding relation between the first style text and the second style text of the basic component in the grammar interpreter; and converting the first style text of the first base component into the second style text according to the second corresponding relation and the first style text of the first base component.
In another possible implementation manner, the operating the second page component according to the interface protocol to obtain the target page includes:
determining each second base component that the second page component comprises;
calling the component interface of each second basic component according to the interface protocol;
rendering the page display effect corresponding to each second basic assembly according to the assembly interface of each second basic assembly;
and rendering each second basic component based on the page display effect corresponding to each second basic component to obtain the target page.
In another possible implementation manner, the invoking the component interface of each second base component according to the interface protocol includes:
determining a component interface of each second base component from the component adaptation layer according to the interface protocol; calling the component interface; the component adaptation layer comprises a corresponding relation between a component interface of a third basic component and a component interface adapted to the target rendering framework, and the third basic component is a basic component in a basic component library based on a specified development language.
In another possible implementation manner, before determining the component interface of each second base component from the component adaptation layer according to the interface protocol, the method further includes:
determining the basic component library;
for each appointed rendering frame, determining a component interface of each third basic component in the basic component library under the rendering frame according to the development language of the rendering frame;
determining the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame according to the component interface adapted to each rendering frame and the component interface of the third basic component in the component library respectively;
and generating a component adaptation layer of the rendering frame according to the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame.
In the embodiment of the disclosure, in response to rendering a target page under a target rendering frame, only a first page component of the target page which is written in advance needs to be obtained, and the first page component is converted through a syntax interpreter, so that the page component which can be rendered under the target rendering frame can be obtained, and therefore, the page component does not need to be rewritten for the target rendering frame, the workload of page developers is reduced, and the development efficiency is improved.
FIG. 3 is a flowchart of a page rendering method according to an example embodiment. As shown in fig. 3, the method comprises the steps of:
step 301: and the server determines a target rendering frame corresponding to the target page to be rendered.
The target rendering frame is a rendering frame corresponding to an application program for displaying a target page. Optionally, the target rendering framework is any one of, for example, Vue (a database for constructing interactive pages), reach (a database for constructing user interfaces), Weex (a framework for developing Native applications), reach Native (an open-source cross-platform mobile application development framework), and the like.
The target page to be rendered is a page designed and developed by a page developer. The method comprises the steps that a first terminal sends a first page component corresponding to a target page developed by a page developer to a server; and rendering the target page to be rendered by the server, sending the related data of the rendered target page to the second terminal, and displaying the target page by the second terminal.
In a possible implementation manner, when receiving the first page component sent by the first terminal, the server determines a rendering frame corresponding to at least one syntax interpreter currently stored in the server as a target rendering frame. In this implementation manner, the server determines at least one target rendering frame, so that the first page component can be subsequently converted into a second page component corresponding to the at least one target rendering frame according to the at least one target rendering frame, and thus when relevant data of a target page is sent to the second terminal, the first page component does not need to be converted, page data corresponding to the second page component can be directly sent, and the page rendering efficiency is improved.
In another possible implementation manner, the server receives a page rendering request of the second terminal, and determines a target rendering frame corresponding to the target page according to the page rendering request. The page rendering request is a page rendering request sent to the server by the second terminal when the second terminal displays the target page. Optionally, the page rendering request carries a page identifier of the target page, the server receives the page rendering request, determines the page identifier of the target page from the page rendering request, determines a rendering frame of the target page according to the page identifier, and determines the rendering frame of the target page as a target rendering frame. Optionally, the page rendering request carries a frame identifier of a rendering frame corresponding to the target page, and correspondingly, the server may parse the page rendering request to obtain the frame identifier, and determine, according to the frame identifier, the target rendering frame corresponding to the target page of the page rendering request.
In the implementation manner, the server determines the page identifier corresponding to the target page only when receiving the page rendering request sent by the second terminal, so that the page rendering is performed only according to the page displayed by the second terminal, the storage space of the server is prevented from being occupied after the page component is converted, and the workload of the server is reduced.
It should be noted that the number of the target rendering frames may be one or more, and in the embodiment of the present disclosure, the number of the target rendering frames is not particularly limited. For example, referring to fig. 4, the server may simultaneously determine rendering frames 401, 402, and 403 as target rendering frames, perform page rendering for each rendering frame, and generate pages of different applications for the user to browse.
Step 302: the server determines a first page component of the target page to be rendered, wherein the first page component is a page component written by a specified development language.
The first page component is a page component developed by a page developer through a first terminal. Optionally, the first page component includes a plurality of first base components. The specified development language is any type of development language. Optionally, the executed development Language is DSL (Domain Specific Language) designed for the present solution by the page developer. Optionally, the DSL is a development language customized by a page developer or a development language corresponding to any rendering frame, and in the embodiment of the present disclosure, the development language of the first page component is not specifically limited.
In a possible implementation manner, when receiving the page component sent by the first terminal, the server determines the received page component as the first page component. In the implementation mode, the server directly converts the received page component as a first page component of a target page to be rendered to obtain a second page component, so that when the second terminal acquires page data, conversion is not needed, the page data can be directly sent when related data of the target page can be directly sent to the second terminal, and the page rendering efficiency is improved.
In another possible implementation manner, the server receives a page rendering request of the second terminal, and determines the first page component according to the page rendering request. Optionally, the page rendering request carries a page identifier of the target page, the server receives the page rendering request, determines the page identifier of the target page from the page rendering request, and determines the first page component of the target page according to the page identifier.
In the implementation manner, the server determines the first page component corresponding to the target page when receiving the page rendering request sent by the second terminal, so that the page rendering is performed only according to the page displayed by the second terminal, the storage space of the server is prevented from being occupied after the page component is converted, and the workload of the server is reduced.
In addition, optionally, the first page component is a plurality of first basic components developed by a page developer according to a target page to be rendered, and the plurality of first basic components are combined into the first page component. Optionally, before rendering the target page, the page developer writes a set of basic component libraries based on the specified development language, where the basic component libraries include a plurality of third basic components, and the plurality of third basic components are used for representing display content and user interaction effects in the page. And responding to the target page to be rendered, selecting a plurality of first basic components from a basic component library written in advance, and combining the selected plurality of first basic components into the first page component.
Optionally, the server determines the target rendering frame first, and then determines the first page component; optionally, the server determines the first page component first, and then determines the target rendering frame; optionally, the server determines the target rendering frame and the first page component simultaneously. Correspondingly, the server executes step 301 first and then executes step 302; or, the server executes step 302 first, and then executes step 301; alternatively, the server performs step 301 and step 302 simultaneously. In the embodiment of the present disclosure, the order in which the server performs steps 301 and 302 is not particularly limited.
Step 303: the first page component is converted into a syntax tree object by the syntax interpreter.
Wherein the grammar interpreter is a tool designed according to the development language of the first page component and used for converting the development language. In this step, the server parses the first page component through the syntax interpreter to generate a syntax tree object. The syntax tree object comprises a plurality of first basic components corresponding to the first page components, and the node structure of the syntax tree object is determined according to the nesting relation of the at least one basic page component in the syntax tree object.
Accordingly, prior to this step, the server determines the grammar interpreter corresponding to the target rendering framework. The process can be realized by the following steps (1) to (3), including:
(1) the server determines a runnable development language for the target rendering framework.
When the server determines the runnable development language development page components of each target rendering frame, the server uses description syntax of data such as component attributes, style texts and the like of the page components.
(2) And the server determines the corresponding relation between the component attribute and the style text of the page component corresponding to the first page component and the target rendering frame according to the operable development language of the target rendering frame and the specified development language.
In the step, the server determines the executable development language of the page component under the target rendering frame and the description grammar of the first page component by the specified development language; and establishing a corresponding relation between the description methods of the same object in different development languages to obtain a corresponding relation between the component attribute and the style text of the page component corresponding to the first page component and the target rendering frame.
(3) And the server stores the corresponding relation between the component attribute and the style text of the page component corresponding to the first page component and the target rendering frame into the grammar interpreter to obtain the grammar interpreter corresponding to the target rendering frame.
In this step, the server stores the generated correspondence between the component attribute and the style text of the page component corresponding to the first page component and the target rendering frame in the grammar interpreter, and obtains the grammar interpreter corresponding to the target explicit frame.
It should be noted that the grammar interpreter is optionally generated by a server, or the grammar interpreter is generated by other electronic devices. Responding to the grammar interpreter generated by the grammar interpreter for other electronic equipment, the server sends an obtaining request to the other electronic equipment according to the target rendering frame, the obtaining request is used for requesting to obtain the grammar interpreter corresponding to the target rendering frame, the other electronic equipment determines the grammar interpreter corresponding to the target rendering frame according to the received obtaining request, the grammar interpreter is sent to the server, and the server receives the grammar interpreter sent by the other electronic equipment. The process of generating the grammar interpreter by other electronic equipment is similar to the process of generating the grammar interpreter by the server, and is not described in detail herein.
In the implementation mode, the grammar interpreter is generated by other electronic equipment, the server acquires the grammar interpreter from other electronic equipment when using the grammar interpreter, the requirement on the server is reduced, and when a new rendering frame is added, only the grammar interpreter of the new rendering frame needs to be generated in other electronic equipment, so that the self-rendering frames can be more conveniently expanded.
Step 304: and the server modifies the component attribute and the style text of each first basic component in the grammar tree object through the grammar interpreter to obtain a plurality of second basic components.
The server determines component attributes and style texts of a plurality of first basic components of the first page component by traversing the syntax tree object.
The first style text includes data for describing a page style, such as a style item and a style unit of the first page component, for example, the style item is a height of a window in the page component, and the style unit is a unit used in a development language of the page component for measuring the style item of the page component, and may be px (pixels), sp (scaled pixels), mm (millimeters), or the like. The component attributes include attributes such as a component tag (tag), a style class (className), and the like of the page component.
In this step, the server converts the component attribute and the style text of each first basic component in the syntax tree object into the group price attribute and the style text corresponding to the target rendering frame, and generates a second basic component according to the converted component attribute and the style text, which can be realized by the following steps (1) - (2), including:
(1) for each first base component in the grammar tree object, the server converts the first component attribute of the first base component into a second component attribute through the grammar interpreter, and converts the first style text of the first base component into a second style text, wherein the second component attribute is a component attribute readable by the target rendering frame, and the second style text is a style text readable by the target rendering frame.
In this step, the server may convert the component property and the text style of the first page component, respectively, and this process may be implemented by the following steps (1-1) - (1-2), including:
(1-1) the server converting the first component property of the first page component in the syntax tree object into a second component property readable by the target rendering frame.
Referring to fig. 5, in this step, the server reads the syntax tree object of the first page component, determines the first component attribute 501 of the first page component from the syntax tree object of the first page component, and performs component attribute conversion on the first component attribute. In one possible implementation, the server adapts a first component attribute of the first page component to the target rendering frame, and converts the first component attribute into a second component attribute. Optionally, the server invokes a correspondence between component attributes in the first page component and the second page component in the syntax interpreter, and converts the first component attribute into the second component attribute. Correspondingly, the server calls a first corresponding relation between the first component attribute and the second component attribute of the basic component in the grammar interpreter; and converting the first component attribute of the first base component into the second component attribute according to the first corresponding relation and the first component attribute of the first base component.
(1-2) the server converting the first style text of the first page component in the syntax tree object into a second style text readable by the target rendering frame.
The style text comprises codes for describing component styles and units of the target page to be rendered. Continuing with fig. 5, in this step, the server determines a first style text 502 corresponding to the first page component, performs style text conversion on the first style text, and converts a code file describing the first page component in the first page component into a second style text that can be read by the target rendering frame. Optionally, the server calls a second corresponding relation between the first style text and the second style text of the base component in the grammar interpreter; and converting the first style text of the first base component into the second style text according to the second corresponding relation and the first style text of the first base component.
It should be noted that, for different units used in the first page component and the second page component, the server may convert the style data in the first page component into the page component data under the target rendering frame according to the binary relation of the units, and then convert the unit code of the first page component into the unit code under the target rendering frame.
Optionally, the server converts the first component attribute into a second component attribute, and then converts the first style text into a second style text; optionally, the server converts the first style text into a second style text, and then converts the first component attribute into a second component attribute; optionally, the server simultaneously converts the first component attribute into the second component attribute and the first style text into the second style text. Correspondingly, the server executes the step (1-1) firstly and then executes the step (1-2); or, the server executes the step (1-2) first and then executes the step (1-1); or, the server executes the step (1-1) and the step (1-2) simultaneously. In the embodiment of the present disclosure, the execution order of step (1-1) and step (1-2) is not particularly limited.
In addition, the server may compare whether the composition syntax of the first component attribute and the component attribute corresponding to the target rendering frame is the same, and the server may not perform step (1-1) in response to the composition syntax of the first component attribute and the component attribute corresponding to the target rendering frame being the same. Similarly, the server may further determine whether the first style text is the same as the style text corresponding to the target rendering frame, not change the style unit of the first style text in response to the style unit in the first style text being the same as the unit corresponding to the target rendering frame, and not change the writing manner of the style item in response to the style unit of the first style text being the same as the writing syntax of the style item corresponding to the target rendering frame.
(2) The server generates the second base component according to the second component attribute and the second style text.
In this step, the server combines the second component attribute and the second style text into a second basic component according to the second component attribute and the second style text.
In the implementation mode, the second basic component is obtained by converting the first component attribute and the first style text of the first basic component, so that the target page is rendered in the target rendering frame, and the target rendering frame can render the page corresponding to the first page component.
Step 305: the server combines the plurality of second basic components into the second page component.
In this step, the server replaces the writing syntax of the data in the syntax tree object of the first page component with the writing syntax of the second component attribute and the second sample file to obtain a syntax tree object corresponding to the second page component, and compiles the syntax tree object corresponding to the second page component to obtain the second page component.
Step 306: the server determines an interface protocol of the target rendering framework, wherein the interface protocol is used for recording component interfaces of basic components used by the target rendering framework.
The interface protocol comprises component interfaces of basic components corresponding to the target rendering framework and page display effects corresponding to each component interface. The component Interface may be an API (Application Programming Interface), and the server may implement a page display effect corresponding to the basic component by calling the component Interface, so that when a page is displayed, different pages may be displayed according to a received operation instruction input by the user.
The page display effect of the basic components corresponding to different rendering frames is the same, so that the displayed page and page interaction are the same when the second terminal displays the page in different application programs. Referring to fig. 6 and 7, fig. 6 and 7 are views showing a target page in the application 1 and the application 2, respectively. Wherein, the rendering frameworks of the application program 1 and the application program 2 are different. For example, the application 1 is an application using a web framework; the application 2 is an application using a real Native framework. The display contents in the window 1 and the window 2 of the target page displayed by the application 1 and the application 2 are the same.
Step 307: and the server operates the second page component according to the interface protocol to obtain the target page.
And the server operates the second page component to render the target page according to the interface protocol of the target rendering frame to obtain the target page. Referring to fig. 8, the server determines a syntax interpreter 801 corresponding to the rendering frame 1 and a syntax interpreter 802 corresponding to the rendering frame 2 respectively based on the rendering frame 1 and the rendering frame 2, respectively converts a first page component into a second page component usable by the rendering frame 1 and the transfection frame 2, then refers to interface protocols of the rendering frame 1 and the rendering frame 2 respectively, and calls a gradual interface of a base component corresponding to the second page component through the interface protocols to perform page rendering, which may be implemented through the following steps (1) - (4), including:
(1) the server determines each second base component that the second page component includes.
The second base component may include a component tag for the base component. Correspondingly, the server determines the component attribute of the second page component, determines the component tag of each component according to the component attribute of the second page component, and determines the basic component of the second page component according to the component tag.
Before this step, the server obtains a base component library, which includes a plurality of third base components. And the server determines a third basic component corresponding to the second page component from the basic component library according to the component attribute of the second page component.
It should be noted that the writing syntax of the base component corresponding to the first page component and the writing syntax of the base component in the base component library corresponding to the target rendering frame are different, but the realized page display effect is the same.
(2) The server calls the component interface of each second base component according to the interface protocol.
And the server determines a component interface corresponding to each basic component from the interface protocol according to the basic components of the second page.
The server obtains the interface protocol in advance, determines a component adaptation layer corresponding to each specified rendering frame according to the interface protocol, and calls a component interface through the component adaptation layer, and correspondingly, the step can be as follows: the server determines a component interface of each second basic component from the component adaptation layer according to the interface protocol; the component interface is invoked. The component adaptation layer comprises a corresponding relation between a component interface of a third basic component and a component interface adapted to the target rendering framework, and the third basic component is a basic component in a basic component library based on a specified development language.
Accordingly, prior to this step, the server generates a component adaptation layer for each specified rendering framework, which may be implemented by the following steps (2-1) - (2-4), including:
(2-1) the server determines a base component library.
The server determines a base component library for development in the specified development language. It should be noted that the plurality of third basic components included in the basic component library may be a set of basic components written in advance by the page developer, and the third basic components in the basic component library may be extended by the first basic components in the first page component. In the embodiments of the present disclosure, this is not particularly limited.
(2-2) for each designated rendering frame, the server determines the component interface of each third basic component in the basic component library under the rendering frame according to the development language of the rendering frame.
In this step, the server interfaces the components of each third base component in the base component library, and so on. And the server writes a component interface of each third basic component according to the development language of each rendering framework.
And (2-3) the server determines the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame according to the component interface adapted to each rendering frame and the component interface of the third basic component in the component library.
And the server records the corresponding relation between the component interface of the third basic component and the component interface corresponding to the development language of the rendering frame, and determines the corresponding relation as the corresponding relation between the component interface of the third basic component and the component interface matched with the target rendering frame.
And (2-4) the server generates a component adaptation layer of the rendering frame according to the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame.
And the server matches the component interface of the third page component with the adaptation component interface of the target rendering frame to complete the introduction of the component adaptation layer.
Through the implementation mode, after the server receives the first page component, the server can directly quote the component interface of the basic component matched with the target rendering frame according to the component matching layer, and cross-frame rendering is achieved.
For example, a first page component X is written using a specified development language and is composed of first base components a, b, c, the interface protocols of which use an agreed base component protocol; after the grammar interpreter carries out grammar translation, the grammar of the first page component X is converted into the development language of the rendering frame A, and the rendering frame A can recognize and run the grammar; at this time, if the page in the rendering frame a needs to refer to the first page component X, only the first basic components a, b, and c implemented by using the syntax of the rendering frame a need to be introduced first, then the necessary conditions for rendering the first page component X in the rendering frame a are met, and at this time, when the first page component X is introduced again, the first page component X will be successfully rendered in the frame a.
(3) And the server renders the page display effect corresponding to each second basic component according to the component interface of each second basic component.
The server renders a target page based on the second page component, responds to the received operation instruction of the user, determines the page display effect of the basic component corresponding to the operation instruction according to the group price interface, and displays the content of the basic component obviously according to the page display effect.
(4) And rendering each second basic component based on the page display effect corresponding to each second basic component to obtain the target page.
In the embodiment of the disclosure, in response to rendering a target page under a target rendering frame, only a first page component of the target page which is written in advance needs to be obtained, and the first page component is converted through a syntax interpreter, so that the page component which can be rendered under the target rendering frame can be obtained, and therefore, the page component does not need to be rewritten for the target rendering frame, the workload of page developers is reduced, and the development efficiency is improved.
FIG. 9 is a block diagram of a page rendering apparatus provided in accordance with an example embodiment. Referring to fig. 9, the apparatus includes:
a first determining module 901, configured to determine a target rendering frame corresponding to a target page to be rendered, and determine a first page component of the target page to be rendered, where the first page component is a page component written in a specified development language;
a conversion module 902, configured to convert, by using a syntax interpreter corresponding to the target rendering frame, the first page component into a second page component, where the second page component is a page component that the target rendering frame can run;
a second determining module 903, configured to determine an interface protocol of the target rendering framework, where the interface protocol is used to record a component interface of a base component used by the target rendering framework;
an operation module 904, configured to operate the second page component according to the interface protocol to obtain the target page.
In one possible implementation, referring to fig. 10, the conversion module 902 includes:
a conversion unit 9021, configured to convert, by the syntax interpreter, the first page component into a syntax tree object, where the first page component includes a plurality of first base components;
a modifying unit 9022, configured to modify, by using the syntax interpreter, the component attribute and the style text of each first basic component in the syntax tree object to obtain a plurality of second basic components;
a composing unit 9023, configured to compose the plurality of second basic components into the second page component.
In another possible implementation, the modifying unit 9022 includes:
a transformation module, configured to, for each first base component in a syntax tree object, transform, by the syntax interpreter, a first component attribute of the first base component into a second component attribute, and transform, by the syntax interpreter, a first style text of the first base component into a second style text, where the second component attribute is a component attribute readable by the target rendering frame, and the second style text is a style text readable by the target rendering frame;
and the generating subunit is used for generating the second basic component according to the second component attribute and the second style text.
In another possible implementation manner, the transformation subunit is configured to invoke a first correspondence between a first component attribute and a second component attribute of the base component in the syntax interpreter; converting the first component attribute of the first basic component into the second component attribute according to the first corresponding relation and the first component attribute of the first basic component; calling a second corresponding relation between the first style text and the second style text of the basic component in the grammar interpreter; and converting the first style text of the first base component into the second style text according to the second corresponding relation and the first style text of the first base component.
In another possible implementation, referring to fig. 10, the execution module 904 includes:
a determining unit 9041, configured to determine each second base component included in the second page component;
a calling unit 9042, configured to call, according to the interface protocol, a component interface of each second basic component;
a rendering unit 9043, configured to render, according to the component interface of each second basic component, a page display effect corresponding to each second basic component; and rendering each second basic component based on the page display effect corresponding to each second basic component to obtain the target page.
In another possible implementation manner, the invoking unit 9042 is configured to determine, according to the interface protocol, a component interface of each second base component from the component adaptation layer; calling the component interface; the component adaptation layer comprises a corresponding relation between a component interface of a third basic component and a component interface adapted to the target rendering framework, and the third basic component is a basic component in a basic component library based on a specified development language.
In another possible implementation, referring to fig. 10, the apparatus further includes:
a third determining module 905, configured to determine the basic component library;
a fourth determining module 906, configured to determine, for each specified rendering framework, a component interface of each third basic component in the basic component library under the rendering framework according to the development language of the rendering framework;
a fifth determining module 907, configured to determine, according to the component interface adapted to each rendering frame and the component interface of the third base component in the component library, a corresponding relationship between the component interface of the third base component and the component interface adapted to the target rendering frame;
a generating module 908, configured to generate a component adaptation layer of the rendering frame according to a correspondence between the component interface of the third base component and the component interface adapted to the target rendering frame.
In the embodiment of the disclosure, in response to rendering a target page under a target rendering frame, only a first page component of the target page which is written in advance needs to be obtained, and the first page component is converted through a syntax interpreter, so that the page component which can be rendered under the target rendering frame can be obtained, and therefore, the page component does not need to be rewritten for the target rendering frame, the workload of page developers is reduced, and the development efficiency is improved.
It should be noted that: in the page rendering apparatus provided in the foregoing embodiment, only the division of the functional modules is illustrated in the page rendering process, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the apparatus is divided into different functional modules to complete all or part of the functions described above. In addition, the page rendering device and the page rendering method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
Fig. 11 is a schematic structural diagram of a server provided in an embodiment of the present disclosure, where the server 103 may generate a relatively large difference due to different configurations or performances, and may include a processor (CPU) 1031 and a memory 1032, where the memory 1032 stores at least one program code, and the at least one program code is loaded and executed by the processor 1031 to implement the page rendering method provided in each method embodiment. Of course, the server 103 may also have components such as a wired or wireless network interface, a keyboard, and an input/output interface, so as to perform input and output, and the server may also include other components for implementing the functions of the device, which is not described herein again.
In an exemplary embodiment, there is also provided a computer readable storage medium having at least one program code stored therein, the at least one program code being loaded and executed by a server to implement the page rendering method in the above embodiments. The computer readable storage medium may be a memory. For example, the computer-readable storage medium may be a ROM (Read-Only Memory), a RAM (Random Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product or a computer program is also provided, which includes computer program code stored in a computer-readable storage medium, the computer program code being read by a processor of a computer device from the computer-readable storage medium, and the computer program code being executed by the processor to cause the computer device to perform the operations performed in the page rendering method described above.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is meant as an alternative embodiment of the disclosure and not as a limitation of the disclosure, and any modification, equivalent replacement, or improvement made within the spirit and principle of the disclosure should be included in the scope of protection of the disclosure.

Claims (10)

1. A method for rendering a page, the method comprising:
determining a target rendering frame corresponding to a target page to be rendered, and determining a first page component of the target page to be rendered, wherein the first page component is a page component written by a specified development language;
converting the first page component into a second page component through a grammar interpreter corresponding to the target rendering frame, wherein the second page component is a page component which can be run by the target rendering frame;
determining an interface protocol of the target rendering framework, wherein the interface protocol is used for recording a component interface of a basic component used by the target rendering framework;
and operating the second page component according to the interface protocol to obtain the target page.
2. The method of claim 1, wherein converting the first page component into a second page component via a grammar interpreter corresponding to the target rendering framework comprises:
converting, by the grammar interpreter, the first page component into a grammar tree object, the first page component including a plurality of first base components;
modifying the component attribute and the style text of each first basic component in the syntax tree object through the syntax interpreter to obtain a plurality of second basic components;
and composing the plurality of second base components into the second page component.
3. The method of claim 2, wherein modifying, by the grammar interpreter, the component properties and style text of each first base component in the grammar tree object to obtain a plurality of second base components comprises:
for each first base component in a syntax tree object, converting, by the syntax interpreter, a first component attribute of the first base component into a second component attribute, and converting a first style text of the first base component into a second style text, where the second component attribute is a component attribute readable by the target rendering frame, and the second style text is a style text readable by the target rendering frame;
and generating the second basic component according to the second component attribute and the second style text.
4. The method of claim 3, wherein converting, by the grammar interpreter, the first component properties of the first base component to second component properties and the first style text of the first base component to second style text comprises:
calling a first corresponding relation between a first component attribute and a second component attribute of a base component in the grammar interpreter; converting the first component attribute of the first base component into the second component attribute according to the first corresponding relation and the first component attribute of the first base component;
calling a second corresponding relation between the first style text and the second style text of the base component in the grammar interpreter; and converting the first style text of the first base component into the second style text according to the second corresponding relation and the first style text of the first base component.
5. The method of claim 1, wherein said operating the second page component to obtain the target page according to the interface protocol comprises:
determining each second base component that the second page component comprises;
calling a component interface of each second basic component according to the interface protocol;
rendering a page display effect corresponding to each second basic component according to the component interface of each second basic component;
and rendering each second basic component based on the page display effect corresponding to each second basic component to obtain the target page.
6. The method of claim 5, wherein said invoking a component interface of said each second base component according to said interface protocol comprises:
determining a component interface of each second base component from a component adaptation layer according to the interface protocol; calling the component interface; the component adaptation layer comprises a corresponding relation between a component interface of a third basic component and a component interface adapted to the target rendering framework, and the third basic component is a basic component in a basic component library based on a specified development language.
7. The method of claim 6, wherein before determining the component interface of each second base component from the component adaptation layer according to the interface protocol, the method further comprises:
determining the basic component library;
for each appointed rendering frame, determining a component interface of each third basic component in the basic component library under the rendering frame according to the development language of the rendering frame;
determining the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame according to the component interface adapted to each rendering frame and the component interface of the third basic component in the component library respectively;
and generating a component adaptation layer of the rendering frame according to the corresponding relation between the component interface of the third basic component and the component interface adapted to the target rendering frame.
8. An apparatus for rendering a page, the apparatus comprising:
the system comprises a first determining module, a second determining module and a display module, wherein the first determining module is used for determining a target rendering frame corresponding to a target page to be rendered and determining a first page component of the target page to be rendered, and the first page component is a page component written by a specified development language;
the conversion module is used for converting the first page component into a second page component through a grammar interpreter corresponding to the target rendering frame, and the second page component is a page component which can be run by the target rendering frame;
a second determining module, configured to determine an interface protocol of the target rendering framework, where the interface protocol is used to record a component interface of a base component used by the target rendering framework;
and the operation module is used for operating the second page component according to the interface protocol to obtain the target page.
9. A server, characterized in that it comprises a processor and a memory, in which at least one program code is stored, which is loaded and executed by the processor to implement the page rendering method according to any one of claims 1-7.
10. A computer-readable storage medium having stored therein at least one program code, the program code being loaded and executed by a processor to implement the page rendering method of any one of claims 1-7.
CN202010697457.8A 2020-07-20 2020-07-20 Page rendering method, device, server and storage medium Pending CN113961279A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010697457.8A CN113961279A (en) 2020-07-20 2020-07-20 Page rendering method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010697457.8A CN113961279A (en) 2020-07-20 2020-07-20 Page rendering method, device, server and storage medium

Publications (1)

Publication Number Publication Date
CN113961279A true CN113961279A (en) 2022-01-21

Family

ID=79459650

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010697457.8A Pending CN113961279A (en) 2020-07-20 2020-07-20 Page rendering method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN113961279A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489861A (en) * 2022-02-16 2022-05-13 平安普惠企业管理有限公司 Target component conversion method and device, electronic equipment and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114489861A (en) * 2022-02-16 2022-05-13 平安普惠企业管理有限公司 Target component conversion method and device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN111158818B (en) Page rendering method and device
CN112363794B (en) Rendering method of front-end list component and electronic equipment
CN113010827B (en) Page rendering method and device, electronic equipment and storage medium
CN113126990B (en) Page development method, device, equipment and storage medium
CN113031932B (en) Project development method, apparatus, electronic device and storage medium
CN113419710B (en) Development method and device of applet, electronic equipment and medium
CN111880813B (en) Method for realizing android card UI (user interface) and storage medium
CN114706616A (en) Applet construction method and device
CN117093316B (en) Cross-platform page rendering system, electronic equipment and storage medium
CN114138372A (en) Front-end component loading method and device
CN113094138A (en) Interface display method and device, electronic equipment and storage medium
CN115809056B (en) Component multiplexing implementation method and device, terminal equipment and readable storage medium
CN113961279A (en) Page rendering method, device, server and storage medium
CN112965716A (en) Page processing method and device, electronic equipment and readable storage medium
CN111198738A (en) Mobile terminal page display method and device and electronic equipment
CN115994517A (en) Information processing method, apparatus, storage medium, device, and program product
CN116775174A (en) Processing method, device, equipment and medium based on user interface frame
CN113849164A (en) Data processing method and device, electronic equipment and memory
CN109614104B (en) Method and device for adding new semantic structure based on template preprocessing and electronic equipment
CN114489607A (en) Cross-stack application processing and page rendering method, device, equipment and storage medium
CN114254232A (en) Cloud product page generation method and device, computer equipment and storage medium
CN112114805A (en) Page generation method, device and equipment
CN112882698A (en) Development environment generation method and device, computer storage medium and electronic device
CN110837896B (en) Storage and calling method and device of machine learning model
CN115373656A (en) Page generation method and device, computer readable medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination