Disclosure of Invention
The present invention provides a title bar data presentation method and system that overcomes, or at least partially solves, the above-mentioned problems.
According to a first aspect of the present invention, there is provided a title bar data display method, including:
s1, monitoring the status information of each network request completion through the message driver, wherein each network request is used for requesting each level of title data in the title bar from the server;
s2, caching all levels of header data returned by the server aiming at each network request into the configured data packaging component;
and S3, when the message driver determines that all network requests are completed, triggering the data packaging component to assemble the cached title data of each level, and displaying the assembled title data of each level in the title column.
The invention has the beneficial effects that: the synchronous request process of the title data of all levels of the title bar is completed by designing the message driver in the client, and the data packaging assembly is designed to uniformly assemble the title data of all levels, so that the development program is simpler and clearer, and the system resource overhead is reduced.
On the basis of the technical scheme, the invention can be further improved as follows.
Further, each level of title data in the title bar corresponds to a network request, and the network request is used for requesting the corresponding level of title data from the server.
Further, step S1 is preceded by:
and configuring a callback function of each network request in the message driver, so that the message driver monitors the completion status information of each network request through each callback function.
Further, the step S1 further includes:
and designing a static global variable count in the message driver, wherein the static global variable count is used for indicating the number of the network requests which are not completed in all the network requests.
Further, the step S2 further includes:
and after receiving the header data of the corresponding level returned by the server aiming at the network request, the message driver decrements the static global variable count one by one based on the callback function of the network request.
Accordingly, it is determined in step S3 that all network requests are completed by:
the message driver determines whether the static global variable count is 0, if so, it is determined that all network requests are completed, otherwise, the step S2 is continuously executed until the static global variable count is 0.
Further, the step S2 further includes:
configuring a data packaging component, and designing a data processing function in the data packaging component;
the step S3 further includes:
and when the message driver determines that all the network requests are completed, sending a message that all the network requests are completed to the data packaging component, so that the data packaging component calls a data processing function to assemble and process all levels of header data in the cache according to the received message.
Further, the data packaging component calls a data processing function according to the received message to perform assembly processing on each level of header data in the cache, and the assembly processing further includes:
and the data packaging assembly calls a data processing function to combine the title data of each level to form the assembled title data, and transmits the assembled title data to the user interface layer to realize the display of the assembled title data in the title bar.
According to a second aspect of the present invention, there is also provided a title bar data presentation system, comprising a message driver and a data wrapper component;
the message driver is used for monitoring the state information of the completion of each network request, wherein each network request is used for requesting each level of title data in the title bar from the server; and further for triggering the data wrapper component upon determining that all network requests are complete;
the data packaging component is used for caching all levels of header data returned by aiming at each network request; and the message driver is also used for assembling the cached title data of each level according to the triggering of the message driver and displaying the assembled title data of each level in the title bar.
According to a third aspect of the present invention, there is provided an apparatus for a title bar data presentation method, comprising a processor, a memory, and a bus;
the processor and the memory complete mutual communication through the bus;
the memory stores program instructions executable by the processor, and the processor calls the program instructions to perform the various implementation methods described above.
According to a fourth aspect of the present invention, there is provided a non-transitory computer readable storage medium storing computer instructions which cause the computer to perform the method as each above is implemented.
Detailed Description
The following detailed description of embodiments of the present invention is provided in connection with the accompanying drawings and examples. The following examples are intended to illustrate the invention but are not intended to limit the scope of the invention.
Referring to fig. 1, a title bar data display method according to an embodiment of the present invention is provided, including: s1, monitoring the status information of each network request completion through the message driver, wherein each network request is used for requesting each level of title data in the title bar from the server; s2, caching all levels of header data returned by the server aiming at each network request into the configured data packaging component; and S3, when the message driver determines that all network requests are completed, triggering the data packaging component to assemble the cached title data of each level, and displaying the assembled title data of each level in the title bar.
In a live page list of a client, a title bar is usually involved, and data in the title bar is usually composed of multiple levels of title data, for example, data in the whole title bar is composed of secondary title data and tertiary title data together. And the acquisition of the secondary header data and the tertiary header data is to respectively send network requests to the server to obtain the secondary header data and the tertiary header data returned by the server. The second level title data and the third level title data are then merged and displayed in the title bar of the page. The conventional implementation is to design a boolean value for each network request, and start a timer to monitor the change of all boolean values at the same time, and merge the header data of all levels when all boolean values are true. When the number of network requests is large, the number of boolean values to be designed is large, and the overhead of system resources is increased because of the start of the timer.
Based on the above problems, the present embodiment provides a set of title bar data display method, which can reduce the system overhead. The method is realized specifically by configuring a message driver in a client and monitoring state information of completion of all network requests through the message driver, wherein one network request is set for each level of title in a title bar, and the client requests title data of a corresponding level from a server through each network request. And after receiving the network request, the server returns the title data of the corresponding level to the client. And the client side is also provided with a data packaging component, and the client side caches the title data of each level returned by the server into the data packaging component. When the message driver determines that the network requests corresponding to the titles at all levels in the title bar are all completed, namely the title data at all levels in the title bar are all obtained, the message driver triggers the data packaging assembly to perform assembly processing on the cached title data at all levels, and the assembled data are displayed in the title bar.
In the embodiment, the message driver is designed at the client to complete the synchronous request process of the title data of each level of the title bar, and the data packaging assembly is designed to uniformly assemble the title data of each level, so that the development program is simpler and clearer, and the system resource overhead is reduced.
On the basis of the above embodiment, in an embodiment of the present invention, each level of title data in the title bar corresponds to a network request, and the network request is used for requesting the corresponding level of title data from the server.
In an application scenario of the embodiment, the title bar includes multiple levels of title data, for example, the data in the entire title bar is composed of two-level title data and three-level title data. And each network request is used for corresponding the network request of the level to the server, wherein each network request is independent from each other.
On the basis of the foregoing embodiments, in another embodiment of the present invention, before the step S1, the method further includes: and configuring a callback function of each network request in the message driver, so that the message driver monitors the completion status information of each network request through each callback function.
The message driver configured in the client is in a strong coupling relationship with each network request, specifically, the message driver internally holds a callback function of each network request, that is, after the network request completes the request to the server, the callback function informs the message driver of the state information of the completion of the network request, so that the message driver can know the state information of each network request. In this embodiment, the message driver is designed to be in a strong coupling relationship with each network request, so that the message driver can directly know whether each network request is completed.
On the basis of the foregoing embodiments, in another embodiment of the present invention, the step S1 further includes: and designing a static global variable count in the message driver, wherein the static global variable count is used for indicating the number of the network requests which are not completed in all the network requests.
Because each grade of title corresponds to one network request, the whole title column has a plurality of network requests, and the title data of all grades can be merged only when all the network requests are completed. When determining whether all network requests are completed, a conventional scheme is to define a boolean value for each network request, and set the boolean value of the network request to true when the network request is successfully completed. Then, a timer is started, all the boolean values are scanned periodically, and when all the boolean values are scanned to be tube, all the data requests are completed, and then the data of all the levels can be combined.
The traditional scheme needs to maintain a plurality of Boolean values, when the number of network requests is large, the number of Boolean values is large, so that the program maintenance is complex, and simultaneously, the system resource overhead is increased because a timer is started to monitor all Boolean values.
In the embodiment, a static global variable count is designed in the message driver, and the global static variable represents the number of outstanding network requests in all network requests. For example, in the initial state, there are 3 levels of header data in the header bar, and there are 3 network requests correspondingly, so the initial value of the static global variable is 3. When any network request is completed, the message driver is informed of the completion of the network request through the callback function, at this time, the message driver subtracts 1 from the value of the static global variable count, and caches the header data of the corresponding level returned by the server in the data wrapper component. And then judging whether the value of the static global variable count is 0 or not, if so, indicating that all network requests are finished, otherwise, not all network requests are finished. If the value of the static global variable count is not 0, continuing to wait, when the next network request is completed, continuing to subtract 1 from the value of the static global variable count, then judging whether the value of the static global variable count is 0 again, and repeating the steps until the value of the static global variable count is 0.
In the embodiment, the problem of synchronization of multiple network requests is effectively solved by designing a message driver, and a static global variable count is designed in the message driver to record the number of times of successful network request access, and when the value of the static global variable count is 0, it indicates that all network requests are completed. And whether all network requests are finished can be monitored only by designing a static global variable, and compared with the traditional scheme of configuring a Boolean value for each network request and starting a timer, the method has the advantages that the program is simpler and clearer, and the system overhead is saved.
On the basis of the foregoing embodiments, in another embodiment of the present invention, the step S2 further includes: configuring a data packaging component, and designing a data processing function in the data packaging component; the step S3 further includes: and when the message driver determines that all network requests are completed, sending a message to the data packaging component so that the data packaging component calls a data processing function to perform assembly processing on each level of cached header data according to the received message.
When the value of the static global variable count in the message driver is 0, the message driver sends a message that all network requests are completed to the data wrapper component, and the data wrapper component receives the message and then merges all cached header data of all levels.
In the traditional data assembling process, each level of header data returned for each network request relates to a processing function, the header data of the corresponding level are processed through the processing function, and then the processed data are assembled, so that each level of header data is processed in a plurality of different processing functions, and the data integration is very complicated. In the embodiment, the specific merging of the header data of each level is realized by designing a data processing function handleData in the data packaging component, where the data processing function handleData is used for processing data service assembly. When the value of the static global variable count in the message driver is 0, the data packaging component calls a data processing function handleData to assemble all levels of title data, the specific assembly process is that the data packaging component calls the data processing function to screen out data information required in all levels of title data, the data information is combined together to form assembled title data, and then the assembled title data is transmitted to a user interface layer, so that the assembled title data is displayed in a title bar. The title bar is displayed in the form of title data of each level.
Referring to fig. 2, a title bar data presentation system of another embodiment of the present invention is provided, comprising a message driver 21 and a data wrapper component 22.
The message driver 21 is configured to monitor status information of completion of each network request, where each network request is used to request the server for each level of title data in the title bar; and also for triggering the data wrapper component 23 when it is determined that all network requests are complete.
The data packaging component 22 is used for caching all levels of header data returned for each network request; and is further configured to assemble the cached title data of each level according to the trigger of the message driver 21, and display the assembled title data of each level in the title bar.
Referring to fig. 3, a title bar data display system according to another embodiment of the present invention is provided, and on the basis of the above embodiment, the title bar data display system further includes a configuration module 23.
The configuration module 23 is configured to configure a callback function of each network request inside the message driver 21, so that the message driver 21 monitors status information of completion of each network request through each callback function.
The configuration module 24 is further configured to design a static global variable count in the message driver 21, where the static global variable count is used to indicate the number of outstanding network requests in all network requests.
The message driver 21 is further configured to decrement the static global variable count one by one based on a callback function of the network request after the client receives the header data of the corresponding level returned by the server for the network request; and is further configured to determine whether the static global variable count is 0, determine that all network requests are completed if the static global variable count is 0, and otherwise, invoke the storage module 22 until the static global variable count is 0.
The configuration module 23 is further configured to configure the data wrapper component 22 in the client and to design the data processing functions in the data wrapper component 22.
Accordingly, the message driver 21 is further configured to send a message to the data wrapper component 22 that all network requests are completed when it is determined that all network requests are completed.
The data packaging component 22 is further configured to invoke a data processing function according to the received message to perform assembly processing on each level of cached header data.
Referring to fig. 4, a block diagram of an apparatus for a title bar data presentation method according to an embodiment of the present application is shown.
Referring to fig. 4, the apparatus of the title bar data presentation method includes: a processor (processor)401, a memory (memory)402, and a bus 403; wherein, the processor 401 and the memory 402 complete the communication with each other through the bus 403.
The processor 401 is configured to call the program instructions in the memory 402 to execute the methods provided by the above-mentioned method embodiments, for example, including: monitoring state information of completion of each network request through a message driver, wherein each network request is used for requesting each level of title data in a title bar from a server; caching all levels of header data returned by the server aiming at each network request into a configured data packaging component; and when all the network requests are determined to be completed through the message driver, triggering the data packaging component to assemble the cached title data of each level, and displaying the assembled title data of each level in the title bar.
The invention discloses a computer program product, which comprises a computer program stored on a non-transitory computer readable storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer, the computer can execute the title bar data display method provided by the corresponding embodiment, for example, the method comprises the following steps: monitoring state information of completion of each network request through a message driver, wherein each network request is used for requesting each level of title data in a title bar from a server; caching all levels of header data returned by the server aiming at each network request into a configured data packaging component; and when all the network requests are determined to be completed through the message driver, triggering the data packaging component to assemble the cached title data of each level, and displaying the assembled title data of each level in the title bar.
The present invention also provides a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions cause a computer to execute the title bar data display method provided in the corresponding embodiment, for example, the method includes: monitoring state information of completion of each network request through a message driver, wherein each network request is used for requesting each level of title data in a title bar from a server; caching all levels of header data returned by the server aiming at each network request into a configured data packaging component; and when all the network requests are determined to be completed through the message driver, triggering the data packaging component to assemble the cached title data of each level, and displaying the assembled title data of each level in the title bar.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
The above-described embodiments of the title bar data display method, such as the device and the like, are merely illustrative, where units illustrated as separate components may or may not be physically separate, and components displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute the various embodiments or some parts of the methods of the embodiments.
According to the title bar data display method and system provided by the invention, the synchronous request process of all levels of title data of the title bar is completed by designing the message driver in the client, and the data packaging assembly is designed to uniformly assemble all levels of title data, so that the development program is simpler and clearer, and the system resource overhead is reduced.
Finally, the method of the present application is only a preferred embodiment and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.