Single-page application resource loading exception processing method and device and related equipment

By monitoring the resource load feedback information of a single page application in real time and calling the exception handling hook of the build tool plug-in, the resource waste caused by resource loading exceptions of a single page application is solved, and the stability and efficiency of resource loading are improved.

CN119311443APending Publication Date: 2025-01-14SF TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202310870419.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-14
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

During the on-demand loading process of a single page application, the change in resource address leads to network request errors, resulting in page crashes and resource waste.

Method used

By sending request information to the preset target server, receiving feedback information, determining whether the resource loading is abnormal, identifying the exception type, and calling the exception processing hook in the build tool plug-in for processing, obtaining the processing result data for page rendering, avoiding the front-end and Multiple communication between servers.

Benefits of technology

It effectively avoids resource waste, reduces page crashes and user waiting time caused by resource loading exceptions, and improves the stability and efficiency of resource loading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311443A_ABST
    Figure CN119311443A_ABST
Patent Text Reader

Abstract

The invention provides a single-page application resource loading exception processing method and device and related equipment. The method comprises the following steps: sending first request information for acquiring a target static resource to a preset target server; feedback information of the target server is received; based on the feedback information, judging whether resource loading of the target single-page application is abnormal or not; if the resource loading of the target single page application is abnormal, identifying an abnormal feedback type of the feedback information; if the identification result represents that the type of the feedback information is a first exception feedback type, calling a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single page application, and obtaining processed result data; and according to the result data, performing page rendering on the target single-page application. Therefore, repeated communication between the front end and the target server is avoided, and resource waste is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and in particular to a method, device and related equipment for handling exceptions in loading resources of a single-page application. Background Art

[0002] Single Page Application (SPA) refers to a website with only one HTML page, and all functions and interactions are completed in this single page. More resources are loaded at one time.

[0003] On-demand loading is a major measure for front-end performance optimization. As the name implies, on-demand loading means loading resources as needed. In js, we generally trigger some loading actions through some user behaviors or scheduled tasks. For example, but not limited to the following situations: mouse click, text input, scroll bar pull, mouse movement, window size change, etc. The loaded files can be JS, pictures, CSS, HTML, etc. This is on-demand loading.

[0004] However, when users are using an application, after the application developer performs version upgrades or other updates to the application, the address of the content to be loaded on demand changes. When using this resource, an error will occur in the network request, causing the page to crash and waste resources. Summary of the invention

[0005] The present application provides a method, device and related equipment for handling resource loading exceptions in a single-page application, aiming to solve the problem of resource waste caused by on-demand loading exceptions.

[0006] On the one hand, the present application provides a method for handling resource loading exceptions in a single-page application, the method comprising:

[0007] Sending first request information for acquiring target static resources to a preset target server;

[0008] receiving feedback information from the target server;

[0009] Based on the feedback information, determine whether resource loading of the target single-page application is abnormal;

[0010] If an exception occurs in resource loading of the target single-page application, identifying an abnormal feedback type of the feedback information;

[0011] If the recognition result indicates that the type of the feedback information is a first exception feedback type, calling a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single-page application, and obtaining processing result data;

[0012] The target single-page application is rendered according to the result data.

[0013] In a possible implementation of the present application, judging whether resource loading of the target single-page application is abnormal based on the feedback information includes:

[0014] identifying content of the feedback information;

[0015] If the content includes abnormal feedback information, determining that the resource loading of the target single-page application is abnormal;

[0016] If the content does not include abnormal feedback information, it is determined that the resource loading of the target single-page application is normal.

[0017] In a possible implementation of the present application, after identifying the abnormal type of the feedback information and obtaining the identification result, the method further includes:

[0018] If the identification result is that the type of the feedback information is the second exception feedback type, a second exception handling hook in a preset construction tool plug-in is called to obtain processing result data.

[0019] In a possible implementation of the present application, calling the second exception handling hook in the preset construction tool plug-in includes:

[0020] Call the second exception handling hook in the preset build tool plug-in;

[0021] Based on the second exception handling hook, calling the preset on-demand loading module and recording the number of calls;

[0022] Based on the on-demand loading module and the recorded call times, return structure data is determined.

[0023] In a possible implementation of the present application, before calling the first exception handling hook in the preset construction tool plug-in, the method further includes:

[0024] Building an initial system, and connecting a preset building tool plug-in to the initial system to obtain a target system;

[0025] The target system is stored in a target storage medium.

[0026] In a possible implementation of the present application, the method further includes:

[0027] Generate feedback information to be evaluated;

[0028] Sending the feedback information to be evaluated to a preset user terminal;

[0029] Receive evaluation feedback information sent by the user terminal.

[0030] In a possible implementation of the present application, after rendering the target single-page application according to the returned data, the method further includes:

[0031] Get page operation data;

[0032] The page operation data is classified to obtain operation classification data.

[0033] On the other hand, the present application provides a single-page application resource loading exception handling device, the device comprising:

[0034] A first sending unit, used to send first request information for acquiring a target static resource to a preset target server;

[0035] A first receiving unit, configured to receive feedback information from the target server;

[0036] A first judgment unit, configured to judge whether an abnormality occurs in resource loading of a target single-page application based on the feedback information;

[0037] A first identification unit, configured to identify an abnormal feedback type of the feedback information if an abnormality occurs in resource loading of the target single-page application;

[0038] A first calling unit is configured to call a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single-page application if the recognition result indicates that the type of the feedback information is a first exception feedback type, and obtain processing result data;

[0039] The first rendering unit is used to render the target single-page application according to the result data.

[0040] In a possible implementation of the present application, the first determination unit is specifically configured to:

[0041] identifying content of the feedback information;

[0042] If the content includes abnormal feedback information, determining that the resource loading of the target single-page application is abnormal;

[0043] If the content does not include abnormal feedback information, it is determined that the resource loading of the target single-page application is normal.

[0044] In a possible implementation of the present application, after identifying the abnormal type of the feedback information and obtaining the identification result, the device further includes:

[0045] The second calling unit is used to call a second exception handling hook in a preset construction tool plug-in and obtain processing result data if the identification result is that the type of the feedback information is a second exception feedback type.

[0046] In a possible implementation of the present application, the calling of the second exception handling hook in the preset construction tool plug-in is specifically used to:

[0047] Call the second exception handling hook in the preset build tool plug-in;

[0048] Based on the second exception handling hook, calling the preset on-demand loading module and recording the number of calls;

[0049] Based on the on-demand loading module and the recorded call times, return structure data is determined.

[0050] In a possible implementation of the present application, before calling the first exception handling hook in the preset construction tool plug-in, the device is further used to:

[0051] Building an initial system, and connecting a preset building tool plug-in to the initial system to obtain a target system;

[0052] The target system is stored in a target storage medium.

[0053] In a possible implementation of the present application, the device is further used for:

[0054] Generate feedback information to be evaluated;

[0055] Sending the feedback information to be evaluated to a preset user terminal;

[0056] Receive evaluation feedback information sent by the user terminal.

[0057] In a possible implementation of the present application, after rendering the target single-page application according to the returned data, the device is further configured to:

[0058] Get page operation data;

[0059] The page operation data is classified to obtain operation classification data.

[0060] On the other hand, the present application also provides a computer device, the computer device comprising:

[0061] one or more processors;

[0062] Memory; and

[0063] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the single-page application resource loading exception handling method.

[0064] On the other hand, the present application also provides a computer-readable storage medium on which a computer program is stored, and the computer program is loaded by a processor to execute the steps in the single-page application resource loading exception handling method.

[0065] Beneficial effects:

[0066] The single-page application resource loading exception handling method provided by the present application includes sending a first request information for obtaining a target static resource to a preset target server; receiving feedback information from the target server; judging whether the resource loading of the target single-page application is abnormal based on the feedback information; if the resource loading of the target single-page application is abnormal, identifying the abnormal feedback type of the feedback information; if the identification result indicates that the type of the feedback information is the first abnormal feedback type, calling the first exception handling hook in the preset construction tool plug-in to handle the resource loading exception of the target single-page application and obtain the processing result data; according to the result data, rendering the target single-page application. Compared with the traditional method, the present application monitors the feedback information of the target server in the process of loading resources of the single-page application in real time. When an abnormality is identified, the first exception handling hook in the preset construction tool plug-in can be used for intervention processing, thereby avoiding multiple communications between the front end and the target server and reducing resource waste. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0068] Figure 1 It is a scenario diagram of a single-page application resource loading exception handling system provided by an embodiment of the present application;

[0069] Figure 2 It is a flowchart of an embodiment of a method for handling exceptions in loading resources of a single-page application provided in an embodiment of the present application;

[0070] Figure 3 It is a schematic diagram of the structure of an embodiment of a single-page application resource loading exception handling device provided in an embodiment of the present application;

[0071] Figure 4It is a schematic diagram of the structure of an embodiment of a computer device provided in the embodiments of the present application. DETAILED DESCRIPTION

[0072] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0073] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the said features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0074] In this application, the word "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any technician in the field to implement and use the present application. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present application can be implemented without using these specific details. In other instances, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present application with unnecessary details. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0075] The embodiments of the present application provide a method, apparatus and related equipment for handling exceptions in loading resources of a single-page application, which are described in detail below.

[0076] like Figure 1 As shown, Figure 11 is a schematic diagram of a scenario of a single-page application resource loading exception handling system provided in an embodiment of the present application. The single-page application resource loading exception handling system may include a computer device 100, in which a single-page application resource loading exception handling device is integrated, such as Figure 1 A computer device 100 in FIG.

[0077] In the embodiment of the present application, the computer device 100 is mainly used to send a first request information for obtaining a target static resource to a preset target server; receive feedback information from the target server; based on the feedback information, determine whether an exception occurs in the resource loading of the target single-page application; if an exception occurs in the resource loading of the target single-page application, identify the abnormal feedback type of the feedback information; if the identification result indicates that the type of the feedback information is the first abnormal feedback type, call a first exception handling hook in a preset build tool plug-in to handle the resource loading exception of the target single-page application, and obtain the processing result data; according to the result data, render the page of the target single-page application.

[0078] In the embodiment of the present application, the computer device 100 may be a terminal or a server. When the computer device 100 is a server, it may be an independent server, or a server network or server cluster composed of servers. For example, the computer device 100 described in the embodiment of the present application includes but is not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server constructed by a plurality of servers. The cloud server is constructed by a large number of computers or network servers based on cloud computing.

[0079] It is understandable that when the computer device 100 in the embodiment of the present application is a terminal, the terminal used may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. Such a device may include: a cellular or other communication device having a single-line display or a multi-line display or a cellular or other communication device without a multi-line display. The specific computer device 100 may be a desktop terminal or a mobile terminal, and the computer device 100 may also be one of a mobile phone, a tablet computer, a laptop computer, a medical auxiliary instrument, etc.

[0080] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the present application solution, and is not intended to limit the application scenario of the present application solution. Other application environments may also include Figure 1 More or less computer equipment as shown in Figure 1Only one computer device is shown in the figure. It can be understood that the single-page application resource loading exception handling system can also include one or more other computer devices, which are not specifically limited here.

[0081] In addition, if Figure 1 As shown, the single-page application resource loading exception handling system may also include a memory 200 for storing data, such as storing feedback information of the target server and single-page application resource loading exception handling data, such as single-page application resource loading exception handling data when the single-page application resource loading exception handling system is running.

[0082] It should be noted that Figure 1 The scenario diagram of the single-page application resource loading exception handling system shown is merely an example. The single-page application resource loading exception handling system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided by the embodiment of the present application. A person of ordinary skill in the art can know that with the evolution of the single-page application resource loading exception handling system and the emergence of new business scenarios, the technical solution provided by the embodiment of the present application is also applicable to similar technical problems.

[0083] Next, a single-page application resource loading exception handling method provided in an embodiment of the present application is introduced.

[0084] In the embodiment of the single-page application resource loading exception handling method of the present embodiment, a single-page application resource loading exception handling device is used as the execution body. For the sake of simplicity and convenience of description, the execution body will be omitted in the subsequent method embodiments. The single-page application resource loading exception handling device is applied to a computer device. The method includes: sending a first request information for obtaining a target static resource to a preset target server; receiving feedback information from the target server; based on the feedback information, determining whether an exception occurs in the resource loading of the target single-page application; if an exception occurs in the resource loading of the target single-page application, identifying the abnormal feedback type of the feedback information; if the identification result indicates that the type of the feedback information is the first abnormal feedback type, calling the first exception handling hook in the preset construction tool plug-in to handle the resource loading exception of the target single-page application, and obtaining the processing result data; and rendering the target single-page application page according to the result data.

[0085] See also Figures 2 to 4 , Figure 2 This is a flow chart of an embodiment of a method for handling exceptions in loading resources of a single-page application provided in an embodiment of the present application. The method for handling exceptions in loading resources of a single-page application includes steps 201 to 206:

[0086] 201. Sending first request information for acquiring a target static resource to a preset target server;

[0087] Among them, the preset target server is the backend server to be accessed. In Web applications, the backend server is the core part of implementing the application. It is mainly responsible for processing data, logic and business processes, and transmitting data between the client and the database. In layman's terms, it is like a machine that provides various services and support for websites or applications. The backend server usually runs on a remote computer (also called a server) connected to the user's device through the Internet. Users access the website or application on their devices and make requests to the backend server. The backend server executes the corresponding code based on the request, such as retrieving data from the database or generating dynamic content (such as news releases or search results). The backend server then sends the response back to the client device to display a web page or other application interface. The backend server consists of multiple components, including an operating system, a Web server, a database server, and an application server. These components need to be configured reasonably and properly managed to ensure safe and efficient operation. At the same time, the backend server also needs to interact with the front-end code and other third-party APIs (application programming interfaces), so developers need to master relevant programming languages ​​and technologies, such as Python, Java, Ruby, etc., and use a series of tools and frameworks to assist in development.

[0088] In this embodiment, static resources refer to files or data that do not need to be dynamically generated in a website or application, including but not limited to HTML files, CSS style sheets, JavaScript scripts, images, font files, etc. Preferably, the characteristic of these resources is that they have a fixed copy on the server and are directly returned when requested by the client.

[0089] 202. Receive feedback information from the target server;

[0090] 203. Based on the feedback information, determine whether resource loading of the target single-page application is abnormal;

[0091] Among them, some abnormal situations may occur during the resource loading process of the target single-page application. The following are the situations where resource loading abnormalities may occur:

[0092] Network error: Network problems are one of the most common anomalies when loading resources. For example, the request may fail because the server is down, the network is disconnected, or other reasons. Timeout: If the resource takes a long time to load, the browser / client may think that the request has timed out and cancel the request. This can usually be solved by increasing the loading time (timeout). Large number of JavaScript code files: When using a large number of JavaScript files in a single-page application, the browser will have to process and download more files, which will increase the loading time. In this case, technologies such as Webpack code splitting can be used to reduce the number and size of JavaScript files. Cache problem: If the cache is disabled or the resource has been updated, the browser may refuse to extract the resource from the cache and trigger a re-request. Performance bottleneck: Due to various reasons, the server may not be able to respond to all resource requests. For example, high CPU load, excessive memory consumption, etc. This can be alleviated by using CDN and better server hardware. Therefore, when loading resources in a single-page application, you need to pay attention to the above situations and ensure corresponding handling measures to ensure that the resources are loaded effectively.

[0093] Therefore, after receiving the feedback information from the target server, it is necessary to preliminarily determine whether there is an abnormality in the resource loading of the target single-page application. The specific determination method is as follows:

[0094] Exemplarily, judging whether an abnormality occurs in the resource loading of the target single-page application based on the feedback information includes: identifying the content of the feedback information; if the content includes abnormal feedback information, determining that the resource loading of the target single-page application is abnormal; if the content does not include abnormal feedback information, determining that the resource loading of the target single-page application is normal, wherein the abnormal feedback information includes: 404, network error.

[0095] Specifically, 404 is an HTTP status code that indicates that the web server cannot find the requested resource. In a web browser, when you try to access a non-existent web page, a "404 Not Found" error message is usually displayed, which means that the server cannot find the requested web page. It can happen in any browser and on any device, not just a computer or mobile phone. Usually, there are many possible reasons for a 404 error, such as the website administrator may have deleted the page, the user entered an incorrect URL address, or the network connection is abnormal. A network error is an error message that usually appears in network use, which means that a problem occurred during the communication process between the server and the client. This problem can be caused by a variety of reasons, such as a server crash, a connection timeout, a DNS resolution error, etc. When a network error occurs, it may prevent users from accessing application services or websites that require network support, and it may also cause the current network connection to be unstable. Solutions include checking the local network connection, ensuring that the server service is running normally, etc. If the problem still exists, you can try to clear the cache and restart the network device, or contact the corresponding technical support.

[0096] 204. If an exception occurs in resource loading of the target single-page application, identify an abnormal feedback type of the feedback information;

[0097] In this embodiment, the abnormal feedback type of the feedback information can be identified in the following manner:

[0098] Monitor network requests: Use the browser's developer tools or professional network packet capture tools to monitor network requests and check for abnormal situations such as request failures and response timeouts.

[0099] Analyze error information: If an abnormal request occurs, you should be able to find the corresponding HTTP status code and error information in the developer tools. Based on the status code and error information, you can preliminarily determine what type of exception has occurred, such as 404 Not Found, 500 Internal Server Error, etc.

[0100] Logging: In single-page applications, there are usually some logging-related libraries or plugins that can capture and log all errors in the application. View these error logs in the console or other tools to get more detailed error information and background information.

[0101] The above method can be used to identify the abnormal feedback type of the feedback information.

[0102] 205. If the type of the feedback information represented by the recognition result is the first exception feedback type, a first exception handling hook in a preset construction tool plug-in is called to handle the resource loading exception of the target single-page application, and obtain the processing result data;

[0103] The first exception feedback type is the 404 exception type. The first exception handling hook is also called the default exception handling hook. The plug-in comes with an exception parameter processing module, which is used to process subsequent logic according to the exception parameters and return the page component module of the "refresh page prompt".

[0104] 206. Render the target single page application according to the result data.

[0105] For example, the result data of the "refresh page prompt" in step 205 is used to render the target single-page application.

[0106] The single-page application resource loading exception handling method provided by the present application includes sending a first request information for obtaining a target static resource to a preset target server; receiving feedback information from the target server; judging whether the resource loading of the target single-page application is abnormal based on the feedback information; if the resource loading of the target single-page application is abnormal, identifying the abnormal feedback type of the feedback information; if the identification result indicates that the type of the feedback information is the first abnormal feedback type, calling the first exception handling hook in the preset construction tool plug-in to handle the resource loading exception of the target single-page application and obtain the processing result data; according to the result data, rendering the target single-page application. Compared with the traditional method, the present application monitors the feedback information of the target server in the process of loading resources of the single-page application in real time. When an abnormality is identified, the first exception handling hook in the preset construction tool plug-in can be used for intervention processing, thereby avoiding multiple communications between the front end and the target server and reducing resource waste.

[0107] In order to avoid long waiting time and waste of resources caused by network error, in some embodiments of the present application, after identifying the abnormal type of the feedback information and obtaining the identification result, the method further includes: if the identification result is that the type of the feedback information is the second abnormal feedback type, then calling the second abnormal handling hook in the preset build tool plug-in and obtaining the processed result data. Among them, the second abnormal feedback type is network error, and the second abnormal handling hook is also called a retry hook. The plug-in comes with a re-call on-demand loading module. First, execute steps 201-204, and retry 3 times. If the retry limit is exceeded, execute step 206.

[0108] The embodiment of the present application uses the second exception handling hook in the preset construction tool plug-in to efficiently handle network errors, thereby avoiding long waiting times and waste of resources caused by network errors.

[0109] Optionally, in some embodiments of the present application, the calling of the second exception handling hook in the preset build tool plug-in includes: calling the second exception handling hook in the preset build tool plug-in; based on the second exception handling hook, calling the preset on-demand loading module and recording the number of calls; based on the on-demand loading module and the recorded number of calls, determining the return structure data.

[0110] In some embodiments of the present application, before calling the first exception handling hook in the preset build tool plug-in, the method also includes: building an initial system and connecting the preset build tool plug-in to the initial system to obtain a target system; storing the target system to a target storage medium.

[0111] The embodiment of the present application obtains a target system by connecting a preset construction tool plug-in to the initial system, and stores the target system to a target storage medium, thereby improving subsequent calls to the construction tool and improving data processing efficiency.

[0112] In some embodiments of the present application, the method further includes: generating feedback information to be evaluated; sending the feedback information to be evaluated to a preset user terminal; and receiving evaluation feedback information sent by the user terminal.

[0113] The embodiment of the present application uses the above-mentioned solution to continuously collect user evaluation feedback, thereby providing assistance for subsequent application iteration and upgrading, thereby improving product competitiveness.

[0114] In some embodiments of the present application, after rendering the target single-page application according to the returned data, the method further includes: acquiring page operation data; and classifying the page operation data to obtain operation classification data.

[0115] In order to better implement the single-page application resource loading exception handling method in the embodiment of the present application, based on the single-page application resource loading exception handling method, the embodiment of the present application also provides a single-page application resource loading exception handling device, such as Figure 3 As shown, the single-page application resource loading exception handling device 300 includes:

[0116] The first sending unit 301 is used to send first request information for acquiring a target static resource to a preset target server;

[0117] A first receiving unit 302, configured to receive feedback information from the target server;

[0118] A first judging unit 303 is used to judge whether resource loading of the target single-page application is abnormal based on the feedback information;

[0119] A first identification unit 304 is configured to identify an abnormal feedback type of the feedback information if an abnormality occurs in resource loading of the target single-page application;

[0120] The first calling unit 305 is used to call a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single-page application if the recognition result indicates that the type of the feedback information is a first exception feedback type, and obtain the processing result data;

[0121] The first rendering unit 306 is configured to perform page rendering on the target single-page application according to the result data.

[0122] In some embodiments of the present application, the first determining unit 303 is specifically configured to:

[0123] identifying content of the feedback information;

[0124] If the content includes abnormal feedback information, determining that the resource loading of the target single-page application is abnormal;

[0125] If the content does not include abnormal feedback information, it is determined that the resource loading of the target single-page application is normal.

[0126] In some embodiments of the present application, after identifying the abnormal type of the feedback information and obtaining the identification result, the device further includes:

[0127] The second calling unit is used to call a second exception handling hook in a preset construction tool plug-in and obtain processing result data if the identification result is that the type of the feedback information is a second exception feedback type.

[0128] In some embodiments of the present application, the calling of the second exception handling hook in the preset construction tool plug-in is specifically used to:

[0129] Call the second exception handling hook in the preset build tool plug-in;

[0130] Based on the second exception handling hook, calling the preset on-demand loading module and recording the number of calls;

[0131] Based on the on-demand loading module and the recorded call times, return structure data is determined.

[0132] In some embodiments of the present application, before calling the first exception handling hook in the preset construction tool plug-in, the device is further used to:

[0133] Building an initial system, and connecting a preset building tool plug-in to the initial system to obtain a target system;

[0134] The target system is stored in a target storage medium.

[0135] In some embodiments of the present application, the device is also used for:

[0136] Generate feedback information to be evaluated;

[0137] Sending the feedback information to be evaluated to a preset user terminal;

[0138] Receive evaluation feedback information sent by the user terminal.

[0139] In some embodiments of the present application, after rendering the target single-page application according to the returned data, the apparatus is further configured to:

[0140] Get page operation data;

[0141] The page operation data is classified to obtain operation classification data.

[0142] The single-page application resource loading exception handling device provided in the present application includes a first sending unit 301, which is used to send a first request information for obtaining a target static resource to a preset target server; a first receiving unit 302, which is used to receive feedback information from the target server; a first judgment unit 303, which is used to judge whether an exception occurs in the resource loading of the target single-page application based on the feedback information; a first identification unit 304, which is used to identify the abnormal feedback type of the feedback information if an exception occurs in the resource loading of the target single-page application; a first calling unit 305, which is used to call a first exception handling hook in a preset build tool plug-in to handle the resource loading exception of the target single-page application if the identification result indicates that the type of the feedback information is the first abnormal feedback type, and obtain the processing result data; a first rendering unit 306, which is used to render a page of the target single-page application according to the result data. Compared with traditional devices, the present application monitors the feedback information of the target server in real time during the loading process of single-page application resources. When an exception is identified, intervention can be performed through the first exception handling hook in the preset build tool plug-in, thereby avoiding multiple communications between the front end and the target server and reducing resource waste.

[0143] In addition to the above-mentioned method and device for handling exceptions in loading resources of a single-page application, the embodiment of the present application further provides a computer device, which integrates any of the single-page application resource loading exception handling devices provided in the embodiment of the present application, and the computer device includes:

[0144] one or more processors;

[0145] Memory; and

[0146] One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to perform the operations of any of the methods described in any of the embodiments of the single-page application resource loading exception handling method.

[0147] The present application embodiment also provides a computer device, which integrates any single-page application resource loading exception handling device provided in the present application embodiment. Figure 4 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:

[0148] The computer device may include components such as a processor 401 with one or more processing cores, a storage unit 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 4 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0149] The processor 401 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the storage unit 402 and calling data stored in the storage unit 402, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0150] The storage unit 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the storage unit 402. The storage unit 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the storage unit 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the storage unit 402 may also include a memory controller to provide the processor 401 with access to the storage unit 402.

[0151] The computer device also includes a power supply 403 for supplying power to various components. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 403 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0152] The computer device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0153] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in the embodiment of the present application, the processor 401 in the computer device will load the executable file corresponding to the process of one or more application programs into the storage unit 402 according to the following instructions, and the processor 401 will run the application program stored in the storage unit 402, thereby realizing various functions, as follows:

[0154] Sending a first request message for acquiring a target static resource to a preset target server; receiving feedback information from the target server; judging whether an exception occurs in resource loading of a target single-page application based on the feedback information; if an exception occurs in resource loading of the target single-page application, identifying the abnormal feedback type of the feedback message; if the identification result indicates that the type of the feedback information is a first abnormal feedback type, calling a first exception handling hook in a preset build tool plug-in to handle the resource loading exception of the target single-page application, and obtaining processing result data; and rendering a page of the target single-page application according to the result data.

[0155] The present application provides a method for handling exceptions in resource loading of a single-page application. Compared with traditional methods, the present application monitors the feedback information of the target server in real time during the loading process of single-page application resources. When an exception is identified, intervention processing can be performed through the first exception handling hook in the preset build tool plug-in, thereby avoiding multiple communications between the front end and the target server and reducing resource waste.

[0156] To this end, an embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. The computer-readable storage medium stores multiple instructions, which can be loaded by a processor to execute the steps in any single-page application resource loading exception handling method provided in an embodiment of the present application. For example, the instruction can execute the following steps:

[0157] The single-page application resource loading exception handling method provided by the present application includes sending a first request information for obtaining a target static resource to a preset target server; receiving feedback information from the target server; judging whether an exception occurs in the resource loading of the target single-page application based on the feedback information; if an exception occurs in the resource loading of the target single-page application, identifying the abnormal feedback type of the feedback information; if the identification result indicates that the type of the feedback information is a first abnormal feedback type, calling a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single-page application and obtain processing result data; and rendering a page of the target single-page application according to the result data.

[0158] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0159] The above is a detailed introduction to a single-page application resource loading exception handling method, device and related equipment provided in an embodiment of the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for handling exceptions in resource loading for a single-page application, characterized in that: The method comprises: Sending first request information for acquiring target static resources to a preset target server; receiving feedback information from the target server; Based on the feedback information, determine whether resource loading of the target single-page application is abnormal; If an exception occurs in resource loading of the target single-page application, identifying an abnormal feedback type of the feedback information; If the recognition result indicates that the type of the feedback information is a first exception feedback type, calling a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single-page application, and obtaining processing result data; The target single-page application is rendered according to the result data.

2. The method for handling single-page application resource loading exceptions according to claim 1, characterized in that: The determining, based on the feedback information, whether resource loading of the target single-page application is abnormal includes: identifying content of the feedback information; If the content includes abnormal feedback information, determining that the resource loading of the target single-page application is abnormal; If the content does not include abnormal feedback information, it is determined that the resource loading of the target single-page application is normal.

3. The method for handling exceptions in loading resources of a single-page application according to claim 1, characterized in that: After identifying the abnormal type of the feedback information and obtaining the identification result, the method further includes: If the identification result is that the type of the feedback information is the second exception feedback type, a second exception handling hook in a preset construction tool plug-in is called to obtain processing result data.

4. The method for handling single-page application resource loading exceptions according to claim 3, characterized in that: The calling of the second exception handling hook in the preset construction tool plug-in includes: Call the second exception handling hook in the preset build tool plug-in; Based on the second exception handling hook, calling the preset on-demand loading module and recording the number of calls; Based on the on-demand loading module and the recorded call times, return structure data is determined.

5. The method for handling exceptions in loading resources of a single-page application according to claim 1, characterized in that: Before calling the first exception handling hook in the preset construction tool plug-in, the method further includes: Building an initial system, and connecting a preset building tool plug-in to the initial system to obtain a target system; The target system is stored in a target storage medium.

6. The method for handling single-page application resource loading exceptions according to claim 1, characterized in that: The method further comprises: Generate feedback information to be evaluated; Sending the feedback information to be evaluated to a preset user terminal; Receive evaluation feedback information sent by the user terminal.

7. The method for handling exceptions in loading resources of a single-page application according to claim 1, characterized in that: After rendering the target single-page application according to the returned data, the method further includes: Get page operation data; The page operation data is classified to obtain operation classification data.

8. A single-page application resource loading exception handling device, characterized in that: The device comprises: A first sending unit, used to send first request information for acquiring a target static resource to a preset target server; A first receiving unit, configured to receive feedback information from the target server; A first judgment unit, configured to judge whether an abnormality occurs in resource loading of a target single-page application based on the feedback information; A first identification unit, configured to identify an abnormal feedback type of the feedback information if an abnormality occurs in resource loading of the target single-page application; A first calling unit is configured to call a first exception handling hook in a preset construction tool plug-in to handle the resource loading exception of the target single-page application if the recognition result indicates that the type of the feedback information is a first exception feedback type, and obtain processing result data; The first rendering unit is used to render the target single-page application according to the result data.

9. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the single-page application resource loading exception handling method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the single-page application resource loading exception handling method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Database loading exception processing method and device, equipment and medium

    CN121455792A

  • Database loading exception handling method, apparatus, device, and medium

    CN121455792B