Browser kernel-based preposition method, device, equipment, medium and system

The problem of excessive memory footprint is solved by using singleton mode in the browser kernel to ensure browser performance and responsiveness.

CN119025772APending Publication Date: 2024-11-26SHENZHEN GREEN CONNECTION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410996821.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

Network requests from existing browser kernels lead to excessive memory usage, resulting in performance degradation, extended response time, and even lag.

Method used

Using a pre-approach based on the browser kernel, the third-party library is built in a singleton mode, instantiates the storage database and stores the request response data in the local storage database of the client to avoid repeated creation of objects and reduce memory consumption.

Benefits of technology

It effectively reduces the browser memory usage, ensures that the browser program remains in normal operation during long-term use, and improves performance and response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025772A_ABST
    Figure CN119025772A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of browsers, in particular to a browser kernel-based preposition method, device, equipment, medium and system. The method comprises the following steps: performing instantiation operation by taking a library constructed according to a singleton mode as a target library, introducing a name of a local storage database stored in a client, and establishing connection with the storage database; a target front interface is obtained, a front request is generated, and the front request comprises an identifier of the target front interface; reading a front request list, wherein the identification of the executed front interface is stored in the front request list; judging whether an identifier of a target front interface is included in a front request list or not based on the front request; if not, adding the target front interface into a front request list, and executing the front request to obtain request response data; and storing the request response data in a storage database, wherein the storage position is a storage space corresponding to the target front interface. According to the method, memory occupation can be effectively reduced, and running lagging is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of browser technology, and in particular to a browser kernel-based pre-processing method, device, equipment, medium and system. Background Art

[0002] The network request of the browser kernel is usually based on the HTTP protocol. When the application starts, if it needs to access the server data, it will first check whether the data already exists in the program memory. If the data already exists in the memory, it will directly use the data in the memory without initiating a new network request.

[0003] For different business scenarios, applications need to distinguish memory storage locations, which increases development costs. The data in memory is used by the application when it is running, so it will also indirectly increase the application's running memory consumption. As memory consumption increases, the application may become more bloated, resulting in performance degradation. Excessive memory usage may also cause the program to run slower, increase response time, and even cause freezes. Summary of the invention

[0004] The embodiments of the present invention provide a browser kernel-based pre-processing method, device, equipment, medium and system to solve the problem of excessive memory usage in the prior art.

[0005] The present invention discloses a browser kernel-based pre-processing method, comprising:

[0006] Use the third-party library built in singleton mode based on the browser kernel as the target library;

[0007] Instantiate the target database, pass in the name of the storage database, and establish a connection with the storage database, which is stored locally on the client;

[0008] Acquire a target front-end interface, and generate a front-end request based on the target front-end interface, wherein the front-end request includes an identifier of the target front-end interface;

[0009] Reading a pre-request list, wherein the pre-request list stores identifiers of pre-interfaces that have been executed;

[0010] Determining whether the pre-placement request list includes the identifier of the target pre-placement interface based on the pre-placement request;

[0011] If not, adding the target front-end interface to the front-end request list, and executing the front-end request to obtain request response data;

[0012] The request response data is stored in the storage database, and the storage location is a storage space corresponding to the target front-end interface.

[0013] Optionally, after the step of determining whether the target front-end interface is included in the front-end request list, the following steps are included:

[0014] If yes, obtaining a storage space in the storage database corresponding to the target front-end interface, and reading the request response data in the storage space;

[0015] The storage space is deleted, and a new front-end request is generated again based on the target front-end interface.

[0016] Optionally, the step of adding the target front-end interface to the front-end request list and executing the front-end request includes:

[0017] Obtaining the interface address of the target front-end interface, and adding the interface address to the request queue;

[0018] The list state is modified to a preset state, a list loop method is executed, each of the interface addresses in the request queue is traversed, and a corresponding request is initiated according to the interface address.

[0019] Optionally, the step of instantiating the target library further includes:

[0020] Pass in the error callback function;

[0021] After the step of executing the preceding request, the following step is further included:

[0022] If the pre-conditioning request fails to respond, the address of the target pre-conditioning interface and the error message of the server that failed to respond are transmitted to the error callback function, so that the pre-conditioning of the target pre-conditioning interface can be removed in the error callback function.

[0023] Optionally, the method further comprises:

[0024] When the address of the target front-end interface needs to be updated, obtaining the original address and the updated address of the target front-end interface; deleting the storage space in the storage database;

[0025] Based on the original address, it is determined whether the pre-request list includes the target pre-interface; if so, the original address in the pre-request list is replaced with the updated address, and the pre-request is executed according to the updated address.

[0026] Optionally, the step of judging whether the pre-request list includes the identifier of the target pre-interface based on the pre-request includes:

[0027] Circularly filter the pre-placement request list to determine whether the target pre-placement interface has been pre-placed;

[0028] If not, a network interface request is initiated to obtain request response data of the target front-end interface;

[0029] If yes, query the storage database whether there is a storage space corresponding to the target front-end interface, and if yes, return the parameter value in the storage space as the request response data;

[0030] If not, a network interface request is initiated to obtain request response data of the target front-end interface.

[0031] The present invention also discloses a browser kernel-based front-end device, comprising:

[0032] Local module, used to use third-party libraries built in singleton mode based on the browser kernel as target libraries;

[0033] An instance module is used to instantiate the target database, pass in the name of the storage database, and establish a connection with the storage database, which is stored locally on the client;

[0034] A request module, used for obtaining a target front-end interface and generating a front-end request based on the target front-end interface;

[0035] A reading module, used for reading a pre-request list, wherein the pre-request list stores identifiers of pre-interfaces that have been executed;

[0036] A judging module, configured to judge whether the target pre-interface is included in the pre-request list based on the pre-request;

[0037] an execution module, for, if not, adding the target front-end interface to the front-end request list and executing the front-end request to obtain request response data;

[0038] The storage module is used to store the request response data in the storage database, and the storage location is the storage space corresponding to the target front-end interface.

[0039] The present invention also discloses a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes the steps described above.

[0040] The present invention also discloses an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps described above.

[0041] The present invention also discloses a browser kernel-based front-end system, comprising: a network attached storage device and the electronic device as described above, wherein the electronic device is installed with an application program capable of executing the steps of the method as described above.

[0042] Compared with the prior art, the browser kernel-based pre-processing method provided by the embodiment of the present invention has the following beneficial effects:

[0043] When instantiating the target library, the name of the storage database is passed in so that the target library can establish a connection with the storage database. In this way, the request and response data corresponding to the target front-end interface can be stored in the storage database, and the storage database is stored locally on the client. Therefore, when running the browser, it will not occupy a large amount of memory even if it is used for a long time, thereby ensuring that the browser program always maintains normal operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The scheme of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments, in which:

[0045] Figure 1 It is a flowchart of a first embodiment of a browser kernel-based pre-processing method provided by the present invention;

[0046] Figure 2 It is a flowchart of an embodiment of a method for executing a pre-request provided by the present invention;

[0047] Figure 3 It is a flowchart diagram of another embodiment of the browser kernel-based pre-processing method provided by the present invention;

[0048] Figure 4 It is a flow chart of an embodiment of a method for updating a target front-end interface address provided by the present invention;

[0049] Figure 5 It is a flowchart of an embodiment of a method for determining whether a target pre-interface is included in a pre-request list based on a pre-request provided by the present invention;

[0050] Figure 6 It is a structural diagram of an embodiment of a browser kernel-based front-end device provided by the present invention;

[0051] Figure 7 A schematic diagram of the internal structure of an electronic device in one embodiment is shown;

[0052] Figure 8 It is a structural diagram of an embodiment of a front-end system based on a browser kernel provided by the present invention.

[0053] The reference numerals in the figures are:

[0054] 10. Front-end device based on browser kernel; 11. Local module; 12. Instance module; 13. Request module; 14. Read module; 15. Judgment module; 16. Execution module; 17. Storage module; 20. Front-end system based on browser kernel; 21. Electronic device; 22. Network attached storage device. DETAILED DESCRIPTION

[0055] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. Now, in conjunction with the accompanying drawings, the preferred embodiments of the present invention are described in detail.

[0056] See also Figure 1 , Figure 1 1 is a flow chart of a first embodiment of a browser kernel-based pre-processing method provided by the present invention. The browser kernel-based pre-processing method comprises the following steps:

[0057] S101: taking a third-party library built in a singleton mode based on a browser kernel as a target library;

[0058] Third-party libraries based on browser kernels refer to libraries or frameworks provided by third-party developers or organizations that developers can use in web development. These libraries or frameworks can run in a browser environment and provide various functions and tools to enable developers to build web applications more efficiently. These third-party libraries are usually developed based on the features and APIs of browser kernels (such as WebKit, Blink, etc.), and can help developers handle various tasks such as DOM operations, network requests, animation effects, data processing, etc. Some common third-party libraries based on browser kernels include jQuery, React, Vue.js, Angular, Electron, etc.

[0059] In a specific embodiment, Electron is used as an example. Electron is an open source framework that allows developers to build cross-platform desktop applications using Web technologies such as HTML, CSS, and JavaScript. It is based on Chromium and Node.js, which means it uses the browser kernel to render the user interface and can access the native functions of the operating system.

[0060] The library in this embodiment is a library encapsulated based on Axios, which strictly follows the RESTful specification and obtains data through Request.get(xxx,RequestData) or Request({method:"get",params:ParamsData,...}). However, this method will first query whether this interface is pre-set. If it is pre-set, it will directly return the data without initiating any request.

[0061] This third-party library is built according to the singleton pattern. Libraries implemented based on the singleton pattern usually refer to the use of the singleton pattern in software design to ensure that there is only one instance object in the system and provide a global access point to access the instance. In this case, all configuration parameters and logic are managed and executed through this singleton object. By using the singleton pattern, you can avoid repeated object creation, unify resource management, simplify code logic, and provide a global access point to access this object, making it easier to share data and status throughout the system. In third-party libraries implemented based on the singleton pattern, all configuration parameters and logic are managed and executed through this singleton object, ensuring that there is only one instance in the system to handle these configurations and logic, thereby improving the maintainability and scalability of the system.

[0062] S102: Instantiate the target database, input the name of the storage database, and establish a connection with the storage database.

[0063] In a specific implementation scenario, a third-party library built in a singleton mode based on a browser kernel is used as a target library, and an instance of the target library can be created so that the functions and methods of the target library can be used in the program. When instantiating the library, the name of the storage database (e.g., Index DB) needs to be passed so that the target library can establish a connection with the storage database, thereby being able to store and access data in the storage database. IndexedDB is an API for storing structured data in a client browser, which allows client applications to store large amounts of data in the browser without taking up too much memory.

[0064] In this embodiment, the storage database is stored locally on the client. When using IndexedDB, the data will be stored in the client's database instead of being loaded into memory. This allows large amounts of data to be processed without causing memory overflow. IndexedDB uses asynchronous methods for data access and operations, so it can efficiently process large amounts of data without blocking the main thread.

[0065] In other implementation scenarios, when instantiating the target library, the user can pass an error callback function (ErrorCallback function). This error callback function can be used to handle errors or exceptions encountered during the execution of the library. When an error occurs inside the library, this callback function will be called to notify the user or execute specific error handling logic.

[0066] S103: Obtain a target front-end interface, and generate a front-end request based on the target front-end interface.

[0067] In a specific implementation scenario, the interface that needs to be pre-placed is pre-selected as the target pre-placed interface. For example, an interface that does not change frequently can be selected as the target pre-placed interface, or an interface that is used more frequently can be selected as the target pre-placed interface. It can also be based on the dependency relationship between interfaces. Some interfaces may depend on the execution results of other interfaces, and the dependent interfaces need to be pre-placed as the target pre-placed interface. It can also be based on response speed. For example, there are two interfaces A and B in a site under the same domain. When interface A is opened, interface B is not opened at this time. The response speed of interface B can be improved by pre-loading the requests required by interface B after interface A is opened.

[0068] A pre-request is generated based on the target pre-interface. The pre-request may include one or more of the target pre-interface's interface address, interface name, request content, permission data, status data, required time, and resource loading as the identifier of the target pre-interface. The pre-request is used to add the target pre-interface to the pre-request list, thereby implementing the pre-operation on the target pre-interface. A pre-request may correspond to one target pre-interface or to multiple target pre-interfaces, depending on the actual scenario requirements.

[0069] S104: Reading a pre-request list, wherein the pre-request list stores identifiers of pre-interfaces that have been executed.

[0070] In a specific implementation scenario, a pre-request list is preset. When an identifier of a pre-request is added to the pre-request list, it indicates that the pre-request has been executed.

[0071] S105: Determine whether the pre-placement request list includes the identifier of the target pre-placement interface based on the pre-placement request; if not, execute step S106.

[0072] In a specific implementation scenario, after obtaining the pre-request, it is determined whether the pre-request list includes the identifier of the target pre-interface according to the identifier of the target pre-interface in the pre-request, such as the interface name, interface address, etc. If the pre-request list already includes the identifier of the target pre-interface, it means that the target pre-interface has completed the pre-request, and the result data of the request can be directly obtained from the storage database. If the identifier of the target pre-interface is not in the pre-request list, it means that the pre-request of the target pre-interface has not been executed.

[0073] S106: Add the target front-end interface to the front-end request list, and execute the front-end request to obtain request response data.

[0074] In a specific implementation scenario, execute the pre-request corresponding to the target pre-interface, obtain the request response data that the target pre-interface needs to obtain, store the request response data in the storage space corresponding to the target pre-interface in the storage database, and add the target pre-interface that has executed the pre-request to the pre-request list. In this way, if the request response data corresponding to the target pre-interface is needed in the future, the storage space corresponding to the target pre-interface can be found in the storage database to read the request response data. If a pre-request is generated again based on the same target pre-interface in the future, it can be learned by querying the pre-request list that the target pre-interface has already executed the pre-request, and the pre-request will not be executed again.

[0075] S107: Store the request response data in a storage space corresponding to the target front-end interface in a storage database.

[0076] In a specific implementation scenario, when storing request response data, a storage space is constructed in the storage database corresponding to the target front-end interface for storing the request response data. For example, the name of the storage space is the address (API) of the target front-end interface, so that when requesting to obtain the request response data, the corresponding data can be found quickly, thereby improving the efficiency of reading data.

[0077] In other implementation scenarios, if the request response of the target front-end interface fails, the address of the target front-end interface and the error message of the server that failed to respond are transmitted to the error callback function, thereby removing the front-end of the target front-end interface in the error callback function. By passing the error information to the error callback function, the system can take corresponding processing measures according to the specific error situation, such as recording an error log, notifying the user, or executing specific error handling logic. Removing the front-end of the target front-end interface can prevent the continued execution of operations that may cause errors, thereby avoiding further expansion of the problem. This helps the system quickly recover to a stable state after an error occurs, reducing the risk of system crashes or anomalies due to accumulated errors.

[0078] From the above description, it can be seen that in this embodiment, when the target library is instantiated, the name of the storage database is passed in, so that the target library can establish a connection with the storage database, so that the request response data corresponding to the target front-end interface can be stored in the storage database, and the storage database is stored locally on the client. Therefore, when running the browser, it will not occupy a large amount of memory even if it is used for a long time, thereby ensuring that the browser program always maintains a normal operating state.

[0079] In an implementation scenario, the target library provides AddRequestPre method, RemoveRequestPre method, UpdateRequestPre method, RequestQueue method, GetRequestPre method, SetStorageKey method, and GetStorageKey method.

[0080] Generate a pre-request through the AddRequestPre method. The example of using the AddRequestPre method is: Request.AddRequestPre(API Address). API Address is the interface address of the target pre-interface. When a pre-request is generated through the AddRequestPre method, the interface address is stored in the pre-request list RequestPreList. When storing, it will first determine whether this interface address (API Address) already exists in the RequestPreList. If it does, the execution of the AddRequestPre function will be terminated directly. Otherwise, the interface address (API Address) is used as a parameter and handed over to the RequestQueue method in the library for pre-request. When the request response of the target pre-interface is successful, the request response data is formatted as {timestamp:Date.now,value:Response Value} and saved in the Index DB (storage database). Value is the data returned by the interface.

[0081] In one implementation scenario, the name of the storage space in Index DB is set using the SetStorageKey method, and the calling example is: Request.SetStorageKey("XXX"), so that the storage space can be named. When the stored request response data needs to be obtained, the name of the storage space in Index DB is obtained using the GetStorageKey method, and the calling example is: Request.GetStorageKey(). Thus, the request response data corresponding to the target front-end interface is obtained.

[0082] When the request response of the target front-end interface fails, the Error Callback callback function passed above is triggered, and the request address of the target front-end interface and the server error information are passed to the Error Callback function. Thus, the user can call the method of the instantiated object of the target library (RemoveRequestPre method) to remove the front request of the interface. In this way, the user can decide whether to continue preloading the data of a certain interface according to their own needs and logic. This design can increase the flexibility of the target library, allowing users to manage front requests according to specific circumstances, so as to better control the page loading process and data prefetching behavior. The RemoveRequestPre method usage example is: Request.RemoveRequestPre(API Address).

[0083] In one embodiment, when the interface address is stored in the pre-request list RequestPreList, a Map structure is added to the pre-request list RequestPreList to store the target pre-request interface. Map is a collection of key-value pairs, where the key and value can be of any type. The interface address can be used as a key to uniquely identify each target pre-request corresponding to the pre-request, and the value can be any relevant information, such as request parameters.

[0084] When the RemoveRequestPre method is used to remove the pre-request of the target pre-interface, the target pre-interface in RequestPreList is removed through the Map.delete method.

[0085] In other implementation scenarios, the target library also includes the IsRequestPer method, which is a private method. When executed, the IsRequestPer method will loop and filter the RequestPreList in the target library. If the target pre-placed interface exists in the RequestPreList, it indicates that the interface has been pre-placed, otherwise it indicates that the interface has not been pre-placed.

[0086] Please refer to Figure 2 , Figure 2 1 is a flow chart of an embodiment of a method for executing a pre-request provided by the present invention. The method for executing a pre-request comprises the following steps:

[0087] S201: Obtain the interface address of the target front-end interface, and add the interface address to the request queue.

[0088] In a specific implementation scenario, the interface address of the target front-end interface is obtained, and the interface address is added to the request queue. Each interface address in the request queue will be traversed in a loop to execute the front-end request.

[0089] S202: modifying the list state to a preset state, executing the list loop method of the request queue, traversing each interface address in the request queue, and initiating a corresponding request according to the interface address.

[0090] In a specific implementation scenario, a list state is set. When the list state is a preset state, a list loop method is executed to traverse each interface address in the request queue and initiate a corresponding request according to the interface address. When the list state is a non-preset state, the list loop method is not executed on the request queue.

[0091] When executing the list loop method, first define a variable to save the request address of the loop request for the current loop execution attribute list, then delete the loop request for the attribute list, and finally make an interface request for the interface address. If the interface request is responded to, obtain the request response data, and store the request response data in the storage database corresponding to the target front-end interface. If the interface request is not responded to, the address of the target front-end interface and the error message of the server that failed to respond are transmitted to the error callback function, and then the interface address is deleted from the request queue.

[0092] By adding the interface address to the request queue and then cyclically executing the interface requests corresponding to the interface address in the request queue, it can be ensured that the requests are executed in a specific order, the execution process of the request can be optimized, and the page loading speed and user experience can be improved.

[0093] In an implementation scenario, the pre-queue request is executed through the RequestQueue method. The RequestQueue method is used to add a request to the queue, receiving the interface address of the target pre-queue interface as a parameter, and relying on the request queue Queue List. When the RequestQueue method is called, it first checks whether the same interface address already exists in the Queue List property. If the interface address exists in the queue, the method ends directly; if not, the interface address is added to the Queue List to form a request queue.

[0094] The target library in this implementation scenario has a private method While Queue. The While Queue method will modify the list status Exec Status in the target library to true when executed. Therefore, when Exec Status is true, the While Queue method will be executed, otherwise it will not be executed. When the While Queue method is executed, a loop will be started to traverse the interface addresses in the Queue List and execute the corresponding requests. When initiating a request, first define a variable to save the request address of the loop request of the current loop execution attribute list, and then delete this loop request. Then initiate a request for each interface address. If the interface request responds successfully, the result of the successful request is placed in the Index DB. If the interface request responds unsuccessfully, the Error Callback function is triggered, and then the interface address in the Queue List is deleted.

[0095] Please refer to Figure 3 , Figure 3 1 is a flow chart of another embodiment of the browser kernel-based pre-processing method provided by the present invention. The browser kernel-based pre-processing method further includes the following steps:

[0096] S301: taking a third-party library built in a singleton mode based on a browser kernel as a target library;

[0097] S302: Instantiate the target database, input the name of the storage database, and establish a connection with the storage database.

[0098] S303: Obtain a target front-end interface, and generate a front-end request based on the target front-end interface.

[0099] S304: Read a pre-request list, in which identifiers of pre-request interfaces that have been executed are stored.

[0100] S305: Determine, based on the pre-request, whether the pre-request list includes the identifier of the target pre-interface.

[0101] In a specific implementation scenario, steps S301-S305 are substantially consistent with steps S101-S105 in an embodiment of the browser kernel-based pre-processing method provided by the present invention, and will not be described in detail here. If yes, step S306 is executed.

[0102] S306: Acquire a storage space in the storage database corresponding to the target front-end interface setting, and read the request response data in the storage space.

[0103] In a specific implementation scenario, if the target front-end interface is included in the front-end request list, it means that the front-end request of the target front-end interface has been executed and the corresponding request response data has been obtained. Therefore, the request response data in the storage space can be directly read without executing the request operation. According to the description above, a storage space is set in the storage database corresponding to the target front-end interface, and the request response data is stored in the storage space. Specifically, the name of the storage space is the address of the target front-end interface, so the address of the target front-end interface can be obtained, and the request response data can be obtained according to the address.

[0104] S307: Delete the storage space, and generate a new front-end request based on the target front-end interface again.

[0105] In a specific implementation scenario, the request response data has a data consumption problem after being stored. The data consumption problem means that after the data is used, it needs to be removed from the storage in a timely manner to ensure that the data is not consumed repeatedly or causes data confusion. Therefore, after obtaining the request response data, the request response data is deleted from the storage database, indicating that the request response data has been consumed. The storage space can be directly deleted to achieve the deletion of the request response data.

[0106] Then, a new pre-request is generated based on the target pre-interface again and the step S104 is repeated. Specifically, the new pre-request is executed, the request response data is obtained, and the request response data is stored in the storage space corresponding to the target pre-interface in the storage database. The storage space is also newly constructed in the storage database. In this way, the problem of data loading timeliness and the timeliness of interface data can be solved, and it can be ensured that the request response data obtained each time is the latest data.

[0107] In this implementation scenario, the stored data is Index DB, which is a client storage database provided by the browser. Its operation is non-blocking and asynchronous, that is, when a certain operation is performed, the execution of the main thread will not be blocked. When a time-consuming operation of the storage database is executed, the main thread will not be blocked, and other tasks can continue to be performed to maintain the responsiveness of the page. The data is not stored directly in the application's memory, which helps to avoid blocking the execution of the main thread and reduce the impact on garbage collection. By using Index DB to store data, the system does not rely on the browser cache, thereby improving the reliability and stability of the data. By utilizing the asynchronous characteristics of Index DB, this embodiment can better manage the storage and retrieval of large amounts of data while maintaining the smoothness and responsiveness of the page without blocking the user interface or affecting the user experience.

[0108] It can be seen from the above description that in this embodiment, after reading the request response data in the storage space, the storage space is deleted, and a new pre-request is generated again based on the target pre-request interface, so that data duplication or data confusion can be avoided. By deleting the old data and re-requesting, the application can always obtain the latest request response data. Timely deletion of used data can effectively manage storage resources. It avoids unnecessary data accumulation and waste, and keeps the storage database clean and efficient.

[0109] In an implementation scenario, the RemoveData method in the target library is called, and the RemoveData method directly deletes the storage space in the storage database. The request response data is deleted from the storage database through the RemoveData method, indicating that this data has been consumed. Then the address of this target front-end interface is used as a parameter, and the RequestQueue method in the library is called again, and this target front-end interface is pre-added to obtain the corresponding request response data again and cache it in the storage database.

[0110] Please refer to Figure 4 , Figure 4 1 is a flow chart of an embodiment of a method for updating a target front-end interface address provided by the present invention. The method for updating a target front-end interface address comprises the following steps:

[0111] S401: When the address of the target front-end interface needs to be updated, the original address and the updated address of the target front-end interface are obtained; and the storage space in the storage database is deleted.

[0112] In a specific implementation scenario, the address of the target front-end interface needs to be updated. For example, when the system is upgraded or reconstructed, the interface address may change, or the access rights of the interface may change, which may cause the previously stored interface address to be inaccessible. These require updating the address of the target front-end interface. The address of the target front-end interface has changed, and the stored address information needs to be updated in time to ensure that the system can correctly pre-place new interface requests. Obtain the original address and updated address of the target front-end interface so that the original address can be replaced with the updated address later.

[0113] When updating the front-end interface address, if the old data is not cleared, the system may confuse the old and new data, resulting in data inconsistency. In order to ensure the consistency and accuracy of the data, the storage space in the storage database can be deleted, thereby deleting the data corresponding to the old interface address, which can ensure that there is no outdated or invalid data in the system.

[0114] S402: Determine whether the pre-address request list includes the target pre-address interface based on the original address; if so, execute step S403.

[0115] In a specific implementation scenario, the identifier of the target front-end interface is the address of the target front-end interface, so it can be judged based on the original address whether there is an interface with the same address in the front-end request list. If it exists, it proves that the target front-end interface is included in the front-end request list. If it does not exist, it proves that the target front-end interface is not included in the front-end request list. If the target front-end interface is not included in the front-end request list, a front-end request is directly generated according to the updated address, and the method steps after the front-end request is generated are executed, which will not be repeated here.

[0116] S403: Replace the original address in the pre-request list with the updated address, and execute the pre-request according to the updated address.

[0117] In a specific implementation scenario, if the target pre-address interface is included in the pre-address request list, the original address of the target pre-address interface in the pre-address request list is replaced with the updated address, and the pre-address request is executed according to the updated address. New request response data is obtained, a new storage space is constructed in the storage database according to the updated address, and the new request response data is stored in the new storage space.

[0118] It can be seen from the above description that in this embodiment, when the address of the target front-end interface needs to be updated, the storage space of the corresponding target front-end interface in the storage database is deleted to ensure that no old data exists in the system, thereby ensuring data consistency. The original address in the front-end request list is replaced with the updated address. The purpose of this is to ensure that the system can use the latest interface address when requesting data subsequently, avoiding the use of outdated addresses that lead to incorrect or incomplete data acquisition. Executing the front-end request according to the updated address ensures that the system can obtain the latest data.

[0119] In one embodiment, the address of the target front-end interface is updated through the UpdateRequestPre method. An example of the UpdateRequestPre method call is: Request.UpdateRequestPre(Old API Address, NewAPI Address). The Old API Address is the original address, and the New API Address is the updated address. After obtaining the OldAPI Address and the New API Address, the RemoveData method is executed once to delete the storage space in the storage database. The RequestPreList is filtered in a loop to determine whether there is an interface of the Old API Address. If not, the execution is terminated. If so, the Old API Address in the RequestPreList is updated to the New API Address. At the same time, based on the New API Address, the RequestQueue method is called to make a front-end request.

[0120] Please refer to Figure 5 , Figure 5 The method of determining whether a target front-end interface is included in a front-end request list based on a front-end request provided by the present invention comprises the following steps:

[0121] S501: Circularly filter the pre-placement request list to determine whether the target pre-placement interface has been pre-placed; if not, execute step S502; if yes, execute step S503.

[0122] In a specific implementation scenario, after the target front-end interface is obtained, the front-end request list is filtered cyclically to determine whether the target front-end interface is included in the front-end request list. If the front-end request list does not include the target front-end interface, it means that the target front-end interface has not been fronted or requested. If the front-end request list includes the target front-end interface, it means that the target front-end interface has been brought up for fronting.

[0123] S502: Initiate a network interface request to obtain request response data of a target front-end interface.

[0124] In a specific implementation scenario, if the pre-request list does not include the target pre-interface, it means that the target pre-interface has not been pre-required, so a network interface request is initiated to obtain the request response data of the target pre-interface. The request response data can be directly returned to the requester or stored in a storage database. The storage method is the same as that in the previous text and will not be repeated here.

[0125] S503: Query whether there is request response data corresponding to the target front-end interface in the storage database. If yes, execute step S504; if not, execute step S502.

[0126] In a specific implementation scenario, to query whether there is request response data corresponding to the target front-end interface in the storage space, you can find out whether there is a storage space named after the address of the target front-end interface in the storage database. If such a storage space exists, the corresponding request response data exists in the storage database.

[0127] S504: Return the parameter value in the request response data.

[0128] In a specific implementation scenario, if the corresponding request response data exists in the storage database, the parameter value in the request response data is returned to the requesting party.

[0129] From the above description, it can be seen that by first checking whether the required data exists in the storage database, if it already exists, the data can be directly obtained from the storage database without initiating a request to the server again. By reducing the loading time and improving the data access speed, users can obtain the required data faster, thereby improving user experience and satisfaction.

[0130] In a specific implementation scenario, when using Request.get(xxx,RequestData...) or Request({method:"get",params:ParamsData,...}) to obtain data, first determine whether the corresponding interface has been pre-placed. Call the IsRequestPer method in the target library. The IsRequestPer method is a private method. Its function is to loop and filter the RequestPreList in the library to determine whether the specified interface exists in the RequestPreList. If the interface exists, it means that the interface has been pre-placed, and the method returns true; if the interface does not exist, it means that the interface has not been pre-placed, and the method returns false. When the interface has not been pre-placed, initiate a network interface request to obtain the request response data of the target pre-placed interface.

[0131] When an interface has been pre-requested, first check whether the request response data of the required interface already exists in Index DB. If the request response data already exists in Index DB, directly obtain the request response data from the storage database and return the parameter values ​​in the request response data. If the request response data is not found in Index DB, it is necessary to initiate a network request to obtain the request response data of the target pre-request interface.

[0132] Determine whether the required request response data exists in Index DB by calling the ExistsData method in the library. The ExistsData method depends on the DB Name property in the library, which is set by the SetStorageKey method in the library. If this value has never been set, the default is: "RequestPre". After establishing a connection with Index DB, the SetStorageKey method uses the API address of the target front-end interface of the current request as the name of the storage space. This name will be used to locate the stored request response data in IndexDB.

[0133] The ExistsData method attempts to read the storage space corresponding to the address of the target front-end interface from Index DB. If the parameter value can be read from the storage space, the read parameter value is returned. Since the value object contains a timestamp field when adding request response data, the request response data will be deleted from Index DB in this case.

[0134] See also Figure 6 , Figure 6 The schematic diagram of the structure of an embodiment of the browser kernel-based front-end device provided by the present invention is as follows. The browser kernel-based front-end device 10 includes a local module 11, an instance module 12, a request module 13, a reading module 14, a judgment module 15, an execution module 16, and a storage module 17.

[0135] The local module 11 is used to use a third-party library built in a singleton mode based on a browser kernel as a target library, the instance module 12 is used to instantiate the target library, pass in the name of a storage database, establish a connection with the storage database, and the storage database is stored locally on the client; the request module 13 is used to obtain a target front-end interface and generate a front-end request based on the target front-end interface; the reading module 14 is used to read a front-end request list, in which the identifiers of the front-end interfaces that have been executed are stored; the judgment module 15 is used to judge whether the front-end request list includes the identifier of the target front-end interface based on the front-end request; the execution module 16 is used to add the target front-end interface to the front-end request list if not, and execute the front-end request to obtain request response data, and the storage module 17 is used to store the request response data in a storage database, and the storage location is a storage space corresponding to the target front-end interface.

[0136] The judgment module 15 is used to obtain the storage space corresponding to the target front-end interface in the storage database, read the request response data in the storage space, delete the storage space, and generate a new front-end request based on the target front-end interface again.

[0137] The execution module 16 is used to obtain the interface address of the target front-end interface and add the interface address to the request queue; modify the list state to a preset state, execute the list loop method, traverse each interface address in the request queue, and initiate a corresponding request according to the interface address.

[0138] The local module 11 is used to pass in the error callback function; the execution module 14 is used to transmit the address of the target front-end interface and the error information of the server that failed to respond to the error callback function if the front-end request response fails, so that the front-end of the target front-end interface can be removed in the error callback function.

[0139] The browser kernel-based front-end device 10 also includes an update module (not shown), which is used to obtain the original address and update address of the target front-end interface when the address of the target front-end interface needs to be updated; delete the storage space in the storage database; determine whether the target front-end interface is included in the front-end request list based on the original address; if so, replace the original address in the front-end request list with the update address, and execute the front-end request according to the update address.

[0140] The judgment module 15 is used to cyclically filter the pre-conditioning request list to determine whether the target pre-conditioning interface has been pre-conditioning; if not, a network interface request is initiated to obtain the request response data of the target pre-conditioning interface; if so, a query is made as to whether there is a storage space corresponding to the target pre-conditioning interface in the storage database; if so, the parameter value in the storage space is returned as the request response data; if not, a network interface request is initiated to obtain the request response data of the target pre-conditioning interface.

[0141] From the above description, it can be seen that in this embodiment, when the target library is instantiated, the name of the storage database is passed in, so that the target library can establish a connection with the storage database, so that the request response data corresponding to the target front-end interface can be stored in the storage database, and the storage database is stored locally on the client. Therefore, when running the browser, it will not occupy a large amount of memory even if it is used for a long time, thereby ensuring that the browser program always maintains a normal operating state.

[0142] Figure 7 FIG. 1 shows a schematic diagram of the internal structure of an electronic device in an embodiment. The electronic device may be a terminal or a server. Figure 7 As shown, the electronic device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the electronic device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the age recognition method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can implement the age recognition method. Those skilled in the art will understand that Figure 7 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0143] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the above steps.

[0144] In one embodiment, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the processor executes the above steps.

[0145] Please refer to Figure 8 , Figure 8 It is a structural diagram of an embodiment of a front-end system based on a browser kernel provided by the present invention.

[0146] The browser kernel-based front-end system 20 includes the electronic device 21 and the network attached storage device 22 mentioned above. The electronic device 21 is installed with an application program capable of executing the steps of the method described above.

[0147] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0148] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0149] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. For those skilled in the art, the technical solutions described in the above embodiments can be modified, or some of the technical features therein can be replaced by equivalents; and all these modifications and replacements should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A pre-processing method based on the browser kernel. It is characterized in that include: Use the third-party library built in singleton mode based on the browser kernel as the target library; Instantiate the target database, pass in the name of the storage database, and establish a connection with the storage database, which is stored locally on the client; Acquire a target front-end interface, and generate a front-end request based on the target front-end interface, wherein the front-end request includes an identifier of the target front-end interface; Reading a pre-request list, wherein the pre-request list stores identifiers of pre-interfaces that have been executed; Determining whether the pre-placement request list includes the identifier of the target pre-placement interface based on the pre-placement request; If not, adding the target front-end interface to the front-end request list, and executing the front-end request to obtain request response data; The request response data is stored in the storage database, and the storage location is a storage space corresponding to the target front-end interface.

2. The browser kernel-based pre-processing method according to claim 1, It is characterized in that After the step of determining whether the pre-placement request list includes the identifier of the target pre-placement interface based on the pre-placement request, the method further comprises: If yes, obtaining a storage space in the storage database corresponding to the target front-end interface, and reading the request response data in the storage space; The storage space is deleted, and a new front-end request is generated again based on the target front-end interface.

3. The browser kernel-based pre-processing method according to claim 1, It is characterized in that The step of adding the target front-end interface to the front-end request list and executing the front-end request includes: Obtaining the interface address of the target front-end interface, and adding the interface address to the request queue; The list state is modified to a preset state, a list loop method is executed, each of the interface addresses in the request queue is traversed, and a corresponding request is initiated according to the interface address.

4. The browser kernel-based pre-processing method according to claim 1, It is characterized in that The step of instantiating the target library further comprises: Pass in the error callback function; After the step of executing the preceding request, the following step is further included: If the pre-conditioning request fails to respond, the address of the target pre-conditioning interface and the error message of the server that failed to respond are transmitted to the error callback function, so that the pre-conditioning of the target pre-conditioning interface can be removed in the error callback function.

5. The browser kernel-based pre-processing method according to any one of claims 1 to 4, It is characterized in that The method further comprises: When the address of the target front-end interface needs to be updated, obtaining the original address and the updated address of the target front-end interface; deleting the storage space in the storage database; Based on the original address, it is determined whether the pre-request list includes the target pre-interface; if so, the original address in the pre-request list is replaced with the updated address, and the pre-request is executed according to the updated address.

6. The browser kernel-based pre-processing method according to any one of claims 1 to 4, It is characterized in that The step of determining whether the target front-end interface is included in the front-end request list based on the front-end request comprises: Circularly filter the pre-placement request list to determine whether the target pre-placement interface has been pre-placed; If not, a network interface request is initiated to obtain request response data of the target front-end interface; If yes, query the storage database whether there is a storage space corresponding to the target front-end interface, and if yes, return the parameter value in the storage space as the request response data; If not, a network interface request is initiated to obtain request response data of the target front-end interface.

7. A front-end device based on a browser kernel, It is characterized in that include: Local module, used to use third-party libraries built in singleton mode based on the browser kernel as target libraries; An instance module is used to instantiate the target database, pass in the name of the storage database, and establish a connection with the storage database, which is stored locally on the client; A request module, used for obtaining a target front-end interface and generating a front-end request based on the target front-end interface; A reading module, used for reading a pre-request list, wherein the pre-request list stores identifiers of pre-interfaces that have been executed; A judging module, configured to judge whether the target pre-interface is included in the pre-request list based on the pre-request; an execution module, for, if not, adding the target front-end interface to the front-end request list and executing the front-end request to obtain request response data; The storage module is used to store the request response data in the storage database, and the storage location is the storage space corresponding to the target front-end interface.

8. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 6.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 6.

10. A front-end system based on the browser kernel, It is characterized in that include: A network attached storage device and the electronic device as claimed in claim 9, wherein the electronic device has an application installed therein capable of executing the steps of the method as claimed in any one of claims 1 to 6.