List data loading method and loading device, electronic device, and storage medium
By creating first and second lists and using worker child threads for asynchronous loading, the problem of slow data transmission speed in existing technologies is solved, achieving efficient list data loading and improving user experience.
Patent Information
- Application Number
- CN202210439641.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-25
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2042-04-25
AI Technical Summary
Existing technologies struggle to support long-term data transmission of massive amounts of data, placing a heavy burden on users' browser memory and network speed. Furthermore, lazy loading and preloading require users to wait for network latency, reducing user request speed.
By receiving page list data requests, first and second lists are created, list data in visible and non-visible areas are cached, and asynchronous loading is performed using worker child threads. Events that change the position of the view window are listened to, thus realizing multi-threaded calls and data updates.
It improved the speed at which users requested list data, stabilized the browser's data loading speed, reduced network usage, and enhanced the user experience.
Smart Images

Figure CN114756791B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data processing, and in particular to a method and device for loading list data, an electronic device, and a storage medium. Background Art
[0002] With the development of Internet diversification, users' requirements for data are constantly changing, from text to pictures, from pictures to videos, and even to live data. As users spend more time online, the demand for data is also rising sharply, but existing technologies are difficult to support long-term data transmission with huge amounts of data. For example, in a long list of data, when users keep browsing new data for a long time, it is a great test for the browser's memory and network speed. Currently, the commonly used solutions for clients are lazy loading, preloading, timed or quantitative cache clearing, etc., but this method requires users to wait for the network, which takes time, and causes some requests that do not affect the user experience to occupy network resources, reducing the speed of user requests. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to provide a method and device for loading list data, an electronic device, and a storage medium, which can increase the speed at which users request list data.
[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a method for loading list data, the method comprising:
[0005] receiving a page list data request, and calling long list data according to the page list data request;
[0006] Acquire the list height of the visible area of the page, and determine the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page;
[0007] Establishing a first list and a second list, caching the list data in the visible area of the page in the long list data into the first list, and caching the list data in the non-visible area of the page in the long list data into the second list;
[0008] Calling the list data corresponding to the first list to display it in the visible area of the page, and sending the list data corresponding to the second list to a preset worker subthread;
[0009] Obtaining view window position information of list data corresponding to the first list in a visible area of the page;
[0010] When a position change event of the view window position information is monitored, a sub-thread request is sent to the worker sub-thread;
[0011] The list data corresponding to the second list is called according to the child thread request, and the list data corresponding to the first list and the second list are updated according to the long list data.
[0012] In some embodiments, after obtaining the view window position information of the list data corresponding to the first list in the visible area of the page, the method further includes:
[0013] Setting a node for monitoring view window position changes at the view window position corresponding to the view window position information;
[0014] The position change event of the view window position is monitored according to the node for monitoring the view window position change.
[0015] In some embodiments, the view window position includes a head window position and a tail window position, and setting a node for monitoring view window position changes at the view window position corresponding to the view window position information includes:
[0016] A node for monitoring the view window position change is respectively set at the head window position and the tail window position corresponding to the view window position information, and the node for monitoring the view window position change includes a head monitoring node and a tail monitoring node, wherein the head window position corresponds to the head monitoring node, and the tail window position corresponds to the tail monitoring node;
[0017] When the head listening node detects that a position change event of the view window position is triggered, the visible area of the page is pulled down to update the corresponding list data; when the tail listening node detects that a position change event is triggered, the visible area of the page is slid up to update the corresponding list data.
[0018] In some embodiments, calling the list data corresponding to the first list to display in the visible area of the page, and sending the list data corresponding to the second list to a preset worker sub-thread, includes:
[0019] Using the main thread to call the list data corresponding to the first list to display it in the visible area of the page;
[0020] A worker object is introduced through the browser V8 engine, and a worker sub-thread is obtained according to the worker object, and there is a priority relationship between the worker sub-thread and the main thread;
[0021] Sending the list data corresponding to the second list to the worker sub-thread;
[0022] The worker sub-thread and the priority relationship are encapsulated according to a preset encapsulation configuration item to obtain a worker thread library, wherein the worker thread library is used to call the list data corresponding to the second list according to the received sub-thread request.
[0023] In some embodiments, before calling the list data corresponding to the first list to be displayed in the visible area of the page and sending the list data corresponding to the second list to a preset worker sub-thread, the method further includes:
[0024] Obtaining a data loading range threshold preconfigured in the second list;
[0025] Performing data screening on the list data corresponding to the second list according to the data loading range threshold to obtain a third list, wherein the third list is used to cache the list data in the second list that is greater than the data loading range threshold;
[0026] Destroy the list data corresponding to the third list.
[0027] In some embodiments, calling the list data corresponding to the second list according to the child thread request, and updating the list data corresponding to the first list and the second list according to the long list data, includes:
[0028] Obtain the long list data;
[0029] Determine, according to the child thread request, position information of the page visible area after the position change in the long list data;
[0030] Calling the list data of the second list according to the position information to determine the list data corresponding to the visible area of the page after the position change;
[0031] The list data corresponding to the first list and the second list are updated according to the list data corresponding to the visible area of the page after the position change.
[0032] In some embodiments, obtaining the list height of the visible area of the page, and determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page, includes:
[0033] Get the preset list data height and the list height of the visible area of the page;
[0034] Load and render the long list data according to the page list data request and the preset list data height to obtain the real height of the list data in the visible area of the page;
[0035] According to the real height of the list data, the list data in the long list data that are in the visible area of the page and the list data that are in the non-visible area of the page are determined, and the list data in the visible area of the page and the list data in the non-visible area of the page are stored in the browser's cache respectively.
[0036] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a device for loading list data, the device comprising:
[0037] A first data calling module, used for receiving a page list data request and calling long list data according to the page list data request;
[0038] A list data acquisition module, used to acquire the list height of the visible area of the page, and determine the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page;
[0039] A list creation module, used to create a first list and a second list, cache the list data in the visible area of the page in the long list data to the first list, and cache the list data in the non-visible area of the page in the long list data to the second list;
[0040] A second data calling module is used to call the list data corresponding to the first list to display it in the visible area of the page, and send the list data corresponding to the second list to a preset worker sub-thread;
[0041] A position information acquisition module, used to acquire view window position information of list data corresponding to the first list in the visible area of the page;
[0042] A request sending module, configured to send a sub-thread request to the worker sub-thread when a position change event of the view window position information is monitored;
[0043] A data updating module is used to call the list data corresponding to the second list according to the child thread request, and update the list data corresponding to the first list and the second list according to the long list data.
[0044] To achieve the above-mentioned purpose, a third aspect of the embodiments of the present application provides an electronic device, including:
[0045] at least one memory;
[0046] at least one processor;
[0047] at least one computer program;
[0048] The at least one computer program is stored in the at least one memory, and the at least one processor executes the at least one computer program to implement the method for loading list data described in the first aspect above.
[0049] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a storage medium, which is a computer-readable storage medium. The computer-readable storage medium stores a computer program, and the computer program is used to enable a computer to execute the method for loading list data described in the first aspect above.
[0050] The method and device for loading list data, the electronic device, and the storage medium proposed in the present application receive a page list data request and call the long list data according to the page list data request. In order to display the content of the long list data in the current page visible area, the list height of the page visible area is obtained, and according to the list height of the page visible area, the list data in the long list data in the page visible area and the list data in the page non-visible area are determined. By establishing a first list and a second list, the list data in the long list data in the page visible area is cached to the first list, and the list data in the long list data in the page non-visible area is cached to the second list. In order to stably improve the browsing speed of the user for the data in the page visible area, the list data corresponding to the first list is called to be displayed in the page visible area, and the list data corresponding to the second list is sent to the preset worker sub-thread. In order to improve the efficiency of the request for list data, the view window position information of the list data corresponding to the first list in the page visible area is obtained, and when the position change event of the view window position information is monitored, a sub-thread request is sent to the worker sub-thread, the list data corresponding to the second list is called according to the sub-thread request, and the list data corresponding to the first list and the second list are updated according to the long list data. This application can improve the user's request speed for list data by introducing a preset worker sub-thread in the call of long list data. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 is a flowchart of a method for loading list data provided in the first embodiment of the present application;
[0052] Figure 2 is a flowchart of a method for loading list data provided in the second embodiment of the present application;
[0053] Figure 3 yes Figure 2 Flow chart of step S210 in FIG.
[0054] Figure 4 yes Figure 1 Flow chart of step S140 in FIG.
[0055] Figure 5 is a flowchart of a method for loading list data provided in the third embodiment of the present application;
[0056] Figure 6 yes Figure 1 Flowchart of step S170 in FIG.
[0057] Figure 7 yes Figure 1 Flow chart of step S120 in FIG.
[0058] Figure 8 is a schematic diagram of the structure of a device for loading list data provided in an embodiment of the present application;
[0059] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0061] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0063] First, some nouns involved in this application are analyzed:
[0064] Artificial Intelligence (AI): It is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science. AI attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0065] Lazy loading (Load On Demand): also known as delayed loading, is a method of data acquisition. For example, for lazy loading of images, when accessing a page, the background image path of the image element or other elements is first replaced with the path of a 1*1px image. Only when the image appears in the visible area of the browser, the actual path of the image is set to display the image.
[0066] Preloading: that is, loading images in advance, so that they can be rendered directly from the local cache when the user needs to view them.
[0067] Coupling Dependency: is a software metric that refers to the degree of interconnection between modules in the software system structure. The tighter the connection between modules, the stronger the coupling, and the worse the independence of the modules.
[0068] With the development of Internet diversification, users' requirements for data are constantly changing, from text to pictures, from pictures to videos, and even to live data. As users spend more time online, the demand for data is also rising sharply, but existing technologies are difficult to support long-term data transmission with huge amounts of data. For example, in a long list of data, when users keep browsing new data for a long time, it is a great test for the browser's memory and network speed. Currently, the commonly used solutions for clients are lazy loading, preloading, timed or quantitative cache clearing, etc., but this method requires users to wait for the network, which takes time, and causes some requests that do not affect the user experience to occupy network resources, which reduces the user's request speed and cannot meet the user's needs for fast browsing.
[0069] Based on this, the embodiments of the present application provide a method and device for loading list data, an electronic device, and a storage medium, which can increase the speed of users' requests for list data.
[0070] The list data loading method and loading device, electronic device, and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the list data loading method in the embodiments of the present application is described.
[0071] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0072] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0073] The method for loading list data provided in the embodiment of the present application relates to the field of artificial intelligence technology. The method for loading list data provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the method for loading list data, etc., but is not limited to the above forms.
[0074] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0075] See also Figure 1 , Figure 1 is an optional flowchart of the method for loading list data provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S110 to S170. Figure 1 These seven steps are introduced in detail.
[0076] Step S110, receiving a page list data request, and calling long list data according to the page list data request;
[0077] Step S120, obtaining the list height of the visible area of the page, and determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page;
[0078] Step S130, establishing a first list and a second list, caching the list data in the visible area of the page in the long list data into the first list, and caching the list data in the non-visible area of the page in the long list data into the second list;
[0079] Step S140, calling the list data corresponding to the first list to display it in the visible area of the page, and sending the list data corresponding to the second list to a preset worker subthread;
[0080] Step S150, obtaining the view window position information of the list data corresponding to the first list in the visible area of the page;
[0081] Step S160, when a position change event of the view window position information is monitored, a child thread request is sent to the worker child thread;
[0082] Step S170: calling the list data corresponding to the second list according to the child thread request, and updating the list data corresponding to the first list and the second list according to the long list data.
[0083] In the step S110 to step S170 of the embodiment of the present application, a page list data request is received, and the long list data is called according to the page list data request. In order to display the content of the long list data in the current page visible area, the list height of the page visible area is obtained, and according to the list height of the page visible area, the list data in the long list data in the page visible area and the list data in the page non-visible area are determined. By establishing a first list and a second list, the list data in the long list data in the page visible area is cached to the first list, and the list data in the long list data in the page non-visible area is cached to the second list. In order to stably improve the browsing speed of the user for the data in the page visible area, the list data corresponding to the first list is called to be displayed in the page visible area, and the list data corresponding to the second list is sent to the preset worker sub-thread. In order to improve the request efficiency for the list data, the view window position information of the list data corresponding to the first list in the page visible area is obtained, and when the position change event of the view window position information is monitored, a sub-thread request is sent to the worker sub-thread, and the list data corresponding to the second list is called according to the sub-thread request, and the list data corresponding to the first list and the second list are updated according to the long list data. This application can improve the user's request speed for list data by introducing a preset worker sub-thread in the call of long list data.
[0084] Specifically, in step S110 of some embodiments, when the user browses the page list data, the long list data is called according to the received page list data request. It should be noted that the long list data contains a large number of list item data of DOM structure. For example, the long list data includes 1000 list item data. Since the loading of the list item data in the long list data in the visible area of the page is limited, and the list data cannot be loaded in a paging manner, it will take a lot of time to render the long list. Therefore, the virtual list method is used to render the data of the long list data in the visible area of the page, and only the data of the list DOM nodes within the visible area of the page and its preset list item offset range are retained, while the data in the non-visible area is not rendered or partially rendered, thereby improving the rendering performance of the list data. Specifically, the loading and rendering starts from the first list item data of the long list data, and each list item data is loaded and rendered one by one in sequence downward, and the virtual DOM height value is accumulated for the list item height corresponding to the loaded and rendered list item data, and the accumulation is stopped when the accumulated value is greater than or equal to the list height of the visible area of the page.
[0085] It should be noted that the preset list item offset range is a certain number of list item data with DOM structure above and below the visible area of the page, so as to avoid excessive accumulation and reduce the rendering efficiency of the browser page, so that users can maintain a smooth browsing speed and a good user experience when browsing pages with long lists for a long time. Among them, the list item offset range is part of the list data in the non-visible area of the page.
[0086] Specifically, in step S120 and step S130 of some embodiments, in order to completely render the list items in the visible area of the page, the list height of the visible area of the page is obtained, and according to the list height of the visible area of the page, the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data are determined. Since the list height of the visible area of the page is obtained, the number of list items that can be rendered in the visible area of the page is obtained according to the preset list item height in the visible area of the page. In order to clearly illustrate the method of loading list data in the present application, by establishing a first list and a second list, the list data in the visible area of the page in the long list data is cached to the first list, and the list data in the non-visible area of the page in the long list data is cached to the second list.
[0087] It should be noted that the list height in the visible area of the page can be set to different values depending on the device where the page is located, and is not specifically limited here.
[0088] Specifically, in step S140 of some embodiments, in order to fully improve the speed of network development, a multi-threaded operation mode is implemented by introducing a preset worker sub-thread, that is, by calling the list data corresponding to the first list to display it in the visible area of the page, and sending the list data corresponding to the second list to the preset worker sub-thread, that is, the worker sub-thread will preload the list data in the non-visible area of the page in the long list data, and store the preloaded data in the client's cache, thereby quickly and stably improving the user's browsing request speed.
[0089] Specifically, in step S150 of some embodiments, in order to effectively monitor the browsing status of the user in the visible area of the page, the view window position information of the list data corresponding to the first list in the visible area of the page is obtained.
[0090] Specifically, in step S160 of some embodiments, when a position change event of the view window position information is monitored, a sub-thread request is sent to the worker sub-thread. It should be noted that the position change event causing the view window position information includes the user scrolling the current page in the mobile terminal, or using an external input device such as a mouse, and monitoring the position change event generated by the view window position information in the visible area of the page, then sending a sub-thread request to the worker sub-thread can quickly implement the call of the pre-loaded list data in the sub-thread, thereby improving the user's request browsing speed for the list data.
[0091] Specifically, in step S170 of some embodiments, when a position change event of the view window position information is monitored, the list data corresponding to the second list is called according to the child thread request, and the list data corresponding to the first list and the second list are updated according to the long list data. This allows the preloaded list data in the child thread to be called quickly, thereby increasing the user's request browsing speed for the list data and avoiding the reduction in request speed due to long-term browsing.
[0092] Please refer to Figure 2 , Figure 2 is an optional flow chart of a method for loading list data provided in other embodiments of the present application. In some embodiments of the present application, after step S150, the method for loading list data of the present application further includes but is not limited to step S210 and step S220. Figure 2 These two steps are introduced in detail.
[0093] Step S210, setting a node for monitoring view window position changes at the view window position corresponding to the view window position information;
[0094] Step S220: monitoring the position change event of the view window position according to the node that monitors the view window position change.
[0095] Specifically, in some embodiments, in order to effectively monitor the user's browsing status in the visible area of the page, after obtaining the view window position information of the list data corresponding to the first list in the visible area of the page, a node for monitoring the view window position change is set at the view window position corresponding to the view window position information. When the user scrolls the page, the node for monitoring the view window position change monitors the position change event of the view window position, and sends a sub-thread request to the worker sub-thread, and quickly calls the preloaded list data of the second list according to the sub-thread request, thereby improving the user's request browsing speed for the list data.
[0096] Please refer to Figure 3 , Figure 3is a flowchart of a specific method of step S210 provided in some embodiments of the present application. In some embodiments of the present application, the view window position includes the first window position and the last window position, and step S210 specifically includes but is not limited to step S310 and step S320. Figure 3 These two steps are introduced in detail.
[0097] Step S310, respectively setting nodes for monitoring view window position changes at the head window position and the tail window position corresponding to the view window position information, the nodes for monitoring view window position changes include a head monitoring node and a tail monitoring node, wherein the head window position corresponds to the head monitoring node, and the tail window position corresponds to the tail monitoring node;
[0098] Step S320, when the head listening node listens to the position change event of the view window position being triggered, the visible area of the page is pulled down to update the corresponding list data; when the tail listening node listens to the position change event being triggered, the visible area of the page is slid up to update the corresponding list data.
[0099] Specifically, in some embodiments, the view window position includes a head window position and a tail window position, and nodes for monitoring changes in the view window position are respectively set at the head window position and the tail window position corresponding to the view window position information, and the nodes for monitoring changes in the view window position include a head monitoring node and a tail monitoring node, wherein the head window position corresponds to the head monitoring node, and the tail window position corresponds to the tail monitoring node. Specifically, the area range of the first list item data in the current page visible area is obtained, that is, the head monitoring node is set at the head window position of the page visible area, and the head monitoring node can be set at the upper boundary of the area range, but in actual settings, it is not limited to setting the head monitoring node at the upper boundary position. In addition, the area range of the last list item data in the current page visible area is obtained, that is, the tail monitoring node is set at the tail window position of the page visible area, and the tail monitoring node can be set at the lower boundary of the area range, but in actual settings, it is not limited to setting the tail monitoring node at the lower boundary position. When the head listening node listens to the position change event of the view window position being triggered, it means that the user pulls down to update the list data corresponding to the visible area of the page; when the tail listening node listens to the position change event being triggered, it means that the user swipes up to update the list data corresponding to the visible area of the page.
[0100] Please refer to Figure 4 , Figure 4 is a flowchart of a specific method of step S140 provided in some embodiments of the present application. In some embodiments of the present application, step S140 specifically includes but is not limited to steps S410 to S440. Figure 4 These four steps are introduced in detail.
[0101] Step S410, using the main thread to call the list data corresponding to the first list to display it in the visible area of the page;
[0102] Step S420, introducing a worker object through the browser V8 engine, and obtaining a worker sub-thread according to the worker object, and there is a priority relationship between the worker sub-thread and the main thread;
[0103] Step S430, sending the list data corresponding to the second list to the worker sub-thread;
[0104] Step S440, encapsulating the worker sub-threads and the priority relationship according to the preset encapsulation configuration items to obtain a worker thread library, wherein the worker thread library is used to call the list data corresponding to the second list according to the received sub-thread request.
[0105] Specifically, in some embodiments, in order to fully improve the speed of network development, the main thread is used to call the list data corresponding to the first list to display it in the visible area of the page. The worker object is introduced through the browser V8 engine, and the worker sub-thread is obtained according to the worker object. There is a priority relationship between the worker sub-thread and the main thread. The priority relationship can be implemented as a multi-threaded call for the request of the web page, that is, the list data corresponding to the second list is sent to the worker sub-thread. In order to avoid the jamming situation when the user browses the page for a long time, the worker sub-thread and the priority relationship are encapsulated according to the preset encapsulation configuration items to obtain a worker thread library, wherein the worker thread library is used to call the list data corresponding to the second list according to the received sub-thread request.
[0106] It should be noted that the preset encapsulation configuration items include: the request path of the worker subthread, the request parameters of the worker subthread, the return parameter processing, the input parameters, output parameters, call path, data processing process, the range of visible page display, the limit number of list items, etc. The worker subthreads and priority relationships are encapsulated according to the preset encapsulation configuration items to obtain an independent worker thread library, and according to different application scenarios, the preset encapsulation configuration items and the reverse can be flexibly adjusted to reduce the coupling between the modules. The embodiments of the present application can effectively improve the development quality and reduce the development time of loading list data, thereby improving the user's request browsing speed for list data.
[0107] Please refer to Figure 5 , Figure 5is an optional flow chart of a method for loading list data provided in other embodiments of the present application. In some embodiments of the present application, before step S140, the method for loading list data of the present application also includes but is not limited to steps S510 to S530. Figure 5 These three steps are introduced in detail.
[0108] Step S510, obtaining a data loading range threshold pre-configured in the second list;
[0109] Step S520, filtering the list data corresponding to the second list according to the data loading range threshold to obtain a third list, where the third list is used to cache the list data in the second list that is greater than the data loading range threshold;
[0110] Step S530: destroy the list data corresponding to the third list.
[0111] Specifically, in some embodiments, in order to improve the efficiency of requesting list data, before calling the list data corresponding to the first list to display in the visible area of the page, the embodiment of the present application obtains the data loading range threshold value preconfigured by the second list, and screens the list data corresponding to the second list according to the data loading range threshold value to obtain a third list, and the third list is used to cache the list data in the second list that is greater than the data loading range threshold value, and destroy the list data corresponding to the third list. That is, in the second list, only the list data that needs to be preloaded in the non-visible area of the page of the long list data is saved, and the preloaded data is stored in the cache of the client, so that when the user pulls down or swipes up, the changed list data can be quickly called and displayed in the visible area of the page, thereby quickly and stably improving the browsing request speed of the user. It should be noted that the data destruction of the list data corresponding to the third list, that is, the destruction of the DOM structure corresponding to the list data corresponding to the third list, can avoid the accumulation of a large number of redundant DOM structures, thereby reducing the browser rendering efficiency, so as to reduce the efficiency of the user's request for list data.
[0112] It should be noted that the data loading range threshold value pre-configured in the second list can set the value of a certain number of list items above and below the current page visible area as the data loading range threshold value. For example, set the 20 list items above and below the page visible area as the data loading range threshold value, and then cache the list data of the second list that exceeds the 20 list items above and below the page visible area into the set third list. It should be noted that the value of the data loading range threshold value is not specifically limited and can be flexibly adjusted as needed.
[0113] Please refer to Figure 6 , Figure 6is a flowchart of a specific method of step S170 provided in some embodiments of the present application. In some embodiments of the present application, step S170 specifically includes but is not limited to steps S610 to S640. Figure 6 These four steps are introduced in detail.
[0114] Step S610, obtaining long list data;
[0115] Step S620, determining the position information of the page visible area after the position change in the long list data according to the child thread request;
[0116] Step S630, calling the list data in the second list according to the position information to determine the list data corresponding to the visible area of the page after the position change;
[0117] Step S640 , updating the list data corresponding to the first list and the second list according to the list data corresponding to the visible area of the page after the position change.
[0118] Specifically, in some embodiments, after the worker subthread receives the subthread request, it reacquires the long list data, determines the position information of the page visible area after the position change in the long list data according to the subthread request, and calls the list data in the second list according to the position information. Then, the list data of the page visible area is updated at this time, and the list data corresponding to the page visible area after the position change is determined. And the list data corresponding to the first list and the second list are updated according to the list data corresponding to the page visible area after the position change, that is, the list data corresponding to the first list, the second list, and the third list are re-determined according to the long list data.
[0119] It should be noted that when the list data corresponding to the updated second list is empty, that is, the list data corresponding to the visible area of the current page is the list item data at the lower boundary of the long list data, then when the tail listening node again listens to the position change event being triggered, that is, the visible area of the page is swiped up again to update the corresponding list data, a prompt message indicating that there is no more data content can be displayed at the bottom of the visible area of the page.
[0120] Please refer to Figure 7 , Figure 7 is a flowchart of a specific method of step S120 provided in some embodiments of the present application. In some embodiments of the present application, step S120 specifically includes but is not limited to steps S710 to S730. Figure 7 These three steps are introduced in detail.
[0121] Step S710, obtaining a preset list data height and a list height of a visible area of the page;
[0122] Step S720, loading and rendering the long list data according to the page list data request and the preset list data height, and obtaining the real height of the list data in the visible area of the page;
[0123] Step S730, according to the real height of the list data, determine the list data in the long list data that is in the visible area of the page and the list data in the non-visible area of the page, and store the list data in the visible area of the page and the list data in the non-visible area of the page in the browser cache respectively.
[0124] Specifically, in some embodiments, in order to flexibly adjust the height of the list data, the preset list data height and the list height of the visible area of the page are obtained, wherein the preset list data height defines the height of each list item rendered in the visible area of the page. The long list data is loaded and rendered according to the page list data request and the preset list data height to obtain the real height of the list data in the visible area of the page, wherein the real height of the list data is equivalent to the distance between the bottom window position of the bottom list item and the top window position of the top list item in the list data corresponding to the rendered visible area of the page. In order to better improve the efficiency of the request for list data, the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data are determined according to the real height of the list data, and the list data in the visible area of the page and the list data in the non-visible area of the page are stored in the cache of the browser respectively.
[0125] The method for loading list data proposed in the embodiment of the present application receives a request for page list data to call long list data. In order to display the content of the long list data in the visible area of the page, the list height of the visible area of the page is obtained, and according to the list height of the visible area of the page, the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data are determined. By establishing a first list and a second list, the list data in the visible area of the page in the long list data is cached to the first list, and the list data in the non-visible area of the page in the long list data is cached to the second list. In order to stably improve the browsing speed of the user for the data in the visible area of the page, the pre-configured data loading range threshold of the second list is obtained, and the list data corresponding to the second list is screened according to the data loading range threshold, and a third list for caching the list data in the second list that is greater than the data loading range threshold is obtained, and the list data corresponding to the third list is destroyed. In order to fully improve the speed of network development, the main thread is used to call the list data corresponding to the first list to display it in the visible area of the page. The worker object is introduced through the browser V8 engine, and the worker sub-thread is obtained according to the worker object. There is a priority relationship between the worker sub-thread and the main thread. The priority relationship can be realized as a multi-threaded call for the request of the web page, that is, the list data corresponding to the second list is sent to the worker sub-thread. In order to avoid the jamming situation when the user browses the page for a long time, the worker sub-thread and the priority relationship are encapsulated according to the preset encapsulation configuration items to obtain the worker thread library, wherein the worker thread library is used to call the list data corresponding to the second list according to the received sub-thread request. In order to improve the efficiency of the request for list data, the view window position information of the list data corresponding to the first list in the visible area of the page is obtained, when the position change event of the view window position information is monitored, the sub-thread request is sent to the worker sub-thread, the position information of the visible area of the page after the position change in the long list data is determined according to the sub-thread request, and the list data in the second list is called according to the position information to determine the list data corresponding to the visible area of the page after the position change, and the list data corresponding to the first list and the second list are updated according to the list data corresponding to the visible area of the page after the position change, thereby effectively improving the user's request efficiency for list data.
[0126] Please refer to Figure 8 The embodiment of the present application also provides a device for loading list data, which can implement the above-mentioned method for loading list data. The device includes a first data calling module 810, a list data acquisition module 820, a list establishment module 830, a second data calling module 840, a location information acquisition module 850, a request sending module 860 and a data update module 870.
[0127] The first data calling module 810 is used to receive a page list data request and call the long list data according to the page list data request;
[0128] The list data acquisition module 820 is used to acquire the list height of the visible area of the page, and determine the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page;
[0129] A list creation module 830 is used to create a first list and a second list, cache the list data in the visible area of the page in the long list data to the first list, and cache the list data in the non-visible area of the page in the long list data to the second list;
[0130] The second data calling module 840 is used to call the list data corresponding to the first list to display it in the visible area of the page, and send the list data corresponding to the second list to a preset worker sub-thread;
[0131] The position information acquisition module 850 is used to acquire the view window position information of the list data corresponding to the first list in the visible area of the page;
[0132] The request sending module 860 is used to send a sub-thread request to the worker sub-thread when a position change event of the view window position information is monitored;
[0133] The data updating module 870 is used to call the list data corresponding to the second list according to the child thread request, and update the list data corresponding to the first list and the second list according to the long list data.
[0134] It should be noted that the list data loading device of the embodiment of the present application is used to implement the above-mentioned list data loading method. The list data loading device of the embodiment of the present application corresponds to the above-mentioned list data loading method. Please refer to the above-mentioned list data loading method for the specific processing process, which will not be repeated here.
[0135] The embodiment of the present application also provides an electronic device, which includes: at least one memory, at least one processor, and at least one computer program, wherein the at least one computer program is stored in the at least one memory, and the at least one processor executes the at least one computer program to implement any one of the list data loading methods in the above embodiments. The electronic device can be any intelligent terminal including a tablet computer, a vehicle-mounted computer, etc.
[0136] Please refer to Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0137] The processor 910 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0138] The memory 920 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 920 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 920, and the processor 910 calls and executes the method for loading list data in the embodiment of this application;
[0139] Input / output interface 930, used to implement information input and output;
[0140] Communication interface 940, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0141] bus 950 , which transmits information between the various components of the device (e.g., processor 910 , memory 920 , input / output interface 930 , and communication interface 940 );
[0142] The processor 910 , the memory 920 , the input / output interface 930 , and the communication interface 940 are connected to each other in communication within the device via a bus 950 .
[0143] The embodiment of the present application further provides a storage medium, which is a computer-readable storage medium. The computer-readable storage medium stores a computer program, and the computer program is used to enable a computer to execute any one of the list data loading methods in the above embodiments.
[0144] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0145] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0146] It can be understood by those skilled in the art that Figures 1 to 7 The technical solutions shown in the figure do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than those shown in the figure, or a combination of certain steps, or different steps.
[0147] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or 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 this embodiment.
[0148] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0149] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0150] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0151] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0152] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0154] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0155] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for loading list data, characterized in that: The method comprises: receiving a page list data request, and calling long list data according to the page list data request; Obtaining the list height of the visible area of the page, and determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page; the obtaining the list height of the visible area of the page, and determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page, comprises: obtaining a preset list data height and a list height of the visible area of the page; loading and rendering the long list data according to the page list data request and the preset list data height to obtain the real height of the list data in the visible area of the page; determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the real height of the list data, and storing the list data in the visible area of the page and the list data in the non-visible area of the page in the cache of the browser respectively; Establishing a first list and a second list, caching the list data in the visible area of the page in the long list data into the first list, and caching the list data in the non-visible area of the page in the long list data into the second list; Obtaining a data loading range threshold preconfigured in the second list; Performing data screening on the list data corresponding to the second list according to the data loading range threshold to obtain a third list, wherein the third list is used to cache the list data in the second list that is greater than the data loading range threshold; Destroying the list data corresponding to the third list; Calling the list data corresponding to the first list to display in the visible area of the page, and sending the list data corresponding to the second list to a preset worker subthread; Obtaining view window position information of list data corresponding to the first list in the visible area of the page; A node for monitoring view window position changes is set at the view window position corresponding to the view window position information; wherein the view window position includes a head window position and a tail window position, and the node for monitoring view window position changes is set at the view window position corresponding to the view window position information, including: respectively setting nodes for monitoring view window position changes at the head window position and the tail window position corresponding to the view window position information, and the node for monitoring view window position changes includes a head monitoring node and a tail monitoring node, wherein the head window position corresponds to the head monitoring node, and the tail window position corresponds to the tail monitoring node; when the head monitoring node monitors that a position change event of the view window position is triggered, the page visible area is pulled down to update the corresponding list data; when the tail monitoring node monitors that the position change event is triggered, the page visible area is slid up to update the corresponding list data; Monitoring the position change event of the view window position according to the node for monitoring the view window position change; When a position change event of the view window position information is monitored, a sub-thread request is sent to the worker sub-thread; The list data corresponding to the second list is called according to the child thread request, and the list data corresponding to the first list and the second list are updated according to the long list data.
2. The method for loading list data according to claim 1, characterized in that: The calling of the list data corresponding to the first list to display in the visible area of the page, and sending the list data corresponding to the second list to a preset worker sub-thread, includes: Using the main thread to call the list data corresponding to the first list to display it in the visible area of the page; A worker object is introduced through the browser V8 engine, and a worker sub-thread is obtained according to the worker object, and there is a priority relationship between the worker sub-thread and the main thread; Sending the list data corresponding to the second list to the worker sub-thread; The worker sub-thread and the priority relationship are encapsulated according to a preset encapsulation configuration item to obtain a worker thread library, wherein the worker thread library is used to call the list data corresponding to the second list according to the received sub-thread request.
3. The method for loading list data according to claim 1 or 2, characterized in that: The calling of the list data corresponding to the second list according to the child thread request, and updating the list data corresponding to the first list and the second list according to the long list data, comprises: Obtain the long list data; Determine, according to the child thread request, position information of the page visible area after the position change in the long list data; Calling the list data of the second list according to the position information to determine the list data corresponding to the visible area of the page after the position change; The list data corresponding to the first list and the second list are updated according to the list data corresponding to the visible area of the page after the position change.
4. A device for loading list data, characterized in that: The device comprises: A first data calling module, used for receiving a page list data request and calling long list data according to the page list data request; A list data acquisition module, used for acquiring the list height of the visible area of the page, and determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page; the acquiring the list height of the visible area of the page and determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the list height of the visible area of the page, including: acquiring a preset list data height and a list height of the visible area of the page; loading and rendering the long list data according to the page list data request and the preset list data height to obtain the real height of the list data in the visible area of the page; determining the list data in the visible area of the page and the list data in the non-visible area of the page in the long list data according to the real height of the list data, and storing the list data in the visible area of the page and the list data in the non-visible area of the page in the cache of the browser respectively; A list establishment module is used to establish a first list and a second list, cache the list data in the visible area of the page in the long list data to the first list, and cache the list data in the non-visible area of the page in the long list data to the second list; obtain a preconfigured data loading range threshold for the second list; perform data screening on the list data corresponding to the second list according to the data loading range threshold to obtain a third list, wherein the third list is used to cache the list data in the second list that is greater than the data loading range threshold; and perform data destruction on the list data corresponding to the third list; A second data calling module is used to call the list data corresponding to the first list to display it in the visible area of the page, and send the list data corresponding to the second list to a preset worker sub-thread; A position information acquisition module, used for acquiring the view window position information of the list data corresponding to the first list in the visible area of the page; setting a node for monitoring the view window position change at the view window position corresponding to the view window position information; wherein the view window position includes a head window position and a tail window position, and the node for monitoring the view window position change at the view window position corresponding to the view window position information includes: respectively setting nodes for monitoring the view window position change at the head window position and the tail window position corresponding to the view window position information, and the node for monitoring the view window position change includes a head monitoring node and a tail monitoring node, wherein the head window position corresponds to the head monitoring node, and the tail window position corresponds to the tail monitoring node; when the head monitoring node monitors that the position change event of the view window position is triggered, the visible area of the page pulls down to update the corresponding list data; when the tail monitoring node monitors that the position change event is triggered, the visible area of the page slides up to update the corresponding list data; according to the node for monitoring the view window position change, the position change event of the view window position is monitored; A request sending module, configured to send a sub-thread request to the worker sub-thread when a position change event of the view window position information is monitored; A data updating module is used to call the list data corresponding to the second list according to the child thread request, and update the list data corresponding to the first list and the second list according to the long list data.
5. An electronic device, characterized in that include: at least one memory; at least one processor; at least one computer program; The at least one computer program is stored in the at least one memory, and the at least one processor executes the at least one computer program to implement: The method for loading list data according to any one of claims 1 to 3.
6. Storage medium, the storage medium is a computer-readable storage medium, characterized in that: The computer readable storage medium stores a computer program, and the computer program is used to cause a computer to execute: The method for loading list data according to any one of claims 1 to 3.
