Page loading method, device, computer equipment and storage medium
By only parsing and displaying the data on the path from the destination web address to the target node when the page is loaded, the page crash problem caused by the loading of the large data navigation tree is solved, and faster loading speed and better user experience are achieved.
Patent Information
- Application Number
- CN202211724685.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-12-30
AI Technical Summary
When building a navigation tree with a large amount of data, the loading method of tree-shaped data in the prior art is improperly processed, resulting in unresponsive or even crashing of the web front-end page, resulting in a bad user experience.
By obtaining the target web page address, parsing and obtaining the tree data structure, finding the target path from the root node of the target web page corresponding to the target web address to the target node, and only displaying the data under each node on the target path, rather than loading the entire tree data structure.
It reduces the loading amount of data, improves the page loading speed, avoids the problem of unresponsive or even crashing when the data is large, and improves the user experience.
Smart Images

Figure CN116049588B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of page loading, and in particular to a page loading method, apparatus, computer equipment and storage medium. Background Art
[0002] With the continuous development of web technology, most software systems have adopted the browser / server model (B / S structure model). However, when it is necessary to build a navigation tree with a large amount of data, if the loading method of the tree data is not handled properly, the web front-end page will become unresponsive or even crash.
[0003] Taking the performance_web system as an example, the performance_web system is a web version of the document database. Enter the URL address of the corresponding performance analysis document in the address bar, and display the document in a tree structure. The user clicks the corresponding HTML document to display the content of the performance analysis document. The performance analysis document is selected in the directory tree on the left and positioned within the visible range. Sometimes when accessing a performance analysis document, it may have been updated, which will lead to problems such as being unable to select the corresponding performance analysis document. Therefore, when accessing a performance analysis document, first update the entire directory tree, that is, request all data from the background at one time during initialization.
[0004] This method of requesting all data at once during initialization will seriously affect the loading speed when the amount of data is large, resulting in a long response time, unresponsive front-end page or even crash, resulting in a poor user experience; and sometimes users only access a specific performance analysis document, and all data is loaded or updated each time, resulting in a waste of resources. Summary of the invention
[0005] Based on this, it is necessary to provide a page loading method, device, computer equipment and storage medium that can improve the page loading speed and avoid page unresponsiveness or even crash in response to the above technical problems.
[0006] In a first aspect, the present application provides a page loading method, the method comprising:
[0007] Get the target web page address; the target web page address is used to jump to the target web page;
[0008] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0009] Based on the target path, display the data of each node on the target path.
[0010] In one embodiment, in the process of parsing the target webpage address, a tree data structure of the target webpage is obtained, and based on the tree data structure, a target path from a root node of the target webpage corresponding to the target webpage address to a target node is searched, including:
[0011] In the process of parsing the target web page address, a tree data structure of the target web page corresponding to the target web page address is obtained, and a first-level child node in the tree data structure is used as a current node;
[0012] If the current node is not the target node, the current node is triggered, the direct child nodes of the current node in the tree data structure are loaded, the direct child nodes of the current node are used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued to be executed until the current node is the target node, and the target path from the root node of the target web page to the target node is obtained.
[0013] In one embodiment, loading the direct child nodes of the current node in the tree data structure includes:
[0014] Query whether the local cache records the node data used to access the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node, and the search path of the current node in the tree data structure;
[0015] If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache;
[0016] If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the node data of the current node in the local cache is updated.
[0017] In one embodiment, updating the node data of the current node in the local cache includes:
[0018] Get the broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node;
[0019] According to the change information of the current node in the broadcast message, the node data of the current node in the local cache is updated.
[0020] In one embodiment, in the process of parsing the target webpage address, a tree data structure of the target webpage is obtained, and based on the tree data structure, a target path from a root node of the target webpage corresponding to the target webpage address to a target node is searched, including:
[0021] In the process of parsing the target webpage address, obtaining the target node of the target webpage;
[0022] If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache;
[0023] If the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node;
[0024] Obtain a tree data structure of a target web page, and search for a target path from a target node to a root node in the tree data structure.
[0025] In one of the embodiments, if the target node changes, the node data of the direct parent node of the target node is updated.
[0026] In a second aspect, the present application also provides a page loading device. The device comprises:
[0027] The acquisition module is used to obtain the target web page address; the target web page address is used to jump to the target web page;
[0028] A search module is used to obtain a tree data structure of a target web page during the process of parsing the target web page address, and to search for a target path from a root node of the target web page corresponding to the target web page address to a target node based on the tree data structure; the tree data structure includes a mapping relationship between a root node of the target web page and each child node;
[0029] The display module is used to display the data of each node on the target path based on the target path.
[0030] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0031] Get the target web page address; the target web page address is used to jump to the target web page;
[0032] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0033] Based on the target path, display the data of each node on the target path.
[0034] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0035] Get the target web page address; the target web page address is used to jump to the target web page;
[0036] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0037] Based on the target path, display the data of each node on the target path.
[0038] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0039] Get the target web page address; the target web page address is used to jump to the target web page;
[0040] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0041] Based on the target path, display the data of each node on the target path.
[0042] The above-mentioned page loading method, device, computer equipment and storage medium obtain the tree data structure of the target web page in the process of parsing the target web page address, and based on the tree data structure, find the target path from the root node of the target web page corresponding to the target web page address to the target node, and only display the data under each node on the target path, without loading the entire tree data structure, reducing the amount of loaded data, improving the loading speed, and avoiding the problem of page unresponsiveness or even crash when a large amount of data is loaded. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 An application environment diagram of a page loading method in an embodiment;
[0044] Figure 2 A schematic diagram of a flow chart of a page loading method in one embodiment;
[0045] Figure 3 A schematic diagram of a tree data structure in one embodiment;
[0046] Figure 4 A schematic diagram of a process for obtaining a target path in an embodiment;
[0047] Figure 5 A schematic diagram of a process of loading direct child nodes of a current node in a tree data structure in one embodiment;
[0048] Figure 6 A schematic diagram of a process of updating node data of a current node in a local cache in one embodiment;
[0049] Figure 7 A schematic diagram of a process for obtaining a target path in another embodiment;
[0050] Figure 8 is a structural block diagram of a page loading device in one embodiment;
[0051] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0052] 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.
[0053] The page loading method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 obtains the target web page address; the target web page address is used to jump to the target web page; in the process of parsing the target web page address, the tree data structure of the target web page is obtained, and based on the tree data structure, the target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node; based on the target path, the data under each node on the target path is displayed. The terminal 102 communicates with the server 104 through the network. Among them, the terminal 102 can be but not limited to various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart TVs, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0054] In the existing performance_web website, all performance analysis related document data under all files are loaded at once when the main page is initialized. When the amount of data is large, it leads to long page response time, unresponsiveness or even crash of the front-end page, resulting in a bad user experience; sometimes users only access specified documents, and each time the html tree node is loaded, all the data of the tree structure data needs to be updated, which will seriously affect the loading speed when the amount of data is large. Therefore, in order to solve the above problems, this embodiment provides a page loading method, which only loads the elements of the root node during initialization, and loads the direct child nodes of the current node when clicking a certain node, and locally updates the data of the direct parent node of the html node when clicking a certain html node, instead of updating the entire tree, and stores the nodes that have been visited in the local cache, and directly reads from the local cache when visiting the nodes that have been visited again, and introduces a message broadcast mechanism to update the local cache in real time, thereby improving the loading speed and providing a better user experience.
[0055] In one embodiment, Figure 2 As shown, a page loading method is provided, which is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:
[0056] Step 202, obtaining a target web page address; the target web page address is used to jump to the target web page.
[0057] The target webpage address may be a URL address. When a user enters the URL address of the corresponding target webpage in the address bar of the browser, the content of the target webpage may be displayed. The target webpage may be a static webpage or a specified document. For example, the target webpage may be a specified performance analysis related document (profiling).
[0058] Step 204, in the process of parsing the target web page address, obtain the tree data structure of the target web page, and based on the tree data structure, find the target path from the root node of the target web page corresponding to the target web page address to the target node; the tree data structure includes the mapping relationship between the root node of the target web page and each child node.
[0059] Among them, the target web page address resolution process is to obtain the tree data structure of the target web page. The tree data structure includes all the nodes of the target page, where the node is the most basic component of the target web page. Each part of the target web page can be called a node. For example, the part of the target page used to access the specified performance analysis related documents is a node. The tree data structure is also called a navigation tree. It can display hierarchical information with a clear hierarchical structure, which is convenient for users to find the corresponding nodes and data step by step according to the relationship between the data. Therefore, the tree data structure is widely used in the web front-end, such as navigation, logical or spatial organization, cascade selection and page anchor positioning.
[0060] The target node refers to the location of the document that the user needs to load in the tree data structure, and the element corresponding to the target node is the document that the user needs to load.
[0061] The method for obtaining the tree data structure of the target web page can start from the root node and trigger the nodes in hierarchical order to obtain the tree data structure of the target web page, or search upward for the root node from the last node corresponding to the target web page address and obtain the tree data structure of the target web page according to the search order.
[0062] Taking the performance_web system as an example, the performance_web system is a web-based document database that displays documents in a tree structure based on project name, module name, and subblock name. Users can browse online by clicking on the corresponding HTML document.
[0063] like Figure 3 The following is a diagram of a tree data structure, where nodes are the basic units of a tree structure. Nodes can be used to represent the composition relationship between different data. The beginning of the entire tree structure is called the root node. A tree structure must have only one root, for example Figure 3The root node R in the example is usually hidden in actual use, and the displayed nodes usually start from the first-level child nodes. Nodes outside the root node are called child nodes. The direct child nodes of a node are nodes that are directly subordinate to the node. For example, the direct child nodes of child node a are child nodes a1 and a2. The node to which a child node is subordinate is called a parent node. For example, node a is the parent node of child nodes a1 and a2.
[0064] For example, what needs to be loaded is a 4-level tree structure data: A-AA-AAA-xxx.html. Assuming there are 10 first-level nodes, each first-level node has 10 direct child nodes, each second-level child node has 10 direct child nodes, and each third-level child node has 10 direct child nodes, then according to the design of loading all data at one time, a total of 10+10*10+10*10*10+10*10*10*10=11110 pieces of data need to be loaded during initialization. If the target path from the root node of the target web page corresponding to the target web page address to the target node is searched according to the present embodiment, instead of loading the entire tree structure data, when accessing a certain html file, only 10+10+10+10=40 pieces of data need to be loaded. Even if several html files are to be accessed at a time, the amount of data that needs to be loaded varies greatly and is not on the same order of magnitude. This improves the loading speed, improves the user experience, and avoids waste of resources.
[0065] Optionally, the user enters the target web page address in the address bar of the browser, the terminal parses the target web page address, and loads the root node and first-level child nodes of the target web page, displays the page information corresponding to the root node and the first-level child nodes, and the user triggers the nodes on the tree data structure level by level in hierarchical order according to actual needs until the target node is reached, obtains the tree data structure of the target web page according to the search order, and determines the target path from the root node of the target web page corresponding to the target web page address to the target node according to the tree data structure. Alternatively, the user enters the target web page address in the address bar of the browser, the terminal parses the target web page address, and loads the last-level node of the target web page, searches for the root node upward from the last-level node corresponding to the target web page address, obtains the tree data structure of the target web page according to the search order, and determines the target path from the root node of the target web page corresponding to the target web page address to the target node according to the tree data structure.
[0066] Step 206: Based on the target path, display the data of each node on the target path.
[0067] Among them, before displaying the target web page, it is necessary to determine the target path from the root node to the target node. After determining the target path, only the data corresponding to each node on the target path is displayed, and there is no need to display the node data on the entire tree data structure, thereby reducing the amount of loaded data and improving the page loading speed.
[0068] Optionally, after determining the target path from the root node to the target node of the target webpage, the terminal renders elements corresponding to each node on the target path, and displays data corresponding to each node on the target path on the browser page.
[0069] In the above page loading method, in the process of parsing the target web page address, the tree data structure of the target web page is obtained, and based on the tree data structure, the target path from the root node of the target web page corresponding to the target web page address to the target node is found, and only the data under each node on the target path is displayed. There is no need to load the entire tree data structure, which reduces the amount of loaded data, increases the loading speed, and avoids the problem of page unresponsiveness or even crash when a large amount of data is loaded.
[0070] In one embodiment, the target path from the root node of the target webpage to the target node can be determined by searching for the target node from the root node downwards, or by searching for the root node from the target node upwards. This embodiment provides a page initialization loading method, that is, searching for the target node from the root node downwards to obtain an embodiment of the target path from the root node of the target webpage to the target node. Figure 4 As shown, in the process of parsing the target webpage address, the tree data structure of the target webpage is obtained, and based on the tree data structure, the target path from the root node of the target webpage corresponding to the target webpage address to the target node is found, including:
[0071] Step 402: in the process of parsing the target webpage address, a tree data structure of the target webpage corresponding to the target webpage address is obtained, and a first-level child node in the tree data structure is used as a current node.
[0072] Among them, since the web page needs to be executed on the browser, but different browsers have different values for the default style of the label, the effect of the page displayed on different browsers is also different. Therefore, through page initialization, the style of the label can be uniformly set to ensure that the initial value of the page is consistent. The existing page initialization scheme is that when the user opens the web page initialization page, all data is loaded at one time, that is, all data is queried out at one time by calling the back-end server interface and rendered on the page. When the amount of data is large, it leads to a long response time, and the front-end page is unresponsive or even crashes, resulting in a bad user experience. Therefore, in this embodiment, when the user opens the web page initialization, only the first-level child node is loaded. When the user clicks the first-level child node, the direct child node of the first-level child node is loaded. When a certain direct child node is clicked, the child node of the current direct child node is loaded, and so on, until the target node is loaded.
[0073] It should be noted that the target web page address of this embodiment is the first address used to initialize the web page. Therefore, when initializing the web page, only the first-level child node needs to be loaded and the first-level child node is used as the current node.
[0074] Optionally, the terminal obtains a tree data structure of the target web page corresponding to the target web page address during the process of parsing the target web page address, hides the root node in the tree data structure, and uses the first-level child node in the tree data structure as the current node.
[0075] Step 404, if the current node is not the target node, trigger the current node, load the direct child nodes of the current node in the tree data structure, use the direct child nodes of the current node as the current node of the next iteration loop, and return to execute the step of triggering the current node and continue to execute until the current node is the target node, and obtain the target path from the root node of the target web page to the target node.
[0076] In this embodiment, when the user opens the web page for initialization, only the first-level child nodes are loaded. When the user clicks the first-level child node, the direct child nodes of the first-level child node are loaded. When a direct child node is clicked, the child nodes of the current direct child node are loaded, and so on, until the target node is loaded. For example, what needs to be loaded is tree data with 4 levels of nodes, similar to a-aa-aaa-aaaa, and each level of node has n child nodes. Then the existing solution needs to load n+n*n+n*n*n+n*n*n*n*n pieces of data, and the optimized solution needs to load n+n+n+n pieces of data. When the value of n gradually increases from 1, the difference in the number of data that needs to be loaded becomes larger and larger, as shown in the following table.
[0077] n Number of data items loaded by the existing solution Optimize the number of data items loaded Difference in number of loaded data 1 4 4 0 2 30 8 22 3 120 12 108 4 340 16 324 5 780 20 760 6 1554 24 1530 7 2800 28 2772 8 4680 32 4648 9 7380 36 7344 10 11110 40 11070 11 16104 44 16060 12 22620 48 22572 13 30940 52 30888 14 41370 56 41314 15 54240 60 54180
[0078] In some embodiments, when loading a child node, first query whether there is node data of the node in the local cache. If there is node data of the node in the local cache, the node data of the node is loaded from the cache; if not in the cache, query the node data of the node from the background database and add it to the local cache.
[0079] Specifically, Figure 5As shown, loading the direct child nodes of the current node in the tree data structure includes: querying whether the local cache records the node data for accessing the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure; if the local cache does not record the node data for accessing the current node, querying the node data of each direct child node of the current node from the database, and storing the node data of the current node and each direct child node of the current node in the local cache; if the local cache has a record of the node data for accessing the current node, directly reading the node data of each direct child node of the current node from the local cache, and updating the node data of the current node in the local cache.
[0080] The database is designed to use the fields id, pid, name, and path to record each piece of data and the parent-child relationship of each piece of data. The meaning of each field is as follows:
[0081] id: current node id;
[0082] pid: the parent node id of the current node;
[0083] name: the name of the current node;
[0084] path: the search path of the current node in the entire tree structure;
[0085] Assume that the id of the root node R is 0, the id of the child node a is 1, the id of the child node a1 is 2, the id of the child node a2 is 3, the id of the child node a11 is 4, the id of the child node a12 is 5, the id of the child node a21 is 6, and the id of the child node a22 is 7. Then these nodes are stored in the database as shown in the following table:
[0086] id pid name path 1 0 Child node a Child node a 2 1 Child node a1 Subnode a-subnode a1 3 1 Child node a2 Subnode a-subnode a2 4 2 Child node a11 Subnode a-subnode a1-subnode a11 5 2 Child node a12 Subnode a-subnode a1-subnode a12 6 3 Child node a21 Subnode a-subnode a2-subnode a21 7 3 Child node a22 Subnode a-subnode a2-subnode a22
[0087] In some embodiments, Figure 6 As shown, updating the node data of the current node in the local cache includes the following steps:
[0088] Step 1, obtain the broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node.
[0089] The change information may be a change in the element data corresponding to the current node, or a change in the access record of the current node in the local cache. The address of the current node in the broadcast message, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node are the JSON format of the data in the tree data structure and the storage field in the database. The update of the local cache data specifically updates the key-value pair.
[0090] Step 2: Update the node data of the current node in the local cache according to the change information of the current node in the broadcast message.
[0091] Optionally, the terminal queries the local cache based on the address of the current node in the broadcast message whether there is a record for accessing the node data of the current node. If so, the node data of the current node in the local cache is updated to ensure the timeliness of the data in the local cache; if not, the local cache search process is terminated.
[0092] In this embodiment, when the user opens the web page initially, only the first-level child node is loaded. When the user clicks the first-level child node, the direct child node of the first-level child node is loaded. When the user clicks a direct child node, the child node of the current direct child node is loaded, and so on, until the target node is loaded. This can reduce the amount of loaded data, improve the page loading speed, and avoid resource waste. At the same time, the node data that has been visited is stored in the local cache, and a message broadcast mechanism is introduced to update the node data in the local cache in real time. When the node that has been visited is visited again, the data is read directly from the local cache, which reduces the interaction with the background server and reduces unnecessary resource loading.
[0093] In one embodiment, the target path from the root node of the target webpage to the target node can be determined by searching for the target node from the root node downwards, or by searching for the root node from the target node upwards. This embodiment provides a method for loading a specified page when accessing other specified nodes except the first-level child nodes on a tree data structure, that is, searching for the root node upwards from the target node to obtain an embodiment of the target path from the root node of the target webpage to the target node. Figure 7 As shown, in the process of parsing the target webpage address, the tree data structure of the target webpage is obtained, and based on the tree data structure, the target path from the root node of the target webpage corresponding to the target webpage address to the target node is found, including:
[0094] Step 702: in the process of parsing the target webpage address, obtaining the target node of the target webpage.
[0095] The target webpage address of this embodiment is used to jump to other designated nodes on the tree data structure except the first-level child node. For example, if the target webpage address is used to jump to the 4th-level child node on the tree data structure, when the target webpage address is entered in the address bar, it can directly jump to the page corresponding to the 4th-level child node, without the user having to trigger from the first-level child node down until the 4th-level child node is triggered.
[0096] Step 704: If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache.
[0097] Among them, the existing method of jumping to other designated nodes on the tree data structure except the first-level child node is: after entering the URL address corresponding to the target performance debugging related document in the address bar of the browser, first query all the data of the whole tree by calling the backend port, and then request the data of the target performance debugging related document after the front end obtains the data and completes the rendering of the whole tree. This method requires updating the entire tree data structure, resulting in a waste of resources. Therefore, in order to solve the above problem, when accessing the target web page corresponding to the target web page address, this embodiment uses the target node as the starting point and the root node as the end point to search, and only updates the node data under the direct parent node of the target node, without updating the entire tree data structure.
[0098] Optionally, after the user enters the target web page address in the address bar of the browser, the terminal parses the target web page address and obtains the target node corresponding to the target web page; the terminal queries the local cache based on the address of the target node to see whether there is a record of node data for accessing the target node. If there is a record of node data for accessing the target node in the local cache, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache. If there is no record of node data for accessing the target node in the local cache, the database is entered to query the node data of the target node. If the node data does not exist in the database, an error message pops up to prompt the user.
[0099] Step 706, if the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node.
[0100] Optionally, after obtaining the target node and the direct parent node of the target node, the terminal determines whether the direct parent node of the current node is a root node; if the direct parent node of the current node is not a root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is a root node. If the direct parent node of the current node is a root node, step 708 is executed.
[0101] In some embodiments, assuming that tree data with 4 levels of nodes, similar to a-aa-aaa-aaaa, needs to be loaded, and each level of node has n child nodes, then the existing solution needs to load n+n*n+n*n*n+n*n*n*n*n pieces of data, and the optimized solution needs to load n+n+n+n+n pieces of data. When the value of n gradually increases from 1, the difference in the number of pieces of data that need to be loaded becomes larger and larger, as shown in the following table:
[0102] n Number of data items loaded by the existing solution Optimize the number of data items loaded Difference in number of loaded data 1 4 4 0 2 30 8 22 3 120 12 108 4 340 16 324 5 780 20 760 6 1554 24 1530 7 2800 28 2772 8 4680 32 4648 9 7380 36 7344 10 11110 40 11070 11 16104 44 16060 12 22620 48 22572 13 30940 52 30888 14 41370 56 41314 15 54240 60 54180
[0103] Step 708, obtaining the tree data structure of the target web page, and searching for the target path from the target node to the root node in the tree data structure.
[0104] Among them, all nodes can be queried through step 706, and the tree data structure of the target web page can be established based on the search records and the composition relationship between each node. In the tree data structure, the target path from the target node to the root node is searched, and the data corresponding to each node on the target path is rendered.
[0105] In some embodiments, if the target node changes, the node data of the direct parent node of the target node is updated. To access the target webpage, only the node data under the direct parent node of the target node corresponding to the target webpage needs to be updated, without updating the entire tree data structure.
[0106] In this embodiment, the root node is searched upward from the target node to obtain the target path from the root node of the target webpage to the target node, and only the node data under the direct parent node of the target node is updated without updating the entire tree data structure.
[0107] In one embodiment, detailed steps of a page loading method are provided, specifically including:
[0108] Step 1, obtain the target web page address; the target web page address is used to jump to the target web page.
[0109] Step 2, determine the type of the target web page address. If the target web page address is the first address for initializing the web page, execute step 3; if the target web page address is used to access other specified nodes on the tree data structure except the first-level child node, execute step 8.
[0110] Step 3: in the process of parsing the target web page address, a tree data structure of the target web page corresponding to the target web page address is obtained, and a first-level child node in the tree data structure is used as the current node.
[0111] Step 4, if the current node is not the target node, trigger the current node and query whether the local cache records the node data used to access the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure; if the local cache does not record the node data used to access the current node, execute step 5; if the local cache has a record of the node data used to access the current node, execute step 6.
[0112] Step 5: query the database for the node data of each direct child node of the current node, store the node data of the current node and each direct child node of the current node into the local cache, and execute step 7.
[0113] Step 6, directly read the node data of each direct child node of the current node from the local cache, and obtain the broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node; according to the change information of the current node in the broadcast message, update the node data of the current node in the local cache, and execute step 7.
[0114] Step 7, use the direct child node of the current node as the current node of the next iteration loop, and return to the step of triggering the current node and continue executing until the current node is the target node, obtain the target path from the root node of the target web page to the target node, and execute step 12.
[0115] Step 8: in the process of parsing the target webpage address, obtain the target node of the target webpage and execute step 9.
[0116] Step 9: If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache, and step 10 is executed.
[0117] Step 10, if the direct parent node of the current node is not the root node, then use the direct parent node of the current node as the current node of the next iteration loop, return to execute the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache and continue to execute until the direct parent node of the current node is the root node, and execute step 11.
[0118] Step 11 obtains the tree data structure of the target web page, searches for the target path from the target node to the root node in the tree data structure, and executes step 12.
[0119] Step 12: Based on the target path, display the data of each node on the target path.
[0120] In this embodiment, only when a node is clicked will the direct child nodes of the node be loaded, and a solution for local updating of tree data is provided, which only updates the data required for this access; the accessed data is stored in the local cache, and a message broadcast mechanism is introduced to update the local cache data, reducing the interaction with the background database; the amount of data that needs to be loaded is greatly reduced, the access speed is improved, and the user experience is optimized.
[0121] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0122] Based on the same inventive concept, the embodiment of the present application also provides a page loading device for implementing the page loading method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more page loading device embodiments provided below can refer to the limitations on the page loading method above, and will not be repeated here.
[0123] In one embodiment, Figure 8 As shown, a page loading device is provided, including: an acquisition module 100, a search module 200 and a display module 300, wherein:
[0124] The acquisition module 100 is used to acquire the target webpage address; the target webpage address is used to jump to the target webpage;
[0125] The search module 200 is used to obtain the tree data structure of the target webpage in the process of parsing the target webpage address, and search for the target path from the root node of the target webpage corresponding to the target webpage address to the target node based on the tree data structure; the tree data structure includes the mapping relationship between the root node of the target webpage and each child node;
[0126] The display module 300 is used to display the data of each node on the target path based on the target path.
[0127] In one embodiment, the search module 200 is further used to: during the process of parsing the target webpage address, obtain a tree data structure of the target webpage corresponding to the target webpage address, and use the first-level child node in the tree data structure as the current node;
[0128] If the current node is not the target node, the current node is triggered, the direct child nodes of the current node in the tree data structure are loaded, the direct child nodes of the current node are used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued to be executed until the current node is the target node, and the target path from the root node of the target web page to the target node is obtained.
[0129] In one embodiment, the search module 200 is further used to: query whether the local cache records the node data used to access the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure;
[0130] If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache;
[0131] If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the node data of the current node in the local cache is updated.
[0132] In one embodiment, the search module 200 is further used to: obtain a broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node;
[0133] According to the change information of the current node in the broadcast message, the node data of the current node in the local cache is updated.
[0134] In one embodiment, the search module 200 is further used to: obtain a target node of the target webpage during the process of parsing the address of the target webpage;
[0135] If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache;
[0136] If the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node;
[0137] Obtain a tree data structure of a target web page, and search for a target path from a target node to a root node in the tree data structure.
[0138] In one embodiment, the search module 200 is further configured to update the node data of the direct parent node of the target node if the target node changes.
[0139] Each module in the above-mentioned page loading device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0140] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a page loading method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0141] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0142] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0143] Get the target web page address; the target web page address is used to jump to the target web page;
[0144] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0145] Based on the target path, display the data of each node on the target path.
[0146] In one embodiment, when the processor executes the computer program, the following steps are further implemented: in the process of parsing the target webpage address, obtaining a tree data structure of the target webpage corresponding to the target webpage address, and using the first-level child node in the tree data structure as the current node;
[0147] If the current node is not the target node, the current node is triggered, the direct child nodes of the current node in the tree data structure are loaded, the direct child nodes of the current node are used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued to be executed until the current node is the target node, and the target path from the root node of the target web page to the target node is obtained.
[0148] In one embodiment, when the processor executes the computer program, the following steps are further implemented: querying whether the local cache records the node data used to access the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node, and the search path of the current node in the tree data structure;
[0149] If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache;
[0150] If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the node data of the current node in the local cache is updated.
[0151] In one embodiment, when the processor executes the computer program, the following steps are further implemented: obtaining a broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node;
[0152] According to the change information of the current node in the broadcast message, the node data of the current node in the local cache is updated.
[0153] In one embodiment, when the processor executes the computer program, the following steps are further implemented: in the process of parsing the address of the target webpage, obtaining the target node of the target webpage;
[0154] If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache;
[0155] If the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node;
[0156] Obtain a tree data structure of a target web page, and search for a target path from a target node to a root node in the tree data structure.
[0157] In one embodiment, when the processor executes the computer program, the following steps are further implemented: if the target node changes, the node data of the direct parent node of the target node is updated.
[0158] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0159] Get the target web page address; the target web page address is used to jump to the target web page;
[0160] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0161] Based on the target path, display the data of each node on the target path.
[0162] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: in the process of parsing the target webpage address, obtaining a tree data structure of the target webpage corresponding to the target webpage address, and using the first-level child node in the tree data structure as the current node;
[0163] If the current node is not the target node, the current node is triggered, the direct child nodes of the current node in the tree data structure are loaded, the direct child nodes of the current node are used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued to be executed until the current node is the target node, and the target path from the root node of the target web page to the target node is obtained.
[0164] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: querying whether the local cache records the node data used to access the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure;
[0165] If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache;
[0166] If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the node data of the current node in the local cache is updated.
[0167] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining a broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node;
[0168] According to the change information of the current node in the broadcast message, the node data of the current node in the local cache is updated.
[0169] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: in the process of parsing the target webpage address, obtaining the target node of the target webpage;
[0170] If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache;
[0171] If the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node;
[0172] Obtain a tree data structure of a target web page, and search for a target path from a target node to a root node in the tree data structure.
[0173] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: if the target node changes, the node data of the direct parent node of the target node is updated.
[0174] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0175] Get the target web page address; the target web page address is used to jump to the target web page;
[0176] In the process of parsing the target web page address, a tree data structure of the target web page is obtained, and based on the tree data structure, a target path from the root node of the target web page corresponding to the target web page address to the target node is found; the tree data structure includes a mapping relationship between the root node of the target web page and each child node;
[0177] Based on the target path, display the data of each node on the target path.
[0178] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: in the process of parsing the target webpage address, obtaining a tree data structure of the target webpage corresponding to the target webpage address, and using the first-level child node in the tree data structure as the current node;
[0179] If the current node is not the target node, the current node is triggered, the direct child nodes of the current node in the tree data structure are loaded, the direct child nodes of the current node are used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued to be executed until the current node is the target node, and the target path from the root node of the target web page to the target node is obtained.
[0180] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: querying whether the local cache records the node data used to access the current node; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure;
[0181] If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache;
[0182] If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the node data of the current node in the local cache is updated.
[0183] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: obtaining a broadcast message sent by the current node; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node;
[0184] According to the change information of the current node in the broadcast message, the node data of the current node in the local cache is updated.
[0185] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: in the process of parsing the target webpage address, obtaining the target node of the target webpage;
[0186] If the local cache contains node data for accessing the target node, the target node is used as the current node, and the node data of the direct parent node of the current node and the node data of each sibling node of the current node are obtained from the local cache;
[0187] If the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node;
[0188] Obtain a tree data structure of a target web page, and search for a target path from a target node to a root node in the tree data structure.
[0189] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: if the target node changes, the node data of the direct parent node of the target node is updated.
[0190] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0191] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0192] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0193] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A page loading method, characterized in that: The method comprises: Obtaining a target web page address; the target web page address is used to jump to the target web page; In the process of parsing the target web page address, a tree data structure of the target web page corresponding to the target web page address is obtained, and if the target web page address is the first address for initializing the web page, a first-level child node in the tree data structure is used as the current node; If the current node is not the target node, the current node is triggered to query whether the node data used to access the current node is recorded in the local cache; If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache; If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the broadcast message sent by the current node is obtained; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node; according to the change information of the current node in the broadcast message, the node data of the current node in the local cache is updated; The direct child node of the current node is used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued until the current node is the target node, and the target path from the root node of the target webpage to the target node is obtained; If the target web page address is used to access other designated nodes on the tree data structure except the first-level child node, the target node of the target web page is obtained, and if the local cache contains node data for accessing the target node, the target path from the root node of the target web page to the target node is determined according to the node data of the target node in the local cache; if the local cache contains node data for accessing the target node, the database is accessed to query the node data of the target node, and the target path from the root node of the target web page to the target node is determined according to the node data of the target node; Wherein, the local cache is used to store node data that has been visited; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure; Render the elements corresponding to each node on the target path, and display the elements corresponding to each node on the target path.
2. The method according to claim 1, characterized in that The step of determining a target path from a root node of a target webpage to a target node according to the node data of the target node in the local cache includes: Take the target node as the current node, and obtain the node data of the direct parent node of the current node and the node data of each sibling node of the current node from the local cache; If the direct parent node of the current node is not the root node, the direct parent node of the current node is used as the current node of the next iteration loop, and the step of obtaining the direct parent node of the current node and each sibling node of the current node from the local cache is returned and continued until the direct parent node of the current node is the root node; A tree data structure of a target web page is obtained, and a target path from a target node to a root node is searched in the tree data structure.
3. The method according to claim 2, characterized in that The method further includes: if the target node changes, updating the node data of the direct parent node of the target node.
4. A page loading device, characterized in that: The device comprises: An acquisition module is used to acquire a target web page address; the target web page address is used to jump to the target web page; A search module is used to obtain a tree data structure of a target web page corresponding to the target web page address during the process of parsing the target web page address. If the target web page address is the first address for initializing the web page, the first-level child node in the tree data structure is used as the current node; if the current node is not the target node, the current node is triggered to query whether the local cache records the node data for accessing the current node; if the local cache does not record the node data for accessing the current node, the node data of each direct child node of the current node is queried from the database, and the node data of the current node and each direct child node of the current node are stored in the local cache; if the local cache has a record of the node data for accessing the current node, the node data of each direct child node of the current node is directly read from the local cache, and a broadcast message sent by the current node is obtained; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node; according to the change information of the current node in the broadcast message, the current node in the local cache is updated. The method comprises the following steps: first, obtaining the target path from the root node of the target web page to the target node; second, obtaining the target path from the root node of the target web page to the target node; third, obtaining the target path from the root node of the target web page to the target node; fourth, obtaining the target path from the root node of the target web page to the target node; fifth ... The display module is used to render the elements corresponding to each node on the target path and display the elements corresponding to each node on the target path.
5. The device according to claim 4, characterized in that The search module is also used to use the target node as the current node, obtain the node data of the direct parent node of the current node and the node data of each brother node of the current node from the local cache; if the direct parent node of the current node is not the root node, use the direct parent node of the current node as the current node of the next iteration loop, return to execute the step of obtaining the direct parent node of the current node and each brother node of the current node from the local cache and continue to execute until the direct parent node of the current node is the root node; obtain the tree data structure of the target web page, and in the tree data structure, search for the target path from the target node to the root node.
6. The device according to claim 5, characterized in that The search module is also used to update the node data of the direct parent node of the target node if the target node changes.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the following steps are implemented: Obtaining a target web page address; the target web page address is used to jump to the target web page; In the process of parsing the target web page address, a tree data structure of the target web page corresponding to the target web page address is obtained, and if the target web page address is the first address for initializing the web page, a first-level child node in the tree data structure is used as the current node; If the current node is not the target node, the current node is triggered to query whether the node data used to access the current node is recorded in the local cache; If the local cache does not record the node data for accessing the current node, query the database for the node data of each direct child node of the current node, and store the node data of the current node and each direct child node of the current node in the local cache; If there is a record in the local cache for accessing the node data of the current node, the node data of each direct child node of the current node is directly read from the local cache, and the broadcast message sent by the current node is obtained; the broadcast message includes the address of the current node, the address of the parent node of the current node, the storage field of the current node in the database, and the change information of the current node; Update the node data of the current node in the local cache according to the change information of the current node in the broadcast message; The direct child node of the current node is used as the current node of the next iteration loop, and the step of triggering the current node is returned and continued until the current node is the target node, and the target path from the root node of the target webpage to the target node is obtained; If the target web page address is used to access other designated nodes on the tree data structure except the first-level child node, the target node of the target web page is obtained, and if the local cache contains node data for accessing the target node, the target path from the root node of the target web page to the target node is determined according to the node data of the target node in the local cache; if the local cache contains node data for accessing the target node, the database is accessed to query the node data of the target node, and the target path from the root node of the target web page to the target node is determined according to the node data of the target node; Wherein, the local cache is used to store node data that has been visited; the node data includes the address of the current node, the address of the parent node of the current node, the name of the current node and the search path of the current node in the tree data structure; Render the elements corresponding to each node on the target path, and display the elements corresponding to each node on the target path.
8. The computer device according to claim 7, characterized in that When the processor executes the computer program, the following steps are implemented: taking the target node as the current node, obtaining the node data of the direct parent node of the current node and the node data of each brother node of the current node from the local cache; if the direct parent node of the current node is not the root node, taking the direct parent node of the current node as the current node of the next iteration loop, returning to execute the step of obtaining the direct parent node of the current node and each brother node of the current node from the local cache and continuing to execute until the direct parent node of the current node is the root node; obtaining the tree data structure of the target web page, and searching the target path from the target node to the root node in the tree data structure.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Webpage node path information determination method and apparatus
CN106599280A
Webpage view display method and device
CN113656723A