Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The interface updating method provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. Specifically, the terminal 102 has various clients for providing applications for users, and the server 104 is a background server corresponding to the clients. Since the user interface of the client on the terminal 102 needs to be updated frequently, the development workload is large because the user interface is updated in a manner of developing and releasing a new version in the conventional technology. Based on the method, whether a starting instruction for the application program exists or not is detected through the terminal, and when the starting instruction for the application program is detected, the starting instruction is responded, and a page layout file for updating a user interface of the application program is obtained; when an opening instruction of the user interface is detected, analyzing a page layout file updated to the user interface by adopting a single instance class, and acquiring rendering data updated to the user interface; and rendering the user interface by adopting the rendering data, and generating and opening the updated user interface, thereby realizing the dynamic update of the user interface in the application program on the terminal.
In this embodiment, the terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and specifically, the terminal 102 may have an iOS (apple mobile device operating System), and the server 104 may be implemented by an independent server or a server cluster composed of a plurality of servers.
In an embodiment, as shown in fig. 2, an interface updating method is provided, which is described by taking the method as an example applied to the terminal in fig. 1, and includes the following steps:
step 202, in response to the start instruction of the application program, acquiring a page layout file for updating the user interface of the application program.
The starting instruction is an instruction or a command for instructing the terminal to start the application program. The User Interface (UI) is an integral design for man-machine interaction, operation logic and interface beauty of an application program, and is also a medium for interaction and information exchange between the application program and a user, and realizes conversion between an internal form of information and a human acceptable form. The user interface is a bridge between the user and the hardware for interactive communication, and aims to enable the user to conveniently and efficiently operate the hardware to achieve bidirectional interaction and complete the work expected to be completed by the hardware. The page layout file for updating the user interface of the application program refers to a data structure required for updating the user interface, and may include, for example, a control layout and corresponding attributes of a new interface after the user interface is updated. In this embodiment, when the terminal detects a start instruction for an application program, the terminal responds to the start instruction and obtains a page layout file for updating a user interface of the application program, so as to dynamically update the user interface through subsequent steps.
Step 204, when an opening instruction of the user interface is detected, adopting single-instance analysis to update the page layout file of the user interface, and acquiring rendering data for updating the user interface.
The opening instruction is an instruction or a command for instructing the terminal to open the user interface in the application program. Specifically, the opening instruction of the user interface may be sent when the application opens the user interface in a route (router) manner. A singleton class refers to a created unique object with management functions within an application. In particular, a class is a user-defined type of reference data, also called class type, each class containing a description of the data and a set of functions that manipulate the data or pass the message, and instances of the class are called objects. An object is an abstraction of an objective thing, and a class is an abstraction of an object. Briefly, an object is an instance of a class, a class is a template of an object, and a singleton class refers to the only object within an application that has administrative functionality. Rendering data is background data required to update the user interface. In this embodiment, when the terminal detects an opening instruction for the user interface, the page layout file updated for the user interface is analyzed by a single instance, where the analyzing process includes, but is not limited to, performing syntax analysis on the page layout file, so as to obtain a control layout and corresponding attributes in the page layout file, and establish a corresponding data structure based on the control layout and corresponding attributes, so as to form rendering data for updating the user interface.
And step 206, rendering the user interface by adopting the rendering data, and generating and opening the updated user interface.
Specifically, the position, the style and the like of each control in the user interface are calculated by adopting the rendering data, the user interface is rendered according to the calculation result, so that a rendered new user interface is generated, and the updated user interface is opened in response to an opening instruction of the user interface, so that the user interface in an application program on the terminal is dynamically updated.
According to the interface updating method, the page layout file for updating the user interface of the application program is obtained by responding to the starting instruction of the application program, when the opening instruction of the user interface is detected, the page layout file for updating the user interface is analyzed by adopting a single instance type, the rendering data for updating the user interface is obtained, the rendering data is used for rendering the user interface, and the updated user interface is generated and opened, so that the dynamic updating of the user interface in the application program on the terminal is realized when the application program is started, the application program of a new version does not need to be developed and released, the development workload is saved, and the rendering efficiency is greatly improved.
In an embodiment, after the user interface is updated by using the method, when the terminal detects the opening instruction of the user interface again, the updated user interface is directly opened. It can be understood that after the user interface is updated and before the next update, each time the terminal detects an opening instruction for the user interface, the updated user interface is directly opened, so that the user interface does not need to be rendered repeatedly, and the speed of loading the user interface is increased.
In one embodiment, the obtaining of the page layout file for updating the user interface of the application program specifically includes: acquiring an updated data model corresponding to the application program; and extracting the page layout file of the user interface needing to be updated in the application program from the updated data model. The updated data model refers to a data structure required by the application program to be updated, and includes a page layout file of each user interface in the updated application program, and the page layout file includes a corresponding control layout and corresponding attributes. In this embodiment, by obtaining the update data model corresponding to the application program and extracting the page layout file of the user interface that needs to be updated in the application program from the update data model, dynamic update of the user interface in the application program on the terminal is facilitated.
In one embodiment, as shown in FIG. 3, obtaining an updated data model corresponding to an application includes:
step 302, when receiving a start instruction for an application program, sending an update data model acquisition request to a server.
Wherein the update data model acquisition request is a request for acquiring an update data model for updating a user interface in the application from the server. Specifically, when the user interface in the application program needs to be updated, the server can customize the required class and corresponding attributes of the user interface on the basis of the native development of the application program. For example, on the basis of a user interface of native development, a control is customized to be a class of JavaScript statements of "ImageView", and the control has the properties of length, width, round corners, pictures and the like. And the class of the control element 'ImageView' is exposed to a JavaScript terminal through a protocol, so that the JavaScript terminal can directly call the class, and further adopts the JavaScript to write UI logic of the user interface, namely a self-defined page layout file, thereby generating an updated data model for updating the user interface in the application program. Therefore, when the terminal receives a starting instruction of the application program, an acquisition request of the updated data model is sent to the server so as to instruct the server to return the corresponding updated data model.
And step 304, receiving a page layout file which is returned by the server and is customized for the user interface in the native user interface system by adopting the JS language.
The user-defined page layout file comprises corresponding control layout and corresponding attributes. Specifically, the terminal receives a page layout file which is returned by the server and is customized to each user interface in the original user interface system of the application program by adopting the JS language, so that the dynamic update of the user interface in the application program is realized.
In an embodiment, as shown in fig. 4, acquiring rendering data for updating a user interface by adopting singleton-class parsing to update a page layout file of the user interface includes:
step 402, adopting single-case class based on JSCore to perform syntax analysis on the page layout file, and obtaining the corresponding control layout and corresponding attributes in the page layout file.
The singleton class refers to only one object with management function in the application program. In this embodiment, when the terminal detects an open instruction for the user interface, a page layout file updated for the user interface may be parsed by a single instance based on JSCore (JS core), where the parsing process includes, but is not limited to, parsing the page layout file, so as to obtain a control layout and corresponding attributes in the page layout file.
Step 404, generating rendering data for updating the user interface according to the corresponding control layout and the corresponding attributes in the page layout file.
The rendering data is background data required for updating the user interface. In this embodiment, a corresponding data structure is established according to the corresponding control layout and the corresponding attributes in the page layout file to generate rendering data for updating the user interface, and then the rendering data is used to render the user interface, so as to dynamically update the user interface in the application program.
In an embodiment, obtaining the updated data model corresponding to the application program may specifically include: and when a starting instruction of the application program is received, acquiring an updated data model corresponding to the application program from a local storage space. The updated data model may be sent to the terminal by the server in the last operation process of the application program. It can be understood that, in general, when an application is in a running state, the application is in a connected state with a corresponding server. If the developer configures the update data model for the application program through the server, the server may issue the update data model for the application program to the corresponding terminal based on the connection state with the application program. At this time, the application program is in a running state, so that the terminal does not immediately update the application program, but stores the update data model of the application program in the local storage space, and acquires the update data model corresponding to the application program from the local storage space when a start instruction of the application program is subsequently received, so as to update the application program. Therefore, the dependence on the network in the updating process is greatly reduced, and the updating speed and reliability are improved.
Furthermore, the local storage space can be a local cache space, so that the running memory of the terminal is not occupied. And the terminal can also delete the updated data model in the cache space after acquiring the updated data model corresponding to the application program from the local cache space and updating the application program, thereby avoiding unnecessary repeated updating of the terminal.
In an embodiment, as shown in fig. 5, the following further describes the interface updating method of the present application by taking an iOS terminal as an example through a specific interaction embodiment, including the following steps:
step 501, a server obtains classes created by a developer on the basis of native development of an application program.
Specifically, when the user interface in the application needs to be updated, the required class of the user interface can be customized on the basis of the native development of the application, and the class can be a class based on a javascript statement and has corresponding attributes. For example, if the created class is "ImageView," it may have attributes of length, width, rounded corners, pictures, and so on.
Step 502, the server exposes the created class to the JavaScript end through the JSExport protocol provided by JSCore.
For example, the server may expose the above class ImageView to the JavaScript end through a protocol, so that the JavaScript end can directly call the class, where example codes are as follows:
var imageView=ImageView.initWithFrame(0,0,100,100)
imageView.imageUrl=“https:xxxx.xxxx.xxx?picAddress=12345”
in step 503, the server obtains the UI logic of the user interface required for the developer to write using JavaScript.
Specifically, the UI logic of the user interface may be an example describing the user interface through the above-mentioned classes, i.e., a page layout file describing the user interface.
The UI logic example code of the user interface is as follows:
the above example code shows that a view is created in the user interface, and a label of "hello world" and a picture are displayed on the view.
In step 504, the server generates an update data model for updating the user interface according to the written UI logic of the user interface.
In step 505, the iOS terminal receives a start instruction of the application program from the user.
In step 506, the iOS terminal sends an update data model acquisition request to the server.
In step 507, the iOS terminal receives the updated data model returned by the server.
The updated data model may specifically be UI logic example code of the user interface.
And step 508, when the iOS terminal detects an opening instruction of the user interface, adopting a single-case type analysis updating data model based on JSCore to update the page layout file updated to the user interface, and acquiring rendering data updated to the user interface.
The JSCore-based single instance class is adopted to analyze the UI logic example code of the user interface, a page configuration method in JavaScript is called, and corresponding page rendering data of the originally developed user interface are obtained. After the method is called, a self-defined View object, namely backsgroudView in the above example code, can be obtained in a native environment.
In step 509, the iOS terminal renders the user interface with the rendering data to generate an updated user interface.
Specifically, the page rendering data is used to call the corresponding native UI class, and various UI data such as font size, font color, frame and the like are given to the corresponding control. According to the code, when an ImageView class is defined, an object of the class can be reflected to a native control UIImageView, so that the object can be reflected to a corresponding UIView object after a user-defined view object is obtained.
For example, native UIView view ═ UIView new;
view.width=backgroundView.width;
view.height=backgroundView.height;
return view;
background View is the page rendering data whose properties are directly assigned to the reflected controls as above.
Step 510, the iOS terminal opens the updated user interface in response to the opening instruction of the user interface.
When the user interface in the application program needs to be updated, the class and the corresponding attribute of the required user interface are defined by the server on the basis of the original development of the application program, then the user interface UI logic is compiled by calling the defined class by JavaScript, the starting instruction of the application program is received at the iOS terminal, the updated data model of the user interface of the application program, which is transmitted by the server connected with the application program, is obtained, when the opening instruction of the user interface is detected, the page layout file updated to the user interface is analyzed by adopting a single-case class based on JSCore, the rendering data updated to the user interface is obtained, the user interface is rendered by adopting the rendering data, the updated user interface is generated and opened, thereby realizing the dynamic update of the user interface in the application program on the iOS terminal when the application program is started, and the development and the release of a new version of application program are not needed, so that the development workload is saved, the dependence on the network in the updating process is reduced, and the reliability of the rendering efficiency is greatly improved.
It should be understood that although the various steps in the flow charts of fig. 1-5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-5 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 6, there is provided an interface updating apparatus including: an obtaining module 601, an analyzing module 602, and an updating module 603, wherein:
an obtaining module 601, configured to obtain a page layout file for updating a user interface of an application program in response to a start instruction of the application program;
the parsing module 602 is configured to, when an opening instruction for the user interface is detected, parse a page layout file that updates the user interface by using a singleton class to obtain rendering data for updating the user interface;
the updating module 603 is configured to render the user interface with the rendering data, and generate and open an updated user interface.
In one embodiment, the obtaining module 601 specifically includes: an update data model acquisition unit configured to acquire an update data model corresponding to the application program; and the page layout file acquisition unit is used for extracting a page layout file of the user interface needing to be updated in the application program from the updated data model, and the page layout file comprises the corresponding control layout and the corresponding attributes.
In an embodiment, the update data model obtaining unit is specifically configured to: when a starting instruction of an application program is received, sending an updating data model acquisition request to a server, wherein the updating data model acquisition request is used for indicating the server to return a corresponding updating data model; and receiving a page layout file which is returned by the server and is customized for each user interface in the native user interface system of the application program by adopting the JS language.
In one embodiment, the parsing module is specifically configured to: adopting a single case class based on JSCore to carry out syntax analysis on the page layout file, and obtaining the corresponding control layout and corresponding attributes in the page layout file; and generating rendering data for updating the user interface according to the corresponding control layout and the corresponding attributes in the page layout file.
In an embodiment, the update data model obtaining unit is specifically configured to: and when a starting instruction of the application program is received, acquiring an updated data model corresponding to the application program from a local storage space.
In an embodiment, the obtaining module 601 further includes a receiving unit, configured to receive an updated data model of the application program issued by the server, where the updated data model is issued by the server in an application program running process; and saving the updated data model of the application program in a local storage space. In one embodiment, the opening instruction for the user interface is sent when the application opens the user interface in a routing mode.
For the specific definition of the interface updating device, reference may be made to the above definition of the interface updating method, which is not described herein again. The various modules in the above-described interface update apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement an interface update method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
responding to a starting instruction of the application program, and acquiring a page layout file for updating a user interface of the application program;
when an opening instruction of the user interface is detected, adopting single-case type analysis to update a page layout file of the user interface, and acquiring rendering data for updating the user interface;
and rendering the user interface by adopting the rendering data, and generating and opening the updated user interface.
In one embodiment, the processor, when executing the computer program, further performs the steps of: acquiring an updated data model corresponding to the application program; and extracting a page layout file of the user interface needing to be updated in the application program from the updated data model, wherein the page layout file comprises corresponding control layout and corresponding attributes.
In one embodiment, the processor, when executing the computer program, further performs the steps of: when a starting instruction of an application program is received, sending an updating data model acquisition request to a server, wherein the updating data model acquisition request is used for indicating the server to return a corresponding updating data model; and receiving a page layout file which is returned by the server and is customized for each user interface in the native user interface system of the application program by adopting the JS language, wherein the customized page layout file comprises corresponding control layout and corresponding attributes.
In one embodiment, the processor, when executing the computer program, further performs the steps of: adopting a single case class based on JSCore to carry out syntax analysis on the page layout file, and obtaining the corresponding control layout and corresponding attributes in the page layout file; and generating rendering data for updating the user interface according to the corresponding control layout and the corresponding attributes in the page layout file.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and when a starting instruction of the application program is received, acquiring an updated data model corresponding to the application program from a local storage space.
In one embodiment, the processor, when executing the computer program, further performs the steps of: receiving an updated data model of an application program issued by a server, wherein the updated data model is issued by the server in the running process of the application program; and saving the updated data model of the application program in a local storage space.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
responding to a starting instruction of the application program, and acquiring a page layout file for updating a user interface of the application program;
when an opening instruction of the user interface is detected, adopting single-case type analysis to update a page layout file of the user interface, and acquiring rendering data for updating the user interface;
and rendering the user interface by adopting the rendering data, and generating and opening the updated user interface.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring an updated data model corresponding to the application program; and extracting a page layout file of the user interface needing to be updated in the application program from the updated data model, wherein the page layout file comprises corresponding control layout and corresponding attributes.
In one embodiment, the computer program when executed by the processor further performs the steps of: when a starting instruction of an application program is received, sending an updating data model acquisition request to a server, wherein the updating data model acquisition request is used for indicating the server to return a corresponding updating data model; and receiving a page layout file which is returned by the server and is customized for each user interface in the native user interface system of the application program by adopting the JS language, wherein the customized page layout file comprises corresponding control layout and corresponding attributes.
In one embodiment, the computer program when executed by the processor further performs the steps of: adopting a single case class based on JSCore to carry out syntax analysis on the page layout file, and obtaining the corresponding control layout and corresponding attributes in the page layout file; and generating rendering data for updating the user interface according to the corresponding control layout and the corresponding attributes in the page layout file.
In one embodiment, the computer program when executed by the processor further performs the steps of: and when a starting instruction of the application program is received, acquiring an updated data model corresponding to the application program from a local storage space.
In one embodiment, the processor, when executing the computer program, further performs the steps of: receiving an updated data model of an application program issued by a server, wherein the updated data model is issued by the server in the running process of the application program; and saving the updated data model of the application program in a local storage space.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.