Disclosure of Invention
The present invention proposes the following technical solutions to address one or more technical defects in the prior art.
A rendering method for reducing a volume of a small package, the method being performed in an electronic device, the method comprising:
the method comprises the steps of obtaining the type of a data object operated by a user in the electronic equipment when the user operates on an interface of an applet on the electronic equipment;
an application step, namely applying a first memory space in a memory of the electronic equipment and acquiring a first pointer of the first memory space;
and a rendering step, wherein if the data object type is a first type, the first memory space is adjusted based on the first type to obtain a first adjusted memory space, if the data object type is a second type, the first memory space is adjusted based on the second type to obtain a second adjusted memory space, the content of the data object is loaded to the first adjusted memory space or the second adjusted memory space according to the data object type, and the content is rendered from the first adjusted memory space or the second adjusted memory space to a view layer of a display interface for a user to view based on the first pointer.
Further, the first type is video, and the second type is topic.
Further, in the acquiring step, based on the data object operated by the user in the electronic device, the applet acquires an identifier of the data object, and connects to the server to query the data object type of the data object based on the identifier.
Further, in the rendering step: if the first type is a video, the applet requests the server to obtain basic information of the video, obtains a representative frame of the video based on the basic information of the video, loads the representative frame of the video as first content into a first adjustment memory space, and renders the first content from the first adjustment memory space to a view layer of a display interface based on the first pointer to form a video interface for a user to view.
Further, in the rendering step: if the second type is a topic, the applet requests the server to obtain basic information of the topic, whether the topic comprises a plurality of topic videos is judged based on the basic information of the topic, if so, an array Arr [ n ] is created to store the URL of each topic video, the corresponding topic of each topic video is obtained based on each URL, the content representing the topic is obtained from the basic information of the topic, the content of the topic and the topic of each topic video are loaded into a second adjustment memory space as second content, and then the second content is rendered from the second adjustment memory space to a view layer of a display interface based on the first pointer to form a topic interface for a user to view.
Furthermore, when a user clicks a topic of a topic video on a topic interface, a corresponding topic video URL is obtained based on the array Arr [ n ], the applet requests the server to obtain basic information of the topic video, the size of a representative frame of the topic video is obtained based on the basic information, the second adjustment memory space is adjusted again based on the size of the representative frame of the topic video to obtain a third adjustment memory space, the representative frame of the topic video is obtained based on the basic information of the topic video, and the representative frame of the video is loaded into the third adjustment memory space as content.
The invention also provides a rendering device for reducing the volume of the small program package, which is arranged in the electronic equipment to execute, and the device comprises:
the acquisition unit is used for acquiring the data object type operated by the user in the electronic equipment when the user operates on the interface of the small program on the electronic equipment;
the application unit is used for applying for a first memory space in the memory of the electronic equipment and acquiring a first pointer of the first memory space;
and the rendering unit is used for adjusting the first memory space based on the first type to obtain a first adjusted memory space if the data object type is the first type, adjusting the first memory space based on the second type to obtain a second adjusted memory space if the data object type is the second type, loading the content of the data object to the first adjusted memory space or the second adjusted memory space according to the data object type, and rendering the content from the first adjusted memory space or the second adjusted memory space to a view layer of a display interface for a user to view based on the first pointer.
Further, the first type is video, and the second type is topic.
Still further, in the acquiring unit, based on a data object operated by a user in the electronic device, the applet acquires an identifier of the data object, and connects to the server to query a data object type of the data object based on the identifier.
Further, in the rendering unit: if the first type is a video, the applet requests the server to obtain basic information of the video, obtains a representative frame of the video based on the basic information of the video, loads the representative frame of the video as first content into a first adjustment memory space, and renders the first content from the first adjustment memory space to a view layer of a display interface based on the first pointer to form a video interface for a user to view.
Further, in the rendering unit: if the second type is a topic, the applet requests the server to obtain basic information of the topic, whether the topic comprises a plurality of topic videos is judged based on the basic information of the topic, if so, an array Arr [ n ] is created to store the URL of each topic video, the corresponding topic of each topic video is obtained based on each URL, the content representing the topic is obtained from the basic information of the topic, the content of the topic and the topic of each topic video are loaded into a second adjustment memory space as second content, and then the second content is rendered from the second adjustment memory space to a view layer of a display interface based on the first pointer to form a topic interface for a user to view.
Furthermore, when a user clicks a topic of a topic video on a topic interface, a corresponding topic video URL is obtained based on the array Arr [ n ], the applet requests the server to obtain basic information of the topic video, the size of a representative frame of the topic video is obtained based on the basic information, the second adjustment memory space is adjusted again based on the size of the representative frame of the topic video to obtain a third adjustment memory space, the representative frame of the topic video is obtained based on the basic information of the topic video, and the representative frame of the video is loaded into the third adjustment memory space as content.
The invention also proposes a computer-readable storage medium having stored thereon computer program code which, when executed by a computer, performs any of the methods described above.
The invention has the technical effects that: the invention discloses a rendering method, a device, equipment and a storage medium for reducing the volume of a small program package, wherein the method comprises the following steps: the method comprises the steps of obtaining the type of a data object operated by a user in the electronic equipment when the user operates on an interface of an applet on the electronic equipment; an application step, namely applying a first memory space in a memory of the electronic equipment and acquiring a first pointer of the first memory space; and a rendering step, wherein if the data object type is a first type, the first memory space is adjusted based on the first type to obtain a first adjusted memory space, if the data object type is a second type, the first memory space is adjusted based on the second type to obtain a second adjusted memory space, the content of the data object is loaded to the first adjusted memory space or the second adjusted memory space according to the data object type, and the content is rendered from the first adjusted memory space or the second adjusted memory space to a view layer of a display interface for a user to view based on the first pointer. In the invention, the first memory space is applied by the host program according to the type of the applet, namely, the memory relation tables corresponding to different applets are established in the host program, when a user starts one applet, the host program applies the corresponding first memory space according to the relation, the efficiency of memory application is improved due to the establishment of the relation tables, the content of the applet is reduced due to the setting of the relation tables in the host program, and the packet volume of the applet is reduced; in the invention, in order to improve the system performance, the applied first memory is relatively small, in the subsequent operation process, the first memory space needs to be adjusted according to the data object of the actual operation of the user on the small program, the initial address of the adjusted memory space is kept unchanged, namely the pointer of the adjusted memory space is unchanged, thus reducing the complex memory application mechanism in the small program, reducing the code of the small program and reducing the volume of the small program; in the invention, the display interface of the small program only needs to be provided with a basic initial interface, so that the volume of the small program package is reduced, and the content displayed on the small program package at the later stage is matched with the adjustment of the memory according to the type of the content, so that the content display is quick, the memory consumption is low, the operation efficiency of the small program is improved, the influence on the host program is reduced, and the user experience is improved.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows a rendering method for reducing the volume of a small program package according to the present invention, which is executed in an electronic device, where a small program refers to a program that can be run without downloading, and depends on other programs, also called hosted programs, and commonly used small program with little trust, where the small program is an application that can be used without downloading, and is also an innovation, and through the development of nearly two years, a new small program development environment and a new developer ecology have been constructed, and as the functions of the small program become more complex, such as supporting functions of data display, video playing, etc., the volume of the small program is larger and larger, and the memory occupied during running is also larger and larger, which inevitably results in slow running of the host program, which is a defect in the prior art.
The method comprises the following steps:
an obtaining step S101, when a user operates on an interface of an applet on the electronic equipment, obtaining a data object type operated by the user in the electronic equipment;
an application step S102, of applying for a first memory space in a memory of the electronic device, and acquiring a first pointer of the first memory space;
a rendering step S103, if the data object type is a first type, adjusting the first memory space based on the first type to obtain a first adjusted memory space, if the data object type is a second type, adjusting the first memory space based on the second type to obtain a second adjusted memory space, loading the content of the data object to the first adjusted memory space or the second adjusted memory space according to the data object type, and rendering the content from the first adjusted memory space or the second adjusted memory space to a view layer of a display interface for a user to view based on the first pointer.
In the invention, the first memory space is applied by the host program according to the type of the applet, namely, the memory relation tables corresponding to different applets are established in the host program, when a user starts one applet, the host program applies the corresponding first memory space according to the relation, the efficiency of memory application is improved due to the establishment of the relation tables, the content of the applet is reduced due to the fact that the relation tables are arranged in the host program, and the packet volume of the applet is reduced, which is an important invention point of the invention.
In the invention, in order to improve the system performance, the applied first memory is relatively small, in the subsequent operation process, the first memory space needs to be adjusted according to the data object of the actual operation of the user on the applet, the initial address of the adjusted memory space is kept unchanged, namely the pointer of the adjusted memory space is unchanged, so that the complex memory application mechanism in the applet is reduced, the code of the applet is reduced, and the volume of the applet is reduced, which is another important invention point of the invention.
In one embodiment, the first data type is video and the second data type is topical. In the obtaining step S101, based on a data object operated by a user in an electronic device, the applet obtains an identifier of the data object, and connects to a server to query a data object type of the data object based on the identifier. The identification of the data object may be an ID, URL, or the like.
In one embodiment, in the rendering step S103: if the first data type is a video, the applet requests the server to obtain basic information of the video, obtains a representative frame of the video based on the basic information of the video, loads the representative frame of the video as first content into a first adjustment memory space, and renders the first content from the first adjustment memory space to a view layer of a display interface based on the first pointer to form a video interface for a user to view.
In the invention, after the data object type is determined to be a first type, that is, the first type is a video, the first memory space is adjusted based on the first type to obtain a first adjusted memory space, because the content of the video is large, in order to smoothly play the video, the first memory space needs to be increased so that the video can be smoothly played, then a representative frame of the video is obtained and loaded into the first adjusted memory space as a first content, and then the first content is rendered from the first adjusted memory space to a view layer of a display interface based on the first pointer to form a video interface for a user to view, so that the problem that the video playing is not smooth due to slow and small running of other applications due to excessively large memory space applied in advance is solved, and the invention belongs to another important invention point of the invention.
In one embodiment, in the rendering step S103: and if the second data type is a topic, the applet requests the server to obtain basic information of the topic, judges whether the topic comprises a plurality of topic videos based on the basic information of the topic, if so, creates an array Arr [ n ] to store the URL of each topic video, obtains the corresponding topic of each topic video based on each URL, obtains the content representing the topic from the basic information of the topic, loads the content of the topic and the topic of each topic video into a second adjustment memory space as second content, and renders the second content from the second adjustment memory space to a view layer of a display interface based on the first pointer to form a topic interface for a user to view, wherein n is the number of the topic videos. The topic may be a page including a plurality of topic videos, and the page includes a topic of the topic and a topic of the plurality of topic videos, for example, a topic is an 'accounting training lecture', and links of the plurality of topic videos are included below the page, and each link is displayed on the topic of the topic video.
In one embodiment, when a user clicks a topic of a topic video on a topic interface, a corresponding topic video URL is acquired based on the array Arr [ n ], the applet requests the server to acquire basic information of the topic video, acquires a size of a representative frame of the topic video based on the basic information, readjusts the second adjusted memory space based on the size of the representative frame of the topic video to obtain a third adjusted memory space, acquires the representative frame of the topic video based on the basic information of the topic video, and loads the representative frame of the video as content into the third adjusted memory space.
In the invention, as the memory required for only displaying one thematic interface is smaller, the second adjustment memory space is smaller than the first adjustment memory space of the video, thus, when a user browses a thematic page, if the user needs to check the thematic video, the second adjustment memory space is adjusted again, the second adjustment memory space can be adjusted to be multiple times, such as 10-20 times and the like, of the size of a representative frame of the thematic video, then the thematic video is rendered from the second adjustment memory space to a view layer of a display interface based on the first pointer to form a thematic video interface for the user to check, and the URL of the corresponding thematic video is recorded by an array, so that the user can conveniently click the corresponding thematic video and quickly obtain the link of the thematic video, in the invention, the display interface of a small program only needs to be provided with a basic initial interface, thereby reducing the volume of a small program package, and the content displayed on the post-stage is matched with the adjustment of the memory according to the type of the content, so that the content is displayed quickly, the memory consumption is small, the running efficiency of the small program is improved, the influence on the host program is reduced, and the user experience is improved.
Fig. 2 shows a rendering apparatus for reducing the volume of a small program package according to the present invention, which is disposed in an electronic device, where the small program refers to a program that can be run without downloading, and depends on other programs, also called hosted programs, and commonly used small program with little trust, where the small program is an application that can be used without downloading, and is also an innovation, and through the development of nearly two years, a new small program development environment and a new developer ecology have been constructed, and as the functions of the small program become more complex, such as supporting functions of data display, video playing, etc., the volume of the small program is larger and larger, and the memory occupied during running is also larger and larger, which inevitably results in slow running of the host program, which is a defect in the prior art. The device includes:
an acquisition unit 201, which acquires the data object type operated by the user in the electronic device when the user operates on the interface of the small program on the electronic device;
an applying unit 202, configured to apply for a first memory space in a memory of the electronic device, and obtain a first pointer of the first memory space;
a rendering unit 203, configured to, if the data object type is a first type, adjust the first memory space based on the first type to obtain a first adjusted memory space, if the data object type is a second type, adjust the first memory space based on the second type to obtain a second adjusted memory space, load the content of the data object to the first adjusted memory space or the second adjusted memory space according to the data object type, and render the content from the first adjusted memory space or the second adjusted memory space to a view layer of a display interface for a user to view based on the first pointer.
In the invention, the first memory space is applied by the host program according to the type of the applet, namely, the memory relation tables corresponding to different applets are established in the host program, when a user starts one applet, the host program applies the corresponding first memory space according to the relation, the efficiency of memory application is improved due to the establishment of the relation tables, the content of the applet is reduced due to the fact that the relation tables are arranged in the host program, and the packet volume of the applet is reduced, which is an important invention point of the invention.
In the invention, in order to improve the system performance, the applied first memory is relatively small, in the subsequent operation process, the first memory space needs to be adjusted according to the data object of the actual operation of the user on the applet, the initial address of the adjusted memory space is kept unchanged, namely the pointer of the adjusted memory space is unchanged, so that the complex memory application mechanism in the applet is reduced, the code of the applet is reduced, and the volume of the applet is reduced, which is another important invention point of the invention.
In one embodiment, the first data type is video and the second data type is topical. In the obtaining unit 201, based on a data object operated by a user in an electronic device, the applet obtains an identifier of the data object, and connects to a server to query a data object type of the data object based on the identifier. The identification of the data object may be an ID, URL, or the like.
In one embodiment, in the rendering unit 203: if the first data type is a video, the applet requests the server to obtain basic information of the video, obtains a representative frame of the video based on the basic information of the video, loads the representative frame of the video as first content into a first adjustment memory space, and renders the first content from the first adjustment memory space to a view layer of a display interface based on the first pointer to form a video interface for a user to view.
In the invention, after the data object type is determined to be a first type, that is, the first type is a video, the first memory space is adjusted based on the first type to obtain a first adjusted memory space, because the content of the video is large, in order to smoothly play the video, the first memory space needs to be increased so that the video can be smoothly played, then a representative frame of the video is obtained and loaded into the first adjusted memory space as a first content, and then the first content is rendered from the first adjusted memory space to a view layer of a display interface based on the first pointer to form a video interface for a user to view, so that the problem that the video playing is not smooth due to slow and small running of other applications due to excessively large memory space applied in advance is solved, and the invention belongs to another important invention point of the invention.
In one embodiment, in the rendering unit 203: and if the second data type is a topic, the applet requests the server to obtain basic information of the topic, judges whether the topic comprises a plurality of topic videos based on the basic information of the topic, if so, creates an array Arr [ n ] to store the URL of each topic video, obtains the corresponding topic of each topic video based on each URL, obtains the content representing the topic from the basic information of the topic, loads the content of the topic and the topic of each topic video into a second adjustment memory space as second content, and renders the second content from the second adjustment memory space to a view layer of a display interface based on the first pointer to form a topic interface for a user to view, wherein n is the number of the topic videos. The topic may be a page including a plurality of topic videos, and the page includes a topic of the topic and a topic of the plurality of topic videos, for example, a topic is an 'accounting training lecture', and links of the plurality of topic videos are included below the page, and each link is displayed on the topic of the topic video.
In one embodiment, when a user clicks a topic of a topic video on a topic interface, a corresponding topic video URL is acquired based on the array Arr [ n ], the applet requests the server to acquire basic information of the topic video, acquires a size of a representative frame of the topic video based on the basic information, readjusts the second adjusted memory space based on the size of the representative frame of the topic video to obtain a third adjusted memory space, acquires the representative frame of the topic video based on the basic information of the topic video, and loads the representative frame of the video as content into the third adjusted memory space.
In the invention, as the memory required for only displaying one thematic interface is smaller, the second adjustment memory space is smaller than the first adjustment memory space of the video, thus, when a user browses a thematic page, if the user needs to check the thematic video, the second adjustment memory space is adjusted again, the second adjustment memory space can be adjusted to be multiple times, such as 10-20 times and the like, of the size of a representative frame of the thematic video, then the thematic video is rendered from the second adjustment memory space to a view layer of a display interface based on the first pointer to form a thematic video interface for the user to check, and the URL of the corresponding thematic video is recorded by an array, so that the user can conveniently click the corresponding thematic video and quickly obtain the link of the thematic video, in the invention, the display interface of a small program only needs to be provided with a basic initial interface, thereby reducing the volume of a small program package, and the content displayed on the post-stage is matched with the adjustment of the memory according to the type of the content, so that the content is displayed quickly, the memory consumption is small, the running efficiency of the small program is improved, the influence on the host program is reduced, and the user experience is improved.
The invention provides a rendering device for reducing the volume of a small program package, which comprises a processor and a memory, wherein the processor is connected with the processor through a bus, the memory is stored with a computer program, the processor executes the computer program on the memory to realize the method, and the device can be a desktop computer, a server, a notebook, an intelligent terminal and the like.
An embodiment of the present invention provides a computer storage medium, on which a computer program is stored, which when executed by a processor implements the above-mentioned method, and the computer storage medium can be a hard disk, a DVD, a CD, a flash memory, or the like.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present application may be essentially implemented or the portions that contribute to the prior art may be embodied in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the apparatuses described in the embodiments or some portions of the embodiments of the present application.
Finally, it should be noted that: although the present invention has been described in detail with reference to the above embodiments, it should be understood by those skilled in the art that: modifications and equivalents may be made thereto without departing from the spirit and scope of the invention and it is intended to cover in the claims the invention as defined in the appended claims.