Search

CN-117707658-B - Interface rendering method and device for applet, storage medium and computer equipment

CN117707658BCN 117707658 BCN117707658 BCN 117707658BCN-117707658-B

Abstract

The application discloses an interface rendering method, device, storage medium and computer equipment of an applet, wherein the method comprises the steps of responding to a rendering request, determining a key of first rendering data in a local storage space of the applet, wherein the first rendering data is determined according to interface content of the applet, reading the first rendering data from a target object according to the key of the first rendering data, wherein the target object is configured in an operation memory of the applet, target object data stored in the target object is acquired from the local storage space of the applet, the target object data comprises the first rendering data, and performing interface rendering according to the first rendering data. Therefore, the data reading speed is increased, the blockage during rendering is reduced, the fluency of the operation of the applet is improved, the display efficiency of the user interface is effectively improved, the consistency and accuracy of the read data are ensured, and the problem of rendering errors caused by untimely updating of the local storage is avoided.

Inventors

  • DOU CHEN

Assignees

  • 北京完美灵犀科技有限公司

Dates

Publication Date
20260505
Application Date
20230707

Claims (5)

  1. 1. A method of interface rendering for an applet, the method comprising: Configuring a target object in an operation memory of the applet, wherein the target object is always in the memory when the applet operates, and JS files of various interfaces of the applet can refer to the target object; responding to a starting instruction of the applet, calling getStorageSync a method to synchronously acquire target object data stored in a local storage space of the applet, and globally initializing the target object according to the target object data; If the getStorageSync method is called to obtain the target object data, a getStorageInfoSync method is called to obtain a storage name array in the local storage space, the local data stored locally are obtained through traversal according to the storage name array, the obtained local data are spliced according to the structural information of the target object, the target object data with the same structure as the target object are obtained, and the target object is initialized according to the spliced target object data; Determining a key of first rendering data in a local storage space of the applet in response to a rendering request, wherein the first rendering data is determined according to interface content of the applet; Reading corresponding first rendering data from a target object through a key of the first rendering data when the applet reads local storage related data by an overlay or global replacement getStorageSync method, wherein the target object stores target object data in a key value pair format, the target object data stored in the target object is acquired from a local storage space of the applet, and the target object data comprises the first rendering data; performing interface rendering according to the first rendering data; Responding to an update instruction of target object data of the local storage space, and storing the updated target object data in the target object by covering or modifying a global setStorageSync method; calling an asynchronous writing interface to write the updated target object data into the local storage space; If the writing of the data in the current target object into the local storage space fails, error data of the writing failure is recorded so as to be used for initializing the target object after merging the error data with the target object data acquired from the local storage space when the applet is started next time.
  2. 2. The method according to claim 1, wherein the method further comprises: Calling a target application interface to send a data acquisition request to a server; receiving second rendering data sent by the server side; Updating the target object with the second rendering data; reading updated first rendering data from the target object according to the key of the first rendering data; and performing interface secondary rendering according to the updated first rendering data.
  3. 3. An applet interface rendering apparatus, said apparatus comprising: the configuration module is used for configuring a target object in the running memory of the applet, wherein the target object is always in the memory when the applet runs, and JS files of all interfaces of the applet can refer to the target object; the data reading module is used for responding to the starting instruction of the small program and calling getStorageSync a method to synchronously acquire target object data stored in the local storage space of the small program; the initialization module is used for globally initializing the target object according to the target object data; The data migration module is configured to, if the target object data is not acquired by invoking the getStorageSync method, invoke the getStorageInfoSync method to acquire a storage name array in the local storage space, traverse and acquire local data stored locally according to the storage name array, perform a stitching process on the acquired local data according to the structure information of the target object, obtain target object data with the same structure as the target object, and initialize the target object according to the stitched target object data; The data reading module is further used for responding to a rendering request, determining a key of first rendering data in a local storage space of the applet, wherein the first rendering data is determined according to interface content of the applet, and reading the first rendering data from a target object through the key of the first rendering data when the applet reads local storage related data by a covering or global replacement getStorageSync method, wherein the target object adopts a key value pair format to store target object data, the target object data stored in the target object is acquired from the local storage space of the applet, and the target object data comprises the first rendering data; The rendering module is used for performing interface rendering according to the first rendering data; The data writing module is used for responding to an update instruction of target object data of the local storage space, storing the updated target object data in the target object by covering or modifying a global setStorageSync method, and calling an asynchronous writing interface to write the updated target object data into the local storage space; And the error recording module is used for recording error data with failed writing if the writing of the data in the current target object into the local storage space fails, so as to be used for initializing the target object after merging the error data with the target object data acquired from the local storage space when the next applet is started.
  4. 4. A storage medium having stored thereon a computer program, wherein the program when executed by a processor implements the applet interface rendering method according to claim 1 or 2.
  5. 5. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the interface rendering method of the applet of claim 1 or 2 when executing the program.

Description

Interface rendering method and device for applet, storage medium and computer equipment Technical Field The present application relates to the field of internet technologies, and in particular, to an interface rendering method and apparatus for an applet, a storage medium, and a computer device. Background With the development of technology, application integration functions are increasing. The client can be provided with the applets corresponding to different applications, so that a user can operate other applications in the client of the application only through the applets of other applications without installing the client. In the running process of the applet, the applet needs to borrow the local storage space of the client to store data and frequently interact with the client. In the related art, when data is stored, the method setStorageSync is directly called to store the local data in the local storage of the applet, and when the data is read, getStorageSync is used to read the locally stored data. However, with the application of the applet, the read-write data volume is more and more, and the synchronous read-write and local storage can cause the blockage of threads, so that the rendering of the interface is slower. Moreover, if the user data of the server changes and the buffer is not changed in time, the problem of rendering errors is also caused. Disclosure of Invention In view of the above, the present invention has been made to provide an interface rendering method, apparatus, storage medium, and computer device of an applet that overcomes or at least partially solves the above-mentioned problems. According to a first aspect of the present application, there is provided an interface rendering method of an applet, the method comprising: Determining a key of first rendering data in a local storage space of the applet in response to the rendering request, wherein the first rendering data is determined according to interface content of the applet; Reading first rendering data from a target object according to a key of the first rendering data, wherein the target object is configured in an operation memory of an applet, target object data stored in the target object is acquired from a local storage space of the applet, and the target object data comprises the first rendering data; And performing interface rendering according to the first rendering data. Further, before the first rendering data is read from the target object according to the key of the first rendering data, the interface rendering method of the applet further includes: configuring a target object in the running memory of the applet; Responding to a starting instruction of an applet, and calling a synchronous reading interface to acquire target object data stored in a local storage space; and initializing the target object according to the target object data. Further, before the first rendering data is read from the target object according to the key of the first rendering data, the interface rendering method of the applet further includes: And performing data migration processing on the local data stored in the local storage space to generate target object data. Further, performing data migration processing on the local data stored in the local storage space, including: acquiring storage information of first local data; Acquiring first local data from the local data according to the storage information; And performing splicing processing on the first local data according to the structure information of the target object to obtain the target object data. Further, the interface rendering method of the applet further comprises: Calling a target application interface to send a data acquisition request to a server; receiving second rendering data sent by a server; Updating the target object with the second rendering data; and reading updated first rendering data from the target object according to the key of the first rendering data, and performing interface secondary rendering according to the updated first rendering data. Further, the interface rendering method of the applet further comprises: responding to an update instruction of target object data, and storing the updated target object data in a target object; And calling an asynchronous writing interface to write the updated target object data into the local storage space. Further, the interface rendering method of the applet further comprises: if the updated target object data fails to be written into the local storage space, error data of the writing failure is recorded and is used for initializing the target object when the next applet is started. According to a second aspect of the present application, there is provided an interface rendering apparatus of an applet, the apparatus comprising: The system comprises a data reading module, a target object reading module and a data processing module, wherein the data reading module is used for responding to a rendering request and