CN115964584A - Page resource loading method and device, electronic equipment and storage medium - Google Patents

Page resource loading method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115964584A
CN115964584A CN202211638450.4A CN202211638450A CN115964584A CN 115964584 A CN115964584 A CN 115964584A CN 202211638450 A CN202211638450 A CN 202211638450A CN 115964584 A CN115964584 A CN 115964584A
Authority
CN
China
Prior art keywords
resource
loaded
file
data
attribute information
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.)
Pending
Application number
CN202211638450.4A
Other languages
Chinese (zh)
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.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN202211638450.4A priority Critical patent/CN115964584A/en
Publication of CN115964584A publication Critical patent/CN115964584A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the application provides a page resource loading method and device, electronic equipment and a storage medium, and belongs to the technical field of internet. The method comprises the following steps: acquiring file attribute information and a file type of a resource to be loaded, and determining a target byte position in the file attribute information according to the file type; acquiring target byte data of a target byte position, and determining size information of a resource to be loaded according to the target byte data; creating a view container and adjusting the size of the view container according to the size information; and filling the resources to be loaded into the adjusted view container. According to the embodiment of the application, the size information can be read from the file attribute information, the size of the view container is adjusted according to the read size information, the file content data is directly filled into the view container when the file content data is received later, the page shaking situation can not occur, the stability of the page during loading is improved, and the shaking situation of the page during the loading process is reduced.

Description

Page resource loading method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a page resource loading method and apparatus, an electronic device, and a storage medium.
Background
A page is composed of various elements View (View containers), such as buttons, horizontal lines, color blocks, displayed pictures, and the like. The current scheme for drawing View generally comprises the following steps: 1. the method comprises the steps of firstly setting the size of the View, then loading the filling resource and then changing the size of the View, wherein the scheme can cause the situation that a page jumps greatly when viewed by a client. The second method is that the size of the resource can be known only after the complete resource is downloaded, and then the View is drawn to the screen, but the larger the resource volume is, the longer the completion time of waiting for downloading is, and further the waiting time is, and when the resource volume is larger, the larger the influence of the network condition is. The third method is to add the width and height parameters of the picture into the HTTP address of the remote resource, and then know the size of the View when drawing the View, but the scheme needs a server to process the width and height of the picture additionally and splices the picture into the HTTP address, thereby consuming the processing resource; and not all resource links carry the width and height information of the pictures and are spliced into the HTTP address. In summary, in the existing solutions, either a large page bounce occurs or server resources are consumed greatly, and all situations cannot be considered.
Disclosure of Invention
The embodiments of the present application mainly aim to provide a page resource loading method and apparatus, an electronic device, and a storage medium, which aim to improve stability of page loading and reduce jitter in a page loading process.
In order to achieve the above object, a first aspect of the embodiments of the present application provides a page resource loading method, where the method includes: acquiring file attribute information and a file type of a resource to be loaded, and determining a target byte position in the file attribute information according to the file type; acquiring target byte data of the target byte position, and determining the size information of the resource to be loaded according to the target byte data; creating a view container and adjusting the size of the view container according to the size information; and filling the resources to be loaded into the adjusted view container.
In some embodiments, the obtaining the file type of the resource to be loaded includes: acquiring first byte data at a first preset byte position in the file attribute information; and determining the file type of the resource to be loaded according to the first byte data.
In some embodiments, the obtaining file attribute information of the resource to be loaded includes: receiving byte stream data of resources to be loaded from a server; and acquiring second byte data of a second preset position in the byte stream data, wherein the second byte data is the file attribute information of the resource to be loaded.
In some embodiments, the resource to be loaded includes a picture resource and a video resource, and the obtaining of the file attribute information and the file type of the resource to be loaded includes one of: when the resource to be loaded is a picture resource, directly acquiring file attribute information and a file type of the resource to be loaded; when the resource to be loaded is a video resource, determining a target frame picture of the video resource, and acquiring file attribute information and a file type of the target frame picture.
In some embodiments, the populating the resource to be loaded into the adjusted view container includes: acquiring file content data of the resource to be loaded; and analyzing the file content data and filling the file content data into the view container.
In some embodiments, before the obtaining the file attribute information and the file type of the resource to be loaded, the page resource loading method further includes: sending request information of resources to be loaded to a server so that the server can inquire the storage condition of the resources to be loaded according to the request information; and when the storage condition is that the resource to be loaded is stored in the server, receiving a request failure state code fed back by the server based on the request information and byte stream data of the resource to be loaded, wherein the byte stream data comprises the file attribute information and file content data.
In some embodiments, after sending the request information of the resource to be loaded to the server, the page resource loading method further includes: and when the storage condition is that the resource to be loaded is not stored in the server, receiving a request failure status code fed back by the server based on the request information.
In order to achieve the above object, a second aspect of the embodiments of the present application provides a page resource loading apparatus, where the apparatus includes: the data receiving module is used for acquiring file attribute information and a file type of a resource to be loaded and determining a target byte position in the file attribute information according to the file type; the byte acquisition module is used for acquiring target byte data at the target byte position and determining the size information of the resource to be loaded according to the target byte data; the view container creating module is used for creating a view container and adjusting the size of the view container according to the size information; and the resource filling module is used for filling the resources to be loaded into the adjusted view container.
In order to achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.
To achieve the above object, a fourth aspect of the embodiments of the present application proposes a computer-readable storage medium storing a computer program, which when executed by a processor implements the method of the first aspect.
The page resource loading method and device, the electronic device and the storage medium provided by the application acquire file attribute information and a file type of a resource to be loaded before receiving the content of the resource to be loaded, determine a target byte position in the file attribute information according to the file type, acquire target byte data of the target byte position after determining the target byte position, determine size information of the resource to be loaded according to the target byte data, create a view container for filling the resource to be loaded on a page, receive file content data of the resource to be loaded, and fill the resource to be loaded into the adjusted view container.
Drawings
Fig. 1 is an alternative flowchart of a page resource loading method according to an embodiment of the present application;
fig. 2 is a flowchart of acquiring a file type of a resource to be loaded in a page resource loading method provided in an embodiment of the present application;
fig. 3 is a flowchart of acquiring file attribute information of a resource to be loaded in a page resource loading method according to an embodiment of the present application;
fig. 4 is a flowchart for acquiring file attribute information and a file type of a resource to be loaded in the page resource loading method provided in the embodiment of the present application;
fig. 5 is a flowchart of acquiring file attribute information and a file type of a resource to be loaded in the page resource loading method provided in the embodiment of the present application;
fig. 6 is a flowchart of filling a view container in a page resource loading method provided in an embodiment of the present application;
FIG. 7 is an alternative flowchart of a page resource loading method according to an embodiment of the present application;
FIG. 8 is an alternative flowchart of a page resource loading method according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a page resource loading apparatus according to an embodiment of the present application;
fig. 10 is a schematic hardware structure diagram of an electronic device according to an embodiment of the present application.
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.
It is noted that while functional block divisions are provided in device diagrams and logical sequences are shown in flowcharts, in some cases, steps shown or described may be performed in sequences other than block divisions within devices or flowcharts. The terms first, second and the like in the description and in the claims, as well as in the drawings described above, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the application.
First, several terms referred to in the present application are resolved:
artificial intelligence (art ericia l inte l reference, AI): the method is a new technical science for researching and developing theories, methods, technologies and application systems for simulating, extending and expanding human intelligence; artificial intelligence is a branch of computer science, which attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence, and research in this field includes robotics, language recognition, image recognition, natural language processing, expert systems, and the like. The artificial intelligence can simulate the information process of human consciousness and thinking. Artificial intelligence is also a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results.
Natural language processing (natura l language processing i ng, NLP): NLP uses computer to process, understand and use human language (such as chinese, english, etc.), and belongs to a branch of artificial intelligence, which is a cross discipline between computer science and linguistics, also commonly called computational linguistics. Natural language processing includes parsing, semantic analysis, discourse understanding, and the like. Natural language processing is commonly used in the technical fields of machine translation, character recognition of handwriting and print, speech recognition and text-to-speech conversion, information intention recognition, information extraction and filtering, text classification and clustering, public opinion analysis and viewpoint mining, and relates to data mining, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, linguistic research related to language calculation and the like related to language processing.
Information extraction (I information extraction): and extracting the fact information of entities, relations, events and the like of specified types from the natural language text, and forming a text processing technology for outputting structured data. Information extraction is a technique for extracting specific information from text data. The text data is composed of specific units, such as sentences, paragraphs and chapters, and the text information is composed of small specific units, such as words, phrases, sentences and paragraphs or combinations of these specific units. The extraction of noun phrases, names of people, names of places, etc. in the text data is text information extraction, and of course, the information extracted by the text information extraction technology may be various types of information.
An Image description (Image Caption) generates a natural language description for an Image and utilizes the generated description to help an application understand the semantics expressed in the visual scene of the Image. For example, the image description may convert an image search into a text search for classifying images and improving image search results. People usually only need to quickly browse to describe the details of the visual scene of the image, and automatically adding descriptions to the image is a comprehensive and arduous computer vision task, and complex information contained in the image needs to be converted into natural language descriptions. In contrast to common computer vision tasks, image captions not only need to identify objects from an image, but also need to associate the identified objects with natural semantics and describe them in natural language. Thus, image description requires one to extract deep features of an image, associate with semantic features and transform for generating the description.
Hyper Text Transfer Protocol (HTTP) is a simple request-response protocol that typically runs on top of TCP. It specifies what messages the client may send to the server and what responses to get. The header of the request and response messages is given in ASCI I form; and the message content has a format similar to the MI ME. HTTP is an application layer protocol, and like other application layer protocols, is a protocol for implementing a specific application, and the function of the application is implemented by an application program running in a user space. HTTP is a protocol specification that is recorded on a document as an implementation of HTTP that actually communicates via HTTP. The HTTP is communicated based on a B/S architecture, server-side implementation programs of the HTTP include httpd, ngi nx, and the like, and a client-side implementation program of the HTTP is mainly a Web browser.
Joint Photographic Experts Group (JPEG): is a standard for contone still image compression, with the file suffix name jpg or jpeg, the most commonly used image file format. The method mainly adopts a combined coding mode of predictive coding (DPCM), discrete Cosine Transform (DCT) and entropy coding to remove redundant images and color data, belongs to a lossy compression format, can compress the images in a small storage space, and can cause damage to the image data to a certain extent. Especially, the use of an excessively high compression ratio will degrade the quality of the image restored after final decompression, however, the JPEG compression technique is very advanced, and it can remove redundant image data in a lossy compression manner, in other words, it can obtain better image quality with less disk space. Moreover, JPEG is a very flexible format with the capability of adjusting the image quality, allowing files to be compressed with different compression ratios, supporting multiple compression levels.
Portable Network Graphics (PNG): the method is a bitmap format adopting a lossless compression algorithm, and supports the characteristics of index, gray scale, RGB three color schemes, al pha channel and the like. The design objective is to try to replace the gaif and tiiff file formats while adding some features not available with the gaif file format. PNG uses lossless data compression algorithms derived from LZ77 and is typically applied in JAVA programs, web pages or S60 programs because it has a high compression ratio and a small generated file volume. PNG, has the characteristics of small volume, lossless compression, index color mode, more optimized network transmission display, transparent effect support and the like.
Image interchange Format (Graphics I nterchange Format, G if): the name of the G IF Format is an abbreviation of Graphics I technology Format, developed by Compu service in 1987 to fill the gap in the cross-platform image Format. The G if may be supported on a variety of platforms, such as PC and Mact iontosh. The G IF is a bitmap. The general principle of the bitmap is: a picture is composed of a number of pixels, each assigned to a color, which together form the picture. G IF uses Lempe l-Zev-We l ch (LZW) compression algorithm, supporting up to 256 colors. Because of this characteristic, gif is more suitable for less colored pictures such as cartoon characters, company logos, and the like. If one encounters a situation where true color is desired, then the performance of the gif is limited. The gif typically has a palette in which the colors that are needed are stored. In the Web application, the file size of the image will obviously affect the downloading speed, so we can optimize the color palette according to the characteristics of the G if band palette, reduce the number of colors used by the image (some colors that cannot be used by the image can be omitted), and not affect the quality of the image. The biggest difference between the gif format and other image formats is that it is designed entirely as a common standard, and many platforms support the gif format due to the popularity of the Compu service network.
Stream (Stream): in Java, stream processing I O (i nput/output) is used, and Stream (Stream) is an abstract concept, which refers to a series of data (characters or bytes) and is a channel for transmitting information in a first-in first-out manner. When a program needs to read data, it opens a stream to a data source, which may be a file, memory, or network connection. Similarly, when a program needs to write data, a stream to the destination is opened. At this time you can imagine the data as if it were "streaming" through it. In general, the following are the characteristics of the flow: first-in first-out: the data written first into the output stream is read first by the input stream. Sequential access: a string of bytes can be written into the stream one after the other, and read out in the write order, without random access to the intermediate data. Read-only or write-only: each stream can only be one of an input stream or an output stream, and can not have two functions simultaneously, wherein the input stream can only carry out read operation, and the output stream can only carry out write operation. In one data transmission channel, if data is to be written and read, two streams are provided, respectively.
Byte stream (I nputStream): is an abstract class, and the byte stream is generally used for processing files of image, video, audio, PPT, word and the like. The byte stream itself has no buffer, and the efficiency improvement of the buffered byte stream is very high compared with the byte stream.
Internet protocol Address (intemet Protoco l Address, I P Address): the I P protocol is a protocol designed for communication over computer network interconnects. In the internet, it is a set of rules that enable all computer networks connected to the network to communicate with each other, defining rules that computers should follow when communicating over the internet. Any vendor-manufactured computer system can communicate with the internet while complying with the I P protocol. Network systems and devices such as ethernet, packet switching network, etc. produced by various manufacturers cannot communicate with each other, and the main reason for the failure is because the formats of basic units (referred to as frames in the art) of data transmitted by the network systems and devices are different. 5363 the protocol I P is actually a set of protocol software composed of software programs, which converts various "frames" into "I P datagram" format, and this conversion is the most important feature of the internet, so that all kinds of computers can be intercommunicated on the internet, i.e. it has the feature of "openness".
Based on this, embodiments of the present application provide a page resource loading method and apparatus, an electronic device, and a storage medium, which aim to improve stability of page loading and reduce jitter occurring in a page loading process.
Specifically, the following embodiments are provided to explain a page resource loading method and apparatus, an electronic device, and a storage medium, and first describe the page resource loading method in the embodiments of the present application.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. The artificial intelligence (Art I f I c I a l I nte l I gene, AI) is a theory, method, technique and application system for simulating, extending and expanding human intelligence by using a digital computer or a machine controlled by the digital computer, sensing the environment, acquiring knowledge and obtaining the best result by using the knowledge.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The embodiment of the application provides a page resource loading method, and relates to the technical field of Internet. The page resource loading method provided by the embodiment of the application can be applied to a terminal, a server side and software running in the terminal or the server side. In some embodiments, the terminal may be a smartphone, tablet, laptop, desktop computer, or the like; the server side can be configured into an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and cloud servers for providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (content delivery network) and big data and artificial intelligence platforms; the software may be an application or the like that implements a page resource loading method, but is not limited to the above form.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In each embodiment of the present application, when data related to the user identity or characteristic, such as user information, user behavior data, user history data, and user location information, is processed, permission or consent of the user is obtained, and the data collection, use, and processing comply with relevant laws and regulations and standards of relevant countries and regions. In addition, when the embodiment of the present application needs to acquire sensitive personal information of a user, individual permission or individual consent of the user is obtained through a pop-up window or a jump to a confirmation page, and after the individual permission or individual consent of the user is definitely obtained, necessary user-related data for enabling the embodiment of the present application to operate normally is acquired.
Fig. 1 is an optional flowchart of a page resource loading method provided in the embodiment of the present application, and the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, steps S101 to S104.
Step S101, acquiring file attribute information and a file type of a resource to be loaded, and determining a target byte position in the file attribute information according to the file type;
step S102, acquiring target byte data of a target byte position, and determining size information of a resource to be loaded according to the target byte data;
step S103, creating a view container and adjusting the size of the view container according to the size information;
and step S104, filling the resources to be loaded into the adjusted view container.
In steps S101 to S104 illustrated in this embodiment of the present application, before receiving content of a resource to be loaded, file attribute information and a file type of the resource to be loaded are obtained, since target byte positions of size information stored in file attribute information of resources to be loaded of different file types are different, a target byte position in the file attribute information needs to be determined according to the file type, after the target byte position is determined, target byte data of the target byte position is obtained, size information of the resource to be loaded is determined according to the target byte position, a view container for filling the resource to be loaded is created on a page, file content data of the resource to be loaded is received, the resource to be loaded is filled into an adjusted view container, since the file attribute information of the resource to be loaded is sent from a server to a client before the file content data, and the size information of the resource to be loaded is stored in the file attribute information, the client reads out the size information from the file attribute information, adjusts the size of the view container according to the read size information, the size of the view container is a size suitable for the resource to be loaded, when the file content data is received and the file content data is directly analyzed to be loaded, and the size of the view container is adjusted, and the view container is not jittered, and the situation that the view container occurs when the view container is loaded, which occurs.
Illustratively, when the acquired file type is a JPEG file, the format of the JPEG file is fixed, and the JPEG file is formed by sequentially arranging and combining different TAGs (TAGs). As shown in table 1 below and the JPEG file structure table, the width and height information of the JPEG file is included from the beginning of the Start of Frame (SOF) which is the TAG type: specifically, the 4 th to 5 th bytes thereafter represent high pixel values, and the 6 th to 7 th bytes represent wide pixel values. Converted to bytecode positions in the entire file resource then: the 163-164 th bytes are high pixel values, the 165-166 th bytes are wide pixel values, and the 163-164 th bytes and the 165-166 th bytes are target byte positions of the JPEG-type file. The width and height information of the picture, namely the size information of the JPEG file, can be obtained by obtaining the byte data of the 163-164 th byte and the 165-166 th byte, the size of the view container can be set directly according to the size information of the JPEG file (the picture resource content is not filled at the moment), the size of the view container does not need to be adjusted after all data are loaded, and further the culture resource content is refilled. The method can reduce the page jitter caused by readjusting the view container when the data is filled into the view container, improve the stability of the page loading, and reduce the jitter in the loading process of the page.
Figure BDA0004006786350000081
Figure BDA0004006786350000091
TABLE 1 JPEG File Structure Table
Fig. 2 is a flowchart of acquiring a file type of a resource to be loaded in the page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, steps S201 to S202.
Step S201, acquiring first byte data at a first preset byte position in file attribute information;
step S202, determining the file type of the resource to be loaded according to the first byte data.
In steps S201 to S202 illustrated in the embodiment of the present application, each file attribute information of the resource to be loaded has a specific byte position for storing the file type of the resource to be loaded, first byte data at a first preset byte position in the file attribute information of the resource to be loaded is obtained, the first byte data is analyzed to obtain the file type of the resource to be loaded, for example, a JPEG-type picture resource, and a 16-ary system of the first 4 bytes of the file attribute information is denoted as "FFD8FFE0"; and the 16-bit system of the first 4 bytes of file attribute information of the file of the PNG type is represented as '89504E 47'; for a file of the type goif, the 16-ary representation of the first 4 bytes of file attribute information is "47494638". When the file attribute information is acquired, analyzing the data of the first 4 bytes (namely the first preset byte position), and when the analyzed data is 'FFD 8FFE 0', the file type is JPEG; when the analyzed result is '89504E 47', the file type is PNG; when the parsed file is "47494638", it represents that the file type is gif. Because the byte positions of the stored information in the resources to be loaded of different file types are different, the file type is obtained by analyzing the file attribute information, and the speed and the efficiency of subsequently reading the related information are improved.
It should be noted that, the network resource transmission is performed in the form of binary data, and after the connection between the client and the server is established, the client generates an I nputStream object to obtain the binary data transmitted by the server (the binary data is converted into a byte code to be sent to the caller, that is, to the I nputStream through stream conversion processing such as a route, a gateway, a client network frame, and the like). The caller then obtains the data at the corresponding byte position by methods such as I nputstream. In another embodiment of the present application, the file type is obtained by obtaining the first byte data at the first predetermined byte position in the file attribute information by using I nputStream.
Fig. 3 is a flowchart of acquiring file attribute information of a resource to be loaded in the page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, steps S301 to S302:
step S301, receiving byte stream data of resources to be loaded from a server;
step S302, obtaining second byte data at a second preset position in the byte stream data, where the second byte data is file attribute information of the resource to be loaded.
In steps S301 to S302 illustrated in the embodiment of the present application, byte stream data of a resource to be loaded from a server is received, and second byte data at a second preset position in the byte stream data is obtained, where the second byte data is file attribute information of the resource to be loaded, and the file attribute information at the second preset byte position in the byte stream data from the server is obtained first, which is beneficial to improving the speed and efficiency of subsequently reading related information.
It should be noted that, the network resource transmission is performed in the form of binary data, and after the connection between the client and the server is established, the client generates an I nputStream object to obtain the binary data transmitted by the server (the binary data is converted into a byte code to be sent to the caller, that is, to the I nputStream through stream conversion processing such as a route, a gateway, a client network frame, and the like). The caller then obtains the data at the corresponding byte position by methods such as I nputstream. In another embodiment of the present application, the file attribute information is obtained by obtaining a second byte of data at a second predetermined byte position in the file attribute information by using I nputStream.
Fig. 4 is a flowchart of acquiring file attribute information and a file type of a resource to be loaded in the page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, step S401:
step S401, when the resource to be loaded is a picture resource, directly acquiring the file attribute information and the file type of the resource to be loaded.
In step S401 shown in this embodiment of the present application, the resource to be loaded includes a picture resource and a video resource, and when the resource to be loaded is the picture resource, the file attribute information and the file type of the resource to be loaded are directly obtained, that is, the byte stream data of the resource to be loaded from the server in the foregoing embodiment is received, the second byte data at the second preset position in the byte stream data is obtained, where the second byte data is the file attribute information of the resource to be loaded, the first byte data at the first preset byte position in the file attribute information of the resource to be loaded is obtained, and the first byte data is analyzed to obtain the file type of the resource to be loaded.
Fig. 5 is a flowchart of acquiring file attribute information and a file type of a resource to be loaded in the page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, step S501:
step S501, when the resource to be loaded is a video resource, determining a target frame picture of the video resource, and acquiring file attribute information and a file type of the target frame picture.
In step S501 shown in this embodiment of the present application, a resource to be loaded includes a picture resource and a video resource, the video resource is also a frame animation that is finally presented at a client, that is, a picture is sequentially played to form an animation, when the resource to be loaded is the video resource, a target frame picture is determined, file attribute information and a file type of the target frame picture are obtained, that is, byte stream data of the target frame picture of the resource to be loaded from a server is received in the above embodiment, second byte data of a second preset position in the byte stream data is obtained, the second byte data is file attribute information of the target frame picture, then first byte data of a first preset byte position in the file attribute information of the target frame picture is obtained, and the first byte data is analyzed to obtain the file type of the target frame picture.
Fig. 6 is a flowchart of filling a view container in a page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, steps S601 to S602:
step S601, acquiring file content data of a resource to be loaded;
step S602, parsing the file content data and filling the file content data into the view container.
In steps S601 to S602 illustrated in this embodiment of the present application, file content data of a resource to be loaded is obtained, the file content data is analyzed and filled in the view container, after size information of the resource to be loaded is obtained and the size of the view container is adjusted in the above embodiments, the file content data of the resource to be loaded is obtained and analyzed and filled in the view container, and the page shaking caused by adjusting the size of the view container when the data is filled in the view container does not occur, so that the stability of the page loading is improved, and the shaking occurring in the page loading process is reduced.
Fig. 7 is an optional flowchart of the page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, steps S701 to S702:
step S701, sending request information of the resources to be loaded to a server so that the server can inquire the storage condition of the resources to be loaded according to the request information;
step S702, when the storage condition is that the resource to be loaded is stored in the server, receiving a request failure status code fed back by the server based on the request information and byte stream data of the resource to be loaded, wherein the byte stream data comprises file attribute information and file content data.
In steps S701 to S702 illustrated in the embodiment of the present application, the client sends request information of a resource to be loaded to the server, so that the server queries a storage condition of the resource to be loaded according to the request information, and receives a request success status code and byte stream data of the resource to be loaded, where the request success status code and the byte stream data are fed back from the server based on the request information when the storage condition is that the resource to be loaded is stored in the server, and the byte stream data includes file attribute information and file content data.
In addition, in another embodiment of the present application, the client sends request information of resources to be loaded to the server, so that the server first determines whether the client is in a legal connection or not and whether the client is in a white list or not according to the request information; if the I P address of the client requesting the data is prohibited, the resource return cannot be performed; and then the server inquires the storage condition of the resource to be loaded according to the request information, when the storage condition is that the resource to be loaded is stored in the server and the client and the server are still in a connection state, the client receives a request success status code fed back by the server based on the request information and byte stream data of the resource to be loaded, wherein the byte stream data comprises file attribute information and file content data.
Fig. 8 is an optional flowchart of the page resource loading method provided in the embodiment of the present application, where the method in the page resource loading method provided in the embodiment of the present application may include, but is not limited to, step S801:
step S801, when the storage condition is that the resource to be loaded is not stored in the server, receiving a request failure status code fed back from the server based on the request information.
In the step S801 illustrated in the embodiment of the present application, the client sends request information of the resource to be loaded to the server, so that the server queries a storage condition of the resource to be loaded according to the request information, and receives a request failure status code fed back by the server based on the request information when the storage condition is that the resource to be loaded is not stored in the server.
In addition, in another embodiment of the present application, the client sends request information of resources to be loaded to the server, so that the server first determines whether the client is legally connected and is in a white list according to the request information; if the I P address of the client requesting the data is prohibited, the resource return cannot be performed; and then the server inquires the storage condition of the resource to be loaded according to the request information, and when the storage condition is that the resource to be loaded is not stored in the server and the client and the server are still in a connection state, the client receives a request failure state code fed back by the server based on the request information.
Referring to fig. 9, an embodiment of the present application further provides a page resource loading device, which can implement the page resource loading method described above, and the device includes:
the data receiving module is used for acquiring file attribute information and a file type of the resource to be loaded and determining a target byte position in the file attribute information according to the file type;
the byte acquisition module is used for acquiring target byte data of a target byte position and determining size information of resources to be loaded according to the target byte data;
the view container creating module is used for creating a view container and adjusting the size of the view container according to the size information;
and the resource filling module is used for filling the resources to be loaded into the adjusted view container.
The specific implementation of the page resource loading apparatus is substantially the same as the specific implementation of the page resource loading method, and is not described herein again.
The embodiment of the application further provides electronic equipment, the electronic equipment comprises a memory and a processor, the memory stores a computer program, and the processor executes the computer program to realize the page resource loading method. The electronic equipment can be any intelligent terminal including a tablet computer, a vehicle-mounted computer and the like.
Referring to fig. 10, fig. 10 illustrates a hardware structure of an electronic device according to another embodiment, where the electronic device includes:
the processor 1001 may be implemented by a general CPU (central processing unit) such AS a microprocessor, an application specific integrated circuit (App I cat I on Spec I integrated Ci, AS ic), or one or more integrated circuits, and is configured to execute a related program to implement the technical solution provided in the embodiment of the present application;
the Memory 1002 may be implemented in the form of a Read On y Memory (ROM), a static Memory device, a dynamic Memory device, or a Random Access Memory (RAM). The memory 1002 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present disclosure is implemented by software or firmware, the relevant program codes are stored in the memory 1002, and the processor 1001 calls the page resource loading method for executing the embodiments of the present disclosure;
an input/output interface 1003 for realizing information input and output;
a communication interface 1004, configured to implement communication interaction between the apparatus and another apparatus, where the communication may be implemented in a wired manner (e.g., USB, network cable, etc.), or may be implemented in a wireless manner (e.g., mobile network, WI-FI, bluetooth, etc.);
a bus 1005 that transfers information between the various components of the device (e.g., the processor 1001, the memory 1002, the input/output interface 1003, and the communication interface 1004);
wherein the processor 1001, the memory 1002, the input/output interface 1003 and the communication interface 1004 realize communication connections with each other inside the apparatus through a bus 1005.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the method for loading a page resource is implemented.
The memory, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. Further, the memory may include high speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and these remote memories may be connected to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The page resource loading method, the page resource loading device, the electronic device and the storage medium provided by the embodiment of the application acquire the file attribute information and the file type of the resource to be loaded before receiving the content of the resource to be loaded, because the target byte positions of the storage size information in the file attribute information of the resource to be loaded of different file types are different, the target byte position in the file attribute information needs to be determined according to the file type, after the target byte position is determined, the target byte data of the target byte position is acquired, the size information of the resource to be loaded is determined according to the target byte data, the view container for filling the resource to be loaded is created on the page, then the file content data of the resource to be loaded is received, the resource to be loaded is filled into the adjusted view container, the file attribute information of the resources to be loaded is sent to the client by the server before the file content data, and the size information of the resources to be loaded is stored in the file attribute information, so that the client reads the size information from the file attribute information first, adjusts the size of the view container according to the read size information, the size of the view container is the size suitable for the resources to be loaded, and then directly fills the file content data into the view container when receiving and analyzing the file content data, so that the condition that the page shakes due to the fact that the data are filled into the view container and then the size of the view container is adjusted does not occur, the stability of the page during loading is improved, and the shaking condition of the page during loading is reduced. .
The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute limitations on the technical solutions provided in the embodiments of the present application, and it is obvious to those skilled in the art that the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems with the evolution of technologies and the emergence of new application scenarios.
It will be understood by those skilled in the art that the embodiments shown in the figures are not limiting, and may include more or fewer steps than those shown, or some of the steps may be combined, or different steps.
The above-described embodiments of the apparatus are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may also be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
One of ordinary skill in the art will appreciate that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof.
The terms "first," "second," "third," "fourth," and the like (if any) in the description of the present application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the above-described units is only one type of logical functional division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, which are essential or part of the technical solutions contributing to the prior art, or all or part of the technical solutions, may be embodied in the form of a software product stored in a storage medium, which includes multiple instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing programs, such as a usb disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The preferred embodiments of the present application have been described above with reference to the accompanying drawings, and the scope of the claims of the embodiments of the present application is not limited thereto. Any modifications, equivalents and improvements that may occur to those skilled in the art without departing from the scope and spirit of the embodiments of the present application are intended to be within the scope of the claims of the embodiments of the present application.

Claims (10)

1. A page resource loading method is applied to a client, and is characterized by comprising the following steps:
acquiring file attribute information and a file type of a resource to be loaded, and determining a target byte position in the file attribute information according to the file type;
acquiring target byte data of the target byte position, and determining the size information of the resource to be loaded according to the target byte data;
creating a view container and adjusting the size of the view container according to the size information;
and filling the resources to be loaded into the adjusted view container.
2. The page resource loading method according to claim 1, wherein the obtaining the file type of the resource to be loaded comprises:
acquiring first byte data at a first preset byte position in the file attribute information;
and determining the file type of the resource to be loaded according to the first byte data.
3. The page resource loading method according to claim 1, wherein the obtaining of the file attribute information of the resource to be loaded comprises:
receiving byte stream data of resources to be loaded from a server;
and acquiring second byte data of a second preset position in the byte stream data, wherein the second byte data is the file attribute information of the resource to be loaded.
4. The page resource loading method according to claim 1, wherein the resource to be loaded includes a picture resource and a video resource, and the acquiring of the file attribute information and the file type of the resource to be loaded includes one of:
when the resource to be loaded is a picture resource, directly acquiring file attribute information and a file type of the resource to be loaded;
when the resource to be loaded is a video resource, determining a target frame picture of the video resource, and acquiring file attribute information and a file type of the target frame picture.
5. The page resource loading method according to claim 1, wherein the filling the resource to be loaded into the adjusted view container comprises:
acquiring file content data of the resource to be loaded;
and analyzing the file content data and filling the file content data into the view container.
6. The method for loading page resources according to claim 1, wherein before said obtaining the file attribute information and the file type of the resources to be loaded, the method for loading page resources further comprises:
sending request information of resources to be loaded to a server so that the server can inquire the storage condition of the resources to be loaded according to the request information;
and when the storage condition is that the resource to be loaded is stored in the server, receiving a request success status code fed back by the server based on the request information and byte stream data of the resource to be loaded, wherein the byte stream data comprises the file attribute information and file content data.
7. The page resource loading method according to claim 6, wherein after said sending request information of the resource to be loaded to the server, said page resource loading method further comprises:
and when the storage condition is that the resource to be loaded is not stored in the server, receiving a request failure status code fed back by the server based on the request information.
8. An apparatus for loading page resources, the apparatus comprising:
the data receiving module is used for acquiring file attribute information and a file type of a resource to be loaded and determining a target byte position in the file attribute information according to the file type;
the byte acquisition module is used for acquiring target byte data of the target byte position and determining the size information of the resource to be loaded according to the target byte data;
the view container creating module is used for creating a view container and adjusting the size of the view container according to the size information;
and the resource filling module is used for filling the resources to be loaded into the adjusted view container.
9. An electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the page resource loading method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored, which computer program, when being executed by a processor, carries out the page resource loading method of any one of claims 1 to 7.
CN202211638450.4A 2022-12-19 2022-12-19 Page resource loading method and device, electronic equipment and storage medium Pending CN115964584A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211638450.4A CN115964584A (en) 2022-12-19 2022-12-19 Page resource loading method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211638450.4A CN115964584A (en) 2022-12-19 2022-12-19 Page resource loading method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115964584A true CN115964584A (en) 2023-04-14

Family

ID=87357149

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211638450.4A Pending CN115964584A (en) 2022-12-19 2022-12-19 Page resource loading method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115964584A (en)

Similar Documents

Publication Publication Date Title
US7272791B2 (en) Device, method and system for multimedia content adaptation
CN110609965B (en) Page display method, device and storage medium
CN102905045A (en) Method and server for providing picture data to computing terminal
WO2016015564A1 (en) Method and apparatus for displaying document
CN111625308B (en) Information display method and device and electronic equipment
CN102938792B (en) Method and the server of image data are provided to computing terminal
US20170329863A1 (en) Methods and Systems for Tagging Documents and for Compressing Tagged Documents
US20120005564A1 (en) Content distribution system and method
CN109710894A (en) File content extracting method, unit and computer readable storage medium
CN111859210B (en) Image processing method, device, equipment and storage medium
KR20020087482A (en) Object transfer method with format adaptation
EP1341328A1 (en) Data broadcast system, for broadcasting multimedia data; receiving terminal device for receiving said multimedia data
CN105704215B (en) Shared file system and corresponding document sending method and device
CN115964584A (en) Page resource loading method and device, electronic equipment and storage medium
CN113382086B (en) Document transmission method and device, electronic equipment and computer program product
JPWO2015052967A1 (en) Server apparatus, client apparatus, information processing method, and recording medium
KR101012206B1 (en) System and Method for Managing Image Transmission Volume of Web Viewer
CN103631935A (en) Mobile end text and graphics mixed display device and mobile end text and graphics mixed display method
KR20030063559A (en) Method for converting data through extensible markup language
CN109982111B (en) Text content transmission optimization method and device based on live broadcast network system
CN110851155A (en) Method and device for changing theme colors of set top box interface
CN115695850B (en) Video data processing method, device, electronic equipment and medium
JP2015164017A (en) Device, method, and program for providing content
CN103870561A (en) Network picture processing method and system
JP2002342224A (en) Information processing method and information processor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination