WO2020119804A1 - 页面视图的显示方法、装置、设备及存储介质 - Google Patents

页面视图的显示方法、装置、设备及存储介质 Download PDF

Info

Publication number
WO2020119804A1
WO2020119804A1 PCT/CN2019/125322 CN2019125322W WO2020119804A1 WO 2020119804 A1 WO2020119804 A1 WO 2020119804A1 CN 2019125322 W CN2019125322 W CN 2019125322W WO 2020119804 A1 WO2020119804 A1 WO 2020119804A1
Authority
WO
WIPO (PCT)
Prior art keywords
view
data
business
displayed
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2019/125322
Other languages
English (en)
French (fr)
Inventor
温增葵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Publication of WO2020119804A1 publication Critical patent/WO2020119804A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming

Definitions

  • the embodiments of the present disclosure relate to the technical field of application program development, and in particular, to a page view display method, device, device, and storage medium.
  • FIG. 1 shows the structure of the MVC development architecture.
  • the MVC development architecture consists of three parts: a model, a view, and a controller.
  • Model is the data model
  • View is responsible for the management of the view
  • Controller is used to handle the business logic.
  • the controller holds both the view and the data model. The controller updates the data model according to the user actions captured by the view; when the data model changes, the controller then directly operates the view to update.
  • the controller and view in the existing MVC development architecture are seriously coupled, and the reuse degree of the controller is much lower than the view reuse degree, thereby greatly reducing the reuse degree of service implementation.
  • the controller needs to handle more and more services, and the business code rapidly expands, which leads to a very chaotic code structure and unclear internal responsibilities, which is not conducive to the development of functional unit testing ;
  • the increase in business complexity will also lead to the need for more views to carry the business display, making the controller need to manage more views, which will greatly increase the complexity of the controller and reduce the display efficiency of the view.
  • an embodiment of the present disclosure provides a method for displaying a page view.
  • the method includes:
  • the business data and data model corresponding to the view to be displayed of the current page, and generate view rendering data corresponding to the view to be displayed according to the business data and the data model, and send the view rendering data;
  • the business The data includes intermediate data generated during the business process, and the data model includes attribute data of the business object;
  • the method further includes: after rendering and displaying the view,
  • Re-render and display the displayed view according to the regenerated view rendering data.
  • the method further includes: after rendering and displaying the view,
  • Re-render and display the displayed view according to the regenerated view rendering data.
  • performing the corresponding asynchronous operation according to the business command includes:
  • An asynchronous command is generated according to the parameters, and the asynchronous command is triggered to execute the asynchronous operation corresponding to the business command.
  • the method further includes: after re-rendering and displaying the displayed view according to the regenerated view rendering data,
  • Re-render and display the displayed view according to the currently regenerated view rendering data.
  • the asynchronous operation includes an operation of acquiring data from a server.
  • obtaining business data and data models corresponding to the view to be displayed on the current page and generating view rendering data corresponding to the view to be displayed according to the business data and the data model, including:
  • the Dependency is a collection of services that the business depends on.
  • the rendering data calculation service in Dependency is called to obtain the view rendering data corresponding to the view to be displayed.
  • performing view rendering and display according to the view rendering data includes:
  • an embodiment of the present disclosure also provides a page view display device, the device including:
  • the controller module is configured to create a view-driven engine module and a responsive view module for the current page, and establish a binding relationship between the view-driven engine module and the responsive view module;
  • the view driving engine module is configured to obtain the business data and data model corresponding to the view to be displayed of the current page, and generate view rendering data corresponding to the view to be displayed according to the business data and the data model, based on the binding Sending the view rendering data to the responsive view module in a fixed relationship; wherein, the business data includes intermediate data generated during business progress, and the data model includes attribute data of business objects; and
  • the responsive view module is configured to perform view rendering and display according to the view rendering data.
  • establishing a binding relationship between the view driving engine module and the responsive view module includes:
  • the response function of the responsive view module will be updated on the view drive engine module as an output response object of the view drive engine module to register when view rendering data is generated on the view drive engine module And send the generated view rendering data to the responsive view module by calling the response function.
  • the responsive view module also includes:
  • the business command generation unit is configured to detect the touch operation acting on the displayed view through the responsive view module after performing view rendering and display, generate a business command according to the detected touch operation, and send the business command Drive engine module to view;
  • the view driving engine module further includes:
  • the synchronous business command processing unit is configured to receive the business command and determine that the business command is a synchronous business command, regenerate the view rendering data according to the business command, the business data corresponding to the displayed view, and the data model, and based on the binding relationship, the The generated view rendering data is sent to the responsive view module;
  • the responsive view module is further configured to re-render and display the displayed view according to the regenerated view rendering data.
  • the responsive view module also includes:
  • the business command generation unit is configured to detect the touch operation acting on the displayed view through the responsive view module after performing view rendering and display, generate a business command according to the detected touch operation, and send the business command Drive engine module to view;
  • the view driving engine module further includes:
  • the asynchronous business command processing unit is configured to receive the business command and execute the corresponding asynchronous operation according to the business command when it is determined that the business command is an asynchronous business command; update the business data corresponding to the displayed view so that the updated business data contains State data for performing asynchronous operations; regenerate view rendering data based on the updated business data and the data model corresponding to the displayed view; send the regenerated view rendering data to the responsive view module based on the binding relationship;
  • the responsive view module is further configured to re-render and display the displayed view according to the regenerated view rendering data.
  • the asynchronous business command processing unit includes an asynchronous operation execution subunit configured to filter the parameters corresponding to the asynchronous operation corresponding to the business command from the current business data through the view-driven engine module;
  • the parameter generates an asynchronous command, and triggers the asynchronous command to perform the asynchronous operation corresponding to the business command.
  • the asynchronous business command processing unit is further configured to, after re-rendering and displaying the displayed view according to the regenerated view rendering data, obtain the execution result of the asynchronous operation according to the execution result and the displayed view.
  • Business data and data model regenerate view rendering data, and send the currently regenerated view rendering data to the responsive view module based on the binding relationship;
  • the responsive view module is further configured to re-render and display the displayed view according to the currently regenerated view rendering data.
  • the asynchronous operation includes an operation of acquiring data from the server.
  • the view driving engine module includes:
  • the data acquisition service invocation unit is configured to acquire the business data and data model corresponding to the view to be displayed on the current page by invoking the data acquisition service in Dependency;
  • Dependency is a service-dependent service collection;
  • the rendering data calculation service calling unit is configured to call the rendering data calculation service in Dependency based on the acquired business data and data model to obtain view rendering data corresponding to the view to be displayed.
  • the responsive view module is further configured as:
  • the corresponding relationship between the generated view rendering data and the view to be displayed is based on the hierarchical structure and the corresponding relationship, and the view rendering and displaying are performed according to the view rendering data.
  • controller module includes:
  • the binding relationship establishment unit is configured to update the response function of the responsive view module on the view-driven engine module and register it as the output response object of the view-driven engine module so that view rendering data is generated on the view-driven engine module At the time, the generated view rendering data is sent to the reactive view module by calling the response function.
  • an embodiment of the present disclosure also provides a terminal device, the terminal device includes:
  • One or more processors are One or more processors;
  • Memory used to store one or more programs
  • the one or more processors When the one or more programs are executed by the one or more processors, the one or more processors implement the page view display method provided by any embodiment of the present disclosure.
  • an embodiment of the present disclosure also provides a computer storage medium on which a computer program is stored, wherein, when the computer program is executed by a processor, display of a page view as provided by any embodiment of the present disclosure is realized method.
  • the view-driven engine module carries the view-independent business logic
  • the responsive view module to carry the view business related to the view
  • use the view drive engine module to drive the responsive view module without driving through the controller module, so that the controller and the view in the framework can be decoupled
  • the controller module in the embodiment of the present disclosure only needs to be responsible for creating a view-driven engine module and a responsive view module, and binding these two modules, which greatly simplifies the operation of the controller module and improves the view and business logic
  • the degree of reuse makes the definition of responsibilities of each module in the framework clearer, so that the rendering and display of views can be performed more quickly, and the display efficiency of page views is improved.
  • FIG. 1 shows a structural schematic diagram of an MVC development architecture in a technology known to the inventor
  • FIG. 2 shows a flowchart of a method for displaying a page view provided in Embodiment 1 of the present disclosure
  • FIG. 3 shows a schematic diagram of the data flow between the view driving engine module and the responsive view module according to Embodiment 1 of the present disclosure
  • FIG. 4 shows a flowchart of a method for displaying a page view provided by Embodiment 2 of the present disclosure
  • FIG. 5 shows a schematic diagram of the data flow when processing asynchronous service commands according to Embodiment 2 of the present disclosure
  • FIG. 6 shows a schematic diagram of a view response process involved in Embodiment 2 of the present disclosure
  • FIG. 7 shows a schematic structural diagram of a page view display device provided by Embodiment 3 of the present disclosure.
  • FIG. 8 shows a schematic diagram of a hardware structure of a terminal device according to Embodiment 4 of the present disclosure.
  • each embodiment also provides optional features and examples.
  • the various features described in the embodiments can be combined to form multiple optional solutions.
  • Each numbered embodiment should not be regarded as As a technical solution.
  • FIG. 2 shows a flowchart of a method for displaying a page view provided in Embodiment 1 of the present disclosure.
  • the embodiment of the present disclosure can be applied to the case where the page view is displayed in an application based on the iOS system.
  • the display device of the view is executed.
  • the device can be implemented by software and/or hardware, and integrated in a terminal device with a display function, such as a smart phone or a tablet computer.
  • the method for displaying a page view may include the following steps:
  • the current page refers to the current page to be displayed.
  • the controller module may be pre-created to create a view-driven engine module and a reactive view module for the current page, and a module that establishes a binding relationship between the created view-driven engine module and the reactive view module.
  • the view-driven engine module can be used to carry business logic that is not related to views, such as maintaining data, processing data, and calculating view rendering data.
  • the responsive view module is used to carry view services related to views, such as view rendering and display according to view rendering data.
  • the binding relationship may refer to the correspondence between the created view-driven engine module and the responsive view module, so that the view-driven engine module can directly drive the corresponding responsive view module to realize automatic response of the view.
  • a controller module when opening the current page, may be created first, and then the controller module creates a view-driven engine module and a responsive view module for the current page, and will create The view-driven engine module is bound to the created responsive view module, so that when generating view rendering data on the view-driven engine module, the responsive view module can automatically respond and generate the corresponding page view.
  • the view-independent business logic in the controller of the MVC development architecture is extracted into the view-driven engine module, and the view-related view business is extracted into the responsive view module, thereby weakening the role of the controller , Makes the controller operation easier, and also makes the definition of the responsibility of each module in the development framework clearer, which is conducive to business functional unit testing.
  • the business processing performed by the view-driven engine module can be executed in the main thread, so as to ensure the thread safety of the view-driven engine module and the reactive view module.
  • the business data includes the intermediate data generated during the business process.
  • the data model includes attribute data of business objects.
  • the corresponding attribute data may be commodity price, commodity inventory, color type, size, etc.
  • the current page may include one or more views to be displayed.
  • the view rendering data corresponding to the view to be displayed may refer to the view data required to render the view to be displayed, such as background color, foreground color, font color, text font, font size, and font style.
  • the view-driven engine module may be used to obtain the business data and data model corresponding to each view to be displayed in the current page.
  • the business data and data model corresponding to the view to be displayed can be obtained according to the default configuration information in the view driving engine module; the business data of the view to be displayed on the current page can also be obtained by sending a data request to the server And data model.
  • the view drive engine module you can generate corresponding view rendering data based on the obtained business data and data model, and according to the binding relationship between the view drive engine module and the reactive view module, you can pass the generated view rendering data through the controller
  • the module is transparently transmitted to the responsive view module, and the generated view rendering data can also be directly sent to the responsive view module, thereby decoupling the controller and the view in the development architecture, reducing the complexity of the controller.
  • the view to be displayed can be rendered and displayed according to the received view rendering data, which greatly improves the display efficiency of the page view.
  • the current page in this embodiment usually has multiple views to be displayed, that is, the responsive view module often receives the view rendering data corresponding to the multiple views to be displayed.
  • the data can be rendered according to each view based on the preset correspondence. Render and display the corresponding view to be displayed.
  • S130 may include: reading the hierarchy information and data binding protocol of the view to be displayed of the current page from a preset view description file; determining the hierarchy of the view to be displayed of the current page according to the hierarchy information, and according to the data
  • the binding protocol determines the correspondence between the view rendering data generated by the view driving engine module and the view to be displayed. Based on the hierarchical structure and the corresponding relationship, the view rendering data is displayed and displayed according to the view rendering data.
  • the preset view description file may be a structured language used in advance to describe the hierarchical structure information and data binding protocol of the view in the current page. Developers can create preset view description files based on business requirements and structured language specifications.
  • the structured language may be, but not limited to, JavaScript Object Markup JSON (JavaScript Object Notation) language or Extensible Markup Language XML (Extensible Markup Language).
  • the hierarchical structure information may refer to the hierarchical relationship information between the views to be displayed in the current page.
  • the data binding protocol can be used to reflect the binding relationship between each view to be displayed in the current page and each view rendering data generated by the view driving engine module.
  • the hierarchical structure information and data binding protocol of the current page can be obtained by parsing the preset view description file; according to the hierarchical structure information of the view to be displayed in the current page, it can be determined Whether the view to be displayed in the current page is a child view or a parent view. If it is a child view, the child view is added to the corresponding parent view, thereby forming a hierarchy corresponding to the current page.
  • the data binding protocol the corresponding relationship between each view to be displayed in the current page and the rendering data generated by the view driving engine module can be determined, so that based on the corresponding relationship and the hierarchical structure, the generated view can be rendered data Perform accurate view rendering and display.
  • the view-driven engine module is used to carry the view-independent Business logic, and use the reactive view module to carry the view business related to the view, and use the view drive engine module to directly drive the reactive view module, without driving through the controller module, you can control the controller and the view in the development architecture Decoupling; and the controller module in the embodiment of the present disclosure only needs to be responsible for creating a view-driven engine module and a reactive view module, and binding these two modules, which greatly simplifies the operation of the controller module and improves
  • the reuse of views and business logic makes the definition of the responsibility of each module in the development framework clearer, so that the rendering and display of views can be performed more quickly, and the display efficiency of page views is improved.
  • the “establishing the binding relationship between the view-driven engine module and the responsive view module” in S110 may include: updating the response function of the responsive view module on the view-driven engine module as The output response object of the view driving engine module is registered so that when view rendering data is generated on the view driving engine module, the generated view rendering data is sent to the responsive view module by calling a response function.
  • the response function refers to a function that enables the responsive view module to receive view rendering data.
  • the input and output response objects of the view-driven engine module may be created through the data structure Backend.
  • the response function of updating the responsive view module is registered on the view driving engine module, so that the view driving engine module can render the data through the generated view
  • call the registered response function so that the generated view rendering data can be sent to the corresponding responsive view module, so that the data flow between the view drive engine module and the responsive view module is unidirectional to ensure
  • the page view generated by the responsive view module corresponds one-to-one with the data rendering data.
  • “obtaining the business data and data model corresponding to the view to be displayed of the current page and generating the view rendering data corresponding to the view to be displayed according to the business data and data model” in S120 may include: by calling Rely on the data acquisition service in Dependency to obtain the business data and data model corresponding to the view to be displayed on the current page; based on the acquired business data and data model, call the rendering data calculation service in Dependency to obtain the view rendering data corresponding to the view to be displayed .
  • Dependency Dependency is a set of services that the business depends on, which may include but is not limited to data acquisition services and rendering data calculation services.
  • the view-driven engine module in this embodiment may not directly hold the business data and data model, but rely on Dependency by calling
  • the obtained view rendering data can be cached, so that the same business data and data model corresponding to the same need to be generated later
  • the responsive view module can also capture the user's touch operation on the page view, such as touch behavior or click behavior.
  • the responsive view module can convert the captured touch operation into a specific type of view input data. For example, the number 1 represents the operation of clicking the start button, and the number 2 represents the operation of clicking the end button.
  • FIG. 3 shows a schematic diagram of the data flow between the view driving engine module and the responsive view module. As shown in FIG.
  • the responsive view module can send the converted view input data to the view driving engine module, and the view driving engine module performs business processing according to the received view input data to generate corresponding view rendering data, and then generates The view rendering data is sent to the responsive view module, and the responsive view module re-renders and displays based on the received view rendering data.
  • the responsive view module detect the touch operation acting on the displayed view, generate a business command according to the detected touch operation, and send the business command to the view drive engine module; through the view drive engine module, receive the business command, And determine that the business command is a synchronous business command, regenerate the view rendering data according to the business command, the business data corresponding to the displayed view and the data model, and send the regenerated view rendering data to the responsive view module based on the binding relationship;
  • the responsive view module re-renders and displays the displayed view according to the regenerated view rendering data.
  • the touch operation may be but not limited to touch behavior or click behavior.
  • the business command may include a specific type of view input data obtained by converting the captured touch operation, so that the view driving engine module can perform corresponding business processing according to the business command.
  • Synchronous business command refers to a command that can perform business processing immediately and directly without other asynchronous operations.
  • the generated business command may be sent to the view-driven engine module through the responsive view module.
  • the data collection of the business at any time such as the current business data and the corresponding view rendering data, can be maintained in a data structure called State.
  • a preset judgment rule such as determining whether the command identifier corresponding to the business command is a synchronous command identifier; if so, you can determine that the received business command is a synchronous business command.
  • the business data corresponding to the displayed view may be directly updated according to the business command, so that the updated business data includes status data corresponding to the execution of the business command.
  • the new view rendering data is regenerated according to the updated business data and the data model corresponding to the displayed view, that is, a new state is generated.
  • the regenerated view rendering data can be sent to the responsive view module based on the binding relationship; through the responsive view module, the display view data can be displayed based on the regenerated view rendering data.
  • the view is re-rendered and displayed so that when the business data in the drive engine module changes, the responsive view module can automatically respond to the changed business data and generate a corresponding new view to automatically update the displayed view.
  • there is a one-to-one correspondence between views and business data and business data is unique at any time, thereby ensuring the consistency of business data and views, and further ensuring the thread safety of view operations.
  • FIG. 4 shows a flowchart of a method for displaying a page view provided in Embodiment 2 of the present disclosure. This embodiment is based on the various alternatives in the above embodiments.
  • the business command is an asynchronous business command
  • the page The way in which the display of the view is updated is elaborated. The explanation of terms that are the same as or corresponding to those in the above embodiments will not be repeated here.
  • the page view display method provided in an embodiment of the present disclosure may include the following steps:
  • the user after displaying the current page on the display interface, the user can perform touch operation on the displayed view on the current page.
  • the responsive view module can detect whether a touch operation is performed on the displayed view based on the touch operation detection function added in advance in the displayed view; if so, the detected touch operation can be converted into a specific View input data of different types can generate corresponding business commands according to the converted view input data, and send the generated business commands to the view driving engine module, so that the touch operation can be processed correspondingly through the view driving engine module.
  • the asynchronous business command may refer to a command that cannot directly perform the corresponding business processing immediately and needs to perform other asynchronous operations.
  • Asynchronous operations may include, but are not limited to: operations to obtain data from the server, and time-consuming local operations such as writing data and reading data.
  • the state data of performing an asynchronous operation may refer to the state data corresponding to the displayed view when it is in a state of performing an asynchronous operation corresponding to an asynchronous business command.
  • the responsive view module after receiving the business command sent by the responsive view module through the view driving engine module, it can determine whether the received business command is an asynchronous business command according to a preset judgment rule, for example, to judge the business command Whether the corresponding command identifier is an asynchronous command identifier; if so, it can be determined that the received service command is an asynchronous service command.
  • the asynchronous operation corresponding to the asynchronous business command can be executed through the view-driven engine module first, and the currently maintained business data can be updated so that the updated The business data contains status data for performing asynchronous operations.
  • the view rendering data corresponding to the asynchronous operation can be generated, and based on the binding relationship, the generated view rendering data can be sent to the responsive view module again.
  • performing the corresponding asynchronous operation according to the business command includes: filtering the parameters corresponding to the asynchronous operation corresponding to the business command from the current business data through the view-driven engine module; generating the asynchronous command according to the parameter and triggering the asynchronous Commands to perform asynchronous operations corresponding to business commands
  • the parameter Query required for asynchronous operation can be filtered from the currently maintained business data, and then an asynchronous function that can cause side effects can be generated according to the filtered parameter Query Command, the asynchronous command can trigger an asynchronous operation, so that the asynchronous operation corresponding to the business command can be executed.
  • the responsive view module may send an asynchronous business command of data request to the view drive engine module.
  • the data request may be filtered from the current business data maintained The required parameter Query, so that an asynchronous instruction that can trigger an asynchronous data request operation can be generated according to the filtered parameter Query, so as to perform the data request operation.
  • the displayed view can be rendered and displayed again according to the regenerated view rendering data to update the displayed view in the display interface so that the displayed view It can show the status of the asynchronous operation corresponding to the execution of the asynchronous business command, such as displaying the loading icon, so that the user can more intuitively understand the view update status and improve the user's viewing experience.
  • a result callback command capable of generating side effects may be returned, and through the result callback command, the Use the execution result of the asynchronous operation as the parameter of the asynchronous business command to update the business data again, so that the updated business data includes the execution result of the asynchronous operation.
  • the view rendering data corresponding to the asynchronous business command can be generated, and the currently regenerated view rendering data can be sent to the responsive view module again based on the binding relationship.
  • the displayed view can be re-rendered and displayed according to the re-generated view rendering data to update the displayed view in the display interface so that the displayed
  • the view can show the status after executing asynchronous business commands, such as displaying the data obtained from the server.
  • FIG. 5 shows a schematic diagram of the data flow when processing asynchronous service commands.
  • the view-driven engine module when determining that the business command is an asynchronous business command, the view-driven engine module is used to first filter out the parameter Query required for asynchronous operation from the current business data. Based on this parameter, Query can generate a parameter that can be generated.
  • Asynchronous commands with side effects can perform corresponding asynchronous operations by triggering asynchronous commands; at the same time, according to the business data containing the status data of the asynchronous operations, a view rendering data corresponding to the asynchronous operations is generated and sent to the responsive view module for rendering And display.
  • a result callback command that can produce side effects can be returned.
  • the execution result of the asynchronous operation can be used as the parameter of the asynchronous business command to update the business data again, perform a second reduce operation, and use mathematics.
  • This statement can define the processing logic of synchronous and asynchronous business commands at the same time.
  • FIG. 6 shows a schematic diagram of a view response process.
  • the corresponding intermediate view can be generated according to the corresponding view rendering data generated in the view driving engine module when performing the asynchronous operation; after the asynchronous operation ends , According to the final view rendering data generated in the view driving engine module in response to the asynchronous business command to generate the corresponding response back view.
  • the responsive view module can automatically respond to this change and generate a corresponding new view, that is to say, there is a one-to-one correspondence between the view and the business data, and the business data It is unique at any time, thereby ensuring the consistency of the view and business data, and further ensuring the thread safety of the view operation.
  • an asynchronous operation corresponding to the asynchronous business command can be executed through the view-driven engine module, and an execution is generated according to the business data containing the status data of the asynchronous operation The corresponding view rendering data during asynchronous operation.
  • the displayed view is updated according to the regenerated view rendering data, so that the displayed view can show the intermediate view that is currently performing asynchronous operations, so that the user can more intuitively understand the view update status.
  • the displayed view is updated again according to the execution result of the asynchronous operation, so that the displayed view can display the content required by the user, and the user experience is improved.
  • FIG. 7 shows a schematic structural diagram of a page view display device provided by Embodiment 3 of the present disclosure.
  • the embodiment of the present disclosure may be applicable to a case where the page view is displayed in an application based on the iOS system.
  • the page view display device in the embodiment of the present disclosure may include: a controller module 310, a view driving engine module 320 and a responsive view module 330.
  • the controller module 310 can be configured to create a view-driven engine module and a responsive view module for the current page, and establish a binding relationship between the view-driven engine module and the responsive view module;
  • the view-driven engine module 320 can be configured To obtain the business data and data model corresponding to the view to be displayed on the current page, and generate view rendering data corresponding to the view to be displayed according to the business data and data model, and send the view rendering data to the responsive view module based on the binding relationship;
  • the business data includes intermediate data generated during the business process, and the data model includes attribute data of the business object;
  • the responsive view module 330 may be configured to perform view rendering and display according to the view rendering data.
  • the responsive view module 330 may further include:
  • the business command generation unit may be configured to detect the touch operation acting on the displayed view through the responsive view module after the view is rendered and displayed, generate the business command according to the detected touch operation, and send the business command Drive engine module to view;
  • the view driving engine module 320 may further include:
  • the synchronous business command processing unit can be configured to receive the business command and determine that the business command is a synchronous business command, regenerate the view rendering data according to the business command, the business data corresponding to the displayed view, and the data model, and based on the binding relationship, the The generated view rendering data is sent to the responsive view module;
  • the responsive view module 330 may be further configured to re-render and display the displayed view according to the regenerated view rendering data.
  • the responsive view module 330 may further include:
  • the business command generation unit may be configured to detect the touch operation acting on the displayed view through the responsive view module after the view is rendered and displayed, generate the business command according to the detected touch operation, and send the business command Drive engine module to view;
  • the view driving engine module 320 may further include:
  • the asynchronous business command processing unit may be configured to receive the business command and perform the corresponding asynchronous operation according to the business command when it is determined that the business command is an asynchronous business command; update the business data corresponding to the displayed view so that the updated business data contains State data for performing asynchronous operations; regenerate view rendering data based on the updated business data and the data model corresponding to the displayed view; send the regenerated view rendering data to the responsive view module based on the binding relationship;
  • the responsive view module 330 may be further configured to re-render and display the displayed view according to the regenerated view rendering data.
  • the asynchronous business command processing unit including the asynchronous operation execution subunit may be configured to filter the parameters corresponding to the asynchronous operations corresponding to the business command from the current business data through the view-driven engine module;
  • the parameter generates an asynchronous command, and triggers the asynchronous command to perform the asynchronous operation corresponding to the business command.
  • the asynchronous business command processing unit may be further configured to re-render and display the displayed view according to the regenerated view rendering data, and obtain the execution result of the asynchronous operation according to the execution result and the displayed view after obtaining the execution result of the asynchronous operation
  • Corresponding business data and data model regenerate view rendering data, and send the currently regenerated view rendering data to the responsive view module based on the binding relationship;
  • the responsive view module 330 may be further configured to re-render and display the displayed view according to the currently regenerated view rendering data.
  • the asynchronous operation includes an operation of acquiring data from the server.
  • the view driving engine module 320 may include:
  • the data acquisition service invocation unit is configured to acquire the business data and data model corresponding to the view to be displayed on the current page by invoking the data acquisition service in Dependency;
  • Dependency is a service-dependent service collection;
  • the rendering data calculation service calling unit is used to call the rendering data calculation service in Dependency based on the acquired business data and data model to obtain view rendering data corresponding to the view to be displayed.
  • the responsive view module 330 may:
  • the corresponding relationship between the generated view rendering data and the view to be displayed is based on the hierarchical structure and the corresponding relationship, and the view rendering and displaying are performed according to the view rendering data.
  • controller module 310 may include:
  • the binding relationship establishment unit may be configured to update the response function of the responsive view module on the view-driven engine module as an output response object of the view-driven engine module to register so that view rendering data is generated on the view-driven engine module At the time, the generated view rendering data is sent to the reactive view module by calling the response function.
  • the page view display device provided by an embodiment of the present disclosure can execute the page view display method provided by any embodiment of the present disclosure, and has corresponding function modules and beneficial effects for performing the page view display method.
  • FIG. 8 shows a schematic diagram of a hardware structure of a terminal device according to Embodiment 4 of the present disclosure.
  • the terminal devices in the embodiments of the present disclosure may include, but are not limited to, such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g. Mobile terminals such as car navigation terminals) and fixed terminals such as digital TVs, desktop computers, etc.
  • the terminal device shown in FIG. 8 is only an example, and should not bring any limitation to the functions and use scope of the embodiments of the present disclosure.
  • the terminal device 400 may include a processing device (such as a central processing unit, a graphics processor, etc.) 401, which may be stored in a read-only memory (Read-Only Memory, ROM) 402 program or from a storage device 408 loads the program in the random access memory (Random Access Memory, RAM) 403 to perform various appropriate actions and processes.
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • various programs and data necessary for the operation of the terminal device 400 are also stored.
  • the processing device 401, ROM 402, and RAM 403 are connected to each other via a bus 404.
  • An input/output (I/O) interface 405 is also connected to the bus 404.
  • the following devices can be connected to the I/O interface 405: including input devices 406 such as touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; including, for example, liquid crystal display (LCD), speaker, vibration
  • input devices 406 such as touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.
  • An output device 407 such as a storage device; a storage device 408 including, for example, a magnetic tape or a hard disk; and a communication device 409.
  • the communication device 409 may allow the terminal device 400 to perform wireless or wired communication with other devices to exchange data.
  • FIG. 8 shows a terminal device 400 having various devices, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or provided instead.
  • the process described above with reference to the flowchart may be implemented as a computer software program.
  • embodiments of the present disclosure include a computer program product that includes a computer program carried on a computer-readable medium, the computer program containing program code for performing the method shown in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device 409, or from the storage device 408, or from the ROM 402.
  • the processing device 401 When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiments of the present disclosure are executed.
  • the server proposed by the embodiment of the present disclosure and the page view display method proposed by the above embodiment belong to the same concept.
  • this embodiment is provided with the display of the page view.
  • the method has the same beneficial effect.
  • Embodiment 5 of the present disclosure provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a processor, the page view display method provided by any of the foregoing embodiments is implemented.
  • the above-mentioned computer storage medium of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the 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.
  • Computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (Random Access Memory, RAM), read-only memory (Read-Only Memory, ROM), Erasable Programmable Read-Only Memory (EPROM) or Flash (FLASH), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices , Or any suitable combination of the above.
  • the computer-readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • the computer-readable signal medium may include a data signal that is propagated in baseband or as part of a carrier wave, in which computer-readable program code is carried.
  • This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable signal medium may send, propagate, or transmit a program for use by or in combination 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: electric wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
  • the above-mentioned computer storage may be included in the above-mentioned terminal device; or it may exist alone without being assembled into the terminal device.
  • the above computer storage carries one or more programs.
  • the terminal device When the one or more programs are executed by the terminal device, the terminal device: through the controller module, creates a view driving engine module and a responsive view module for the current page, and Establish the binding relationship between the view-driven engine module and the responsive view module; through the view-driven engine module, obtain the business data and data model corresponding to the view to be displayed on the current page, and generate the corresponding view to be displayed according to the business data and data model View rendering data, the view rendering data is sent to the responsive view module based on the binding relationship; where the business data includes intermediate data generated during the business process, and the data model includes attribute data of the business object; through the responsive view module, View rendering and display based on view rendering data.
  • the computer program code for performing the operations of the present disclosure can be written in one or more programming languages or a combination thereof.
  • the above programming languages include object-oriented programming languages such as Java, Smalltalk, C++, as well as conventional Procedural programming language-such as "C" language or similar programming language.
  • the program code may be executed entirely on the user's computer, partly on the user's computer, as an independent software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server.
  • the remote computer may be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, through an Internet service provider Internet connection).
  • LAN local area network
  • WAN wide area network
  • Internet service provider Internet connection for example, AT&T, MCI, Sprint, EarthLink, MSN, GTE, etc.
  • each block in the flowchart or block diagram may represent a module, program segment, or part of code that contains one or more logic functions Executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks represented in succession may actually be executed in parallel, and they may sometimes be executed in reverse order, depending on the functions involved.
  • each block in the block diagrams and/or flowcharts, and combinations of blocks in the block diagrams and/or flowcharts can be implemented with dedicated hardware-based systems that perform specified functions or operations Or, it can be realized by a combination of dedicated hardware and computer instructions.
  • the units described in the embodiments of the present disclosure may be implemented in software or hardware. Among them, the name of the unit does not constitute a limitation on the unit itself under certain circumstances.
  • the first controller module can also be described as "create a view-driven engine module and a reactive view module for the current page, and establish The module of the binding relationship between the view driving engine module and the responsive view module".

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

一种页面视图的显示方法、装置、设备及存储介质,该方法包括:获取当前页面的待显示视图对应的业务数据和数据模型,并根据业务数据和数据模型生成待显示视图对应的视图渲染数据,发送视图渲染数据;根据视图渲染数据进行视图渲染和显示。通过该方法,可以对开发架构中控制器和视图进行解耦,简化控制器,并且使得开发框架中每个模块的职责定义更加清晰,提高页面视图的显示效率。

Description

页面视图的显示方法、装置、设备及存储介质
相关申请的交叉引用
本申请要求2018年12月14日在中国知识产权局提交的中国专利申请No.201811533984.4的优先权,通过引用将该中国专利申请公开的全部内容并入本文。
技术领域
本公开的实施例涉及应用程序开发技术领域,尤其涉及一种页面视图的显示方法、装置、设备及存储介质。
背景技术
在开发基于iOS操作系统的移动应用程序时,开发者通常采用MVC(Model,View,Controller)开发架构。图1给出了MVC开发架构的结构示意图。如图1所示,MVC开发架构由模型(Model)、视图(View)和控制器(Controller)三部分组成。其中,Model作为数据模型,View负责视图的管理,Controller用于处理业务逻辑。在MVC开发架构中,控制器同时持有视图和数据模型。控制器根据视图捕捉的用户动作更新数据模型;当数据模型发生变化后,控制器再直接操作视图进行更新。
可见,现有的MVC开发架构中的控制器与视图耦合严重,控制器的复用度远低于视图复用度,从而大大降低了业务实现的复用度。而且,随着业务复杂度越来越高,控制器需要处理的业务也越来增多,业务代码快速膨胀,进而导致代码结构非常混乱,内部职责划分不清晰,从而不利于功能单元测试工作的开展;并且业务复杂度的升高也会导致需要更多的视图来承载业务的展示,使得控制器需要管理更多的视图,从而也会大大增加控制器的复杂度,降低了视图的显示效率。
发明内容
第一方面,本公开的实施例提供了一种页面视图的显示方法,所述方法包括:
获取当前页面的待显示视图对应的业务数据和数据模型,并根据所述业务数据和所述数据模型生成所述待显示视图对应的视图渲染数据,发送所述视图渲染数据;其中,所述业务数据包括在业务进行过程中产生的中间数据,所述数据模型包括业务对象的属性数据;以及
根据所述视图渲染数据进行视图渲染和显示。
可选地,所述方法还包括:在进行视图渲染和显示之后,
检测作用于所显示视图上的触控操作,根据检测到的所述触控操作生成业务命令,并发送所述业务命令;
接收所述业务命令,并确定所述业务命令为同步业务命令时,根据所述业务命令、所显示视图对应的业务数据和数据模型重新生成视图渲染数据,并发送重新生成的视图渲染数据;以及
根据所述重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,所述方法还包括:在进行视图渲染和显示之后,
检测作用于所显示视图上的触控操作,根据检测到的所述触控操作生成业务命令,并发送所述业务命令;
接收所述业务命令并在确定所述业务命令是异步业务命令时,根据所述业务命令执行对应的异步操作;更新所显示视图对应的业务数据,以使更新后的业务数据中包含执行异步操作的状态数据;根据更新后的业务数据和所显示视图对应的数据模型,重新生成视图渲染数据;发送重新生成的视图渲染数据;以及
根据所述重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,根据所述业务命令执行对应的异步操作,包括:
从当前业务数据中过滤出与所述业务命令对应的异步操作所对应的参数;以及
根据所述参数生成异步命令,并通过触发所述异步命令,以执行所述业务命令对应的异步操作。
可选地,所述方法还包括:在根据所述重新生成的视图渲染数据对所显示视图进行重新渲染和显示之后,
在获取到所述异步操作的执行结果后根据所述执行结果、所显示视图对应的业务数据和数据模型,重新生成视图渲染数据,并发送当前重新生成的视图渲染数据;以及
根据当前重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,所述异步操作包括:从服务器获取数据的操作。
可选地,获取当前页面的待显示视图对应的业务数据和数据模型,并根据所述业务数据和所述数据模型生成所述待显示视图对应的视图渲染数据,包括:
通过调用依赖Dependency中的数据获取服务,获取当前页面的待显示视图对应的业务数据和数据模型;所述Dependency是业务依赖的服务集合;以及
基于获取的所述业务数据和数据模型,调用Dependency中的渲染数据计算服务,得到所述待显示视图对应的视图渲染数据。
可选地,根据所述视图渲染数据进行视图渲染和显示,包括:
从预设视图描述文件中读取当前页面的待显示视图的层次结构信息和数据绑定协议;以及
根据所述层次结构信息确定当前页面的待显示视图的层次结构,确定生成的视图渲染数据与待显示视图的对应关系,基于所述层次结构和所述对应关系,根据所述视图渲染数据进行视图渲染和显示。
第二方面,本公开的实施例还提供了一种页面视图的显示装置,所述装置包括:
控制器模块,被配置为为当前页面创建视图驱动引擎模块和响应式视图模块,并建立所述视图驱动引擎模块与所述响应式视图模块之间的绑定关系;
视图驱动引擎模块,被配置为获取当前页面的待显示视图对应的业务数据和数据模型,并根据所述业务数据和所述数据模型生成所述待显示视图对应的视图渲染数据,基于所述绑定关系将所述视图渲染数据发送给所述响应式视图模块;其中,所述业务数据包括在业务进行过程中产生的中间数据,所述数据模型包括业务对象的属性数据;以及
响应式视图模块,被配置为根据所述视图渲染数据进行视图渲染和显示。
可选地,建立所述视图驱动引擎模块与所述响应式视图模块之间的绑定关系,包括:
在所述视图驱动引擎模块上将更新所述响应式视图模块的响应函数,作为所述视图驱动引擎模块的输出响应对象进行注册,以使在所述视图驱动引擎模块上有视图渲染数据生成时,通过调用所述响应函数将生成的视图渲染数据发送给所述响应式视图模块。
可选地,响应式视图模块还包括:
业务命令生成单元,被配置为在进行视图渲染和显示之后,通过响应式视图模块,检测作用于所显示视图上的触控操作,根据检测到的触控操作生成业务命令,并将业务命令发送给视图驱动引擎模块;
可选地,视图驱动引擎模块还包括:
同步业务命令处理单元,被配置为接收业务命令,并确定业务命令为同步业务命令时, 根据业务命令、所显示视图对应的业务数据和数据模型重新生成视图渲染数据,并基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块;
可选地,响应式视图模块还被配置为:根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,响应式视图模块还包括:
业务命令生成单元,被配置为在进行视图渲染和显示之后,通过响应式视图模块,检测作用于所显示视图上的触控操作,根据检测到的触控操作生成业务命令,并将业务命令发送给视图驱动引擎模块;
可选地,视图驱动引擎模块还包括:
异步业务命令处理单元,被配置为接收业务命令并在确定业务命令是异步业务命令时,根据业务命令执行对应的异步操作;更新所显示视图对应的业务数据,以使更新后的业务数据中包含执行异步操作的状态数据;根据更新后的业务数据和所显示视图对应的数据模型,重新生成视图渲染数据;基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块;
可选地,响应式视图模块还被配置为:根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,异步业务命令处理单元包括异步操作执行子单元,被配置为通过所述视图驱动引擎模块,从当前业务数据中过滤出与所述业务命令对应的异步操作所对应的参数;根据所述参数生成异步命令,并通过触发所述异步命令,以执行所述业务命令对应的异步操作。
可选地,异步业务命令处理单元,还被配置为在根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示之后,在获取到异步操作的执行结果后根据执行结果、所显示视图对应的业务数据和数据模型,重新生成视图渲染数据,并基于绑定关系将当前重新生成的视图渲染数据发送给响应式视图模块;
可选地,响应式视图模块还被配置为:根据当前重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,异步操作包括:从服务器获取数据的操作。
可选地,视图驱动引擎模块包括:
数据获取服务调用单元,被配置为通过调用依赖Dependency中的数据获取服务,获取当前页面的待显示视图对应的业务数据和数据模型;Dependency是业务依赖的服务集合;以及
渲染数据计算服务调用单元,被配置为基于获取的业务数据和数据模型,调用Dependency中的渲染数据计算服务,得到待显示视图对应的视图渲染数据。
可选地,响应式视图模块被进一步配置为:
从预设视图描述文件中读取当前页面的待显示视图的层次结构信息和数据绑定协议;根据层次结构信息确定当前页面的待显示视图的层次结构,根据数据绑定协议确定视图驱动引擎模块生成的视图渲染数据与待显示视图的对应关系,基于层次结构和对应关系,根据视图渲染数据进行视图渲染和显示。
可选地,控制器模块包括:
绑定关系建立单元,被配置为在视图驱动引擎模块上将更新响应式视图模块的响应函数,作为视图驱动引擎模块的输出响应对象进行注册,以使在视图驱动引擎模块上有视图渲染数据生成时,通过调用响应函数将生成的视图渲染数据发送给响应式视图模块。
第三方面,本公开的实施例还提供了一种终端设备,所述终端设备包括:
一个或多个处理器;
存储器,用于存储一个或多个程序;
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如本公开的任意实施例所提供的页面视图的显示方法。
第四方面,本公开的实施例还提供了一种计算机存储介质,其上存储有计算机程序,其中,该计算机程序被处理器执行时实现如本公开的任意实施例所提供的页面视图的显示方法。
根据本公开的实施例,通过将MVC开发架构的控制器中的业务拆分为与视图无关的业务逻辑以及与视图相关的视图业务,然后通过视图驱动引擎模块来承载与视图无关的业务逻辑,以及通过响应式视图模块来承载与视图相关的视图业务,并且利用视图驱动引擎模块驱动响应式视图模块,无需通过控制器模块进行驱动,从而可以对框架中的控制器和视图进行解耦;而且本公开实施例中的控制器模块只需负责创建视图驱动引擎模块和响应式视图模块,并对这两个模块进行绑定即可,大大简化了控制器模块的操作,提高了视图和业务逻辑的复用度,使得框架中每个模块的职责定义更加清晰,从而可以更加快速地进行视图的渲染和显示,提高了页面视图的显示效率。
附图说明
为了更清楚地说明本公开的实施例或发明人所知晓的一种技术中的技术方案,下面将对实施例或发明人所知晓的该技术描述中所需要使用的附图做一简单地介绍,显而易见地,下面描述中的附图是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出了发明人所知晓的一种技术中MVC开发架构的结构示意图;
图2示出了本公开的实施例一提供的一种页面视图的显示方法的流程图;
图3示出了本公开的实施例一所涉及的视图驱动引擎模块与响应式视图模块之间的数据流的示意图;
图4示出了本公开的实施例二提供的一种页面视图的显示方法的流程图;
图5示出了本公开的实施例二所涉及的处理异步业务命令时的数据流的示意图;
图6示出了本公开的实施例二所涉及的一种视图响应过程的示意图;
图7示出了本公开的实施例三提供的一种页面视图的显示装置结构示意图;
图8示出了本公开的实施例四提供的一种终端设备的硬件结构示意图。
具体实施方式
为使本公开的目的、技术方案和优点更加清楚,以下将参照本公开的实施例中的附图,通过实施方式清楚、完整地描述本公开的技术方案,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。
下述各实施例中,每个实施例中同时提供了可选特征和示例,实施例中记载的各个特征可进行组合,形成多个可选方案,不应将每个编号的实施例仅视为一个技术方案。
实施例一
图2示出了本公开的实施例一提供的一种页面视图的显示方法的流程图,本公开实施例可适用于在基于iOS系统的应用程序中显示页面视图的情况,该方法可以由页面视图的显示装置来执行,该装置可以由软件和/或硬件的方式来实现,集成于具有显示功能的终端设备中,如智能手机、平板电脑等。
如图1所示,本公开的实施例中提供的页面视图的显示方法可以包括以下步骤:
S110、通过控制器模块,为当前页面创建视图驱动引擎模块和响应式视图模块,并建立视图驱动引擎模块与响应式视图模块之间的绑定关系。
其中,当前页面是指当前待显示的页面。控制器模块可以是预先创建的,用于为当前页面创建视图驱动引擎模块和响应式视图模块,以及对创建的视图驱动引擎模块和响应式视图 模块建立绑定关系的模块。视图驱动引擎模块可以用于承载与视图无关的业务逻辑,比如维护数据、处理数据和计算视图渲染数据。响应式视图模块用于承载与视图相关的视图业务,比如根据视图渲染数据进行视图渲染和显示。绑定关系可以是指创建的视图驱动引擎模块与响应式视图模块之间的对应关系,以使视图驱动引擎模块可以直接驱动对应的响应式视图模块,实现视图的自动响应。
在本公开的一个或多个实施例中,在打开当前页面时,可以先创建一个控制器模块,然后由控制器模块为当前页面创建一个视图驱动引擎模块和一个响应式视图模块,并将创建的视图驱动引擎模块绑定到创建的响应式视图模块,以便在视图驱动引擎模块上生成视图渲染数据时,响应式视图模块可以自动进行响应并生成对应的页面视图。本实施例通过将MVC开发架构的控制器中与视图无关的业务逻辑抽离到视图驱动引擎模块中,将与视图相关的视图业务抽离到响应式视图模块中,从而弱化了控制器的角色,使得控制器操作更加简单,同时也使开发框架中的每个模块的职责定义更加清晰,有利于业务的功能单元测试。
需要注意的是,通过视图驱动引擎模块进行的业务处理可以在主线程中执行,以便保证视图驱动引擎模块和响应式视图模块的线程安全性。
S120、通过视图驱动引擎模块,获取当前页面的待显示视图对应的业务数据和数据模型,并根据业务数据和数据模型生成待显示视图对应的视图渲染数据,基于绑定关系将视图渲染数据发送给响应式视图模块。
其中,业务数据包括在业务进行过程中产生的中间数据。比如用户在商品页面中选择了商品颜色、商品尺码等参数而产生的相应数据。数据模型包括业务对象的属性数据。示例性地,在业务对象为某个商品时,对应的属性数据可以为商品价格、商品库存量、颜色种类、尺码大小等。当前页面可以包括一个或多个待显示视图。待显示视图对应的视图渲染数据可以是指渲染该待显示视图所需要的视图数据,比如背景颜色、前景颜色、字体颜色、文本字体、字号和字形等。
在本公开的一个或多个实施例中,可以通过视图驱动引擎模块,获取当前页面中每个待显示视图对应的业务数据和数据模型。示例性地,可以通过根据视图驱动引擎模块中的默认配置信息,获得待显示视图对应的业务数据和数据模型;还可以通过向服务器发送数据请求的方式,获得当前页面的待显示视图的业务数据和数据模型。通过视图驱动引擎模块,可以根据获得的业务数据和数据模型生成对应的视图渲染数据,并根据视图驱动引擎模块与响应式视图模块之间的绑定关系,可以将生成的视图渲染数据通过控制器模块透传到响应式视图模块,也可以直接将生成的视图渲染数据发送至响应式视图模块,从而对开发架构中的控制器和视图进行解耦,降低了控制器的复杂度。
S130、通过响应式视图模块,根据视图渲染数据进行视图渲染和显示。
在本公开的一个或多个实施例中,可以通过响应式视图模块,可以根据接收的视图渲染数据对待显示视图进行视图渲染和显示,大大提高了页面视图的显示效率。本实施例中的当前页面通常存在多个待显示视图,即响应式视图模块往往会接收到多个待显示视图对应的视图渲染数据,此时可以基于预设对应关系,根据每个视图渲染数据对对应的待显示视图进行渲染和显示。
示例性地,S130可以包括:从预设视图描述文件中读取当前页面的待显示视图的层次结构信息和数据绑定协议;根据层次结构信息确定当前页面的待显示视图的层次结构,根据数据绑定协议确定视图驱动引擎模块生成的视图渲染数据与待显示视图的对应关系,基于层次结构和对应关系,根据视图渲染数据进行视图渲染和显示。
其中,预设视图描述文件可以是预先采用结构化语言来描述当前页面中视图的层次结构信息和数据绑定协议。开发者可以根据业务需求以及结构化语言规范创建预设视图描述文件。示例性地,结构化语言可以是但不限于JavaScript对象标记JSON(JavaScript Object Notation)语言或可扩展标记语言XML(Extensible Markup Language)。层次结构信息可以是指当前页 面中各待显示视图之间的层级关系信息。数据绑定协议可以用于反映当前页面中的每个待显示视图与视图驱动引擎模块生成的每个视图渲染数据之间的绑定关系。
在本公开的一个或多个实施例中,可以通过对预设视图描述文件进行解析,获得当前页面的层次结构信息和数据绑定协议;根据当前页面中待显示视图的层级结构信息,可以确定当前页面中的待显示视图为子视图还是父视图,若为子视图,则将该子视图添加到对应的父视图上,从而可以形成当前页面对应的层次结构。根据数据绑定协议可以确定当前页面中的每个待显示视图与视图驱动引擎模块生成的每个视图渲染数据之间的对应关系,从而基于该对应关系以及层次结构,可以对生成的视图渲染数据进行准确地视图渲染和显示。
根据本公开的实施例的技术方案,通过将MVC开发架构的控制器中的业务拆分为与视图无关的业务逻辑以及与视图相关的视图业务,然后通过视图驱动引擎模块来承载与视图无关的业务逻辑,以及通过响应式视图模块来承载与视图相关的视图业务,并且利用视图驱动引擎模块来直接驱动响应式视图模块,无需通过控制器模块进行驱动,可以对开发架构中的控制器和视图进行解耦;而且本公开实施例中的控制器模块只需负责创建视图驱动引擎模块和响应式视图模块,并对这两个模块进行绑定即可,大大简化了控制器模块的操作,提高了视图和业务逻辑的复用度,使得开发框架中每个模块的职责定义更加清晰,从而可以更加快速地进行视图的渲染和显示,提高了页面视图的显示效率。
在上述技术方案的基础上,S110中的“建立视图驱动引擎模块与响应式视图模块之间的绑定关系”,可以包括:在视图驱动引擎模块上将更新响应式视图模块的响应函数,作为视图驱动引擎模块的输出响应对象进行注册,以使在视图驱动引擎模块上有视图渲染数据生成时,通过调用响应函数将生成的视图渲染数据发送给响应式视图模块。
其中,响应函数是指可以使响应式视图模块接收到视图渲染数据的函数。在本公开的一个或多个实施例中,可以通过数据结构体Backend创建视图驱动引擎模块的输入和输出响应对象。通过将更新响应式视图模块的响应函数作为视图驱动引擎模块的输出响应对象,从而在视图驱动引擎模块上注册更新响应式视图模块的响应函数,以便视图驱动引擎模块可以通过将生成的视图渲染数据作为函数输入参数,调用注册的响应函数,从而可以将生成的视图渲染数据发送给对应的响应式视图模块,使得视图驱动引擎模块与响应式视图模块之间的数据流是单向的,以保证响应式视图模块生成的页面视图与数据渲染数据一一对应。
在上述技术方案的基础上,S120中的“获取当前页面的待显示视图对应的业务数据和数据模型,并根据业务数据和数据模型生成待显示视图对应的视图渲染数据”,可以包括:通过调用依赖Dependency中的数据获取服务,获取当前页面的待显示视图对应的业务数据和数据模型;基于获取的业务数据和数据模型,调用Dependency中的渲染数据计算服务,得到待显示视图对应的视图渲染数据。
其中,依赖Dependency是业务依赖的服务集合,其可以包括但不限于数据获取服务和渲染数据计算服务。
在本公开的一个或多个实施例中,与MVC开发架构中数据模型的数据形式不同,本实施例中的视图驱动引擎模块可以不直接持有业务数据和数据模型,而是通过调用依赖Dependency中的数据获取服务和渲染数据计算服务方式,分别获得业务数据和数据模型以及计算视图渲染数据,从而视图驱动引擎模块可以将业务的依赖Dependency单独拆分出来,使得视图驱动引擎模块的职责更加清晰明确。
需要注意的是,在通过调用Dependency中的渲染数据计算服务,得到待显示视图对应的视图渲染数据后,可以将获得的视图渲染数据进行缓存,以便后续在需要生成相同业务数据和数据模型对应的视图渲染数据时,可以直接使用缓存的视图渲染数据,无需重复计算渲染数据,从而可以提高视图渲染效率,提高显示速度,进而优化了页面滑动性能,提升了用户的使用体验。
在上述技术方案的基础上,在S130之后,即在显示界面中显示页面视图后,响应式视 图模块还可以捕捉用户对页面视图的触控操作,比如触摸行为或者点击行为。响应式视图模块可以将捕捉到的触控操作转换为特定类型的视图输入数据,比如,利用数字1表示点击开启按钮的操作,利用数字2表示点击结束按钮的操作。图3示出了视图驱动引擎模块与响应式视图模块之间的数据流的示意图。如图3所示,响应式视图模块可以将转换后的视图输入数据发送至视图驱动引擎模块,视图驱动引擎模块根据接收的视图输入数据进行业务处理后生成对应的视图渲染数据,然后再将生成的视图渲染数据发送至响应式视图模块中,响应式视图模块根据接收的视图渲染数据进行重新渲染和显示。
示例性地,在S130之后,还可以包括:
通过响应式视图模块,检测作用于所显示视图上的触控操作,根据检测到的触控操作生成业务命令,并将业务命令发送给视图驱动引擎模块;通过视图驱动引擎模块,接收业务命令,并确定业务命令为同步业务命令时,根据业务命令、所显示视图对应的业务数据和数据模型重新生成视图渲染数据,并基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块;通过响应式视图模块,根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
其中,触控操作可以是但不限于触摸行为或者点击行为。业务命令可以包括将捕捉到的触控操作进行转换后得到的特定类型的视图输入数据,以使视图驱动引擎模块可以根据业务命令进行相应地业务处理。同步业务命令是指可以立即并直接进行相应地业务处理,无需进行其它异步操作的命令。
在本公开的一个或多个实施例中,可以通过响应式视图模块,将生成的业务命令发送给视图驱动引擎模块。在视图驱动引擎模块中,可以将业务任意时刻的数据集合,比如当前业务数据和对应的视图渲染数据维护在一个称为状态State的数据结构中。通过视图驱动引擎模块,可以根据预设判断规则,判断接收的业务命令是否为同步业务命令,比如判断业务命令对应的命令标识是否为同步命令标识;若是,则可以确定接收的业务命令为同步业务命令。当确定业务命令为同步业务命令时,可以直接根据业务命令更新所显示视图对应的业务数据,以使更新后的业务数据中包含执行业务命令对应的状态数据。根据更新后的业务数据和所显示视图对应的数据模型重新生成新的视图渲染数据,即生成了一个新的状态。在视图驱动引擎模块中执行的这个过程可以称为reduce操作,使用使数学符号可以表述成:S n+1=f(S n,C);使用伪代码可以表述成:func reduce(state:State,command:Command)->State。
在重新生成视图渲染数据后,通过视图驱动引擎模块,可以基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块;通过响应式视图模块,可以根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示,从而当驱动引擎模块中的业务数据发生变化时,响应式视图模块可以自动响应变化后的业务数据,并生成对应的新视图,以自动更新所显示视图。也就是说,视图与业务数据是一一对应关系,并且业务数据在任意时刻均具有唯一性,从而保证了业务数据与视图的一致性,进一步保证了视图操作的线程安全性。
实施例二
图4示出了本公开的实施例二提供的一种页面视图的显示方法的流程图,本实施例以上述实施例中各个可选方案为基础,在业务命令为异步业务命令时,对页面视图的显示进行更新的方式进行了详细阐述。其中与上述实施例相同或相应的术语的解释在此不再赘述。
如图4所示,本公开的实施例中提供的页面视图的显示方法可以包括以下步骤:
S210、通过控制器模块,为当前页面创建视图驱动引擎模块和响应式视图模块,并建立视图驱动引擎模块与响应式视图模块之间的绑定关系。
S220、通过视图驱动引擎模块,获取当前页面的待显示视图对应的业务数据和数据模型,并根据业务数据和数据模型生成待显示视图对应的视图渲染数据,基于绑定关系将视图渲染数据发送给响应式视图模块。
S230、通过响应式视图模块,根据视图渲染数据进行视图渲染和显示。
S240、通过响应式视图模块,检测作用于所显示视图上的触控操作,根据检测到的触控操作生成业务命令,并将业务命令发送给视图驱动引擎模块。
在本公开的一个或多个实施例中,在显示界面上展示当前页面后,用户可以对当前页面中的所显示视图进行触控操作。本实施例可以通过响应式视图模块,基于所显示视图中预先添加的触控操作检测函数,检测是否对所显示视图进行触控操作;若是,则可以将检测到的触控操作转换为一个特定类型的视图输入数据,根据转换后的视图输入数据可以生成对应的业务命令,并将生成的业务命令发送给视图驱动引擎模块,以便通过视图驱动引擎模对该触控操作进行相应处理。
S250、通过视图驱动引擎模块,接收业务命令并在确定业务命令是异步业务命令时,根据业务命令执行对应的异步操作;更新所显示视图对应的业务数据,以使更新后的业务数据中包含执行异步操作的状态数据;根据更新后的业务数据和所显示视图对应的数据模型,重新生成视图渲染数据;基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块。
其中,异步业务命令可以是指无法立即直接进行相应的业务处理,需要进行其它异步操作的命令。异步操作可以包括但不限于:从服务器获取数据的操作、以及耗时的本地的写数据、读数据等操作。执行异步操作的状态数据可以是指所显示视图在处于执行异步业务命令对应的异步操作的状态时对应的状态数据。
在本公开的一个或多个实施例中,通过视图驱动引擎模块接收响应式视图模块发送的业务命令后,可以根据预设判断规则,判断接收的业务命令是否为异步业务命令,比如判断业务命令对应的命令标识是否为异步命令标识;若是,则可以确定接收的业务命令为异步业务命令。当确定业务命令为异步业务命令时,由于异步业务命令的执行比较耗时,从而可以通过视图驱动引擎模块先执行异步业务命令对应的异步操作,并对当前维护的业务数据进行更新,使得更新后的业务数据中包含执行异步操作的状态数据。根据更新后的业务数据和对应的数据模型,可以生成执行异步操作时对应的视图渲染数据,并基于绑定关系可以将生成的视图渲染数据再次发送至响应式视图模块中。
示例性地,根据业务命令执行对应的异步操作,包括:通过视图驱动引擎模块,从当前业务数据中过滤出与业务命令对应的异步操作所对应的参数;根据参数生成异步命令,并通过触发异步命令,以执行业务命令对应的异步操作
在本公开的一个或多个实施例中,通过视图驱动引擎模块,可以从当前维护的业务数据中过滤出异步操作所需要的参数Query,然后根据过滤出来的参数Query生成一个能够产生副作用的异步命令,该异步命令可以触发异步操作,从而可以执行业务命令对应的异步操作。
示例性地,若需要从服务器获取数据,则响应式视图模块可以向视图驱动引擎模块发送一个数据请求的异步业务命令,在视图驱动引擎模块中,可以从维护的当前业务数据中过滤出数据请求所需要的参数Query,从而可以根据过滤出的参数Query生成一个可以触发异步的数据请求操作的异步指令,以便进行数据请求操作。
S260、通过响应式视图模块,根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
在本公开的一个或多个实施例中,通过响应式视图模块,可以根据重新生成的视图渲染数据再次对所显示视图进行渲染和显示,以更新显示界面中的所显示视图,使得所显示视图可以展示出当前正在处于执行异步业务命令对应的异步操作的状态,比如显示正在加载Loading的图标,以便用户可以更加直观地了解视图更新状态,提高用户的观看体验。
S270、通过视图驱动引擎模块,在获取到异步操作的执行结果后根据执行结果、所显示视图对应的业务数据和数据模型,重新生成视图渲染数据,并基于绑定关系将当前重新生成的视图渲染数据发送给响应式视图模块。
在本公开的一个或多个实施例中,在异步操作执行结束后,通过视图驱动引擎模块获得 异步操作的执行结果后,可以返回一个能够产生副作用的结果回调命令,通过该结果回调命令,可以将异步操作的执行结果作为异步业务命令的参数再次更新业务数据,以使更新后的业务数据中包含异步操作的执行结果。根据再次更新的业务数据和数据模型,可以生成处理异步业务命令后对应的视图渲染数据,并基于绑定关系将当前重新生成的视图渲染数据再次发送至响应式视图模块中。
S280、通过响应式视图模块,根据当前重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
在本公开的一个或多个实施例中,通过响应式视图模块,可以根据再次重新生成的视图渲染数据对所显示视图重新进行渲染和显示,以更新显示界面中的所显示视图,使得所显示视图可以展示出执行异步业务命令后的状态,比如显示从服务器获取的数据。
图5示出了处理异步业务命令时的数据流的示意图。如图5所示,本实施例在确定业务命令为异步业务命令时,通过视图驱动引擎模块,先从当前业务数据中过滤出异步操作所需要的参数Query,基于这个参数Query可以生成一个能够产生副作用的异步命令,通过触发异步命令可以执行对应的异步操作;同时根据包含执行异步操作的状态数据的业务数据生成一个执行异步操作时对应的视图渲染数据,并发送至响应式视图模块中进行渲染和显示。当异步操作执行结束后,可以返回一个能够产生副作用的结果回调命令,通过该结果回调命令,可以将异步操作的执行结果作为异步业务命令的参数再次更新业务数据,进行二次reduce操作,使用数学符号可以进一步完善reduce的定义为:S n+1,C'=f(S n,C');相应地,使用伪代码可以表述成:func reduce(state:State,command:Command)->(State,Command?)。这样表述可以同时定义同步和异步业务命令的处理逻辑,对于同步业务命令,只会更新一次业务数据;对于异步业务命令,通过返回一个能够产生副作用的结果回调命令,这个结果回调命令可以将异步操作的执行结果作为异步业务命令的参数再次更新业务数据,从而产生一个副作用。
根据本公开的实施例,通过响应式视图模块,可以对视图驱动引擎模块中生成的业务状态数据进行响应,呈现出对应的视图。图6示出了一种视图响应过程的示意图。如图6所示,在业务命令为异步业务命令时,通过响应式视图模块,可以根据视图驱动引擎模块中产生的执行异步操作时对应的视图渲染数据生成对应的中间视图;在异步操作结束后,根据视图驱动引擎模块中产生的响应于异步业务命令的最终视图渲染数据生成对应的响应后视图。可见,当视图驱动引擎模块中的业务数据发生变化时,在响应式视图模块中都可以自动响应这个变化并生成对应的新视图,也就是说视图与业务数据是一一对应关系,并且业务数据在任意时刻均具有唯一性,从而保证了视图与业务数据的一致性,进一步保证了视图操作的线程安全性。
根据本公开的实施例的技术方案,在业务命令为异步业务命令时,可以通过视图驱动引擎模块,执行异步业务命令对应的异步操作,并根据包含执行异步操作的状态数据的业务数据生成一个执行异步操作时对应的视图渲染数据。通过响应式视图模块,根据重新生成的视图渲染数据对所显示视图进行更新,使得所显示视图可以展示出当前正在处于执行异步操作的中间视图,以便用户可以更加直观地了解视图更新状态。并且在异步操作完成后,根据异步操作的执行结果对所显示视图进行再次更新,使得所显示视图可以展示出用户所需求的内容,提高了用户体验。
以下是本公开的实施例提供的页面视图的显示装置的实施例,该装置与上述各实施例的页面视图的显示方法属于同一个构思,在页面视图的显示装置的实施例中未详尽描述的细节内容,可以参考上述页面视图的显示方法的实施例。
实施例三
图7示出了本公开的实施例三提供的一种页面视图的显示装置结构示意图,本公开的实 施例可适用于在基于iOS系统的应用程序中显示页面视图的情况。如图7所示,本公开实施例中页面视图的显示装置可以包括:控制器模块310、视图驱动引擎模块320和响应式视图模块330。
其中,控制器模块310可以被配置为为当前页面创建视图驱动引擎模块和响应式视图模块,并建立视图驱动引擎模块与响应式视图模块之间的绑定关系;视图驱动引擎模块320可以被配置为获取当前页面的待显示视图对应的业务数据和数据模型,并根据业务数据和数据模型生成待显示视图对应的视图渲染数据,基于绑定关系将视图渲染数据发送给响应式视图模块;其中,业务数据包括在业务进行过程中产生的中间数据,数据模型包括业务对象的属性数据;响应式视图模块330可以被配置为根据视图渲染数据进行视图渲染和显示。
可选地,响应式视图模块330还可以包括:
业务命令生成单元可以被配置为在进行视图渲染和显示之后,通过响应式视图模块,检测作用于所显示视图上的触控操作,根据检测到的触控操作生成业务命令,并将业务命令发送给视图驱动引擎模块;
相应地,视图驱动引擎模块320还可以包括:
同步业务命令处理单元可以被配置为接收业务命令,并确定业务命令为同步业务命令时,根据业务命令、所显示视图对应的业务数据和数据模型重新生成视图渲染数据,并基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块;
相应地,响应式视图模块330还可以被配置为:根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,响应式视图模块330还可以包括:
业务命令生成单元可以被配置为在进行视图渲染和显示之后,通过响应式视图模块,检测作用于所显示视图上的触控操作,根据检测到的触控操作生成业务命令,并将业务命令发送给视图驱动引擎模块;
相应地,视图驱动引擎模块320还可以包括:
异步业务命令处理单元可以被配置为接收业务命令并在确定业务命令是异步业务命令时,根据业务命令执行对应的异步操作;更新所显示视图对应的业务数据,以使更新后的业务数据中包含执行异步操作的状态数据;根据更新后的业务数据和所显示视图对应的数据模型,重新生成视图渲染数据;基于绑定关系将重新生成的视图渲染数据发送给响应式视图模块;
相应地,响应式视图模块330还可以被配置为:根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,异步业务命令处理单元包括异步操作执行子单元可以被配置为通过所述视图驱动引擎模块,从当前业务数据中过滤出与所述业务命令对应的异步操作所对应的参数;根据所述参数生成异步命令,并通过触发所述异步命令,以执行所述业务命令对应的异步操作。
可选地,异步业务命令处理单元,还可以被配置为在根据重新生成的视图渲染数据对所显示视图进行重新渲染和显示之后,在获取到异步操作的执行结果后根据执行结果、所显示视图对应的业务数据和数据模型,重新生成视图渲染数据,并基于绑定关系将当前重新生成的视图渲染数据发送给响应式视图模块;
相应地,响应式视图模块330还可以被配置为:根据当前重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
可选地,异步操作包括:从服务器获取数据的操作。
可选地,视图驱动引擎模块320可以包括:
数据获取服务调用单元,被配置为通过调用依赖Dependency中的数据获取服务,获取当前页面的待显示视图对应的业务数据和数据模型;Dependency是业务依赖的服务集合;
渲染数据计算服务调用单元,用于基于获取的业务数据和数据模型,调用Dependency 中的渲染数据计算服务,得到待显示视图对应的视图渲染数据。
可选地,响应式视图模块330可以:
从预设视图描述文件中读取当前页面的待显示视图的层次结构信息和数据绑定协议;根据层次结构信息确定当前页面的待显示视图的层次结构,根据数据绑定协议确定视图驱动引擎模块生成的视图渲染数据与待显示视图的对应关系,基于层次结构和对应关系,根据视图渲染数据进行视图渲染和显示。
可选地,控制器模块310可以包括:
绑定关系建立单元可以被配置为在视图驱动引擎模块上将更新响应式视图模块的响应函数,作为视图驱动引擎模块的输出响应对象进行注册,以使在视图驱动引擎模块上有视图渲染数据生成时,通过调用响应函数将生成的视图渲染数据发送给响应式视图模块。
本公开的实施例所提供的页面视图的显示装置可执行本公开任意实施例所提供的页面视图的显示方法,具备执行页面视图的显示方法相应的功能模块和有益效果。
实施例四
图8示出了本公开的实施例四提供的一种终端设备的硬件结构示意图。本公开实施例中的终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、PDA(个人数字助理)、PAD(平板电脑)、PMP(便携式多媒体播放器)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图8示出的终端设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图8所示,终端设备400可以包括处理装置(例如中央处理器、图形处理器等)401,其可以根据存储在只读存储器(Read-Only Memory,ROM)402中的程序或者从存储装置408加载到随机访问存储器(Random Access Memory,RAM)403中的程序而执行各种适当的动作和处理。在RAM 403中,还存储有终端设备400操作所需的各种程序和数据。处理装置401、ROM 402以及RAM 403通过总线404彼此相连。输入/输出(I/O)接口405也连接至总线404。
通常,以下装置可以连接至I/O接口405:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置406;包括例如液晶显示器(LCD)、扬声器、振动器等的输出装置407;包括例如磁带、硬盘等的存储装置408;以及通信装置409。通信装置409可以允许终端设备400与其他设备进行无线或有线通信以交换数据。虽然图8示出了具有各种装置的终端设备400,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置409从网络上被下载和安装,或者从存储装置408被安装,或者从ROM 402被安装。在该计算机程序被处理装置401执行时,执行本公开实施例的方法中限定的上述功能。
本公开的实施例提出的服务器与上述实施例提出的页面视图的显示方法属于同一构思,未在本实施例中详尽描述的技术细节可参见上述实施例,并且本实施例具备执行页面视图的显示方法相同的有益效果。
实施例五
本公开的实施例五提供了一种计算机存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现上述任意实施例所提供的页面视图的显示方法。
需要说明的是,本公开上述的计算机存储介质可以是计算机可读信号介质或者计算机可 读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、可擦式可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM)或闪存(FLASH)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。
上述计算机存储可以是上述终端设备中所包含的;也可以是单独存在,而未装配入该终端设备中。
上述计算机存储承载有一个或者多个程序,当上述一个或者多个程序被该终端设备执行时,使得该终端设备:通过控制器模块,为当前页面创建视图驱动引擎模块和响应式视图模块,并建立视图驱动引擎模块与响应式视图模块之间的绑定关系;通过视图驱动引擎模块,获取当前页面的待显示视图对应的业务数据和数据模型,并根据业务数据和数据模型生成待显示视图对应的视图渲染数据,基于绑定关系将视图渲染数据发送给响应式视图模块;其中,业务数据包括在业务进行过程中产生的中间数据,数据模型包括业务对象的属性数据;通过响应式视图模块,根据视图渲染数据进行视图渲染和显示。
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在某种情况下并不构成对该单元本身的限定,例如,第一控制器模块,还可以被描述为“为当前页面创建视图驱动引擎模块和响应式视图模块,并建立所述视图驱动引擎模块与所述响应式视图模块之间的绑定关系的模块”。
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。

Claims (12)

  1. 一种页面视图的显示方法,所述方法包括:
    获取当前页面的待显示视图对应的业务数据和数据模型,并根据所述业务数据和所述数据模型生成所述待显示视图对应的视图渲染数据,发送所述视图渲染数据;其中,所述业务数据包括在业务进行过程中产生的中间数据,所述数据模型包括业务对象的属性数据;
    根据所述视图渲染数据进行视图渲染和显示。
  2. 根据权利要求1所述的方法,其中,所述方法还包括:在进行视图渲染和显示之后,
    检测作用于所显示视图上的触控操作,根据检测到的所述触控操作生成业务命令,并发送所述业务命令;
    接收所述业务命令,并确定所述业务命令为同步业务命令时,根据所述业务命令、所显示视图对应的业务数据和数据模型重新生成视图渲染数据,并发送重新生成的视图渲染数据;以及
    根据所述重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
  3. 根据权利要求1所述的方法,其中,所述方法还包括:在进行视图渲染和显示之后,
    检测作用于所显示视图上的触控操作,根据检测到的所述触控操作生成业务命令,并发送所述业务命令;
    接收所述业务命令并在确定所述业务命令是异步业务命令时,根据所述业务命令执行对应的异步操作;更新所显示视图对应的业务数据,以使更新后的业务数据中包含执行异步操作的状态数据;根据更新后的业务数据和所显示视图对应的数据模型,重新生成视图渲染数据;将重新生成的视图渲染数据发送给所述响应式视图模块;以及
    根据所述重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
  4. 根据权利要求3所述的方法,其中,根据所述业务命令执行对应的异步操作,包括:
    从当前业务数据中过滤出与所述业务命令对应的异步操作所对应的参数;以及
    根据所述参数生成异步命令,并通过触发所述异步命令,以执行所述业务命令对应的异步操作。
  5. 根据权利要求3所述的方法,其中,所述方法还包括:在根据所述重新生成的视图渲染数据对所显示视图进行重新渲染和显示之后,
    在获取到所述异步操作的执行结果后根据所述执行结果、所显示视图对应的业务数据和数据模型,重新生成视图渲染数据,并发送当前重新生成的视图渲染数据;以及
    根据当前重新生成的视图渲染数据对所显示视图进行重新渲染和显示。
  6. 根据权利要求3所述的方法,其中,所述异步操作包括:从服务器获取数据的操作。
  7. 根据权利要求1所述的方法,其中,获取当前页面的待显示视图对应的业务数据和数据模型,并根据所述业务数据和所述数据模型生成所述待显示视图对应的视图渲染数据,包括:
    通过调用依赖Dependency中的数据获取服务,获取当前页面的待显示视图对应的业务数据和数据模型;所述Dependency是业务依赖的服务集合;以及
    基于获取的所述业务数据和数据模型,调用Dependency中的渲染数据计算服务,得到所述待显示视图对应的视图渲染数据。
  8. 根据权利要求1所述的方法,其中,根据所述视图渲染数据进行视图渲染和显示,包括:
    从预设视图描述文件中读取当前页面的待显示视图的层次结构信息和数据绑定协议;以及
    根据所述层次结构信息确定当前页面的待显示视图的层次结构,确定生成的视图渲染数据与待显示视图的对应关系,基于所述层次结构和所述对应关系,根据所述视图渲染数据进行视图渲染和显示。
  9. 一种页面视图的显示装置,其中,所述装置包括:
    控制器模块,被配置为为当前页面创建视图驱动引擎模块和响应式视图模块,并建立所述视图驱动引擎模块与所述响应式视图模块之间的绑定关系;
    视图驱动引擎模块,被配置为获取当前页面的待显示视图对应的业务数据和数据模型,并根据所述业务数据和所述数据模型生成所述待显示视图对应的视图渲染数据,基于所述绑定关系将所述视图渲染数据发送给所述响应式视图模块;其中,所述业务数据包括在业务进行过程中产生的中间数据,所述数据模型包括业务对象的属性数据;以及
    响应式视图模块,被配置为根据所述视图渲染数据进行视图渲染和显示。
  10. 根据权利要求9所述的装置,其中,建立所述视图驱动引擎模块与所述响应式视图模块之间的绑定关系,包括:
    在所述视图驱动引擎模块上将更新所述响应式视图模块的响应函数,作为所述视图驱动引擎模块的输出响应对象进行注册,以使在所述视图驱动引擎模块上有视图渲染数据生成时,通过调用所述响应函数将生成的视图渲染数据发送给所述响应式视图模块。
  11. 一种终端设备,其中,所述终端设备包括:
    一个或多个处理器;
    存储器,用于存储一个或多个程序;
    当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-9中任一项所述的页面视图的显示方法。
  12. 一种计算机存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时实现如权利要求1-9中任一项所述的页面视图的显示方法。
PCT/CN2019/125322 2018-12-14 2019-12-13 页面视图的显示方法、装置、设备及存储介质 Ceased WO2020119804A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811533984.4 2018-12-14
CN201811533984.4A CN109634599B (zh) 2018-12-14 2018-12-14 页面视图的显示方法、装置、设备及存储介质

Publications (1)

Publication Number Publication Date
WO2020119804A1 true WO2020119804A1 (zh) 2020-06-18

Family

ID=66074193

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/125322 Ceased WO2020119804A1 (zh) 2018-12-14 2019-12-13 页面视图的显示方法、装置、设备及存储介质

Country Status (2)

Country Link
CN (1) CN109634599B (zh)
WO (1) WO2020119804A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634599B (zh) * 2018-12-14 2020-05-19 北京字节跳动网络技术有限公司 页面视图的显示方法、装置、设备及存储介质
CN110321464B (zh) * 2019-05-30 2022-03-18 南京苏宁加电子商务有限公司 一种基于单向数据流的页面视图的更新方法及装置
CN110321120B (zh) * 2019-07-15 2021-02-23 珠海格力电器股份有限公司 数据处理方法、数据处理装置及计算机可读存储介质
CN110659299B (zh) * 2019-08-30 2020-11-10 珠海格力电器股份有限公司 数据更新的方法及装置、前端开发客户端
CN112000911B (zh) * 2020-07-08 2024-01-02 北京达佳互联信息技术有限公司 页面管理方法、装置、电子设备以及存储介质
CN113760275A (zh) * 2020-09-16 2021-12-07 北京京东尚科信息技术有限公司 一种生成页面的方法和装置
CN113176952B (zh) * 2021-04-20 2026-04-10 海南视联大健康智慧医疗科技有限公司 数据处理方法、装置及可读存储介质
CN113254829B (zh) * 2021-05-24 2022-07-19 稿定(厦门)科技有限公司 网页响应式布局方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484169A (zh) * 2014-12-09 2015-04-01 成都视达科信息技术有限公司 一种Android软件用户界面生成方法、系统及应用系统
CN106250128A (zh) * 2016-07-26 2016-12-21 网易(杭州)网络有限公司 用户界面的显示处理方法及装置
CN106569900A (zh) * 2016-10-28 2017-04-19 腾讯科技(深圳)有限公司 应用程序处理方法和装置
CN106815007A (zh) * 2015-12-02 2017-06-09 阿里巴巴集团控股有限公司 应用程序的处理方法和装置
CN109634599A (zh) * 2018-12-14 2019-04-16 北京字节跳动网络技术有限公司 页面视图的显示方法、装置、设备及存储介质

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10147145B2 (en) * 2011-11-25 2018-12-04 Microsoft Technology Licensing, Llc Integrating an application into operating system components of a mobile computing platform
CN105955777A (zh) * 2016-05-03 2016-09-21 网易(杭州)网络有限公司 用户界面的刷新方法和装置
CN106487918B (zh) * 2016-11-07 2019-06-18 清华大学 一种基于edX平台的MOOC系统
CN106560787A (zh) * 2016-12-29 2017-04-12 武汉斗鱼网络科技有限公司 一种基于mvvm架构的视图页面显示方法和装置
CN108616416B (zh) * 2018-03-23 2020-11-13 广州杰赛科技股份有限公司 基于教学软件的学生端接入方法、教师端、系统及介质
CN108845856B (zh) * 2018-06-11 2021-12-14 腾讯科技(深圳)有限公司 基于对象的同步更新方法、装置、存储介质及设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484169A (zh) * 2014-12-09 2015-04-01 成都视达科信息技术有限公司 一种Android软件用户界面生成方法、系统及应用系统
CN106815007A (zh) * 2015-12-02 2017-06-09 阿里巴巴集团控股有限公司 应用程序的处理方法和装置
CN106250128A (zh) * 2016-07-26 2016-12-21 网易(杭州)网络有限公司 用户界面的显示处理方法及装置
CN106569900A (zh) * 2016-10-28 2017-04-19 腾讯科技(深圳)有限公司 应用程序处理方法和装置
CN109634599A (zh) * 2018-12-14 2019-04-16 北京字节跳动网络技术有限公司 页面视图的显示方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN109634599B (zh) 2020-05-19
CN109634599A (zh) 2019-04-16

Similar Documents

Publication Publication Date Title
WO2020119804A1 (zh) 页面视图的显示方法、装置、设备及存储介质
WO2020119485A1 (zh) 一种页面显示方法、装置、设备及存储介质
WO2020119800A1 (zh) 一种列表显示方法、装置、设备及存储介质
TW201814510A (zh) 介面移動方法、裝置、智慧型終端機、伺服器和操作系統
WO2023093414A1 (zh) 微应用的开发方法、装置、设备、存储介质及程序产品
WO2024160268A1 (zh) 页面渲染方法、装置、设备及存储介质
CN111443909A (zh) 用于生成页面的方法及装置
CN111752644A (zh) 接口模拟方法、装置、设备及存储介质
CN110908629A (zh) 电子设备操作方法、装置、电子设备和存储介质
CN116775174A (zh) 一种基于用户界面框架的处理方法、装置、设备及介质
KR20170016362A (ko) 컴파일 동안 표시 메타데이터를 브라우저 렌더링 가능 포맷으로 변환하는 기법
WO2022184077A1 (zh) 文档编辑的方法、装置、终端及非暂时性存储介质
JP2024509808A (ja) ドキュメント作成方法、装置、デバイス及び記憶媒体
CN116934887A (zh) 基于端云协同的图像处理方法、装置、设备及存储介质
CN118132056A (zh) 页面开发方法、装置、设备及存储介质
WO2025200497A1 (zh) 模型调用方法、装置、介质、设备及计算机程序产品
WO2024212839A1 (zh) 卡片布局方法、装置、介质及电子设备
CN115145560B (zh) 业务编排方法、装置、设备、计算机可读介质和程序产品
US20240329950A1 (en) Method, apparatus, device and storage medium for webpage rendering
CN113835571A (zh) 一种终端设备、信息展示方法和存储介质
CN113656041A (zh) 数据处理方法、装置、设备及存储介质
CN116401173A (zh) 测试用例生成方法、装置、介质及电子设备
CN115698988A (zh) 用于经由远程浏览器实例查看不兼容网页的系统和方法
CN118466948A (zh) 页面编排方法、装置、介质和设备
CN116069227A (zh) 一种界面交互方法、装置、设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19895782

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 27.09.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 19895782

Country of ref document: EP

Kind code of ref document: A1