Data query method and device applied to single-page application

By obtaining and generating view layers in a single-page application and updating the data of the page node using the publish subscription mode, the problem of low data update efficiency during the data query of single-page application is solved, and user experience and information processing efficiency is improved.

CN113779454BActive Publication Date: 2025-03-25BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110055219.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-15
Publication Date
2025-03-25
Estimated Expiration
2041-01-15

AI Technical Summary

Technical Problem

During the data query process of single-page applications, it is difficult for the existing technology to efficiently update the data of page nodes, resulting in poor user experience and low information update efficiency.

Method used

By obtaining the relational data of the data model from the backend of a single page application, a view layer is generated to characterize the correspondence between the page node and the data model layer, and obtaining the data of the page node based on the publish subscription model.

Benefits of technology

It realizes page nodes that can update associated data without the user manually refreshing the page, improves information update efficiency and user experience, and reduces the number of interactions between the front-end and the back-end, and improves information processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113779454B_ABST
    Figure CN113779454B_ABST
Patent Text Reader

Abstract

The present application discloses a data query method and device applied to a single-page application. A specific implementation of the method includes: according to the received operation request, obtaining the relationship data of the data model involved in the page requested by the operation request from the backend of the single-page application, wherein the relationship data is used to characterize the relevance of the data in the data model; according to the relationship data, generating a view layer, wherein the view in the view layer is used to characterize the correspondence between the page node in the page and the data model in the data model layer set at the front end of the single-page application; based on the publish-subscribe mode between the data model layer and the view layer, obtaining the data corresponding to the page node in the page. The present application provides a data query method applied to a single-page application. When the data model layer contains the data involved in the page requested by the operation request, the page nodes of the data involved in the association can be updated through the view traversal in the view layer, thereby improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a data query method and device for single-page applications. Background Art

[0002] With the continuous development of websites, single-page applications are increasingly used due to their better user experience (for example, users do not need to open many tabs and do not need to refresh the page repeatedly to obtain the latest data). The process of a single-page application initiating a request from the front end and accessing the back-end interface to obtain data is called data query. At present, the data query process of a single-page application is as follows: the back end establishes the corresponding data model based on the database table information; according to the needs of data query, the corresponding data query interface is encapsulated, and these data models are processed by business logic to produce data; the front end of the single-page application calls these interfaces and renders the data in the interface onto the page. Summary of the invention

[0003] The embodiments of the present application provide a data query method and device for single-page applications.

[0004] In a first aspect, an embodiment of the present application provides a data query method applied to a single-page application, comprising: obtaining, from the backend of the single-page application, based on a received operation request, relational data of a data model involved in a page requested by the operation request, wherein the relational data is used to characterize the association between data in the data model; generating a view layer based on the relational data, wherein the view in the view layer is used to characterize the correspondence between page nodes in the page and data models in a data model layer set at the front end of the single-page application; and obtaining data corresponding to page nodes in the page based on a publish-subscribe model between the data model layer and the view layer.

[0005] In some embodiments, the above-mentioned obtaining of data corresponding to the page node in the page includes: in response to determining that the cache corresponding to the data model layer includes the data model in the page requested by the operation request, obtaining the data corresponding to the page node in the page from the cache.

[0006] In some embodiments, the above-mentioned acquisition of data corresponding to the page node in the page includes: in response to determining that the cache corresponding to the data model layer does not include the data model in the page requested by the operation request, acquiring the data in the data model involved in the page from the backend of the single-page application, and storing the acquired data model data in the cache.

[0007] In some embodiments, the above-mentioned acquisition of data in the data model involved in the page from the backend of the single-page application includes: sending batch acquisition requests to the backend of the single-page application in units of preset time periods to obtain the data that the front end of the single-page application needs to obtain within the preset time period.

[0008] In some embodiments, before generating the view layer according to the relational data, the method further includes: creating a data model layer in the front end of the application according to the data model in the back end of the single-page application.

[0009] In some embodiments, the above method further includes: rendering a view in a view layer according to data corresponding to a page node in the page to obtain a page requested by the operation request.

[0010] In the second aspect, an embodiment of the present application provides a data query device applied to a single-page application, including: a first acquisition unit, configured to acquire, from the backend of the single-page application, according to the received operation request, the relationship data of the data model involved in the page requested by the operation request, wherein the relationship data is used to characterize the association between the data in the data model; a generation unit, configured to generate a view layer according to the relationship data, wherein the view in the view layer is used to characterize the correspondence between the page nodes in the page and the data models in the data model layer set at the front end of the single-page application; a second acquisition unit, configured to acquire the data corresponding to the page nodes in the page based on the publish-subscribe mode between the data model layer and the view layer.

[0011] In some embodiments, the second acquisition unit is further configured to: in response to determining that the cache corresponding to the data model layer includes the data model of the page requested by the operation request, acquire data corresponding to the page node in the page from the cache.

[0012] In some embodiments, the second acquisition unit is further configured to: in response to determining that the cache corresponding to the data model layer does not include the data model in the page requested by the operation request, obtain the data in the data model involved in the page from the backend of the single-page application, and store the obtained data model data in the cache.

[0013] In some embodiments, the second acquisition unit is further configured to send acquisition requests to the backend of the single-page application in batches in units of a preset time period to obtain the data that the frontend of the single-page application needs to obtain within the preset time period.

[0014] In some embodiments, the above-mentioned apparatus further includes: a creation unit configured to: create a data model layer in the front end of the application according to the data model in the back end of the single-page application.

[0015] In some embodiments, the above-mentioned device also includes: a rendering unit, which is configured to render the view in the view layer according to the data corresponding to the page node in the page, and obtain the page requested by the operation request.

[0016] In a third aspect, an embodiment of the present application provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method described in any implementation manner of the first aspect is implemented.

[0017] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation manner of the first aspect.

[0018] The data query method and device applied to a single-page application provided in an embodiment of the present application obtain, from the back end of the single-page application, the relational data of the data model involved in the page requested by the operation request according to the received operation request, wherein the relational data is used to characterize the relevance of the data in the data model; generate a view layer according to the relational data, wherein the view in the view layer is used to characterize the correspondence between the page node in the page and the data model in the data model layer set at the front end of the single-page application; based on the publish-subscribe mode between the data model layer and the view layer, obtain the data corresponding to the page node in the page, thereby providing a data query method applied to a single-page application, when the data model layer has the data involved in the page requested by the operation request, the page node of the data involved in the association can be updated through the view in the view layer. In this way, there is no need for the user to manually refresh the entire page or the developer to manually refresh all associated page nodes, thereby improving the information update efficiency and user experience; setting the data model layer at the front end of the single-page application reduces the number of interactions between the front end and the back end of the single-page application, thereby improving the information processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0020] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present application may be applied;

[0021] Figure 2 is a flow chart of an embodiment of a data query method applied to a single-page application according to the present application;

[0022] Figure 3A-3B This is a schematic diagram of a single-page application page;

[0023] Figure 4 is a schematic diagram of an application scenario of the data query method applied to a single-page application according to this embodiment;

[0024] Figure 5 is a flow chart of another embodiment of a data query method applied to a single-page application according to the present application;

[0025] Figure 6 is a structural diagram of an embodiment of a data query device applied to a single-page application according to the present application;

[0026] Figure 7 It is a structural diagram of a computer system suitable for implementing the embodiments of the present application. DETAILED DESCRIPTION

[0027] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It should also be noted that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.

[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0029] Figure 1 An exemplary architecture 100 to which the data query method and apparatus for a single-page application of the present application can be applied is shown.

[0030] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The communication connection between the terminal devices 101, 102, 103 constitutes a topological network, and the network 104 is used to provide a medium for the communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0031] Terminal devices 101, 102, 103 may be hardware devices or software that support network connection for data interaction and data processing. When terminal devices 101, 102, 103 are hardware, they may be various electronic devices that support network connection, information acquisition, interaction, display, processing and other functions, including but not limited to smart phones, tablet computers, e-book readers, laptop computers and desktop computers, etc. When terminal devices 101, 102, 103 are software, they may be installed in the electronic devices listed above. They may be implemented as multiple software or software modules for providing distributed services, or they may be implemented as a single software or software module. No specific limitation is made here.

[0032] Server 105 can be a server that provides various services, such as obtaining operation requests for single-page applications on terminal devices 101, 102, and 103, and a background processing server that supports the operation of single-page applications. The background processing server generates a view layer and a data model layer at the front end of the single-page application, and obtains the data corresponding to the page nodes in the page in the single-page application based on the publish-subscribe model between the data model layer and the view layer. Among them, the view in the view layer is used to represent the correspondence between the page nodes in the page and the data model in the data model layer set at the front end of the single-page application, and the data model layer includes multiple data models. As an example, server 105 can be a cloud server.

[0033] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0034] It should also be noted that the data query method applied to a single-page application provided by the embodiments of the present disclosure can be executed by a server, can be executed by a terminal device, or can be executed by a server and a terminal device in cooperation with each other. Accordingly, the various parts (such as various units, sub-units, modules, and sub-modules) included in the data query device applied to a single-page application can be all set in the server, can be all set in the terminal device, or can be set in the server and the terminal device respectively.

[0035] It should be understood that Figure 1The number of terminal devices, networks, and servers in the system is only illustrative. Any number of terminal devices, networks, and servers may be provided as required. When the electronic device on which the data query method applied to a single-page application runs does not need to perform data transmission with other electronic devices, the system architecture may only include the electronic device (e.g., server or terminal device) on which the data query method applied to a single-page application runs.

[0036] Continue to refer Figure 2 , shows a process 200 of an embodiment of a data query method applied to a single-page application, including the following steps:

[0037] Step 201: According to the received operation request, the relationship data of the data model involved in the page requested by the operation request is obtained from the backend of the single-page application.

[0038] In this embodiment, the execution subject of the data query method applied to the single-page application (for example Figure 1 The server in the application may receive an operation request from the user and, based on the received operation request, obtain the relational data of the data model involved in the page requested by the operation request from the back end of the single-page application.

[0039] SPA (Single-Page Application) is a website application model that consists of a shell page and multiple page fragments. It can dynamically rewrite the current page fragment to interact with the user and implement partial updates of page fragments without reloading the entire page. For example, in a single-page application, a page fragment is deleted or hidden, and another page fragment is displayed, so as to achieve jumps between page fragments.

[0040] like Figure 3A-3B As shown, a page diagram 300 of a single-page application for production process control of a manufacturing enterprise is shown. It can be seen that the page includes operation buttons for viewing information such as "process flow", "production line management", "task list" and "user list". By clicking "task list", the user issues an operation request to view the "task list", and the page displays the specific content in the task list. Figure 3A As shown, task 1 corresponds to user A, user B, and user C, task 2 corresponds to user A and user B, and task 3 corresponds to user B and user C.

[0041] When the user clicks the action button corresponding to the "user list", an action request to view the "user list" is issued. The single-page application hides the specific content in the task list and displays the page representing the specific content in the user list. Figure 3BAs shown, user A has tasks 1 and 2, user B has tasks 1, 2 and 3, and user C has tasks 1 and 3.

[0042] It is understandable that applications are generally designed to solve problems in a certain field, and there will be various entity concepts in these fields. Figure 3A ,The task list involves team collaboration issues. For example, Task 1 requires the collaboration of User A, User B, and User C. It involves two entity concepts: Task and User. These two concepts have their own unique attributes (such as the type of task, the age of the user, and other attribute information). When these concepts are abstracted into the application, they are expressed as data models.

[0043] Specifically, the data model includes the following contents: specific data of the data model, which is used to characterize the specific information included in the data model; descriptive data of the data model, which is used to describe the specific data in the data model. Taking the above-mentioned data model representing the task as an example, the descriptive data includes data such as the task name and participating users; a method of requesting data in the data model. Continuing with the above-mentioned data model representing the task as an example, the method of requesting data in the data model can be to obtain the specific data of the task data model from the back end through the data interface of the back end corresponding to the task data model.

[0044] For an application, it is generally divided into two parts: the front-end and the back-end. The front-end is usually located on the client side and is responsible for displaying data. For a single-page application, the front-end generally refers to the Web browser client. The back-end is usually located on the server side and is responsible for providing data interfaces and processing data. For each data model, the back-end will provide a corresponding data interface so that the front-end of the single-page application can obtain the data in the data model from the back-end through the data interface corresponding to the data model.

[0045] The relational data of the data model is used to represent the relationship between the data in the data model. Figure 3A The relational data of the task data model involved in its page is used to characterize the association between task 1 and user A, user B, and user C, the association between task 2 and user A and user B, and the association between task 3 and user B and user C.

[0046] Specifically, the execution subject can describe the relationship data of the data model through the ID (Identity document) of each data in the data model. For example, the relationship data of the task data model is:

[0047] Task 1-ID: User A-ID, User B-ID, User C-ID

[0048] Task 2-ID: User A-ID, User B-ID

[0049] Task 3-ID: User B-ID, User C-ID

[0050] Through the ID corresponding to the data, the above execution entity can concisely describe the relational data of the data model.

[0051] Step 202: Generate a view layer according to the relationship data.

[0052] In this embodiment, the execution subject can generate a view layer based on the relationship data. The view in the view layer is used to represent the corresponding relationship between the page node in the page and the data model in the data model layer set at the front end of the single-page application. The page node represents each area in the page. For example, Figure 3A , 3B The page areas corresponding to each user and each task are all page nodes.

[0053] In this embodiment, the front end of the single-page application is provided with a data model layer. The data model layer includes multiple data models. The data model in the data model layer set at the front end of the single-page application corresponds to the data model of the back end of the single-page application. It should be noted that the data model in the back end is used to update the database table information of the back end, while the data model in the data model layer in the front end is used to update the page nodes corresponding to each view in the view layer.

[0054] It can be understood that the view layer may include multiple views, and each of the multiple views is used to represent the corresponding relationship between the page node corresponding to the view and the data model in the data model layer set in the front end.

[0055] Continue to refer Figure 3A The task data model shown in Figure 1. Task 1, Task 2, and Task 3 can correspond to the task views in the view layer in turn. Figure 1 , Mission View Figure 2 , Task View 3. Among them, Task View Figure 1 It is used to represent the correspondence between the page nodes "Task 1", "User A", "User B", "User C" in the view and the task data model in the data model layer. Figure 1 Used to characterize the correspondence between the page nodes "Task 1", "User A", "User B", "User C" in the view and the specific data corresponding to Task 1 under the task data model in the data model layer.

[0056] The execution subject first generates a placeholder page node on the page according to the relational data of the data model involved in the requested page; then, traverses all placeholder page nodes and instantiates each view; finally, determines the page node corresponding to each view in the view layer.

[0057] by Figure 3ATaking the task data model shown in the figure as an example, first, generate 4 placeholder page nodes in the page to represent 3 users involved in a task, 3 placeholder page nodes to represent 2 users involved in another task, and 3 placeholder page nodes to represent 2 users involved in another task. Then, traverse the above 4 placeholder page nodes, 3 placeholder page nodes, and 3 placeholder page nodes, and get 3 views after instantiation. For example, the above 4 placeholder page nodes correspond to "Task 1", "User A", "User B", and "User C" respectively, then the task view Figure 1 Includes "Task 1", "User A", "User B", and "User C".

[0058] It can be understood that since relational data is data that represents the association between data in a data model, the view generated by the above-mentioned execution subject based on the relational data can represent the corresponding relationship between each page node and the view model in the data model layer.

[0059] Step 203: Based on the publish-subscribe mode between the data model layer and the view layer, the data corresponding to the page node in the page is obtained.

[0060] In this embodiment, the execution subject can obtain the data corresponding to the page node in the page based on the publish-subscribe mode between the data model layer and the view layer.

[0061] The publish-subscribe model is actually a one-to-many dependency relationship between objects. When the state of an object changes, all objects that depend on it will be notified of the state change.

[0062] Specifically, the subscriber registers (Subscribe) the event he wants to subscribe to to the dispatch center (Event Channel). When the publisher (Publisher) publishes the event (Publish Event) to the dispatch center, that is, when the event is triggered, the dispatch center uniformly dispatches (Fire Event) the processing code registered by the subscriber to the dispatch center.

[0063] In this embodiment, each view in the view layer acts as a subscriber, and the data model in the data model layer acts as a publisher. When the data model in the data model layer changes, all views subscribed to the data model will receive the data representing the change. It can be understood that for each data model in the data model layer, the page node in the view subscribing to the data model corresponds to the view model. As an example, in Figure 3A In the task, task 1, task 2, and task 3 correspond to task views respectively. Figure 1 , Mission View Figure 2 , task view 3, the above three task views subscribe to the task data model in the data model layer; Figure 3B In the example, user 1, user 2, and user 3 correspond to user views respectively. Figure 1 , User View Figure 2 , user view 3, the above three user views subscribe to the user data model in the data model layer.

[0064] In some optional implementations of this embodiment, in response to determining that the cache corresponding to the data model layer includes the data model of the page requested by the operation request, data corresponding to the page node in the page is obtained from the cache.

[0065] As an example, the above execution entity may cache the data in the data model layer into the memory of the client.

[0066] In some optional implementations of this embodiment, in response to determining that the cache corresponding to the data model layer does not include the data model of the page requested by the operation request, the data in the data model involved in the page is obtained from the backend of the single-page application, and the obtained data of the data model is stored in the cache. Based on the publish-subscribe mode between the data model layer and the view layer, the data model in the data model layer pushes the data in the data model to the view that subscribes to the data model.

[0067] In some optional implementations of this embodiment, the execution subject sends batch acquisition requests to the backend of the single-page application in units of preset time periods to obtain the data that the frontend of the single-page application needs to obtain within the preset time period. The length of the preset time period can be specifically set according to actual conditions, for example, the length of the preset time period is 1 second.

[0068] It can be understood that in this embodiment, since the data model layer is set in the front end, the front end can obtain data in the data model layer, which reduces the number of interactions between the front end and the back end of the single-page application. On this basis, the single-page application uniformly processes the operation requests received within a preset time period by batch acquisition, thereby improving the efficiency of information processing.

[0069] Continue to see Figure 4 , Figure 4 FIG4 is a schematic diagram 400 of an application scenario of the data query method applied to a single-page application according to this embodiment. Figure 4In the application scenario, user 401 first views page 4021 representing the user list in the single-page application through client 402. Then, the "task list" button in page 4021 is clicked to issue an operation request to view the task list. Server 403 obtains the relationship data of the data model involved in the page requested by the operation request from the backend of the single-page application according to the received operation request. Among them, the relationship data is used to represent the association of data in the data model. Among them, the relationship data includes three parts, the first part is "Task 1-ID: User A-ID, User B-ID, User C-ID", which is used to represent that the users represented by these three IDs, user A-ID, user B-ID, and user C-ID, jointly complete the task represented by Task 1-ID. The second part is "Task 2-ID: User A-ID, User B-ID", which is used to represent that the users represented by these two IDs, user A-ID and user B-ID, jointly complete the task represented by Task 2-ID. The third part is "Task 3-ID: User B-ID, User C-ID", which is used to represent that the users represented by User B-ID and User C-ID in turn jointly complete the task represented by Task 3-ID.

[0070] Then, the view layer is generated according to the relational data. Among them, the view layer includes views 404, 405, and 406. Views 404, 405, and 406 correspond to the first part, the second part, and the third part of the above-mentioned relational data in sequence. It can be understood that the three views in the view layer are used to represent the corresponding relationship between the page node in the page and the task data model in the data model layer set at the front end of the single-page application. Finally, the server 403 obtains the data corresponding to the page node in the page based on the publish-subscribe mode between the data model layer and the view layer. Among them, task 1 represents the task of preparing production materials, task 2 represents the task of pre-processing production materials, and task 3 represents the task of ensuring production processing. User A, user B, and user C are Zhang San, Li Si, and Wang Wu respectively. For task 1, user A, user B, and user C complete 20%, 30%, and 50% respectively; for task 2, user A, user B, and user C complete 50% respectively; for task 2, user B and user C complete 40% and 60% respectively.

[0071] The method provided by the above-mentioned embodiment of the present disclosure obtains the relational data of the data model involved in the page requested by the operation request from the back end of the single-page application according to the received operation request, wherein the relational data is used to characterize the relevance of the data in the data model; generates a view layer according to the relational data, wherein the view in the view layer is used to characterize the correspondence between the page node in the page and the data model in the data model layer set at the front end of the single-page application; based on the publish-subscribe mode between the data model layer and the view layer, obtains the data corresponding to the page node in the page, thereby providing a data query method applied to the single-page application, when the data model layer contains the data involved in the page requested by the operation request, the page node of the data involved in the association can be updated through the view in the view layer, so that the user does not need to manually refresh the entire page or the developer does not need to manually refresh all the associated page nodes, thereby improving the information update efficiency and user experience; setting the data model layer at the front end of the single-page application reduces the number of interactions between the front end and the back end of the single-page application, thereby improving the information processing efficiency.

[0072] Continue to refer Figure 5 , shows a schematic process 500 of an embodiment of a data query method applied to a single-page application according to the present application, including the following steps:

[0073] Step 501: According to the received operation request, the relationship data of the data model involved in the page requested by the operation request is obtained from the backend of the single-page application.

[0074] Among them, relational data is used to represent the association between data in the data model.

[0075] Step 502: Generate a view layer according to the relationship data.

[0076] The view in the view layer is used to represent the corresponding relationship between the page nodes in the page and the data models in the data model layer set at the front end of the single-page application.

[0077] Step 503, based on the publish-subscribe mode between the data model layer and the view layer, in response to determining that the cache corresponding to the data model layer includes the data model of the page requested by the operation request, obtain the data corresponding to the page node in the page from the cache.

[0078] Step 504, based on the publish-subscribe model between the data model layer and the view layer, in response to determining that the cache corresponding to the data model layer does not include the data model in the page requested by the operation request, batch acquisition requests are sent to the backend of the single-page application in units of preset time periods to obtain the data that the front end of the single-page application needs to obtain within the preset time period, and the acquired data model data is stored in the cache.

[0079] Step 505 , rendering the view in the view layer according to the data corresponding to the page node in the page, and obtaining the page requested by the operation request.

[0080] In this embodiment, after the subscribe function starts to execute, it will first combine the page template and data to render an HTML (Hyper Text Markup Language) string; then, it will traverse and replace all page nodes in the page, and the page will be redrawn at this time (which is a spontaneous behavior of the browser after replacing the node), and the page will be updated in real time. After the subscribe function is executed, depending on whether there is an error during the execution process, if an error is reported, the error callback function will be executed; otherwise, the success callback function will be executed.

[0081] It can be seen from this embodiment that Figure 2 Compared with the corresponding embodiments, the process 500 of the data query method applied to a single-page application in this embodiment specifically describes the process of obtaining data in the specification page and the process of rendering the page, further improving the user experience and information processing efficiency.

[0082] Continue to refer Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a data query device applied to a single-page application. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0083] like Figure 6 As shown, a data query device applied to a single-page application includes: a first acquisition unit 601, configured to acquire, according to a received operation request, relational data of a data model involved in a page requested by the operation request from the backend of the single-page application, wherein the relational data is used to characterize the association of data in the data model; a generation unit 602, configured to generate a view layer according to the relational data, wherein the view in the view layer is used to characterize the correspondence between page nodes in a page and data models in a data model layer set at the front end of the single-page application; a second acquisition unit 603, configured to acquire data corresponding to page nodes in a page based on a publish-subscribe mode between the data model layer and the view layer.

[0084] In some optional implementations of this embodiment, the second acquisition unit 603 is further configured to: in response to determining that the cache corresponding to the data model layer includes the data model of the page requested by the operation request, obtain data corresponding to the page node in the page from the cache.

[0085] In some optional implementations of this embodiment, the second acquisition unit 603 is further configured to: in response to determining that the cache corresponding to the data model layer does not include the data model of the page requested by the operation request, obtain the data in the data model involved in the page from the backend of the single-page application, and store the obtained data model data in the cache.

[0086] In some optional implementations of this embodiment, the second acquisition unit 603 is further configured to: send acquisition requests to the backend of the single-page application in batches in units of preset time periods to obtain the data that the frontend of the single-page application needs to obtain within the preset time period.

[0087] In some optional implementations of this embodiment, the above-mentioned device also includes: a creation unit (not shown in the figure), which is configured to: create a data model layer in the front end of the application according to the data model in the back end of the single-page application.

[0088] In some optional implementations of this embodiment, the above-mentioned device also includes: a rendering unit (not shown in the figure), which is configured to render the view in the view layer according to the data corresponding to the page node in the page to obtain the page requested by the operation request.

[0089] In this embodiment, a first acquisition unit in a data query device applied to a single-page application acquires, from the backend of the single-page application, relationship data of a data model involved in a page requested by an operation request according to a received operation request, wherein the relationship data is used to characterize the association of data in the data model; a generation unit generates a view layer according to the relationship data, wherein the view in the view layer is used to characterize the correspondence between page nodes in a page and data models in a data model layer provided at the front end of the single-page application; a second acquisition unit acquires, based on a publish-subscribe model between the data model layer and the view layer, data corresponding to page nodes in a page, thereby providing a data query device applied to a single-page application; when the data model layer contains data involved in a page requested by an operation request, the page nodes of the associated data can be updated through view traversal in the view layer, thereby improving the user experience.

[0090] Reference below Figure 7 , which shows a device suitable for implementing the embodiments of the present application (eg Figure 1 Schematic diagram of the structure of a computer system 700 of devices 101, 102, 103, 105) shown. Figure 7 The device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0091] like Figure 7As shown, the computer system 700 includes a processor (e.g., CPU, central processing unit) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The processor 701, ROM 702, and RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0092] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0093] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 709, and / or installed from a removable medium 711. When the computer program is executed by the processor 701, the above-mentioned functions defined in the method of the present application are executed.

[0094] It should be noted that the computer-readable medium of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0095] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the client computer, partially on the client computer, as a separate software package, partially on the client computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the client computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0096] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the device, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0097] The units involved in the embodiments of the present application may be implemented by software or by hardware. The units described may also be provided in a processor, for example, may be described as: a processor comprising a first acquisition unit, a generation unit, and a second acquisition unit. Among them, the names of these units do not constitute a limitation on the unit itself in certain circumstances. For example, the first acquisition unit may also be described as "a unit for acquiring, from the backend of a single-page application, according to a received operation request, the relational data of the data model involved in the page requested by the operation request".

[0098] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the device, the computer device: obtains the relationship data of the data model involved in the page requested by the operation request from the back end of the single-page application according to the received operation request, wherein the relationship data is used to characterize the association of the data in the data model; generates a view layer according to the relationship data, wherein the view in the view layer is used to characterize the correspondence between the page node in the page and the data model in the data model layer set at the front end of the single-page application; obtains the data corresponding to the page node in the page based on the publish-subscribe mode between the data model layer and the view layer.

[0099] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

Claims

1. A data query method applied to a single-page application, comprising: According to the received operation request, acquiring, from the backend of the single-page application, relational data of a data model involved in the page requested by the operation request, wherein the data model is used to represent data in a page node in the page, and the relational data is used to represent the relevance of data in the data model; Generate a view layer according to the relationship data, wherein the view in the view layer is used to represent the corresponding relationship between the page node in the page and the data model in the data model layer set at the front end of the single-page application; Based on the publish-subscribe mode between the data model layer and the view layer, data corresponding to the page node in the page is obtained.

2. The method according to claim 1, wherein: The acquiring the data corresponding to the page node in the page includes: In response to determining that the cache corresponding to the data model layer includes the data model of the page requested by the operation request, data corresponding to the page node in the page is obtained from the cache.

3. The method according to claim 1, wherein: The acquiring the data corresponding to the page node in the page includes: In response to determining that the cache corresponding to the data model layer does not include the data model in the page requested by the operation request, data in the data model involved in the page is obtained from the backend of the single-page application, and the obtained data model data is stored in the cache.

4. The method according to claim 3, wherein: The acquiring data in the data model involved in the page from the backend of the single-page application includes: Taking a preset time period as a unit, batches of acquisition requests are sent to the backend of the single-page application to acquire data that the frontend of the single-page application needs to acquire within the preset time period.

5. The method according to claim 1, wherein: Before generating the view layer according to the relationship data, the method further includes: The data model layer is created in the front end of the application according to the data model in the back end of the single page application.

6. The method according to any one of claims 1 to 5, wherein: Also includes: The view in the view layer is rendered according to the data corresponding to the page node in the page to obtain the page requested by the operation request.

7. A data query device applied to a single-page application, comprising: A first acquisition unit is configured to acquire, according to the received operation request, the relationship data of the data model involved in the page requested by the operation request from the backend of the single-page application, wherein the data model is used to represent the data in the page node in the page, and the relationship data is used to represent the relevance of the data in the data model; A generating unit is configured to generate a view layer according to the relationship data, wherein the view in the view layer is used to represent the corresponding relationship between the page node in the page and the data model in the data model layer set at the front end of the single-page application; The second acquisition unit is configured to acquire data corresponding to the page node in the page based on the publish-subscribe mode between the data model layer and the view layer.

8. The device according to claim 7, wherein: The second acquisition unit is further configured to: In response to determining that the cache corresponding to the data model layer includes the data model of the page requested by the operation request, data corresponding to the page node in the page is obtained from the cache.

9. The device according to claim 7, wherein: The second acquisition unit is further configured to: In response to determining that the cache corresponding to the data model layer does not include the data model in the page requested by the operation request, data in the data model involved in the page is obtained from the backend of the single-page application, and the obtained data model data is stored in the cache.

10. The device according to claim 9, wherein: The second acquisition unit is further configured to: Taking a preset time period as a unit, batches of acquisition requests are sent to the backend of the single-page application to acquire data that the frontend of the single-page application needs to acquire within the preset time period.

11. The device according to claim 7, wherein: Also includes: Create a unit, configured as: The data model layer is created in the front end of the application according to the data model in the back end of the single page application.

12. The device according to any one of claims 7 to 11, wherein: Also includes: The rendering unit is configured to render the view in the view layer according to the data corresponding to the page node in the page, so as to obtain the page requested by the operation request.

13. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

14. An electronic device comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dynamic generation method and device of service system, computer equipment and storage medium

    CN108446327A