Loading method, device, storage medium and electronic device

By receiving load request instructions and obtaining target adapters for independent loading, the code complexity and error troubleshooting problems caused by nesting load logic in the World Wide Web programming environment is solved, and a simpler and more efficient loading process is achieved.

CN112988267BActive Publication Date: 2024-12-17BEIJING DA MI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202110257208.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-09
Publication Date
2024-12-17
Estimated Expiration
2041-03-09

AI Technical Summary

Technical Problem

In the World Wide Web programming environment, different loading logics can be nested together, resulting in high code complexity and difficult to troubleshoot loading errors.

Method used

By receiving load request instructions, obtaining the target adapter and controlling its loading, ensuring that the loading process of each adapter is independent and avoiding nested loading.

Benefits of technology

Reduces code complexity, simplifies the load error troubleshooting process, and improves the maintainability and scalability of loading methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112988267B_ABST
    Figure CN112988267B_ABST
Patent Text Reader

Abstract

The present application discloses a loading method, device, storage medium and electronic device, which belongs to the field of computer technology. The loading method comprises: receiving a loading request instruction for a target service, obtaining a target adapter corresponding to the loading request instruction through an external interface based on the loading request instruction, controlling the target adapter to load, and obtaining a corresponding loading result. Therefore, the complexity of the loading code is reduced in the present application, and it is convenient to troubleshoot errors in the loading process of each adapter.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a loading method, device, storage medium and electronic device. Background Art

[0002] With the development of science and technology, people need to perform more and more business through computers and other electronic devices. Computers and other electronic devices can only get relevant results after loading relevant business. Therefore, the loading method of business is also called one of the research focuses of technical personnel in this field.

[0003] In the related art, different loading logics can be written for the business in the World Wide Web programming environment, and different loading logics can be nested together, resulting in the loading of other nested loading logics during the loading process of one loading logic. Therefore, this loading method has technical problems such as high code complexity and difficulty in troubleshooting loading errors. Summary of the invention

[0004] The embodiments of the present application provide a loading method, device, storage medium and electronic device, which can solve the technical problem that different loading logics in the related art can be nested together, resulting in high code complexity and difficulty in troubleshooting loading errors in the loading method. The technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides a loading method, including:

[0006] Receiving a loading request instruction for a target business;

[0007] Based on the load request instruction, obtaining a target adapter corresponding to the load request instruction through an external interface; wherein the external interface corresponds to at least one adapter;

[0008] The target adapter is controlled to load and a corresponding loading result is obtained.

[0009] In a second aspect, an embodiment of the present application provides a loading device, the device comprising:

[0010] A receiving module, used for receiving a loading request instruction for a target service;

[0011] An acquisition module, used for acquiring a target adapter corresponding to the load request instruction through an external interface based on the load request instruction; wherein the external interface corresponds to at least one adapter;

[0012] The loading module is used to control the target adapter to load and obtain the corresponding loading result.

[0013] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0014] In a fourth aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0015] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:

[0016] When the above-mentioned loading method, device, storage medium and electronic device are working, they first receive a loading request instruction for the target business; then based on the loading request instruction, the target adapter corresponding to the loading request instruction is obtained through the external interface; wherein the external interface corresponds to at least one adapter; finally, the target adapter is controlled to load and the corresponding loading result is obtained. Since each adapter can be pre-defined to correspond to the same external interface in the present application, after receiving the loading request instruction, the target adapter corresponding to the loading request instruction can be directly obtained through the external interface, and the target adapter can be controlled to load. The target adapter will not involve the loading process of other adapters during the loading process, that is, the loading process of each adapter is independent, which greatly reduces the complexity of the code and is more convenient for troubleshooting errors in the loading process of each adapter. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 is a schematic diagram of a network architecture of a loading system provided in an embodiment of the present application;

[0019] Figure 2 is an interactive schematic diagram of a loading method provided in an embodiment of the present application;

[0020] Figure 3 This is a user loading interaction schematic diagram provided in an embodiment of the present application;

[0021] Figure 4 This is a schematic diagram of a loading progress display provided by an embodiment of the present application;

[0022] Figure 5is another interactive schematic diagram of a loading method provided in an embodiment of the present application;

[0023] Figure 6 is a schematic structural diagram of a loading device provided in an embodiment of the present application;

[0024] Figure 7 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0026] When the following description is designed with drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0027] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.

[0028] The present application is described in detail below with reference to specific embodiments.

[0029] Figure 1 An exemplary system architecture 100 is shown that can be applied to the loading method of the present application.

[0030] like Figure 1As shown, the system architecture 100 may include at least a user 101, a processor 102 and a loader 103. Among them, the system architecture 100 can be applied to various practical application scenarios. For example, when the system architecture 100 is applied to online live broadcast, the user 101 can be a teacher or student participating in an online live course. The processor 102 may be responsible for, but not limited to, reading various instructions triggered by the user 101, decoding and executing the instructions, and the final execution of information processing and program operation. The loader 103 may be, but not limited to, used to store a plurality of predefined adapters that can be called by the processor 102. Exemplarily, in the process of an online live course, the user 101 (for example, but not limited to Student A) needs to load Picture 1 and complete the exercises recorded on Picture 1 in order to interact with the teacher. In order to complete the service of loading picture 1, user 101 (for example but not limited to Student A) can click the load button with the mouse to trigger the loading of the service of obtaining picture 1, and then the processor 102 receives the loading request instruction for loading picture 1, obtains the corresponding target adapter in the loader 103 to execute the service of loading picture 1, completes the loading of picture 1, and displays picture 1 to user 101 (for example but not limited to Student A) through the display screen.

[0031] The processor 102 may be hardware or software. When the processor 102 is hardware, it may be a core component such as a central processing unit (CPU) or a modem (MODEM) used for computing and controlling the core of an electronic device. When the processor 102 is software, it may be implemented as multiple software or software modules (for example, for controlling processing services), or it may be implemented as a single software or software module, which is not specifically limited here.

[0032] The loader 103 may be hardware or software. When the loader 103 is hardware, it may be a storage accessory in an electronic device for storing multiple adapters. When the processor 102 loader 103 is software, it may be implemented as multiple software or software modules (for example, for storing storage services), or it may be implemented as a single software or software module, which is not specifically limited here.

[0033] The processor 102 and the loader 103 may exchange data via a network, which may be a wired network or a wireless network. The wired network may include an optical fiber, a twisted pair or a coaxial cable, and the wireless network may include a Bluetooth communication link, a Wireless-Fidelity (Wi-Fi) communication link or a microwave communication link.

[0034] It should be understood that Figure 1The number of users 101, processors 102 and loaders 103 in FIG. 1 is only illustrative. According to implementation requirements, there can be any number of users 101, processors 102 and loaders 103.

[0035] In the following method embodiments, the execution subject may be an electronic device or a processor. For ease of description, only the execution subject of each step is introduced as the processor.

[0036] The following will be combined with the attached Figures 2 to 3 , the loading method provided in the embodiment of the present application is introduced in detail.

[0037] See also Figure 2 , provides an interactive schematic diagram of a loading method according to an embodiment of the present application. The method may include the following steps:

[0038] S201: Receive a loading request instruction for a target service.

[0039] Generally, the target service may refer to the tasks / operations / steps that the electronic device needs to complete in order to meet the different needs of the user. The target service here does not necessarily refer to a certain (or a category) of specific services, and there is no specific limitation, but it may refer to the service determined for the user's current operation, in order to distinguish it from other services being executed. Target services may include: image loading services, audio and video loading services, and text loading services. For example, when student A is taking a live online course, he needs to load an audio and video to explain the knowledge points in detail. For the electronic device, loading the audio and video can be used as the target service.

[0040] The loading request instruction can be an instruction generated by the user through the operation of the keyboard, mouse or screen of the electronic device in order to trigger the loading of the target service. For example, in the process of a live online course, in order to complete the loading of the audio and video target service, student A can click the loading button with his finger, and then the processor detects the interaction of student A, and then obtains the loading request instruction corresponding to the target service, and completes the loading of the audio and video target service based on the loading request instruction. Figure 3 As shown, it is a schematic diagram of user loading interaction. The user can touch the "Confirm Loading" button on the electronic device display screen with his finger to generate a loading request instruction. Then the electronic device completes the loading of the target business of the audio and video based on the loading request instruction, and plays the teaching audio and video in the audio and video playback area on the electronic device display screen.

[0041] Optionally, the loading request instruction can also be generated according to a preset time or time period. For example, during a live online course, when the processor detects that the English class has been going on for 10 minutes, the processor can query in a pre-defined target business and time correspondence table to determine the target business that needs to be completed at this time (for example, but not limited to loading classroom test question 1), and then obtain the corresponding loading request instruction based on the target business.

[0042] Optionally, the loading request instruction can also be generated after detecting a preset trigger condition. For example, during an online live course examination, when the processor detects that Student A has left the range of the electronic device's camera to capture images, it is necessary to load the target task with the voice prompt "The exam is not completed, please do not leave". The processor then obtains the corresponding loading request instruction based on the target business.

[0043] S202: Based on the load request instruction, obtain a target adapter corresponding to the load request instruction through an external interface.

[0044] Generally, after receiving a loading request instruction for a target business, the target business can be loaded based on the loading request instruction. There are various ways to load the target business. For example, the resources corresponding to the target business can be sent to the server so that the server loads the target business based on the resources corresponding to the target business; or the target business can be loaded by calling an adapter for loading the business.

[0045] In the embodiment of the present application, at least one adapter can be pre-written, and the adapter can be considered as a code with execution logic. Each adapter can be stored in a preset storage location so that other events or programs can call the adapter at any time to load the target business. Specifically, each adapter can also be stored in a storage location with a high read / write priority or not easily erased, which can make calling the adapter faster or the adapter more secure.

[0046] Optionally, an external interface can also be generated. The external interface can be considered as a reference type that defines the protocol. The interface can improve the reuse rate of program code and increase the maintainability and scalability of the program. The external interface is matched with the above-mentioned adapters so that other events or programs can directly call any one of the adapters through the external interface.

[0047] Since the external interface corresponds to at least one adapter, there may be a situation where the external interface corresponds to multiple adapters. Therefore, when calling the adapter for loading, it is necessary to select the appropriate adapter corresponding to the load request instruction to avoid loading failure. There are many ways to determine the adapter corresponding to the load request instruction. For example, the adapter corresponding to the load request instruction can be determined by the identifier carried in the load request instruction; the adapter corresponding to the load request instruction can also be determined by the network environment type corresponding to the load request instruction; the adapter corresponding to the load request instruction can also be determined by the business resources of the target business corresponding to the load request instruction. The present application does not limit the method of determining the adapter corresponding to the load request instruction.

[0048] S203: Control the target adapter to load and obtain a corresponding loading result.

[0049] Generally, after obtaining the target adapter corresponding to the load request instruction through the external interface based on the load request instruction, the target adapter can be controlled to load the target service. The processor can obtain the loading progress during the loading process and display the loading progress to the user, such as Figure 4 As shown, it is a schematic diagram of loading progress. There are various forms of progress display, such as displaying real-time loading progress on a display area on an electronic device. In a possible embodiment, the processor can first detect the amount of data that needs to be loaded for the target business. When the amount of data is greater than the data amount threshold, the target business is loaded in segments to improve loading efficiency. In a possible embodiment, after the processor obtains the corresponding loading result, the loading result can be reported. If the loading fails, it can be used to analyze and record the reason for the loading failure, so that the technician can make adjustments.

[0050] As can be seen from the above content, first, a loading request instruction for the target business is received; then, based on the loading request instruction, the target adapter corresponding to the loading request instruction is obtained through the external interface; wherein the external interface corresponds to at least one adapter; finally, the target adapter is controlled to load and the corresponding loading result is obtained. Since each adapter can be pre-defined to correspond to the same external interface in the present application, after receiving the loading request instruction, the target adapter corresponding to the loading request instruction can be directly obtained through the external interface, and the target adapter can be controlled to load. The target adapter will not involve the loading process of other adapters during the loading process, that is, the loading process of each adapter is independent, which greatly reduces the complexity of the code and is more convenient for troubleshooting errors in the loading process of each adapter.

[0051] See also Figure 5 , another interactive schematic diagram of a loading method is provided for an embodiment of the present application. The loading method may include the following steps:

[0052] S501. Define at least one adapter, and establish a corresponding relationship between the at least one adapter and an external interface.

[0053] Generally, the adapter can be considered as a code with execution logic, and each adapter can be stored in a preset storage location so that other events or programs can call the adapter at any time to load the target business. The processor can first generate an external interface. The external interface can be considered to refer to the reference type that defines the agreement. The interface can improve the reuse rate of program code, increase the maintainability and scalability of the program, and establish a corresponding relationship between the external interface and each adapter so that other events or programs can directly call any one of the adapters through the external interface. The adapter can be a script adapter, a network request adapter, and an application adapter, etc. For example: if the user needs to use an application (such as but not limited to an online class live broadcast application), the processor can define an application adapter to meet the user's needs for loading pictures, text, and other services when using the online class live broadcast application.

[0054] S502: Receive a loading request instruction for a target service.

[0055] For details not disclosed in the S502 method step, please refer to the specific description in the above S201 method step.

[0056] In the embodiment of the present application, the method for obtaining the target adapter corresponding to the load request instruction through the external interface based on the load request instruction may not be limited. Two methods are explained below. One method is:

[0057] S503: parse the load request instruction to obtain the load identifier.

[0058] Generally, the loading identifier is an identifier used to instruct the electronic device to determine the target adapter, and different loading identifiers correspond to different adapters. The processor receives a loading request instruction for the target service, parses and processes the loading request instruction, and if the loading request instruction carries a loading identifier, the processor determines the loading identifier, for example: the processor determines that the loading identifier is b. The loading identifier can be a custom identifier or an identifier generated according to the target service information.

[0059] S504: Based on the loading identifier, query the corresponding adapter number in a preset identifier and adapter mapping database, and determine the corresponding target adapter according to the adapter number.

[0060] Generally, after the processor parses the load request instruction to obtain the load identifier, it can query the corresponding adapter number in the preset identifier and adapter mapping database based on the load identifier, and then determine the corresponding target adapter according to the adapter number. For example: As shown in Table 1, the processor presets the load identifier and the adapter mapping database. The processor determines that the load identifier is b, and then determines that the adapter number is 2, then the target adapter is the network request adapter, which is used for loading pictures, texts and other services when the processor makes a network request. The mapping database can be stored in a local storage space. If the amount of data in the mapping database is greater than the data volume threshold, the mapping database can also be stored in the cloud to reduce the storage capacity of the local storage space, which helps to improve the efficiency of service loading.

[0061] Table 1 Relationship between loading identifier and adapter type

[0062] Loading logo Adapter Number Adapter Type a 1 Script Adapter b 2 Network Request Adapter c 3 Generic Application Adapter

[0063] Optionally, another method of obtaining the target adapter corresponding to the load request instruction through the external interface based on the load request instruction is:

[0064] S505: parse the load request instruction to determine the network environment type.

[0065] Generally, a network environment may refer to a working environment in which a processor performs business processing. The network environment type includes at least one of a script environment type, a network request environment type, and an application environment type. For example, when a user uses an online course live broadcast application, he needs to perform image loading, and the processor determines that the environment type of the image loading service is an application environment. After receiving a loading request instruction for a target service, the processor may parse the loading request instruction to determine the network environment type. Different network environment types correspond to different adapters, and the processor may determine the target adapter by determining the network environment type.

[0066] S506: Search for a corresponding adapter in a preset adapter list based on the network environment type, and use the corresponding adapter as a target adapter.

[0067] Generally, after the terminal device parses the load request instruction to determine the network environment type, it searches for a corresponding adapter in a preset adapter list based on the network environment type, and uses the corresponding adapter as the target adapter. For example, as shown in Table 2, which is a preset adapter list, the terminal device determines that the network environment type is a network request environment type, and then searches in the adapter list to determine that the target adapter is a network request adapter.

[0068] Table 2 Network environment type and adapter relationship table

[0069] Network environment type Adapter Type Scripting environment type Script Adapter Network request environment type Network Request Adapter Application environment type Application Adapter

[0070] In the embodiment of the present application, since the target adapter can be at least one of a script adapter, a network request adapter, and an application adapter, the target adapter can be controlled to load according to the specific type of the target adapter. When the target adapter is the script adapter, controlling the target adapter to load includes:

[0071] S507: Create a hypertext markup language tag, obtain a corresponding script file based on the hypertext markup language tag, and load the script file.

[0072] Generally, a hypertext tag is the most basic unit in a hypertext language. A hypertext tag is the most important component of hypertext (an application under the standard universal markup language) and is used to edit the hypertext language. Hypertext tags are case-insensitive. For example, "body" and "subject" have the same meaning, and it is generally recommended to use lowercase. When the electronic device determines that the target adapter is the script adapter, the electronic device can first create a hypertext markup language tag (such as but not limited to an HTML Script tag), then obtain a corresponding script (such as but not limited to a JavaScript file) file based on the hypertext markup language tag, and finally load the script file.

[0073] When the target adapter is the network request adapter, controlling the target adapter to load includes:

[0074] S508: Create a browser object corresponding to the loading request instruction, and load the file data based on the corresponding browser object.

[0075] Generally, when the electronic device determines that the target adapter is the network request adapter, the processor can first create a browser object (such as but not limited to a Firefox browser object, driver = webdriver.Firefox()), obtain and set the browser size (such as but not limited to full screen size) and position, etc. Then the electronic device loads the file data (including but not limited to the protocol file, domain name information file, etc.) based on the corresponding browser object.

[0076] When the target adapter is the common application adapter, controlling the target adapter to load includes:

[0077] S509: Performing environment configuration on the web page view, performing bridge processing through program objects based on the configured web page view environment, and performing communication according to the public interface function after bridging.

[0078] Generally, a web view (WebView) is a control encapsulated on the basis of a browser kernel. WebView is literally translated as a web view, which can be simply regarded as a browser control that can be nested on an interface. Bridging refers to the process of forwarding network data packets based on the address of the link layer of the Open System Interconnection Reference Model (OSI) network model, working at the second layer of OSI. General switches and bridges have bridging functions. Functions in programming languages ​​can be divided into public functions, private functions, and protected functions. When the electronic device determines that the target adapter is the ordinary application adapter, the user can click on the web view WebView to run the user request and bridge with the ordinary application server based on the program object JavascriptBridge method, and then communicate with the two parties by defining a public interface function. When the communication is completed, the final result is confirmed by executing a preset success function, a failure function, or a return function. In a possible embodiment, when the electronic device determines that the target adapter is a light application adapter, for example: the processor can load text, pictures, and other services by calling the loading interface (such as but not limited to the adding interface, the display interface, etc.) provided by the microblog applet.

[0079] In the embodiment of the present application, the processor may call the target adapter to load and various results may occur. When the target adapter is loaded successfully, the corresponding loading results include:

[0080] S510: If the target adapter is loaded successfully, output a first loading success result.

[0081] Generally, after the electronic device calls the target adapter to load, if the target adapter loads the file successfully, it can output a first successful loading result, for example: the electronic device successfully loads the script file and uses the script file as the first successful loading result.

[0082] When the target adapter fails to load, the corresponding loading result includes:

[0083] S511: If the target adapter fails to load, control the target adapter to perform abnormal loading; if the target adapter succeeds, output a second successful loading result. If the target adapter fails to load, control the target adapter to perform abnormal loading.

[0084] Generally, the abnormal record includes repeating the loading at least once, which helps to ensure that the processor loads stably and accurately. When the electronic device fails to load successfully for the first time, the target adapter is controlled to perform abnormal loading. The abnormal loading method can be other forms of loading triggers (such as but not limited to calling alternative methods for loading), or it can be repeated loading for a preset number of times. For example: if the electronic device fails to load successfully for the first time, the preset number of times is set to 5 times, then the processor needs to repeat the loading at least 5 times to determine the abnormal loading result.

[0085] In the embodiment of the present application, after the processor performs an exception load, a variety of exception load results may be obtained, and when the exception load is successful, the results include:

[0086] S512: If the target adapter is loaded successfully during the abnormal loading process of the target adapter, a second loading success result is output.

[0087] Generally, the processor may obtain a successful loading result when performing abnormal loading. For example, the processor repeats loading within 5 times, and if the fourth loading is successful, the script file is taken as the second successful loading result. If the fifth loading is also unsuccessful, it is determined that the loading has failed.

[0088] In case of abnormal loading failure, including:

[0089] S513: If the target adapter fails to load after the abnormal loading process of the target adapter, obtain failure data information.

[0090] Generally, the failure data information may include one or more of an error code, an abnormal message information, an original target triggered by the error, and an error level segment. After the electronic device determines that the target adapter fails to load, the electronic device obtains the failure data information, for example: the error code is 123, the abnormal message information is the network connection failure code 456, the original target code triggered by the error is 789, the error level segment is 6, and it is set in a unified data format {123,456,789,6} and the like.

[0091] S514: Call an exception function to report the failure data information.

[0092] Generally, after the electronic device obtains the failure data information, it triggers the exception function catch and returns the unified data format {123,456,789,6}, which is reported to the monitoring server for processing to facilitate calculation and analysis of the cause of the failure.

[0093] When the scheme of the embodiment of the present application is executed, first a load request instruction for the target business is received; then based on the load request instruction, the target adapter corresponding to the load request instruction is obtained through the external interface; wherein the external interface corresponds to at least one adapter; finally, the target adapter is controlled to load and the corresponding loading result is obtained. Since each adapter can be pre-defined to correspond to the same external interface in the present application, after receiving the load request instruction, the target adapter corresponding to the load request instruction can be directly obtained through the external interface, and the target adapter can be controlled to load. The target adapter will not involve the loading process of other adapters during the loading process, that is, the loading process of each adapter is independent, which greatly reduces the complexity of the code and is more convenient for troubleshooting errors in the loading process of each adapter.

[0094] Optionally, in an embodiment of the present application, in order to ensure that the steps in the above embodiment can be executed sequentially without distinguishing the usage environment and completing the loading and downloading of files in a callback manner, relevant functions can be called according to the language used when writing programs or instructions in practice to ensure that the steps can be executed sequentially.

[0095] For example, when the language used to write a program or instruction is the TypeScript programming language, after receiving the loading request instruction for the target business, you can also load different adapters by calling the await function in the TypeScript programming language. Since the await function must wait for the Promise function to process the loading result before executing the subsequent steps of the await function, the corresponding loading result obtained by loading the target adapter can be regarded as the loading result processed by the Promise function. Then, by using the await function in conjunction with the Promise function to process the loading result, it can be ensured that the steps between the await function and the Promise function processing the loading result can be loaded sequentially, ensuring that the loading process of each adapter is independent, that is, the loading and downloading of files can be completed without distinguishing the usage environment or requiring callbacks.

[0096] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0097] See also Figure 6 , which shows a schematic diagram of the structure of a loading device provided by an exemplary embodiment of the present application, hereinafter referred to as loading device 6. Loading device 6 can be implemented as all or part of the terminal through software, hardware or a combination of both. It includes:

[0098] The receiving module 601 is used to receive a loading request instruction for a target service;

[0099] The acquisition module 602 is used to acquire the target adapter corresponding to the load request instruction through the external interface based on the load request instruction; wherein the external interface corresponds to at least one adapter;

[0100] The loading module 603 is used to control the target adapter to load and obtain the corresponding loading result.

[0101] In a possible embodiment, the loading device 6 further includes:

[0102] A definition module is used to define at least one adapter and establish a corresponding relationship between the at least one adapter and an external interface; wherein the adapter is at least one of a script adapter, a network request adapter and an application adapter.

[0103] In a possible embodiment, the load request instruction carries a load identifier, and the acquisition module 602 includes:

[0104] A first parsing unit, configured to parse the loading request instruction to obtain the loading identifier;

[0105] A first query unit, configured to query a corresponding adapter number in a preset identifier and adapter mapping database based on the loading identifier;

[0106] The determining unit is used to determine the corresponding target adapter according to the adapter number.

[0107] In a possible embodiment, the acquisition module 602 includes:

[0108] A second parsing unit, configured to parse the load request instruction to determine a network environment type; wherein the network environment type includes at least one of a script environment type, a network request environment type, and an application environment type;

[0109] A second query unit, configured to query a corresponding adapter in a preset adapter list based on the network environment type;

[0110] The processing unit is used to use the corresponding adapter as a target adapter.

[0111] In a possible embodiment, when the target adapter is the script adapter, the loading module 603 includes:

[0112] A first creation unit, used for creating a hypertext markup language tag;

[0113] An acquisition unit, used for acquiring a corresponding script file based on the hypertext markup language tag;

[0114] The first loading unit is used to load the script file.

[0115] In a possible embodiment, when the target adapter is the network request adapter, the loading module 603 includes:

[0116] A second creation unit, used to create a browser object corresponding to the loading request instruction;

[0117] The second loading unit is used to load the file data based on the corresponding browser object.

[0118] In a possible embodiment, when the target adapter is the common application adapter, the loading module 603 includes:

[0119] A configuration unit, used to configure the environment of the web page view;

[0120] A bridging unit, used for performing bridging processing through a program object based on a configured web page view environment;

[0121] The communication unit is used for communicating according to the public interface function after bridging.

[0122] In a possible embodiment, the loading module 603 includes:

[0123] A first output unit, configured to output a loading success result if the target adapter is loaded successfully;

[0124] A control unit, configured to control the target adapter to perform abnormal loading if the target adapter fails to load; wherein the abnormal recording includes repeating the loading at least once;

[0125] A second output unit, configured to output a second loading success result if the target adapter is loaded successfully during the abnormal loading process of the target adapter;

[0126] The third output unit is configured to output a loading failure result if the target adapter fails to load after the abnormal loading process of the target adapter.

[0127] In a possible embodiment, the third output unit includes:

[0128] An acquisition subunit, used to acquire failure data information; wherein the failure data information includes one or more of an error code, an abnormal message information, an original target triggered by the error, and a level segment of the error;

[0129] The calling subunit is used to call the abnormal function to report the failure data information for processing.

[0130] The embodiments of this application and Figure 2 or Figure 5 The method embodiments are based on the same concept, and the technical effects they bring are also the same. The specific process can be referred to Figure 2 or Figure 5 The description of the method embodiment will not be repeated here.

[0131] The device 6 can be a field-programmable gate array (FPGA), a dedicated integrated chip, a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processing circuit, a microcontroller unit (MCU), and a programmable logic device (PLD) or other integrated chips.

[0132] When the scheme of the embodiment of the present application is executed, first a load request instruction for the target business is received; then based on the load request instruction, the target adapter corresponding to the load request instruction is obtained through the external interface; wherein the external interface corresponds to at least one adapter; finally, the target adapter is controlled to load and the corresponding loading result is obtained. Since each adapter can be pre-defined to correspond to the same external interface in the present application, after receiving the load request instruction, the target adapter corresponding to the load request instruction can be directly obtained through the external interface, and the target adapter can be controlled to load. The target adapter will not involve the loading process of other adapters during the loading process, that is, the loading process of each adapter is independent, which greatly reduces the complexity of the code and is more convenient for troubleshooting errors in the loading process of each adapter.

[0133] The present application also provides a computer storage medium, which can store multiple instructions, which are suitable for being loaded by a processor and executing the above method steps. The specific execution process can be seen in Figure 2 or Figure 5 The specific description of the illustrated embodiment will not be repeated here.

[0134] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the template control method described in the above embodiments.

[0135] See also Figure 7 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7As shown, the electronic device 7 may include: at least one processor 701 , at least one network interface 704 , a user interface 703 , a memory 705 , and at least one communication bus 702 .

[0136] The communication bus 702 is used to realize the connection and communication between these components.

[0137] The user interface 703 may include a display screen (Display) and a camera (Camera), and the optional user interface 703 may also include a standard wired interface and a wireless interface.

[0138] The network interface 704 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0139] Among them, the processor 701 may include one or more processing cores. The processor 701 uses various interfaces and lines to connect various parts in the entire terminal 700, and executes various functions and processes data of the terminal 700 by running or executing instructions, programs, code sets or instruction sets stored in the memory 705, and calling data stored in the memory 705. Optionally, the processor 701 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 701 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 501, and can be implemented separately through a chip.

[0140] Among them, the memory 705 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 705 includes a non-transitory computer-readable storage medium. The memory 705 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 705 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory 705 may optionally be at least one storage device located away from the aforementioned processor 701. As Figure 7 As shown, the memory 705 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a loaded application program.

[0141] exist Figure 7 In the electronic device 700 shown, the user interface 703 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 701 can be used to call the loading application stored in the memory 705 and specifically perform the following operations:

[0142] Receiving a loading request instruction for a target business;

[0143] Based on the load request instruction, obtaining a target adapter corresponding to the load request instruction through an external interface; wherein the external interface corresponds to at least one adapter;

[0144] The target adapter is controlled to load and a corresponding loading result is obtained.

[0145] In one embodiment, before the processor 701 executes the receiving of the load request instruction for the target service, it is further configured to execute:

[0146] Defining at least one adapter, and establishing a corresponding relationship between the at least one adapter and an external interface;

[0147] The adapter is at least one of a script adapter, a network request adapter and an application adapter.

[0148] In one embodiment, the processor 701 executes the load request instruction carrying the load identifier, and when acquiring the target adapter corresponding to the load request instruction through the external interface based on the load request instruction, specifically executes:

[0149] Parsing the loading request instruction to obtain the loading identifier;

[0150] Based on the loading identifier, querying a preset identifier and adapter mapping database for a corresponding adapter number;

[0151] The corresponding target adapter is determined according to the adapter number.

[0152] In one embodiment, when the processor 701 executes the method of obtaining the target adapter corresponding to the load request instruction through the external interface based on the load request instruction, the processor 701 specifically executes:

[0153] Parsing the loading request instruction to determine the network environment type; wherein the network environment type includes at least one of a script environment type, a network request environment type, and an application environment type;

[0154] Querying a corresponding adapter in a preset adapter list based on the network environment type;

[0155] The corresponding adapter is used as the target adapter.

[0156] In one embodiment, when the target adapter is the script adapter, the processor 701 executes the control of the target adapter to load, specifically executing:

[0157] Create HTML tags;

[0158] Acquire a corresponding script file based on the hypertext markup language tag;

[0159] The script file is loaded.

[0160] In one embodiment, when the target adapter is the network request adapter, the processor 701 executes the control of the target adapter to load, specifically performing:

[0161] Creating a browser object corresponding to the loading request instruction;

[0162] The file data is loaded based on the corresponding browser object.

[0163] In one embodiment, when the target adapter is the common application adapter, the processor 701 executes the control of the target adapter to load by specifically performing:

[0164] Configure the environment for the web view;

[0165] Based on the configured web view environment, bridge processing is performed through program objects;

[0166] Communication is performed based on the public interface functions after bridging.

[0167] In one embodiment, when the processor 701 executes the method of obtaining the corresponding loading result, it specifically executes:

[0168] If the target adapter is loaded successfully, output a loading success result;

[0169] If the target adapter fails to load, controlling the target adapter to perform abnormal loading; wherein the abnormal record includes repeating the loading at least once;

[0170] If the target adapter is loaded successfully during the abnormal loading process of the target adapter, outputting a second loading success result;

[0171] If the target adapter fails to load after the abnormal loading process of the target adapter, a loading failure result is output.

[0172] In one embodiment, when the processor 701 executes the output of the load failure result, it specifically executes:

[0173] Acquire failure data information; wherein the failure data information includes one or more of an error code, an abnormal message information, an original target triggered by the error, and a level segment of the error;

[0174] The exception function is called to report the failure data information for processing.

[0175] The technical concept and Figure 2 or Figure 5 The technical concept is the same as that of Figure 2 or Figure 5 The method embodiments are not described in detail here.

[0176] In an embodiment of the present application, a load request instruction for a target service is first received; then, based on the load request instruction, a target adapter corresponding to the load request instruction is obtained through an external interface; wherein the external interface corresponds to at least one adapter; finally, the target adapter is controlled to load and a corresponding loading result is obtained. Since each adapter can be pre-defined to correspond to the same external interface in the present application, after receiving the load request instruction, the target adapter corresponding to the load request instruction can be directly obtained through the external interface, and the target adapter can be controlled to load. The target adapter will not involve the loading process of other adapters during the loading process, that is, the loading process of each adapter is independent, which greatly reduces the complexity of the code and is more convenient for troubleshooting errors in the loading process of each adapter.

[0177] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0178] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A loading method, characterized in that: The method comprises: Receiving a loading request instruction for a target business; Based on the load request instruction, obtaining a target adapter corresponding to the load request instruction through an external interface; wherein the external interface corresponds to at least one adapter; Control the target adapter to load and obtain a corresponding loading result; wherein obtaining the corresponding loading result includes: if the target adapter is loaded successfully, outputting a first loading success result; if the target adapter fails to load, controlling the target adapter to perform abnormal loading; the abnormal loading includes calling an alternative method to load and repeating the loading a preset number of times; if the target adapter is loaded successfully during the process of the target adapter performing the abnormal loading, outputting a second loading success result; if the target adapter fails to load after the target adapter performs the abnormal loading process, obtaining failure data information; the failure data information includes one or more of an error code, an exception message information, an original target triggered by the error, and an error level segment; setting the failure data information in a unified data format, and calling an exception function to report the failure data information in the unified data format for processing.

2. The method according to claim 1, characterized in that: Before receiving the loading request instruction for the target service, the method further includes: Defining at least one adapter, and establishing a corresponding relationship between the at least one adapter and an external interface; The adapter is at least one of a script adapter, a network request adapter and an application adapter.

3. The method according to claim 1, characterized in that: The load request instruction carries a load identifier, and obtaining a target adapter corresponding to the load request instruction through an external interface based on the load request instruction includes: Parsing the loading request instruction to obtain the loading identifier; Based on the loading identifier, querying a preset identifier and adapter mapping database for a corresponding adapter number; The corresponding target adapter is determined according to the adapter number.

4. The method according to claim 1, characterized in that: The step of obtaining a target adapter corresponding to the load request instruction through an external interface based on the load request instruction includes: Parsing the loading request instruction to determine the network environment type; wherein the network environment type includes at least one of a script environment type, a network request environment type, and an application environment type; Querying a corresponding adapter in a preset adapter list based on the network environment type; The corresponding adapter is used as the target adapter.

5. The method according to claim 2, when the target adapter is the script adapter, controlling the target adapter to load comprises: Create HTML tags; Acquire a corresponding script file based on the hypertext markup language tag; The script file is loaded.

6. The method according to claim 2, when the target adapter is the network request adapter, controlling the target adapter to load comprises: Creating a browser object corresponding to the loading request instruction; The file data is loaded based on the corresponding browser object.

7. The method according to claim 2, when the target adapter is the application adapter, controlling the target adapter to load comprises: Configure the environment for the web view; Based on the configured web view environment, bridge processing is performed through program objects; Communication is performed based on the public interface functions after bridging.

8. A synchronous loading device, characterized in that: include: A receiving module, used for receiving a loading request instruction for a target service; An acquisition module, used for acquiring a target adapter corresponding to the load request instruction through an external interface based on the load request instruction; wherein the external interface corresponds to at least one adapter; A loading module, used for controlling the target adapter to load and obtain a corresponding loading result; wherein, obtaining the corresponding loading result includes: if the target adapter is loaded successfully, outputting a first loading success result; if the target adapter fails to load, controlling the target adapter to perform abnormal loading; the abnormal loading includes calling an alternative method to load and repeating the loading a preset number of times; if the target adapter is loaded successfully during the process of the target adapter performing the abnormal loading, a second loading success result is output; if the target adapter fails to load after the target adapter performs the abnormal loading process, failure data information is obtained; the failure data information includes one or more of an error code, an abnormal message information, an original target triggered by the error, and an error level segment; the failure data information is set in a unified data format, and an abnormal function is called to report the failure data information in the unified data format for processing.

9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps as claimed in any one of claims 1 to 7.

10. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Page loading method and device, computer readable storage medium and terminal equipment

    CN110851756A

  • Paging loading data logic control method and device, computer equipment and medium

    CN111782304A

  • Interface adaptation method, system and device, computer readable medium and electronic equipment

    CN112035270A

  • Picture loading method, device and equipment and readable storage medium

    CN112052419A

  • Bi-directional affinity within a load-balancing multi-node network interface

    US20040003099A1