Tree structure display method, device, system, electronic device and storage medium

By generating a virtual list and rendering a tree structure using the visible area, combined with the DIFF algorithm and hardware acceleration technology, the operability and rendering efficiency of tree structure display under big data are solved, achieving efficient tree display and rendering.

CN113867880BInactive Publication Date: 2024-11-19HANGZHOU DBAPPSECURITY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111204832.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-15
Publication Date
2024-11-19
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing technology has not effectively solved the problems of weak operability and page lag in the case of big data.

Method used

By obtaining a virtual list from the server device, a flat DOM structure is generated based on the flat data. Virtual nodes are rendered using the visible area, and nodes are expanded or collapsed according to user commands. The node rendering process is optimized by combining the DIFF algorithm and hardware acceleration technology.

Benefits of technology

It improves the smoothness and operability of tree-shaped display on terminal devices under big data, reduces page lag, and improves rendering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113867880B_ABST
    Figure CN113867880B_ABST
Patent Text Reader

Abstract

The present application relates to a tree structure display method, device, system, electronic device and storage medium, wherein the tree structure display method includes: obtaining a virtual list of a server device; obtaining a preset visible area, obtaining a first visible virtual node in the virtual list according to the visible area, and rendering the first visible virtual node; obtaining a user instruction, expanding or collapsing the specified first visible virtual node according to the user instruction to obtain a second visible virtual node; and rendering the second visible virtual node according to the visible area. Through this application, the problems of weak operability and page jamming of tree structure display are solved, and the tree display and rendering efficiency of terminal devices are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of user interface implementation, and in particular to a tree structure display method, device, system, electronic device and storage medium. Background Art

[0002] In order to reasonably display certain structural relationships in the user interface, it is necessary to use a tree structure, such as a region tree and a multi-level unit management tree; when displaying the tree structure, the tree structure needs to be rendered.

[0003] In the related art, the tree structure is generally rendered and displayed by traversing the hierarchical nested tree structure of DOM (Document Object Model), such as the ZTREE framework and the TREE component in IVIEW. The display method of traversing the tree structure will cause problems such as weak operability and page freeze in the case of big data.

[0004] There is currently no effective solution to the problems of weak operability of tree structure display and page jams in related technologies. Summary of the invention

[0005] In this embodiment, a tree structure display method, device, system, electronic device and storage medium are provided to solve the problems of weak operability and page jamming of tree structure display in related technologies.

[0006] In a first aspect, a tree structure display method is provided in this embodiment, including:

[0007] Acquire a virtual list of the server device; the virtual list is generated by the server device acquiring a flat DOM structure based on the received flattened data and according to the flat DOM structure; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure;

[0008] Acquire a preset visible area, acquire a first visible virtual node in the virtual list according to the visible area, and render the first visible virtual node;

[0009] A user instruction is obtained, and according to the user instruction, the first visual virtual node is expanded or collapsed to obtain a second visual virtual node; and according to the visual area, the second visual virtual node is rendered.

[0010] In some embodiments, the expanding or collapsing the designated first visual virtual node according to the user instruction to obtain the second visual virtual node includes:

[0011] If the user instruction is to collapse the specified first visual virtual node, all virtual nodes in the virtual list are traversed, a next virtual node whose depth is less than or equal to the depth of the first visual virtual node is searched, and according to the first visual virtual node and the next virtual node, all traversed target virtual nodes are deleted to obtain the second visual virtual node, and the display state of the second visual virtual node is set to the collapsed state;

[0012] The target virtual node refers to a virtual node traversed from the specified first visible virtual node to the next virtual node among all the virtual nodes, except the specified first visible virtual node and the next virtual node;

[0013] If the user instruction is to expand the specified first visual virtual node, all virtual nodes in the virtual list are traversed, the next virtual node is queried, and based on the first visual virtual node and the next virtual node, all traversed target virtual nodes are reloaded to obtain the second visual virtual node, and the display state of the second visual virtual node is set to the expanded state.

[0014] In some embodiments, the loading of all traversed target virtual nodes further includes:

[0015] Obtain the display status of all traversed target virtual nodes, find the variable virtual node whose display status is in the collapsed state in the target virtual node, delete the variable virtual node, modify all display states of the variable virtual node to the expanded state, and reload the variable virtual node and its child nodes to the virtual list.

[0016] In some embodiments, the expanding the specified first visual virtual node, or the collapsing the specified first visual virtual node, further includes:

[0017] If querying the target virtual node fails, deleting the specified first visible virtual node, setting the state of the specified first visible virtual node to be unchangeable, and reloading the specified first visible virtual node.

[0018] In some embodiments, the acquiring, according to the visible area, after expanding or collapsing the designated first visible virtual node, the second visible virtual node and rendering the second visible virtual node include:

[0019] After expanding or collapsing the specified first visual virtual node, obtain all virtual nodes whose display states are expanded and unchangeable, and according to the initial position and the end position of the visual area, obtain the virtual nodes in the visual area from all the virtual nodes whose display states are expanded and unchangeable to obtain the second visual virtual node; render the second visual virtual node.

[0020] In some embodiments, rendering the second visual virtual node includes:

[0021] Monitor the scroll bar, and when the time difference between the time after the scroll bar scrolls and the time after the last scroll bar scrolls is greater than a preset execution period, perform rendering of the second visual virtual node;

[0022] The rendering of the second visual virtual node refers to rendering the second visual virtual node in a hardware acceleration mode.

[0023] In a second aspect, a tree structure display device is provided in this embodiment, including: a receiving module, a rendering module and an execution module;

[0024] The receiving module is used to obtain a virtual list of a server device; the virtual list is generated by the server device according to the flattened data and the flat DOM structure is obtained; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure;

[0025] The rendering module is used to obtain a preset visible area, obtain a first visible virtual node in a virtual list according to the visible area, and render the first visible virtual node; the rendering module is also used to render a second visible virtual node according to the visible area;

[0026] The execution module is used to obtain a user instruction, and expand or collapse the specified first visual virtual node according to the user instruction to obtain a second visual virtual node.

[0027] In a third aspect, a tree structure display system is provided in this embodiment, including: a terminal device, a transmission device and a server device; wherein the terminal device is connected to the server device via the transmission device;

[0028] The server device is used to obtain flattened data, and obtain a flat DOM structure according to the flattened data; the server device is also used to construct a virtual DOM, load the flat DOM structure, and obtain the virtual list; wherein the flat DOM structure contains all nodes in the flattened data;

[0029] The transmission device is used to transmit the flattened data; the transmission device is also used to transmit the virtual list and all virtual nodes;

[0030] The terminal device is used to execute the tree structure display method described in the first aspect above.

[0031] In a fourth aspect, an electronic device is provided in this embodiment, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, a tree structure display method described in the first aspect is implemented.

[0032] In a fifth aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, a tree structure display method described in the first aspect is implemented.

[0033] Compared with the related art, the tree structure display method, device, system, electronic device and storage medium provided in this embodiment obtain a virtual list of a server device; obtain a preset visible area, obtain a first visible virtual node in the virtual list according to the visible area, and render the first visible virtual node; obtain a user instruction, and expand or collapse the specified first visible virtual node according to the user instruction to obtain a second visible virtual node; render the second visible virtual node according to the visible area, thereby solving the problems of weak operability and page jamming of tree structure display, and realizing the improvement of tree display and rendering efficiency of terminal devices under big data.

[0034] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0036] Figure 1 This is an application scenario diagram of a tree structure display method in an embodiment;

[0037] Figure 2 It is a flowchart of a tree structure display method in one embodiment;

[0038] Figure 3 It is a flowchart of the tree structure display method in the preferred embodiment;

[0039] Figure 4It is a structural block diagram of a tree structure display device in an embodiment;

[0040] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0041] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0042] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0043] The tree structure display method provided in this application can be applied to Figure 1In the application environment shown. Among them, the terminal device 102 communicates with the server device 104 through the network. The terminal device 102 obtains the virtual list of the server device 104; the virtual list is the server device 104 based on the flattened data received to obtain the horizontal DOM structure, and is generated according to the horizontal DOM structure; the virtual list contains virtual nodes corresponding to all nodes in the horizontal DOM structure; the terminal device 102 obtains a preset visible area, obtains the first visible virtual node in the virtual list according to the visible area, and renders the first visible virtual node; the terminal device 102 obtains a user instruction, expands or collapses the specified first visible virtual node according to the user instruction to obtain a second visible virtual node; according to the visible area, the second visible virtual node is rendered. Among them, the terminal device 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server device 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0044] In this embodiment, a tree structure display method is provided. Figure 2 is a flowchart of the tree structure display method of this embodiment. Figure 2 As shown, the process includes the following steps:

[0045] Step S202, obtaining a virtual list of the server device; the virtual list is generated by the server device according to the flattened data and the flat DOM structure; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure.

[0046] It should be noted that the server device obtains a flat DOM structure based on the received flattened data, and generates a virtual list according to the flat DOM structure, which means that: the server device builds a DOM structure based on the vue framework; the server device obtains the original data of the multi-layer nested tree structure, reduces the key value of the original data, flattens the original data, and changes the multi-layer nested tree structure into a one-dimensional array in the order of the original data id field to obtain flattened data; the server device builds a hierarchical DOM structure, and according to the flattened data, changes the hierarchical DOM structure into a flat DOM structure through recursion or traversal in the order of the original data id field, and the flat DOM structure contains all the nodes in the original data; the server device, based on the flat DOM structure, also builds a virtual flat DOM structure corresponding to the flat DOM structure, called a virtual list; the virtual list refers to a list that is based on all the data of the flat DOM structure and only renders the data in the visually visible visible area, which is separated from the original DOM structure. Among them, reducing the key value of the original data refers to reducing the key value of the original data using a key value reduction tool, or directly obtaining the reduced original data, and the reduced key value is 2 characters; since the method of reducing the key value is adopted in the process of constructing the virtual list, the data volume of the big data can be greatly reduced.

[0047] The original data is a multi-layer nested structure composed of nodes, and the fields contained in the nodes are: id (numbering starts from 0 according to the parent-child relationship of the nodes, and the child nodes of a node are numbered first and then the other nodes of the same level are numbered sequentially), index (index, initial value is 0), name (including "parent node" and "child node"), depth (node ​​depth, indicating the level of the node, the parent node depth is 0, and the child node depth is the parent node depth plus 1), haveChildren (child node attribute, the value is true when the node has child nodes, otherwise it is false).

[0048] Among them, the vue framework is vue.js, which is a progressive framework for building user interfaces; DOM is a standard programming interface for processing extensible markup language recommended by W3C (World Wide Web Consortium), which can reconstruct pages through JavaScript code to enhance the interactivity of pages. It is a hierarchical structure (or tree) of nodes.

[0049] Step S204: obtaining a preset visible area, obtaining a first visible virtual node in the virtual list according to the visible area, and rendering the first visible virtual node.

[0050] Specifically, a first initial virtual node corresponding to the initial position of the visible area is obtained in the virtual list, and a first terminal virtual node corresponding to the terminal position of the visible area is obtained, a first visual virtual node is obtained according to the first initial virtual node and the first terminal virtual node, and the first visual virtual node is rendered; wherein the first visual virtual node includes the first initial virtual node and the first terminal virtual node, as well as virtual nodes traversed in sequence between the first initial virtual node and the first terminal virtual node.

[0051] It should be noted that the user can pre-set the size of the above visible area according to different application scenarios.

[0052] Step S206 , obtaining a user instruction, and expanding or collapsing the designated first visual virtual node according to the user instruction to obtain a second visual virtual node; and rendering the second visual virtual node according to the visible area.

[0053] Specifically, in the list after the first visual virtual node is expanded or collapsed, a second initial virtual node corresponding to the initial position of the visual area is obtained, and a second terminal virtual node corresponding to the terminal position of the visual area is obtained, and a second visual virtual node is obtained according to the second initial virtual node and the second terminal virtual node, and the second visual virtual node is rendered; wherein, the second visual virtual node includes the second initial virtual node and the second terminal virtual node, and the virtual nodes between the second initial virtual node and the second terminal virtual node. Preferably, there are 20 virtual nodes in the first visual virtual node, and the user specifies to expand the 20th virtual node. The 20th virtual node has 20,000 child nodes, and the number of nodes allowed to be displayed in the visual area is 25. Therefore, only 5 child nodes of the 20th virtual node can be rendered, and the 5 child nodes are the second visual virtual node.

[0054] It should be noted that the expansion or collapse operation process can be implemented using the DIFF algorithm; the DIFF algorithm is based on the vue framework and is an efficient algorithm that compares tree nodes at the same level, avoiding layer-by-layer search and traversal of the tree. The time complexity is only O(n). By directly comparing the attributes of nodes at the same level, the frequent removal and loading of scroll bar listening events due to frequent changes in the hierarchical DOM structure are reduced, thereby simplifying the operation process.

[0055] Through the above steps, on the server device, the DOM structure is constructed as a virtual list in a virtualized manner, and the first visible virtual node in the virtual list is rendered according to the preset visible area. The operation of flattening the data can reduce the nesting of DOM levels. There is no need to perform too many recursive operations during data processing. Only a one-dimensional array needs to be traversed, which optimizes the calculation rate of the data processing process, improves the fluency and operability of the tree display and rendering of the terminal device under big data, and improves the operating efficiency. Moreover, the above DOM structure and the visible area can be customized to execute, and the above tree structure display method can be customized for different data structures, user needs and terminal devices.

[0056] In some embodiments, expanding or collapsing the designated first visible virtual node according to the user instruction to obtain the second visible virtual node includes:

[0057] If the user instruction is to collapse the specified first visible virtual node, all virtual nodes in the virtual list are traversed, a next virtual node whose depth is less than or equal to the depth of the first visible virtual node is searched, and according to the first visible virtual node and the next virtual node, all traversed target virtual nodes are deleted to obtain the second visible virtual node, and the display state of the second visible virtual node is set to the collapsed state;

[0058] The target virtual node refers to a virtual node traversed from the specified first visible virtual node to the next virtual node among all the virtual nodes, except the specified first visible virtual node and the next virtual node;

[0059] If the user instruction is to expand the specified first visible virtual node, all virtual nodes in the virtual list are traversed, the next virtual node is queried, and based on the first visible virtual node and the next virtual node, all traversed target virtual nodes are reloaded to obtain the second visible virtual node, and the display state of the second visible virtual node is set to the expanded state.

[0060] Specifically, when the above-mentioned user instruction indicates that the specified first visual virtual node is to be collapsed, deleting all traversed target virtual nodes to obtain the second visual virtual node according to the first visual virtual node and the next virtual node means that starting from the first visual virtual node, the one-dimensional group is traversed in node order, and when the depth is less than or equal to the depth of the first visual virtual node, the next virtual node is obtained, and the node between the first visual virtual node and the next virtual node is the target virtual node; after deleting the target virtual node, a virtual list after deletion is obtained, and in the virtual list after deletion, a second initial virtual node corresponding to the initial position of the visible area is obtained, and a second terminal virtual node corresponding to the end position of the visible area is obtained, and a second visual virtual node is obtained according to the second initial virtual node and the second terminal virtual node, and the second visual virtual node is rendered; wherein, the second visual virtual node includes the second initial virtual node and the second terminal virtual node, and the virtual nodes between the second initial virtual node and the second terminal virtual node.

[0061] Specifically, when the above-mentioned user instruction indicates that the specified first visual virtual node is to be expanded, reloading all the traversed target virtual nodes to obtain the second visual virtual node according to the first visual virtual node and the next virtual node means that starting from the first visual virtual node, the one-dimensional group is traversed in node order, and when the depth is less than or equal to the depth of the first visual virtual node, the next virtual node is obtained, and the node between the first visual virtual node and the next virtual node is the target virtual node; reloading the above-mentioned target virtual node that has been deleted in the collapsed state to the virtual list to obtain the loaded virtual list, in the loaded virtual list, the second initial virtual node corresponding to the initial position of the visible area is obtained, and the second terminal virtual node corresponding to the terminal position of the visible area is obtained, and the second visual virtual node is obtained according to the second initial virtual node and the second terminal virtual node, and the second visual virtual node is rendered; wherein, the second visual virtual node includes the second initial virtual node and the second terminal virtual node, and the virtual node between the second initial virtual node and the second terminal virtual node.

[0062] It should be noted that the above expansion or collapse operation process is implemented using the DIFF algorithm; the DIFF algorithm is based on the vue framework and is an efficient algorithm that compares tree nodes at the same level, avoiding layer-by-layer search and traversal of the tree, with a time complexity of only O(n).

[0063] Through the above steps, on the basis of the virtual list, the DIFF algorithm is used to delete or load the traversed target virtual nodes, which can reduce the frequent removal and loading of scroll bar listening events due to frequent changes in the hierarchical DOM structure, simplify the operation process, and improve the fluency and operability of the tree display and rendering of terminal devices under big data.

[0064] In some embodiments, the step of loading all traversed target virtual nodes further includes:

[0065] Obtain the display status of all traversed target virtual nodes, find the variable virtual node whose display status is in the collapsed state in the target virtual node, delete the variable virtual node, modify all display states of the variable virtual node to the expanded state, and reload the variable virtual node and its child nodes to the virtual list.

[0066] Through the above steps, in the process of node expansion, among the child nodes of the specified first visible virtual node, the child nodes that are already in the expanded state and the unchangeable state are screened, and the child nodes in the expanded state and the unchangeable state are not changed; for the child nodes in the collapsed state, the variable virtual node whose display state is in the collapsed state is obtained, and the child nodes of the variable virtual node have been deleted from the virtual list. In order to display all the child nodes of the variable virtual node, it is necessary to delete the variable virtual node, and at the same time set the display state of the variable virtual node to the expanded state, and then reload the variable virtual node and its child nodes to the virtual list; the above process only operates on the child nodes in the collapsed state, avoiding repeated operations on the nodes in the expanded state and the unchangeable state, and realizing the improvement of the fluency and operability of the tree display and rendering of terminal devices under big data.

[0067] In some embodiments, the step of expanding the designated first visible virtual node or the step of collapsing the designated first visible virtual node further includes:

[0068] If querying the target virtual node fails, the specified first visible virtual node is deleted, the state of the specified first visible virtual node is set to be unchangeable, and the specified first visible virtual node is reloaded.

[0069] Through the above steps, the display status of the leaf node without child nodes is marked as unchangeable. After the unchangeable state is detected on the display of the terminal device, the leaf node will not be further expanded or collapsed, avoiding repeated operations on the expanded state and unchangeable state nodes, and achieving the improvement of the fluency and operability of the tree display and rendering of the terminal device under big data.

[0070] In some embodiments, according to the visible area, after the designated first visible virtual node is expanded or collapsed, a second visible virtual node is obtained, and the second visible virtual node is rendered, including:

[0071] After the designated first visual virtual node is expanded or collapsed, all virtual nodes whose display states are expanded and unchangeable are obtained, and according to the initial position and the end position of the visual area, the virtual nodes in the visual area are obtained from all the virtual nodes whose display states are expanded and unchangeable to obtain the second visual virtual node; and the second visual virtual node is rendered.

[0072] Specifically, in the list after the first visual virtual node is expanded or collapsed, a second initial virtual node corresponding to the initial position of the visible area is obtained, and a second terminal virtual node corresponding to the terminal position of the visible area is obtained, a second visual virtual node is obtained according to the second initial virtual node and the second terminal virtual node, and the second visual virtual node is rendered; wherein the second visual virtual node includes the second initial virtual node and the second terminal virtual node, and the virtual nodes between the second initial virtual node and the second terminal virtual node.

[0073] It should be noted that the expansion or collapse operation is implemented using the DIFF algorithm; the DIFF algorithm is based on the vue framework and is an efficient algorithm that compares tree nodes at the same level, avoiding layer-by-layer search and traversal of the tree, with a time complexity of only O(n).

[0074] Through the above steps, in the logic of implementing node expansion or collapse, the data is flattened into a one-dimensional array. Logically, it can be considered that all child nodes are arranged in order on the parent node. At the same time, the DIFF algorithm is used to reduce the frequent removal and loading of scroll bar listening events due to frequent changes in the hierarchical DOM structure, simplify the operation process, and improve the fluency and operability of the tree display and rendering of terminal devices under big data; and the above DOM structure and visible area can be customized to execute, and the above tree structure display method can be customized for different data structures, user needs and terminal devices.

[0075] In some embodiments, rendering the second visible virtual node includes:

[0076] Monitor the scroll bar, and when the time difference between the time after the scroll bar scrolls and the time after the last scroll bar scrolls is greater than a preset execution period, perform rendering of the second visual virtual node;

[0077] The rendering of the second visible virtual node refers to rendering the second visible virtual node in a hardware acceleration mode.

[0078] Among them, the monitoring of the scroll bar can be performed using the built-in functions of the front-end development js framework, such as debounce (anti-shake) and throttle (interception); the hardware acceleration mode refers to the use of GPU or APU for accelerated operation, and the hardware call can be executed through the transform-translate3D function.

[0079] Through the above steps, the purpose of rendering the nodes in the visible area and not rendering the nodes outside the visible area can be achieved, which solves the problems of weak operability and page jams in tree structure display, and improves the tree display and rendering efficiency of terminal devices under big data.

[0080] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least a part of the steps in the above method may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps. The present embodiment is described and illustrated by preferred embodiments below.

[0081] Figure 3This is a flowchart of the tree structure display method in the preferred embodiment. First, reference vue.js to build a tree structure display environment; flatten the original data, change the multi-layer nested structure into a one-dimensional array, and reduce the key value of the original data to reduce the data volume; optimize the constructed DOM structure, change the hierarchical DOM structure of the parent-child relationship into a flat structure, thereby constructing a virtual list, and at the same time use the depth field to indicate the level of the node to reduce the nesting of the DOM level and optimize performance; secondly, set the size of the visible area, and render a specific number of nodes in the visible area into the page; then, traverse the Nodes node, and find the nodes with a depth less than or equal to the depth through the depth. The node is equal to the next node of the node; if the node is to be collapsed, it is deleted from the virtual list; if the node is to be expanded, it is necessary to determine whether there is a collapsed child node among all the child nodes of the node, and the collapsed child nodes are first removed and then the remaining child nodes are added back to the virtual list; if the traversal is completed and the next node with a depth less than or equal to the node is not found, it means that there is no peer node of the same level or parent level. After the node is removed, the expanded and collapsed state is modified and loaded back to the virtual list; finally, by monitoring the scroll bar, the initial position and the end position are obtained, so as to obtain the position of the visible area in the virtual list and render it. Among them, the above-mentioned operations on the node, including but not limited to the expansion or collapse of the node and the traversal operation of the node, are all node events, and the above-mentioned node events are delegated to the parent element, so as to reduce the frequent removal and loading of monitoring events due to frequent changes in the hierarchical DOM structure.

[0082] The above method constructs a virtual list by changing the hierarchical DOM structure of the parent-child relationship into a flat structure, and uses the depth field to indicate the level of the node. This method can change all nodes from a nested delegation structure to a one-dimensional array in which all node elements are sequentially bound to the parent element, thereby reducing the nesting of DOM levels, reducing the frequent removal and loading of scroll bar listening events due to frequent changes in the hierarchical DOM structure, optimizing performance, improving the fluency and operability of tree display and rendering of terminal devices under big data, and improving operating efficiency.

[0083] It should be noted that the implementation results of the tree structure display method of the present application can be compared with the timing results of displaying the TREE component in the ZTREE framework and IVIEW on the same page. The comparison results are as follows: when the TREE component in IVIEW is introduced, 3000 sample data are loaded, and the total time consumption of the TREE component displayed on the page is 10852ms, of which loading data (loading) takes 57ms, script construction (scripting) takes 9273ms, rendering tree construction (rendering) takes 546ms, painting (painting) takes 8ms, system delay (system) takes 381ms, and integrated development environment delay (Idle) takes 577ms; when the ZTREE framework is introduced, 60,000 sample data are loaded, and the total time consumption of the page display is 17869ms, of which loading data (loading) takes 2038ms, script construction (scripting) takes 3824ms, rendering tree construction (rendering) takes 8ms, system delay (system) takes 381ms, and integrated development environment delay (Idle) takes 577ms. The total time consumption for page display in the present application is 2267ms, including 50ms for loading data, 1736ms for scripting, 12ms for rendering tree construction, 2ms for painting, 326ms for system delay and 142ms for integrated development environment delay. Compared with the time consumption of terminal page display using ZTREE framework and TREE component in IVIEW, the tree structure display method of the present application consumes less time in tree structure display of big data without changing the display effect, solves the problems of weak operability and page jam in tree structure display, and improves the tree display and rendering efficiency of terminal devices under big data.

[0084] It should be noted that the steps shown in the above process or the flowchart in the attached figure can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here. For example, the two operation steps of folding nodes and expanding nodes can be to fold the nodes first and then expand the folded nodes; or the nodes can be expanded first to ensure that no node is hidden in the tree structure, and then the nodes that need to be folded can be folded after the complete tree structure is obtained.

[0085] In this embodiment, a tree structure display device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit" and the like used below can implement a combination of software and / or hardware of predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0086] Figure 4 is a structural block diagram of the tree structure display device of this embodiment, such as Figure 4 As shown, the device includes: a receiving module 20, a rendering module 30 and an execution module 40;

[0087] The receiving module 20 is used to obtain a virtual list of the server device; the virtual list is generated by the server device according to the flattened data and the flat DOM structure is obtained; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure;

[0088] The rendering module 30 is used to obtain a preset visible area, obtain a first visible virtual node in the virtual list according to the visible area, and render the first visible virtual node; the rendering module is also used to render a second visible virtual node according to the visible area;

[0089] The execution module 40 is used to obtain a user instruction, and expand or collapse the designated first visible virtual node according to the user instruction to obtain a second visible virtual node.

[0090] For the specific definition of the tree structure display device, please refer to the definition of the tree structure display method above, which will not be repeated here. Each module in the above-mentioned tree structure display device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0091] In this embodiment, a tree structure display system is also provided, which includes a terminal device, a transmission device and a server device; wherein the terminal device is connected to the server device via the transmission device;

[0092] The server device is used to obtain flattened data, and obtain a flat DOM structure according to the flattened data; the server device is also used to construct a virtual DOM, load the flat DOM structure, and obtain the virtual list; wherein the flat DOM structure contains all nodes in the flattened data;

[0093] The transmission device is used to transmit the flattened data; the transmission device is also used to transmit the virtual list and all virtual nodes;

[0094] The terminal device is used to execute any of the above-mentioned tree structure display methods.

[0095] In this embodiment, an electronic device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0096] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0097] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0098] S1, obtaining a virtual list of a server device; the virtual list is generated by the server device according to the flattened data received and the flat DOM structure is obtained; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure;

[0099] S2, obtaining a preset visible area, obtaining a first visible virtual node in the virtual list according to the visible area, and rendering the first visible virtual node;

[0100] S3, obtaining a user instruction, and expanding or collapsing the designated first visual virtual node according to the user instruction to obtain a second visual virtual node; and rendering the second visual virtual node according to the visual area.

[0101] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0102] In addition, in combination with the tree structure display method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the method. The storage medium stores a computer program; when the computer program is executed by a processor, any one of the tree structure display methods in the above embodiments is implemented.

[0103] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. 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 network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a tree structure display method is implemented. The display screen of the computer device 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 housing, or an external keyboard, touchpad or mouse, etc.

[0104] Those skilled in the art will understand that Figure 5 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.

[0105] 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 memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0106] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0107] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0108] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0109] The above-mentioned 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 patent protection. 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 scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. A tree structure display method, characterized in that: include: Get the virtual list of server devices; The virtual list is generated by the server device according to the flattened data received to obtain the flat DOM structure; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure; Acquire a preset visible area, acquire a first visible virtual node in the virtual list according to the visible area, and render the first visible virtual node; Obtaining a user instruction, and expanding or collapsing the specified first visual virtual node according to the user instruction to obtain a second visual virtual node; and rendering the second visual virtual node according to the visual area; The step of expanding or collapsing the designated first visual virtual node according to the user instruction to obtain the second visual virtual node includes: If the user instruction is to collapse the specified first visual virtual node, all virtual nodes in the virtual list are traversed, a next virtual node whose depth is less than or equal to the depth of the first visual virtual node is searched, and according to the first visual virtual node and the next virtual node, all traversed target virtual nodes are deleted to obtain the second visual virtual node, and the display state of the second visual virtual node is set to the collapsed state; The target virtual node refers to a virtual node traversed from the specified first visible virtual node to the next virtual node among all the virtual nodes, except the specified first visible virtual node and the next virtual node; If the user instruction is to expand the specified first visual virtual node, all virtual nodes in the virtual list are traversed, the next virtual node is queried, and based on the first visual virtual node and the next virtual node, all traversed target virtual nodes are reloaded to obtain the second visual virtual node, and the display state of the second visual virtual node is set to the expanded state.

2. The tree structure display method according to claim 1, characterized in that: The loading of all traversed target virtual nodes also includes: Obtain the display status of all traversed target virtual nodes, find the variable virtual node whose display status is in the collapsed state in the target virtual node, delete the variable virtual node, modify all display states of the variable virtual node to the expanded state, and reload the variable virtual node and its child nodes to the virtual list.

3. The tree structure display method according to claim 1, characterized in that: The step of expanding the specified first visual virtual node or the step of collapsing the specified first visual virtual node further includes: If querying the target virtual node fails, deleting the specified first visible virtual node, setting the state of the specified first visible virtual node to be unchangeable, and reloading the specified first visible virtual node.

4. The tree structure display method according to claim 3, characterized in that: The acquiring, according to the visible area, a second visible virtual node after expanding or collapsing the designated first visible virtual node, and rendering the second visible virtual node comprises: After expanding or collapsing the specified first visual virtual node, obtain all virtual nodes whose display states are expanded and unchangeable, and according to the initial position and the end position of the visual area, obtain the virtual nodes in the visual area from all the virtual nodes whose display states are expanded and unchangeable to obtain the second visual virtual node; render the second visual virtual node.

5. The tree structure display method according to any one of claims 1 to 4, characterized in that: The rendering of the second visual virtual node includes: Monitor the scroll bar, and when the time difference between the time after the scroll bar scrolls and the time after the last scroll bar scrolls is greater than a preset execution period, perform rendering of the second visual virtual node; The rendering of the second visual virtual node refers to rendering the second visual virtual node in a hardware acceleration mode.

6. A tree structure display device, characterized in that: include: Receiving module, rendering module and execution module; The receiving module is used to obtain a virtual list of server devices; The virtual list is generated by the server device according to the flattened data received to obtain the flat DOM structure; the virtual list contains virtual nodes corresponding to all nodes in the flat DOM structure; The rendering module is used to obtain a preset visible area, obtain a first visible virtual node in the virtual list according to the visible area, and render the first visible virtual node; The rendering module is further used to render the second visual virtual node according to the visible area; The execution module is used to obtain a user instruction, and expand or collapse the specified first visual virtual node according to the user instruction to obtain a second visual virtual node; The step of expanding or collapsing the designated first visual virtual node according to the user instruction to obtain the second visual virtual node includes: If the user instruction is to collapse the specified first visual virtual node, all virtual nodes in the virtual list are traversed, a next virtual node whose depth is less than or equal to the depth of the first visual virtual node is searched, and according to the first visual virtual node and the next virtual node, all traversed target virtual nodes are deleted to obtain the second visual virtual node, and the display state of the second visual virtual node is set to the collapsed state; The target virtual node refers to a virtual node traversed from the specified first visible virtual node to the next virtual node among all the virtual nodes, except the specified first visible virtual node and the next virtual node; If the user instruction is to expand the specified first visual virtual node, all virtual nodes in the virtual list are traversed, the next virtual node is queried, and based on the first visual virtual node and the next virtual node, all traversed target virtual nodes are reloaded to obtain the second visual virtual node, and the display state of the second visual virtual node is set to the expanded state.

7. A tree structure display system, characterized in that: include: Terminal equipment, transmission equipment and server equipment; wherein the terminal equipment is connected to the server equipment via the transmission equipment; The server device is used to obtain flattened data, and obtain a flat DOM structure according to the flattened data; the server device is also used to construct a virtual DOM, load the flat DOM structure, and obtain the virtual list; wherein the flat DOM structure contains all nodes in the flattened data; The transmission device is used to transmit the flattened data; the transmission device is also used to transmit the virtual list and all virtual nodes; The terminal device is used to execute the tree structure display method described in any one of claims 1 to 5.

8. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the tree structure display method according to any one of claims 1 to 5.

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 tree structure display method according to any one of claims 1 to 5 are implemented.