CN113515328A - Page rendering method and device, electronic equipment and storage medium - Google Patents

Page rendering method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113515328A
CN113515328A CN202010273940.3A CN202010273940A CN113515328A CN 113515328 A CN113515328 A CN 113515328A CN 202010273940 A CN202010273940 A CN 202010273940A CN 113515328 A CN113515328 A CN 113515328A
Authority
CN
China
Prior art keywords
event
resource file
target
triggered
page
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
CN202010273940.3A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202010273940.3A priority Critical patent/CN113515328A/en
Publication of CN113515328A publication Critical patent/CN113515328A/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

Abstract

The invention discloses a page rendering method and device, electronic equipment and a storage medium, and relates to the technical field of computers. One embodiment of the method comprises: rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed; acquiring and operating a static resource file according to the static resource information in the page data, and acquiring a service resource file according to the service resource information; detecting whether a target event is triggered; if so, rendering the page to be displayed according to the result of operating the service resource file, and enabling the rendered page to be displayed to replace the occupation map. The implementation method can avoid the problems that when the business resource file is operated, the static resource file is not generated and finished, so that the operation of the business resource file is wrong, and the rendering of the page cannot be finished.

Description

Page rendering method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for page rendering, an electronic device, and a storage medium.
Background
In the page display technology, in order to optimize the user experience, before the user waits for the final page rendering to be completed, the occupation bitmap is usually displayed first, so as to alleviate the user waiting process. And after the page rendering occupation bitmap, operating the static resource file and the service resource file to obtain a final rendered page.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
since the operation of the service resource file needs to be completed by the static resource file, the static resource file is usually generated before the service resource file. However, in some scenarios, the static resource file is not generated yet when the service resource file is operated, so that the operation of the service resource file is wrong, the page stays in a state of displaying the occupied bitmap, and the page cannot be rendered.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, a system, and a storage medium for page rendering, which can avoid the problem that a static resource file is not generated and completed when a service resource file is run, so that the service resource file runs incorrectly, and a page cannot be rendered.
To achieve the above object, according to an aspect of an embodiment of the present invention, a method of page rendering is provided.
The page rendering method of the embodiment of the invention comprises the following steps: rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed; acquiring and operating a static resource file according to the static resource information in the page data, and acquiring a service resource file according to the service resource information; detecting whether a target event is triggered, wherein the target event is triggered when the static resource file is operated and the service resource file is acquired; if so, rendering the page to be displayed according to the result of operating the service resource file, and enabling the rendered page to be displayed to replace the occupation map.
In one embodiment, before the detecting whether the target event is triggered, the method further includes:
after the static resource file is operated and the service resource file is acquired, changing the value of the target parameter into a target value;
whether the target event is triggered or not is detected, and the method comprises the following steps:
detecting whether the value of the target parameter is the target value;
if yes, the target event is triggered; if not, the target event is not triggered.
In yet another embodiment, the target parameters include a first target parameter and a second target parameter, and the target values include a first target and a second target value;
the changing the value of the target parameter to the target value includes:
when the running of the static resource file is finished, changing the value of the first target parameter into the first target value;
and when the service resource file is acquired, changing the value of the second target parameter into the second target value.
In another embodiment, the target event includes a first event and a second event, the first event represents that the static resource file is completely run, and the second event represents that the business resource file is completely acquired;
whether the target event is triggered or not is detected, and the method comprises the following steps:
detecting whether the first event and the second event are both triggered;
if yes, the target event is triggered; if not, the target event is not triggered.
In another embodiment, the first event represents that the static resource file is completely executed, and the second event represents that the service resource file is completely acquired;
before the detecting whether the target event is triggered, further comprising:
when the running of the static resource file is completed, triggering the first event;
when the service resource file is acquired, triggering the second event;
triggering the target event when detecting that both the first event and the second event are triggered.
In another embodiment, before rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed, the method further includes:
configuring a first event in the page data, wherein the first event is used for triggering after the running of the static resource file is finished;
setting a second event at the end of the configuration of the service resource file, wherein the second event is used for triggering after the acquisition of the service resource file is finished;
configuring a target event, wherein the target event is used for triggering after the first event and the second event are both triggered.
To achieve the above object, according to another aspect of the present invention, there is provided an apparatus for page rendering.
The invention relates to a page rendering device, which comprises: the rendering unit is used for rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed; the processing unit is used for acquiring and operating a static resource file according to the static resource information in the page data and acquiring a service resource file according to the service resource information; the detection unit is used for detecting whether a target event is triggered or not, wherein the target event is triggered when the static resource file is operated and the service resource file is acquired; and if so, the rendering unit is further configured to render the page to be displayed according to the result of operating the service resource file, so that the rendered page to be displayed replaces the occupation map.
In one embodiment, further comprising:
the adjusting unit is used for changing the value of the target parameter into the target value after the static resource file is operated and the service resource file is acquired;
the detection unit is specifically configured to:
detecting whether the value of the target parameter is the target value;
if yes, the target event is triggered; if not, the target event is not triggered.
In yet another embodiment, the target parameters include a first target parameter and a second target parameter, and the target values include a first target and a second target value;
the adjusting unit is specifically configured to:
when the running of the static resource file is finished, changing the value of the first target parameter into the first target value;
and when the service resource file is acquired, changing the value of the second target parameter into the second target value.
In another embodiment, the target event includes a first event and a second event, the first event is triggered to represent that the static resource file is completely run, and the second event is triggered to represent that the service resource file is completely acquired;
the detection unit is specifically configured to:
detecting whether the first event and the second event are both triggered;
if yes, the target event is triggered; if not, the target event is not triggered.
In another embodiment, the first event represents that the static resource file is completely executed, and the second event represents that the service resource file is completely acquired;
the apparatus further comprises a trigger unit for: when the running of the static resource file is completed, triggering the first event;
when the service resource file is acquired, triggering the second event;
triggering the target event when detecting that both the first event and the second event are triggered.
In a further embodiment, the apparatus further comprises a configuration unit for:
configuring a first event in the page data, wherein the first event is used for triggering after the running of the static resource file is finished;
setting a second event at the end of the configuration of the service resource file, wherein the second event is used for triggering after the acquisition of the service resource file is finished;
configuring a target event, wherein the target event is used for triggering after the first event and the second event are both triggered.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the page rendering method provided by the embodiment of the invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium.
A computer readable medium of an embodiment of the present invention stores thereon a computer program, and when the computer program is executed by a processor, the computer program implements the method for rendering a page provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: in the embodiment of the invention, after the page to be displayed is rendered into the occupation map, the static resource file and the service resource file can be respectively obtained, the static resource file is operated, whether the processes of the static resource file operation and the service resource file acquisition are completed or not is judged by detecting whether the target event is triggered or not, and the service resource file is operated after the target event is triggered, so that the page to be displayed is rendered. In the embodiment of the invention, whether the static resource file finishes running and whether the business resource file is completely acquired are judged by detecting whether the target event is triggered, and the business resource file is run after the static resource file finishes running and the business resource file is completely acquired, so that the running of the static resource file is ensured to be finished when the business resource file is run, the problem that the business resource file runs wrongly because the static resource file does not finish running is avoided, and the problem that the page stays in the state of displaying the occupied bitmap and cannot finish rendering is further avoided.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of one main flow of a method of page rendering according to an embodiment of the invention;
FIG. 2 is a schematic diagram of another main flow of a method of page rendering according to an embodiment of the invention;
FIG. 3 is a schematic diagram of the main elements of an apparatus for page rendering according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
FIG. 5 is a schematic block diagram of a computer system suitable for use in implementing embodiments of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
The embodiment of the invention provides a page rendering method, which can be used in a scene of performing page rendering display after acquiring page data of a page to be displayed. Specifically, in the embodiment of the present invention, a system architecture to which the page rendering method is applied may include a client and a server, where the client and the server interact with each other, the client may send a page display request to the server, the server returns page data of a page to be displayed, which is requested by the client, according to the request sent by the client, and the client, after receiving the page data, may render the page to be displayed according to the page data, thereby implementing page display.
In the embodiment of the invention, in order to improve the user experience, the client performs occupation bitmap rendering in the page to be displayed first, so that the mood of the page display waiting for the user is relieved. After the occupation bitmap is displayed, the client side can obtain and operate the static resource file and the service resource file, and therefore the content to be displayed is rendered on the page to be displayed. Because the service resource file needs to depend on the static resource file during running, in order to ensure that the static resource file is completely run during running of the service resource file, in the embodiment of the invention, a trigger event and a monitoring event are set in both the service resource file and the rendering process, so that a target event can be triggered after the static resource file is completely obtained and run and the service resource file is completely obtained. The target event is triggered to represent that the static resource file is obtained and operated completely and the service resource file is obtained completely, namely when the static resource file is operated completely and the service resource file is obtained completely, the service resource file can be operated after the client detects the trigger target event, so that the operation sequence of the static resource file and the service resource file can be ensured, and the problem that the page cannot be rendered due to the fact that the static resource file is not operated completely and mistakes are made during the operation of the service resource file is solved.
An embodiment of the present invention provides a method for page rendering, which may be performed by a client, as shown in fig. 1, and includes the following steps.
S101: and rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed.
The method comprises the steps that when a page needs to be displayed, a client can send a page request of the page to be displayed to a server to request page data of the page to be displayed, the server sends the page data of the page to be displayed to the client according to the page request of the client, and page data returned by the server is html. After the client receives the page data, the client can render the placeholder map according to the information of the placeholder map, so that the page to be displayed displays the placeholder map.
In the embodiment of the present invention, the placeholder map may include multiple types, for example, the placeholder map may be embodied as a skeleton screen.
S102: and acquiring and operating the static resource file according to the static resource information in the page data, and acquiring the service resource file according to the service resource information.
After the client renders the occupation bitmap, the client can acquire the static resource file according to the static resource information in the page data, operate the static resource file after acquiring the static resource file, and acquire the service resource file according to the service resource information. Because the operation of the service resource file needs to depend on the static resource file, after the service resource file is obtained, whether the static resource file is operated or not needs to be determined, and after the static resource file is determined to be operated, the service resource file is operated.
In the embodiment of the present invention, the step may be specifically executed as: generating a static resource label and a service resource label according to the static resource information and the service resource information in the page data; and acquiring and operating the static resource file according to the static resource label, and acquiring the service resource file according to the service resource label.
The static resource information may include code for a static resource, and the static resource tag may be generated by running the static resource code. The static resource label comprises a link for acquiring the static resource file, so that the client can acquire the static resource file according to the static resource label. The service resource information may include a code of the service resource, and the service resource tag may be generated by executing the service resource code. The service resource label comprises a link for acquiring the service resource file, so that the client can acquire the service resource file according to the service resource label.
After generating the static resource tag and the business resource tag, the client may place the static resource tag and the business resource tag at the bottom of the < body > tag of the html file, so as to facilitate the running of the static resource tag and the business resource tag.
It should be noted that, in the embodiment of the present invention, the static resource file may include a JS (JavaScript, a lightweight, interpreted, or just-in-time compilation programming language with function priority) file and a CSS (Cascading Style Sheets) file.
S103: it is detected whether a target event is triggered.
And the target event is triggered to represent that the static resource file is completely operated and the service resource file is completely acquired. The target event is pre-configured.
In the embodiment of the invention, the target event can be triggered after the static resource file is completely operated and the service resource file is completely acquired, so that the client can judge whether the static resource file is completely operated and the service resource file is completely acquired by detecting whether the target event is triggered. When the target event is triggered, the static resource file is indicated to be completely operated and the service resource file is completely acquired; when the target event is not triggered, it indicates that the static resource file operation is not completed or the service resource file acquisition is not completed, and at this time, it may wait for detecting that the target event is triggered and then execute the subsequent steps.
In an implementation manner of the embodiment of the present invention, whether the target event is triggered or not may be reflected by adjusting a value of the target parameter corresponding to the target event. Specifically, the parameter value when the target event is not triggered may be a default value, and the parameter value when the target event is triggered may be a target value, where the default value is different from the target value.
Therefore, after step S102 is executed, since the static resource file is run and the service resource file is acquired, the value of the target parameter can be changed to the target value. In this step, whether the target event is triggered may also be determined by detecting a value of the target parameter. The specific process is as follows: detecting whether the value of the target parameter is a target value; if yes, triggering a target event; if not, the target event is not triggered. Namely, the value of the target parameter is detected to be a target value, which indicates that the running of the static resource file is finished and the acquisition of the service resource file is finished; and detecting that the value of the target parameter is not the target value, and indicating that the running of the static resource file is not finished or the acquisition of the service resource file is not finished.
Specifically, in this embodiment of the present invention, the target parameter may further include a first target parameter and a second target parameter, and the target value includes a first target value and a second target value, and the step of changing the value of the target parameter to the target value is specifically executed as: when the running of the static resource file is finished, changing the value of the first target parameter into a first target value; and when the service resource file is acquired, changing the value of the second target parameter into a second target value.
Whether the static resource file operation is finished or not is represented by the value of the first target parameter, and if the value of the first target parameter is the first target value, the static resource file operation is finished; if the value of the first target parameter is not the first target value, it indicates that the static resource file has not been run. Whether the service resource file is acquired is represented by the value of the second target parameter, and if the value of the second target parameter is the second target value, the service resource file is acquired; and if the value of the second target parameter is not the second target value, indicating that the service resource file acquisition is not finished. Therefore, in the embodiment of the present invention, when the static resource file is completely run, the value of the first target parameter is changed to the first target value, and when the service resource file is completely obtained, the value of the second target parameter is changed to the second target value, so as to facilitate the detection of the subsequent target event. The first target value and the second target value may be the same or different.
In another implementation manner of the embodiment of the present invention, the static resource file is completely run and the service resource file is completely obtained, which can be split into two events for controlling respectively. Specifically, the target event may include a first event and a second event, where the first event is triggered to indicate that the static resource file is completely run, and the second event is triggered to indicate that the service resource file is completely acquired.
Based on this, this step may be specifically performed as: detecting whether a first event and a second event are both triggered; if yes, triggering a target event; if not, the target event is not triggered.
After the client finishes running the static resource file, the client can trigger a first event, so whether the running of the static resource file is finished or not is judged by detecting whether the first event is triggered or not. After the client finishes acquiring the service resource file, the client may trigger the second event, so whether the service resource file is acquired is judged by detecting whether the second event is triggered. Whether the target event is triggered or not in the step can be detected by detecting that both the first event and the second event are triggered, wherein both the first event and the second event are triggered to indicate that the running of the static resource file is finished and the acquisition of the service resource file is finished.
In the embodiment of the present invention, the static resource file may include a JS file and a CSS file, and the first event includes a JS file operation completion event and a CSS file operation completion event, so that detecting whether both the first event and the second event are triggered specifically performs: and detecting whether the JS file operation completion event, the CSS file operation completion event and the second event are all triggered.
In another implementation manner of the embodiment of the present invention, it may further be configured that a first event is triggered to indicate that the static resource file is completely run, a second event is triggered to indicate that the service resource file is completely acquired, and a target event is triggered when both the first event and the second event are triggered. Therefore, before the step, the client can trigger a first event when the running of the static resource file is finished; when the acquisition of the service resource file is completed, triggering a second event; when it is detected that both the first event and the second event are triggered, a target event is triggered, and then it may be detected whether the target event is triggered in this step.
In the embodiment of the present invention, in order to implement the above process, the page data may be configured during data development. Specifically, a first event is configured in the page data, and the first event is used for triggering after the running of the static resource file is finished; setting a second event after the service resource file is configured, wherein the second event is used for triggering after the service resource file is obtained; and configuring a target event in the page data, wherein the target event is used for triggering after the first event and the second event are both triggered.
Since the service resource file cannot be run immediately after the acquisition is successful, the second event is configured at the end of the code in the service resource file, so that the second event is triggered after the acquisition of the service resource file is finished. Meanwhile, since the service resource file can be run after the target event is triggered, a monitoring event needs to be configured at the forefront of the code in the service resource file so as to detect whether the target event is triggered, and the service resource file is run after the target event is triggered. Since the static resource file is directly run after the acquisition is completed, a logic for triggering the first event may be directly configured in the page data, that is, the first event is configured in the page data, so as to trigger the first event after the running of the static resource file is completed. After both the first event and the second event are triggered, a target event may be triggered, so the logic that triggers the target event is configured in the page data.
S104: if so, rendering the page to be displayed according to the result of operating the service resource file, and enabling the rendered page to be displayed to replace the occupation map.
After step S103 detects whether the target event is triggered, if it is determined that the target event is triggered, it indicates that the service resource file can be run, at this time, the service resource file can be run, and the page to be displayed is rendered according to the result of running the service resource file. Since the occupation bitmap is displayed in the page to be displayed by executing step S101, after the page to be displayed is rendered in this step, the rendered content will replace the occupation bitmap.
In the embodiment of the invention, whether the static resource file finishes running and whether the business resource file is completely acquired are judged by detecting whether the target event is triggered, and the business resource file is run after the static resource file finishes running and the business resource file is completely acquired, so that the running of the static resource file is ensured to be finished when the business resource file is run, the problem that the business resource file runs wrongly because the static resource file does not finish running is avoided, and the problem that the page stays in the state of displaying the occupied bitmap and cannot finish rendering is further avoided.
In the embodiment of the invention, the static resource file comprises a JS-dependent file and a CSS file, and the service resource file is a service JS file. The embodiment shown in fig. 1 is specifically described by taking an example in which the parameter X in the configuration-dependent JS file operation completion trigger event C and the parameter Y in the change event C are target values, the parameter Y in the CSS file operation completion trigger event C and the parameter Y in the change event C are target values, the service JS file acquires the post-trigger event B, the parameter Z in the trigger event C and the parameter Y in the change event C are target values after the trigger event B is triggered, the event a is triggered after the parameters X, Y, Z in the event C are target values, and the service JS file is operated after the event a is triggered.
In the above configuration, the event B needs to be configured in the code of the service JS file, that is, the event B is added at the last of the code in the service JS file, so as to trigger the event B after the service JS file is completed, and meanwhile, monitoring logic needs to be configured at the forefront of the code in the service JS file, so as to detect whether the event a is triggered, so as to operate the service JS file after the event a is triggered. Moreover, a monitoring function is configured on the page data so as to detect events such as completion of acquisition and operation of the JS-dependent file, completion of operation of the CSS file, triggering of the event B, triggering of the event C and the like, and when the completion of acquisition and operation of the JS-dependent file is detected, the parameter X in the event C is changed to be a target value; when the CSS file acquisition operation is detected to be completed, changing the parameter Y in the event C to be a target value; when detecting that the event B is triggered, changing the parameter Z in the event C to be a target value; event a is triggered when it is detected that event C is triggered, i.e. the values of parameter X, Y, Z in event C are all target values.
It should be noted that, in the embodiment of the present invention, the configuration process may be implemented by a JS-dependent file, a CSS file, and a JS-service file that are developed by packaging through Webpack, where the configuration of the JS-service code may use a nodjs read-write technology to complete code configuration in the JS-service file, that is, an event monitoring logic is added at the forefront of the code of the JS-service file to monitor the event a, and a trigger event B is added at the rearmost of the JS-service code. The reason why the trigger event B is added at the end of the service code is that the execution function defined by the monitoring event a must be acquired after the service code is loaded, otherwise the execution function of the monitoring event a cannot be acquired and an error is reported. Through the processing, the service JS code generated by Webpack packaging is wrapped by the monitoring event A, so that the client side can not immediately execute the service JS file after acquiring the service JS file. And finally, adding a trigger event B to the service JS file, so that the trigger event B can be triggered after the service JS file is obtained.
The following specifically describes the page rendering method in the embodiment of the present invention with reference to the embodiment shown in fig. 1 and the above description. As shown in fig. 2, the method includes the following steps.
S201: and acquiring page data of the page to be displayed from the server.
The client side can send a page request to the server side according to an instruction input by a user, the page request can include a URL of a page to be displayed, the server side can return page data of the page to be displayed to the client side after receiving the page request, and the page data is usually html.
It should be noted that the configuration of the trigger event, the monitoring function, and the like has already been completed in the page data returned by the server.
S202: and rendering the skeleton screen in the page to be displayed.
After the client receives the page data, the client can render the skeleton screen according to the skeleton screen information in the page data, so that the page to be displayed displays the skeleton screen.
In the embodiment of the invention, in order to relieve the mood of a user waiting for page rendering, a skeleton screen can be rendered first, and then the static resource file and the business resource file are acquired and operated.
S203: and generating a JS-dependent tag, a CSS tag and a service JS tag, and adding the JS tag to the bottom of a body tag of the page data.
After the skeleton screen is rendered on the page to be displayed, JS tags, CSS tags and service JS tags can be dynamically generated and added to the bottoms of < body > tags of the page data.
Because the skeleton screen is rendered first in the embodiment of the invention, the JS-dependent tag, the CSS tag and the JS service tag need to be generated by the client in the page rendering process, and the JS tag, the CSS tag and the JS service tag are added to the bottom of the < body > tag of the html of the page data. The tags include information such as connection of the corresponding files, so that the client can load the corresponding files by running the tags.
S204: and acquiring and operating the JS-dependent file and the CSS file, and acquiring the service JS file.
In this step, the JS-dependent file, the CSS file, and the service JS can be obtained by operating the JS-dependent tag, the CSS tag, and the service JS tag, respectively. The JS file and the CSS file are relied on to directly run after the acquisition is completed, and the operation is needed to be carried out after the event A is triggered after the acquisition of the service JS file is completed.
S205: and detecting that the JS-dependent file is operated completely, and changing the value of the parameter X in the event C into a target value.
And a monitoring function is configured in the page data, so that after the completion of the operation of the JS-dependent file is detected, a trigger event C can be executed, namely, the value of the parameter X in the event C is changed into a target value.
S206: and detecting that the CSS file is completely operated, and changing the value of the parameter Y in the event C into a target value.
The page data is configured with a monitoring function, so that after the CSS file is detected to be completely run, a trigger event C can be executed, that is, the value of the parameter Y in the event C is changed into a target value.
S207: and triggering an event B after the detection of the service JS file is finished.
And if the code in the service JS file is configured with the event B, the event B can be triggered after the service JS file is obtained.
In the embodiment of the present invention, the manner of triggering the event B may be to adjust the parameter included in the event B to a preset value, so as to indicate that the event B is triggered.
S208: after the detection event B is triggered, the value of the parameter Z in the event C is changed to a target value.
The page data is configured with a monitoring function, so that after detecting that the event B is triggered, a triggering event C can be executed, that is, the value of the parameter Z in the event C is changed to a target value.
In the embodiment of the present invention, the specific value of the target value may be set according to a scene, for example, may be set to true.
S209: after detecting event C is triggered, event a is triggered.
Event C is triggered, which means that the values of parameters X, Y and Z in event C are both target values, so after detecting that the values of parameters X, Y and Z in event C are both target values, it can be determined that time C is triggered, at which time event a can be triggered.
S210: and running the service JS file after detecting the event A is triggered.
The code in the service JS file configures the monitoring event of time A, so that the monitoring event can run the service JS file after detecting that the event A is triggered, and a result of running the service JS file is obtained.
S211: and rendering the page to be displayed according to the result of the operation of the service JS file.
And when the result of the operation of the service JS file is obtained, rendering the page to be displayed, so that the initially displayed skeleton screen is replaced in the page to be displayed, and the content to be displayed is displayed.
In the embodiment of the invention, whether the static resource file finishes running and whether the business resource file is completely acquired are judged by detecting whether the target event is triggered, and the business resource file is run after the static resource file finishes running and the business resource file is completely acquired, so that the running of the static resource file is ensured to be finished when the business resource file is run, the problem that the business resource file runs wrongly because the static resource file does not finish running is avoided, and the problem that the page stays in the state of displaying the occupied bitmap and cannot finish rendering is further avoided.
In order to solve the problems in the prior art, an embodiment of the present invention provides an apparatus 300 for page rendering, as shown in fig. 3, the apparatus 300 includes:
the rendering unit 301 is configured to render a placeholder map of a page to be displayed according to placeholder map information in page data of the page to be displayed;
a processing unit 302, configured to obtain and run a static resource file according to the static resource information in the page data, and obtain a service resource file according to the service resource information;
a detecting unit 303, configured to detect whether a target event is triggered, where the target event is triggered when the static resource file completes running and the service resource file completes acquiring;
if so, the rendering unit 301 is further configured to render the page to be displayed according to the result of running the service resource file, so that the rendered page to be displayed replaces the occupation map.
It should be understood that the manner of implementing the embodiment of the present invention is the same as the manner of implementing the embodiment shown in fig. 2, and the description thereof is omitted.
In an implementation manner of the embodiment of the present invention, the apparatus 300 further includes:
the adjusting unit is used for changing the value of the target parameter into the target value after the static resource file is operated and the service resource file is acquired;
the detecting unit 303 is specifically configured to:
detecting whether the value of the target parameter is the target value;
if yes, the target event is triggered; if not, the target event is not triggered.
In yet another implementation manner of the embodiment of the present invention, the target parameters include a first target parameter and a second target parameter, and the target values include a first target and a second target value;
the adjusting unit is specifically configured to:
when the running of the static resource file is finished, changing the value of the first target parameter into the first target value;
and when the service resource file is acquired, changing the value of the second target parameter into the second target value.
In another implementation manner of the embodiment of the present invention, the target event includes a first event and a second event, where the first event is triggered to represent that the static resource file is completely run, and the second event is triggered to represent that the service resource file is completely acquired;
the detecting unit 303 is specifically configured to:
detecting whether the first event and the second event are both triggered;
if yes, the target event is triggered; if not, the target event is not triggered.
In another implementation manner of the embodiment of the present invention, the first event represents that the static resource file is completely run, and the second event represents that the service resource file is completely obtained;
the apparatus 300 further comprises a triggering unit configured to:
when the running of the static resource file is completed, triggering the first event;
when the service resource file is acquired, triggering the second event;
triggering the target event when detecting that both the first event and the second event are triggered.
In a further embodiment, the apparatus 300 further comprises a configuration unit for:
configuring a first event in the page data, wherein the first event is used for triggering after the running of the static resource file is finished;
setting a second event at the end of the configuration of the service resource file, wherein the second event is used for triggering after the acquisition of the service resource file is finished;
configuring a target event, wherein the target event is used for triggering after the first event and the second event are both triggered.
It should be understood that the embodiment of the present invention is implemented in the same manner as the embodiment shown in fig. 1 or fig. 2, and is not repeated herein.
In the embodiment of the invention, whether the static resource file finishes running and whether the business resource file is completely acquired are judged by detecting whether the target event is triggered, and the business resource file is run after the static resource file finishes running and the business resource file is completely acquired, so that the running of the static resource file is ensured to be finished when the business resource file is run, the problem that the business resource file runs wrongly because the static resource file does not finish running is avoided, and the problem that the page stays in the state of displaying the occupied bitmap and cannot finish rendering is further avoided.
The invention also provides an electronic device and a readable storage medium according to the embodiment of the invention.
The electronic device of the present invention includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the processor, and the instructions are executed by the at least one processor to cause the at least one processor to execute the page rendering method provided by the embodiment of the invention.
Fig. 4 shows an exemplary system architecture 400 of a page rendering method or a page rendering apparatus to which an embodiment of the present invention may be applied.
As shown in fig. 4, system architecture 400 may include at least one terminal device (three terminal devices 401, 402, and 403 are shown in fig. 4). Taking the terminal device 401 as an example for illustration, the terminal device 401 may be various electronic devices that have a display screen and support page display, including but not limited to a smart phone, a tablet computer, a laptop portable computer, a desktop computer, and the like, and the terminal device 401 may implement a page rendering function when displaying a page by installing a client or an application for page display. When the terminal device 401 operates, a page data request may be sent to the server 405, so as to obtain page data of a page to be displayed from the server 405, and perform rendering of the page data.
The system architecture 400 may further include a server 405, where the server 405 may be a background management server (for example only) that provides support for a page browsed by a user using the terminal devices 401, 402, and 403, and the background management server may analyze and process data such as a received page data request, and feed back a processing result (for example, page data — for example only) to the terminal device.
As shown in fig. 4, the system architecture 400 may also include a network 404. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few. A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like.
It should be noted that the method for page rendering provided by the embodiment of the present invention is generally executed by the terminal devices 401, 402, and 403, and accordingly, the apparatus for page rendering is generally disposed in the terminal devices 401, 402, and 403.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use in implementing embodiments of the present invention is shown. The computer system illustrated in FIG. 5 is only an example and should not impose any limitations on the scope of use or functionality of embodiments of the invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a rendering unit, a processing unit, and a detection unit. Where the names of these units do not in some cases constitute a limitation of the unit itself, for example, a rendering unit may also be described as a "unit of the function of the rendering unit".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to perform the method of page rendering provided by the present invention.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of page rendering, comprising:
rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed;
acquiring and operating a static resource file according to the static resource information in the page data, and acquiring a service resource file according to the service resource information;
detecting whether a target event is triggered, wherein the target event is triggered when the static resource file is operated and the service resource file is acquired;
if so, rendering the page to be displayed according to the result of operating the service resource file, and enabling the rendered page to be displayed to replace the occupation map.
2. The method of claim 1, prior to the detecting whether the target event is triggered, further comprising:
after the static resource file is operated and the service resource file is acquired, changing the value of the target parameter into a target value;
whether the target event is triggered or not is detected, and the method comprises the following steps:
detecting whether the value of the target parameter is the target value;
if yes, the target event is triggered; if not, the target event is not triggered.
3. The method of claim 2, wherein the target parameters include a first target parameter and a second target parameter, and the target values include a first target value and a second target value;
the changing the value of the target parameter to the target value includes:
when the running of the static resource file is finished, changing the value of the first target parameter into the first target value;
and when the service resource file is acquired, changing the value of the second target parameter into the second target value.
4. The method according to claim 1, wherein the target event comprises a first event and a second event, the first event is triggered to represent that the static resource file is completely run, and the second event is triggered to represent that the business resource file is completely acquired;
whether the target event is triggered or not is detected, and the method comprises the following steps:
detecting whether the first event and the second event are both triggered;
if yes, the target event is triggered; if not, the target event is not triggered.
5. The method of claim 1, wherein the first event represents completion of the running of the static resource file, and wherein the second event represents completion of the obtaining of the business resource file;
before the detecting whether the target event is triggered, further comprising:
when the running of the static resource file is completed, triggering the first event;
when the service resource file is acquired, triggering the second event;
triggering the target event when detecting that both the first event and the second event are triggered.
6. The method of claim 5, before rendering the placeholder map for the page to be displayed according to the placeholder map information in the page data of the page to be displayed, further comprising:
configuring a first event in the page data, wherein the first event is used for triggering after the running of the static resource file is finished;
setting a second event at the end of the configuration of the service resource file, wherein the second event is used for triggering after the acquisition of the service resource file is finished;
and configuring a target event in the page data, wherein the target event is used for triggering after the first event and the second event are both triggered.
7. An apparatus for page rendering, comprising:
the rendering unit is used for rendering the placeholder map of the page to be displayed according to the placeholder map information in the page data of the page to be displayed;
the processing unit is used for acquiring and operating a static resource file according to the static resource information in the page data and acquiring a service resource file according to the service resource information;
the detection unit is used for detecting whether a target event is triggered or not, wherein the target event is triggered when the static resource file is operated and the service resource file is acquired;
and if so, the rendering unit is further configured to render the page to be displayed according to the result of operating the service resource file, so that the rendered page to be displayed replaces the occupation map.
8. The apparatus of claim 7, further comprising:
a changing unit, configured to change a value of a target parameter to a target parameter after the static resource file is completely run and the service resource file is completely acquired;
the detection unit is specifically configured to:
detecting whether the value of the target parameter is the target parameter;
if yes, the target event is triggered; if not, the target event is not triggered.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202010273940.3A 2020-04-09 2020-04-09 Page rendering method and device, electronic equipment and storage medium Pending CN113515328A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010273940.3A CN113515328A (en) 2020-04-09 2020-04-09 Page rendering method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010273940.3A CN113515328A (en) 2020-04-09 2020-04-09 Page rendering method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113515328A true CN113515328A (en) 2021-10-19

Family

ID=78060225

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010273940.3A Pending CN113515328A (en) 2020-04-09 2020-04-09 Page rendering method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113515328A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023077951A1 (en) * 2021-11-08 2023-05-11 北京沃东天骏信息技术有限公司 Data rendering method and apparatus

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023077951A1 (en) * 2021-11-08 2023-05-11 北京沃东天骏信息技术有限公司 Data rendering method and apparatus

Similar Documents

Publication Publication Date Title
CN107844324B (en) Client page jump processing method and device
CN109766082B (en) Method and device for application program page jump
CN109684008A (en) Card rendering method, device, terminal and computer readable storage medium
CN109582317B (en) Method and apparatus for debugging hosted applications
CN113961311A (en) Service data processing method, device, electronic equipment and medium
CN107347093B (en) Configuration method and device for distributed server system
CN114218890A (en) Page rendering method and device, electronic equipment and storage medium
CN112486783B (en) Progress bar display method and device
CN112817562A (en) Service processing method and device
CN113515328A (en) Page rendering method and device, electronic equipment and storage medium
CN110825425A (en) Configuration data management method and device, electronic equipment and storage medium
CN116302271A (en) Page display method and device and electronic equipment
CN106933449B (en) Icon processing method and device
CN113779122B (en) Method and device for exporting data
CN112925521A (en) Interface generation method and device
CN114625458A (en) Page data processing method and device, electronic equipment and storage medium
CN112947918A (en) Data display method and device
CN113312900A (en) Data verification method and device
CN114398023A (en) File generation method and page configuration method and device
CN110069417B (en) A/B test method and device
CN110647327A (en) Method and device for dynamic control of user interface based on card
CN113361286A (en) Information prompting method and device
CN113535187B (en) Service online method, service updating method and service providing method
CN112784195A (en) Page data publishing method and system
CN115827392B (en) Monitoring method, device and system of distributed system

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