CN107491334B - Method for organizing and loading preloaded files - Google Patents

Method for organizing and loading preloaded files Download PDF

Info

Publication number
CN107491334B
CN107491334B CN201710757757.9A CN201710757757A CN107491334B CN 107491334 B CN107491334 B CN 107491334B CN 201710757757 A CN201710757757 A CN 201710757757A CN 107491334 B CN107491334 B CN 107491334B
Authority
CN
China
Prior art keywords
resource
loading
configuration file
resources
file
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.)
Active
Application number
CN201710757757.9A
Other languages
Chinese (zh)
Other versions
CN107491334A (en
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.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201710757757.9A priority Critical patent/CN107491334B/en
Publication of CN107491334A publication Critical patent/CN107491334A/en
Application granted granted Critical
Publication of CN107491334B publication Critical patent/CN107491334B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44568Immediately runnable code
    • G06F9/44578Preparing or optimising for loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method for organizing and loading preloaded files, which comprises the following steps: firstly, filing a directory; step two, generating a resource configuration file; acquiring a resource configuration file, and then analyzing the resource configuration file through a corresponding rule to form a resource preloading object list; step four, the resource loader of the main application loads the resource preloading object arrays in batches; step five, directly obtaining the data through a resource manager; and step six, for resources which are not preloaded, such as resources which are loaded continuously after entering the application, the resources can be loaded by using a resource loader, then the resource manager is used for managing the finally loaded resource objects, and the called interfaces are uniform. By using the technical scheme of the application, a good resource configuration file can be formed; and can avoid modified resources from loading the cache file; the resource configuration file is processed in the application, and the whole loading method can be optimized.

Description

Method for organizing and loading preloaded files
Technical Field
The invention relates to a resource or file loading method, in particular to a preloading file organizing and loading method, belonging to the technical field of internet product application,
background
In many websites or PC end applications, mobile end applications, online webcasts, we will often see that a loading page is displayed when entering for the first time, a progress bar (or progress animation) is displayed, and some resources are preloaded. And after the preloading resources are loaded, entering a formal page of the website or entering a main scene of the application. Such a function is called a preload function. The preloading is needed because some resources need to be prepared in advance so as to be clear and smooth in the presentation; otherwise, the user can be very unsmooth while downloading, and the interaction experience is very poor. After the preloading is completed, other resources may be subsequently loaded in the website and the application, and the other resources are separately loaded according to the scene needs.
This patent is primarily concerned with the entire process of preloading. In the preloading process, a loading manager can obtain a url address of a file to be loaded and some related information from a certain place; the display of progress is processed in the loading process; and after the loading is finished, the local available resources can be automatically encapsulated. The whole process needs to consider a plurality of problems: how to better organize the url of the loaded file to form a good resource configuration file; how to avoid modified resources from loading the cache file; how to process the resource profile in the application; how to better display the loading progress; how loaded resources are managed; and details of some optimizations throughout the process. Of course, there are many well-established solutions to the existing preloading functions.
The main technologies of preloading are how to organize preloaded files in the early stage, how to generate preloaded resource configuration files, and how to load resources in the main application. Currently, "preloading" has several different implementations in several different fields, such as H5, where a Link prefetch with its own can implement similar functions; part of the browser also has pre-loader functionality.
Different from the preloading function of a browser and the Link prefetch of H5, the browser-based Link prefetch is based on actionscript3 language of flash, and the preloading function (similar to technical engines based on H5, such as aigret and layobox) in flash application is researched to form a set of good preloading mechanism by combining development of the browser-based preload function and the development of the browser-based preload function on the basis of integrating several preloading schemes. For preloaded files there are generally various types, such as picture formats (jpg, png, gif, etc.), document formats (txt, xml, json, etc.), audio formats (wav, mp3, ogg, etc.), and for gaming applications there may be swf, 3D model file types, etc. The patent adopts a uniform generation mode for the generation of the configuration files of the files; while type differentiation is performed when parsing the configuration file.
Disclosure of Invention
The invention aims to provide a method for forming a good resource configuration file; the organization and the loading method of the preloaded file can avoid the modified resource from loading the cache file and can optimize and manage the loaded resource.
The invention is realized in such a way that:
a method for organizing and loading preloaded files, characterized by:
generating a resource configuration file, separating resource loading and resource management, respectively encapsulating the resource configuration file and the resource management into modules, and comprising the following steps of:
step one, performing catalog filing according to large types on filing and sorting of resources.
And step two, traversing the resource directory to generate a resource configuration file.
And step three, in the main application, when initializing, acquiring the resource configuration file, and then analyzing the resource configuration file through a corresponding rule to form a resource preloading object list.
And step four, the resource loader of the main application loads the resource preloading object arrays in batches.
And step five, directly acquiring the resources through the resource manager at any place of the main application once the resources are required to be acquired.
And step six, for resources which are not preloaded, such as resources which are loaded continuously after entering the application, the resources can be loaded by using a resource loader, and then the resource manager is used for managing the finally loaded resource objects. The interfaces invoked are all unified.
The further scheme is as follows:
in the first step, according to the big type, the directory archiving is performed, and the specific example is as follows: such as all picture types in img directory (whether jpg, png, or other), all audio types in sound directory (whether wav, mp3, or other), … ….
The further scheme is as follows:
in the second step, the format of the resource configuration file is txt text information, and each line in the resource configuration file represents one resource, namely the resource is divided by using a '\ n' character string. The different information in each row is again segmented with "|" characters, organized in the order of "timestamp of file modification time | filename | file path | file size".
The further scheme is as follows:
in the third step, the specific analysis method is as follows: and (5) after reading the resource configuration file generated in the step two, acquiring the text content in the resource configuration file, and then processing the text content by using the corresponding api of the character string to perform truncation. Dividing according to '\ n', obtaining a dimension array, wherein each element corresponds to the information of one resource; then, each element is divided according to '|' to obtain a two-dimensional array, wherein each element is different information of the resource. Thus, through two loop nesting, the encapsulation of each resource preloading object and the encapsulation of one resource preloading object array can be completed.
The further scheme is as follows:
in the fourth step, the display of the progress is processed according to the call-back when loading.
The further scheme is as follows:
in the fourth step, after the resource preloading object array finishes the loading of the resource, the loaded resource and the preloading information are packaged into a final resource object, and the final resource object is put into the resource manager for management.
By utilizing the technical scheme of the application, the url of the loaded file can be better organized to form a good resource configuration file; and can avoid modified resources from loading the cache file; the resource configuration file is processed in the application, and the whole loading method can be optimized.
Drawings
FIG. 1 is a resource organization catalog.
Txt is a schematic diagram of a resource profile version.
FIG. 3 is a resource preload object.
FIG. 4 is a flowchart of the entire process of resource resolution and loading.
Fig. 5 shows two modes of the progress display processing.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings.
The embodiment of the invention provides a method for organizing and loading a preloaded file.
First, there is no strict requirement on the consolidation and archiving of the preloaded resources, as long as it is guaranteed that the corresponding url or relative path can be found in the host application. However, for the convenience of maintenance management, it is still necessary to perform a catalog distinguishing resources by types. The patent is explained based on a network photo album editor application developed by flash, and the organization of the directory is shown in figure 1. Referring to fig. 1, only three layers of directory structures are illustrated, an asset folder is below an application root directory, and html is entered: html, the entry html is wrapped with the design editorcommon. Swf is the master application. Various resources are stored in the assets folder: the flash resources are stored in the swf folder, the picture resources are stored in the img folder, and the audio files are stored in the sound folder. If the rest text files, xml and the like can be stored in the corresponding subfolders.
Second, note that there is a version. txt file inside, which is the resource configuration file and is where the patent focuses on. The generation of the configuration file is specially performed with a small tool, and the tool mainly has the main functions of traversing all sub-files (including files in all levels of sub-files) under an asset folder, reading relative paths (including file names), suffix names, file sizes, modification time and file names of the files, and sequentially writing version. As shown in figure 2. As can be seen in FIG. 2, each file configuration information occupies a line, separated by '\ n'. In each profile, different information is separated by '|'. From left to right are: a time stamp of the file modification time, a file suffix name, a path of the file relative to assets, a file name, and a file size. The configuration file generation tool was also developed by flash air technology.
Then, in the initialization method of the host application, version. And packaging each line of configuration information into a resource preloading object, and putting the resource preloading object array into the resource preloading object. Each resource preloading object (see fig. 3) includes 5 member variables, which respectively correspond to a time stamp of the file modification time, a file suffix name, a path of the file relative to assets, a file name, and a file size. There is also a url method of getter for obtaining the final path of the resource. The method internally splices the domain name, the relative path and the timestamp of the file modification time, so that the newly modified file can be prevented from being loaded from the cache. The host application will then initiate a load manager to bulk load the entire array of resource preload objects. The specific batch loading mode is as follows: traversing the resource preloading object array, starting different types of loaders to load independently according to the type of each resource preloading object, and transmitting two callbacks before loading: and the completed and the progress are respectively used for processing the completion and the progress of a single resource. Meanwhile, after completing the completion of each resource, the loading manager is informed, and the loading manager can increase the number of the completed resources, so that a prompt of 'number loaded/total number' can be displayed. After the type loader loads a single resource, the loaded resource and some pre-loading information are packaged into an Asset object, the types are distinguished, if the type loader is swf, the resource and some pre-loading information are packaged into SWFAsset, and if the type loader is img, the resource and some pre-loading information are packaged into IMGAsset. The Asset objects are put into a resource manager for management, and the subsequent applications are called to acquire corresponding resources and acquired through a uniform resource manager. The whole process is shown in figure 4. Note that in the resource manager, each resource is managed by a key-value pair, the key being the path of the resource and the value being the resource. There is a special Dictionary class in the actionscript3 language of flash to manage.
In the whole process, the configuration file is not necessarily stored in version. In this way, in the initialization method of the main application, the interface is first called to obtain the resource configuration file, and then the subsequent process is performed.
The present invention will be described in further detail with reference to the accompanying drawings.
According to fig. 1, the management of resources should be classified by category.
According to FIG. 2, the profile generation tool traverses the resource directory and then writes the relevant information for each resource into the profile. The specific information includes the relative path (including the file name), the suffix name, the file size, the modification time and the file name of the file, and is written into version.
According to fig. 3, after parsing version.txt, the primary application generates a resource preloading object array, where each resource preloading object manages its own corresponding information, so that a subsequent resource loader loads the information. Note that the url method of getter for resource preload objects, with the end added with "? ver is the timestamp of the modification time ", so that when the resource loader loads, it can automatically identify which files are modified, thereby avoiding loading from the cache.
According to fig. 4, the whole loading process is that the resource configuration file is firstly analyzed to generate a resource preloading object array; then the resource loader carries out classified loading, and the loading display is carried out in the loading process; after each resource object is loaded, a final resource (Asset) object is generated and placed in the resource manager. When the main application wants to acquire the resource, the resource manager can input the key of the resource to acquire the corresponding resource for subsequent processing.
According to fig. 5, when the progress display is processed, there may be two processing modes. One is to process the loading progress only according to the number of the loaded resources/the total number of the resources, at this time, the progress bar is equivalently divided into a plurality of small sections of the total resources, and when the loading of the resources is finished, the progress bar advances one small section to the right; the other method is that on the technology of 'number of loaded resources/total number of resources', single-segment resource progress processing is carried out on the inside of each small segment according to 'loadedBytes/totalBytes' of the current resources.
Although the present invention has been described herein with reference to the illustrated embodiments thereof, which are intended to be preferred embodiments of the present invention, it is to be understood that the invention is not limited thereto, and that numerous other modifications and embodiments can be devised by those skilled in the art that will fall within the spirit and scope of the principles of this disclosure.

Claims (4)

1. A method for organizing and loading preloaded files, characterized by:
generating a resource configuration file, separating resource loading and resource management, respectively encapsulating the resource configuration file and the resource management into modules, and comprising the following steps of:
firstly, filing a directory according to a large type on filing and sorting of resources;
step two, traversing the resource directory to generate a resource configuration file;
the format of the resource configuration file is txt text information, each line in the resource configuration file represents a resource, namely the resource is divided by a '\\ n' character string; the different information in each line is divided by the character of 'I', and the information is organized according to the sequence of 'timestamp of file modification time, | file suffix, | file path, | file size';
step three, in the main application, when initializing, acquiring a resource configuration file, and then analyzing the resource configuration file through a corresponding rule to form a resource preloading object list;
step four, the resource loader of the main application loads the resource preloading object arrays in batches; the batch loading mode is as follows: traversing the resource preloading object array, starting different types of loaders to load independently according to the type of each resource preloading object, and transmitting two callbacks before loading: the completed and progress are respectively used for processing the completion and progress of the single resource; in the fourth step, after each resource preloading object array finishes the loading of the resource, the loaded resource and the preloading information are packaged into a final resource object which is put into a resource manager for management; after completing the completed of each resource, the loading manager is informed, and the loading manager can automatically increase the number of the completed resources, so that a prompt of 'loaded number/total number' can be displayed; after the type loader loads a single resource, the loaded resource and some pre-loading information are packaged into an Asset object, the types are distinguished, if the resource is swf, the resource is packaged into SWFAsset, if the resource is img, the resource object is packaged into IMGAsset, the Asset objects are put into a resource manager for management, and when a subsequent application calls to obtain the corresponding resource, the resource is obtained through a unified resource manager;
step five, in any place of the main application, once the resource needs to be acquired, the resource is directly acquired through a resource manager;
and step six, for resources which are not preloaded, such as resources which are loaded continuously after entering the application, the resources can be loaded by using a resource loader, then the resource manager is used for managing the finally loaded resource objects, and the called interfaces are uniform.
2. The method for organizing and loading preloaded files according to claim 1, wherein:
in the first step, according to the big type, the directory archiving is performed, and the specific example is as follows: all picture types are put in img directory and all audio types are put in sound directory.
3. The method for organizing and loading preloaded files according to claim 1, wherein:
in the third step, the specific analysis method is as follows: after reading the resource configuration file generated in the step two, acquiring the text content in the resource configuration file, and then processing the text content by using the corresponding api of the character string to cut off the text content; dividing according to '\ n', obtaining a dimension array, wherein each element corresponds to the information of one resource; then, each element is divided according to '|' to obtain a two-dimensional array, wherein each element is different information of the resource; thus, through two loop nesting, the encapsulation of each resource preloading object and the encapsulation of one resource preloading object array can be completed.
4. The method for organizing and loading preloaded files according to claim 1, wherein:
in the fourth step, the display of the progress is processed according to the call-back when loading.
CN201710757757.9A 2017-08-29 2017-08-29 Method for organizing and loading preloaded files Active CN107491334B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710757757.9A CN107491334B (en) 2017-08-29 2017-08-29 Method for organizing and loading preloaded files

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710757757.9A CN107491334B (en) 2017-08-29 2017-08-29 Method for organizing and loading preloaded files

Publications (2)

Publication Number Publication Date
CN107491334A CN107491334A (en) 2017-12-19
CN107491334B true CN107491334B (en) 2020-12-15

Family

ID=60651104

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710757757.9A Active CN107491334B (en) 2017-08-29 2017-08-29 Method for organizing and loading preloaded files

Country Status (1)

Country Link
CN (1) CN107491334B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109522055B (en) * 2018-11-01 2022-04-05 中国工商银行股份有限公司 Connection preheating method and system based on distributed service calling
CN110795394B (en) * 2019-11-01 2022-09-30 网易(杭州)网络有限公司 File acquisition method and device
CN111193558B (en) * 2019-12-28 2022-05-06 惠州Tcl移动通信有限公司 Radio frequency parameter calibration method and device, storage medium and mobile terminal
CN112579530B (en) * 2020-12-14 2024-05-14 莱诺斯科技(北京)股份有限公司 Data resource organization method and device of automatic test system
CN112691382B (en) * 2021-01-15 2023-02-28 腾讯科技(深圳)有限公司 Resource processing method, device and computer readable storage medium
CN112764732B (en) * 2021-01-25 2024-03-08 百果园技术(新加坡)有限公司 Code generation method and device applied to loading target resource

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598679A (en) * 2016-12-21 2017-04-26 北京奇虎科技有限公司 Method and device for loading picture resources

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7055113B2 (en) * 2002-12-31 2006-05-30 Lsi Logic Corporation Simplified process to design integrated circuits
US8316361B2 (en) * 2003-01-09 2012-11-20 Hewlett-Packard Development Company, L.P. Method of enabling a user to update one or more low-level resources of a computer system in a user-friendly manner
US8510711B2 (en) * 2006-05-30 2013-08-13 Siemens Aktiengesellschaft Central strategy management component for providing semantic-free administration functions for a system of applications
CN102662676B (en) * 2012-04-16 2014-12-24 厦门游家网络有限公司 Method, system and equipment for batch addition and loading of progress bar for Flash game
CN102855311A (en) * 2012-08-24 2013-01-02 乐视网信息技术(北京)股份有限公司 Intelligent file resource loader and intelligent file resource loading method
CN103412782B (en) * 2013-09-04 2017-03-22 广东全通教育股份有限公司 Dynamic resource loading method and system based on flash
US9727215B2 (en) * 2013-11-11 2017-08-08 Htc Corporation Method for performing multimedia management utilizing tags, and associated apparatus and associated computer program product
CN105630556B (en) * 2015-12-25 2019-02-19 北京像素软件科技股份有限公司 A kind of method and system loading resource
CN106502729B (en) * 2016-10-09 2019-05-17 武汉斗鱼网络科技有限公司 A kind of the resource loading method and system of Flash player

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598679A (en) * 2016-12-21 2017-04-26 北京奇虎科技有限公司 Method and device for loading picture resources

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
华为手机如何设置文件管理;江南第七;《https://jingyan.baidu.com/article/7908e85ca1a024af481ad289.html》;20160406;全文 *

Also Published As

Publication number Publication date
CN107491334A (en) 2017-12-19

Similar Documents

Publication Publication Date Title
CN107491334B (en) Method for organizing and loading preloaded files
US10936179B2 (en) Methods and systems for web content generation
Buels et al. JBrowse: a dynamic web platform for genome visualization and analysis
CN108984714B (en) Page rendering method and device, electronic equipment and computer readable medium
US7490167B2 (en) System and method for platform and language-independent development and delivery of page-based content
CN102521230B (en) For the result type that data with good conditionsi show
US10572581B2 (en) System and method for web content presentation management
US9015657B2 (en) Systems and methods for developing and delivering platform adaptive web and native application content
US20170242665A1 (en) Generation of hybrid enterprise mobile applications in cloud environment
US20130132422A1 (en) System and method for creating and controlling an application operating on a plurality of computer platform types
US9026608B1 (en) Methods and systems for application programming interface mashups
US20140115442A1 (en) Conversion of a presentation to darwin information typing architecture (dita)
CN105589959A (en) Form processing method and form processing system
US10262073B2 (en) Generating and distributing interactive documents
US10567472B2 (en) Manipulation of PDF files using HTML authoring tools
US11843679B2 (en) Automated dependency management based on page components
CN102467502A (en) Retrieval method and system
US20230177103A1 (en) Systems and methods for rendering interactive web pages
US20150277723A1 (en) Exporting a component of a currently displayed user interface to a development system
US10102122B2 (en) Personal computing device for editing mainframe data
Means Node for Front-End Developers: Writing Server-Side JavaScript Applications
CN117873627A (en) Data operation page building method and device, electronic equipment and storage medium
CN117010338A (en) Document editing method, apparatus, device, medium, and program product
Del Sole et al. Creating ASP. NET Core Web Applications
de Freitas Alves Declarative Approach to Data Extraction of Web pages

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
GR01 Patent grant
GR01 Patent grant