Front-end multi-level multi-dimensional parameter data request method and device and medium
Through modular processing and props data transfer logic, combined with the use of timers and global counters, the problem of repeated requests and return mismatches in multi-level and multi-dimensional data requests is solved, and the performance and user experience of front-end applications are improved.
Patent Information
- Application Number
- CN202410872088.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When the traditional front-end development method handles data requests with multi-level and multi-dimensional conditions, it is easy to cause rapid changes in request parameters, resulting in multiple repeated requests and mismatch in returned results, resulting in low performance and reduced user experience.
By modularizing the front-end multi-level and multi-dimensional parameter content, reusable functional components are formed, and the data transfer logic between functional components is constructed through props. The watch mechanism is used to monitor changes in conditional parameters, and the setTimeout timer is used to delay sending to the network. requests, and counts and verifies requests based on global variable counters to ensure the correctness of the returned data.
It realizes the reuse of functional modules, improves code management efficiency, avoids repeated rendering and waste of network resources, ensures the correctness of interface returns, and reduces the risk of data confusion and repeated returns.
Smart Images

Figure CN118740671A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a front-end multi-level and multi-dimensional parameter data request method, device and medium. Background Art
[0002] With the rapid development of front-end technology, component-based development has become the mainstream trend of front-end development because it can improve code reuse, enhance code maintainability and scalability. In actual front-end development, especially when it comes to data requests involving multi-level and multi-dimensional conditions, traditional development methods often face a series of challenges.
[0003] Data requests with multiple levels and dimensions are common in complex web applications, which need to dynamically obtain and display data at different levels and dimensions based on user operations or state changes. However, in traditional development methods, the processing of such requests often relies on repetitive, hard-coded code logic, resulting in code redundancy, poor maintainability, and difficulty in adapting to changes in requirements.
[0004] To solve the above problems, front-end developers began to try to develop multi-level and multi-dimensional data requests in a componentized way. By encapsulating codes with similar functions or logic into reusable components, developers can build complex front-end applications more efficiently. However, in the process of componentized development, data transmission between components has become a problem that needs to be solved urgently.
[0005] Traditional data transmission methods, such as direct manipulation of DOM, use of global variables or event buses, often lead to complex code, poor performance, poor maintainability and other problems. In addition, due to the asynchrony of network requests and the uncertainty of interface return values, traditional methods often encounter problems such as repeated requests and mismatched return results due to rapid changes in request parameters when processing data requests with multi-level and multi-dimensional conditions, thus wasting a lot of network resources and reducing application performance and user experience. Summary of the invention
[0006] The embodiments of the present application provide a front-end multi-level and multi-dimensional parameter data request method, device and medium to solve the following technical problems: When processing data requests with multi-level and multi-dimensional conditions in the prior art, the request parameters often change rapidly, resulting in multiple repeated requests and mismatched returned results.
[0007] In the first aspect, an embodiment of the present application provides a front-end multi-level and multi-dimensional parameter data request method, characterized in that the method includes: modularizing the front-end multi-level and multi-dimensional parameter content to form reusable functional components; constructing the data transfer logic between functional components through props, and applying the watch mechanism to monitor whether the conditional parameters in the functional components change; when the conditional parameters are monitored to change, based on a preset setTimeout timer, delaying the sending of several network requests generated for the conditional parameter changes; based on a preset global variable counter, counting each network request and assigning a corresponding count value to each network request; after the interface returns the parameter data, comparing the count value in the parameter data with the count value in the global variable counter to determine whether it is a correct return value.
[0008] In one implementation of the present application, the front-end multi-level and multi-dimensional parameter content is modularized to form reusable functional components, specifically including: identifying and extracting multi-level and multi-dimensional parameters reused in front-end applications; encapsulating multi-level and multi-dimensional parameters into independent and reusable functional components; defining interfaces for functional components so that they can be integrated and called based on the interfaces in other parts of the application.
[0009] In one implementation of the present application, the data transfer logic between functional components is constructed by props, specifically including: defining the input props of the functional component; in the functional component, configuring the conditional parameters corresponding to the input props.
[0010] In one implementation of the present application, a watch mechanism is applied to monitor whether the conditional parameters in the functional component change, specifically including: in the functional component, setting a watch monitor for the input props; when the conditional parameters corresponding to the input props change, the watch mechanism triggers a preset callback function; based on the callback function, the content logic is ignored, and the changed conditional parameters in the input props are passed.
[0011] In one implementation of the present application, when a change in a conditional parameter is detected, based on a preset setTimeout timer, a delay is made in sending a number of network requests generated in response to the change in the conditional parameter, specifically including: when a change in the conditional parameter is detected, based on a preset setTimeout timer, a periodic timing is set; each time the preset time of the setTimeout timer is reached periodically, a number of network requests are sent accordingly; wherein the number of network requests are generated based on the change in the conditional parameter and the multi-level and multi-dimensional parameter changes caused by the change in the conditional parameter.
[0012] In one implementation of the present application, each network request is counted based on a preset global variable counter, and a corresponding count value is assigned to each network request, specifically including: defining a global variable counter to record the number of network requests currently initiated; each time a new network request is initiated, the counter is incremented by one, and the new count value is assigned to the request.
[0013] In one implementation of the present application, a count value in the parameter data is compared with a count value in a global variable counter to determine whether it is a correct return value, specifically including: when the response parameter data is received, the count value in the parameter data is compared with the current value in the global variable counter; if the two are equal, the parameter data is determined to be a correct return value; if they are not equal, the parameter data is determined to be an outdated or invalid return value.
[0014] In one implementation of the present application, the method also includes: when it is determined to be a correct return value, updating the value of the global variable counter and processing the parameter data for front-end display; when it is determined to be an outdated or invalid return value, ignoring the parameter data and resending the corresponding network request based on a preset repetition strategy.
[0015] In the second aspect, an embodiment of the present application also provides a front-end multi-level and multi-dimensional parameter data request device, characterized in that the device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can: modularize the front-end multi-level and multi-dimensional parameter content to form reusable functional components; construct data transfer logic between functional components through props, and apply the watch mechanism to monitor whether the conditional parameters in the functional components change; when the conditional parameters are monitored to change, based on a preset setTimeout timer, delay sending several network requests generated for the conditional parameter changes; based on a preset global variable counter, count each network request and assign a corresponding count value to each network request; after the interface returns the parameter data, compare the count value in the parameter data with the count value in the global variable counter to determine whether it is a correct return value.
[0016] In the third aspect, the embodiment of the present application also provides a non-volatile computer storage medium for data requests of front-end multi-level and multi-dimensional parameters, which stores computer executable instructions, and is characterized in that the computer executable instructions are set to: modularly process the front-end multi-level and multi-dimensional parameter content to form reusable functional components; construct the data transfer logic between functional components through props, and apply the watch mechanism to monitor whether the conditional parameters in the functional components change; when the conditional parameters are monitored to change, based on the preset setTimeout timer, delay the sending of several network requests generated for the conditional parameter changes; based on the preset global variable counter, count each network request and assign a corresponding count value to each network request; after the interface returns the parameter data, compare the count value in the parameter data with the count value in the global variable counter to determine whether it is a correct return value.
[0017] The method, device and medium for requesting data of multi-level and multi-dimensional parameters of a front-end provided in the embodiments of the present application have the following beneficial effects:
[0018] 1. Component-based development of functional modules facilitates the reuse of functional modules and also facilitates the management of project codes.
[0019] 2. By using Props for data transfer, the dependency relationship between parent components and child components can be decoupled, making the code of child components more independent and reusable. In this way, when the parent component changes, the code of the child component does not need to be modified, and only the correct data needs to be passed through Props.
[0020] 3. Setting a timer on the front end to delay the request can avoid repeated rendering of data and save network resources.
[0021] 4. The interface returns the correct judgment, and can deduplicate duplicate requests, returning only the last result of the request, avoiding repeated return of the same data, reducing the risk of data confusion and repeated rendering of the front end. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 A flow chart of a front-end multi-level and multi-dimensional parameter data request method provided in an embodiment of the present application;
[0024] Figure 2A schematic diagram of the internal structure of a front-end multi-level and multi-dimensional parameter data request device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. 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 ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0026] The embodiments of the present application provide a front-end multi-level and multi-dimensional parameter data request method, device and medium to solve the following technical problems: When processing data requests with multi-level and multi-dimensional conditions in the prior art, the request parameters often change rapidly, resulting in multiple repeated requests and mismatched returned results.
[0027] The technical solution proposed in the embodiments of the present application is described in detail below with reference to the accompanying drawings.
[0028] Figure 1 A flow chart of a method for requesting data of multi-level and multi-dimensional parameters at the front end provided in an embodiment of the present application. Figure 1 As shown, a front-end multi-level and multi-dimensional parameter data request method provided in an embodiment of the present application specifically includes the following steps:
[0029] Step 101: modularize the multi-level and multi-dimensional parameter content of the front end to form reusable functional components.
[0030] In one embodiment of the present application, in order to implement data requests for front-end multi-level and multi-dimensional parameters, it is first necessary to modularize the front-end multi-level and multi-dimensional parameter content to form reusable functional components.
[0031] Specifically, identify and extract multi-level and multi-dimensional parameters that are repeatedly used in front-end applications; encapsulate the multi-level and multi-dimensional parameters into independent and reusable functional components; define interfaces for the functional components so that they can be integrated and called based on the interfaces in other parts of the application.
[0032] In one embodiment, first, a comprehensive code review and analysis is performed on the front-end application to identify those multi-level and multi-dimensional parameters that are reused in different pages or functions. These parameters may involve user information, configuration options, query conditions, etc. Through this step, it is possible to clarify which parameters are universal and which parameters are specific to a certain function, thereby providing a basis for subsequent modular processing.
[0033] After identifying the reusable parameters, encapsulate them into independent functional components. Each component is responsible for processing a specific type of parameters and has good encapsulation, that is, the state and behavior inside the component will not affect the outside. These functional components are designed to be reusable, which means that they can be reused in different parts of the front-end application without a lot of modification or customization.
[0034] In order to make these functional components easily integrated and called in other parts of the application, clear interfaces are defined for each component. These interfaces specify how to interact with the components, including passing parameters, triggering events, and obtaining component status. By defining interfaces, loose coupling between components is ensured, allowing front-end applications to respond more flexibly to changes in requirements and functional expansion.
[0035] After completing the encapsulation and interface definition of functional components, these components can be easily integrated into different parts of the front-end application. Whether building a new page or expanding existing functions, rapid development can be achieved by calling the corresponding functional components. In addition, since these components are reusable, duplication of work can be greatly reduced during the development process, improving development efficiency.
[0036] Step 102: Build the data transfer logic between functional components through props, and apply the watch mechanism to monitor whether the conditional parameters in the functional components change.
[0037] In one embodiment of the present application, after the front-end multi-level and multi-dimensional parameter content is modularized to form reusable functional components, the data transfer logic between the functional components is constructed through props.
[0038] Specifically, define the input props of the functional component; in the functional component, configure the conditional parameters corresponding to the input props.
[0039] Furthermore, the watch mechanism is applied to monitor whether the conditional parameters in the functional component change.
[0040] Specifically, in the functional component, a watch listener is set for the input props; when the conditional parameters corresponding to the input props change, the watch mechanism triggers the preset callback function; based on the callback function, the content logic is ignored, and the changed conditional parameters in the input props are passed.
[0041] In one embodiment, the input props of the functional component are first defined. These props serve as the external interface of the component, allowing external data to flow in and be used inside the component. In this way, the flexibility and reusability of the component are ensured, because different components can interact with data through the same props interface without the need to customize each component separately.
[0042] Next, inside the functional component, configure the conditional parameters corresponding to these input props in detail. These conditional parameters are the key to the internal logic processing of the component and directly affect the state and behavior of the component. By accurately configuring these parameters, you can ensure that the component can respond correctly when receiving external data.
[0043] In order to further enhance the responsiveness and real-time performance of the component, the watch mechanism is further applied to monitor whether the conditional parameters in the functional component have changed. Specifically, in the functional component, a watch is set for the previously defined input props. This means that once any value of these props changes, the watch mechanism will immediately capture the change.
[0044] When the conditional parameters corresponding to the input props change, the watch mechanism will quickly trigger a preset callback function. This callback function is a predefined piece of code that is used to process a series of logic after the conditional parameters change. In this way, it can ensure that the component can respond immediately when the data changes, without waiting for other external trigger conditions.
[0045] In the callback function, a mechanism is specially designed to ignore the content logic and directly pass the changed conditional parameters in the input props. This means that when the conditional parameters change, the logic of the entire component will not be reconstructed or recalculated, but these new parameter values will be directly passed to the next processing link of the component. This approach greatly improves the processing efficiency and response speed of the component, ensuring that the front-end application can respond quickly when the data changes.
[0046] Step 103: When a change in the conditional parameter is detected, based on a preset setTimeout timer, delay sending of several network requests generated for the change in the conditional parameter.
[0047] In one embodiment of the present application, when a change in a condition parameter is monitored, based on a preset setTimeout timer, sending of several network requests generated for the change in the condition parameter is delayed.
[0048] Specifically, when a change in the conditional parameters is monitored, a periodic timing is set based on a preset setTimeout timer; each time the preset time of the setTimeout timer is reached periodically, a number of network requests are sent accordingly; wherein the number of network requests are generated based on the change in the conditional parameters and the multi-level and multi-dimensional parameter changes caused by the change in the conditional parameters.
[0049] In one embodiment, first, the monitoring mechanism previously set is used to capture changes in conditional parameters in the functional component in real time. These conditional parameters may include user input, application status or other dynamic data, and their changes often require responses from backend services.
[0050] Once the condition parameter changes, instead of sending a network request immediately, a short delay is set based on the preset setTimeout timer. This timer is used to create a periodic scheduled task, and its cycle length can be adjusted according to actual needs to find the best performance balance point.
[0051] When the timer reaches the preset time point each time, several network requests are sent in sequence. These requests are generated based on the changes in conditional parameters and the changes in multi-level and multi-dimensional parameters caused by them. This means that not only does it respond to the change of a single parameter, but it also takes into account the changes in other related parameters that may be caused by this change, thereby building a more comprehensive request set.
[0052] For each network request sent out, a callback function is set to handle the server's response. These callback functions are responsible for parsing the response data, updating the front-end status, and handling possible errors or exceptions.
[0053] In actual applications, the timer cycle length and request sending strategy may be dynamically adjusted according to the response time of network requests, server load, and front-end performance. For example, when the network is congested or the server load is high, we can appropriately increase the timer cycle to reduce the pressure on the server.
[0054] Step 104: Count each network request based on a preset global variable counter, and assign a corresponding count value to each network request.
[0055] In one embodiment of the present application, when a change in a conditional parameter is monitored, each network request is counted based on a preset global variable counter, and a corresponding count value is assigned to each network request.
[0056] Specifically, a global variable counter is defined to record the number of network requests currently initiated; each time a new network request is initiated, the counter is incremented by one, and the new count value is assigned to the request.
[0057] In one embodiment, first, a global variable counter is defined to record the number of network requests currently initiated. This counter is unique in the entire application and can be accessed and modified in any part of the application.
[0058] When the application starts, the global variable counter is initialized to 0, indicating that no network request is currently being initiated. When the conditional parameters in the function component are monitored to change, the corresponding network request is prepared to be initiated. At this time, we do not send the request immediately, but operate the counter first.
[0059] Each time a new network request is about to be initiated, the global variable counter is first incremented by one to indicate that a new request is about to be initiated. Then, the updated count value is assigned to the request. This can be achieved by appending the count value to the request data packet or storing the count value in the request object.
[0060] Step 105: After the interface returns the parameter data, the count value in the parameter data is compared with the count value in the global variable counter to determine whether it is a correct return value.
[0061] In one embodiment of the present application, after the interface returns parameter data, a count value in the parameter data is compared with a count value in a global variable counter to determine whether it is a correct return value.
[0062] Specifically, when the response parameter data is received, the count value in the parameter data is compared with the current value in the global variable counter; if the two are equal, the parameter data is determined to be a correct return value; if they are not equal, the parameter data is determined to be an outdated or invalid return value.
[0063] In one embodiment of the present application, when it is determined to be a correct return value, the value of the global variable counter will also be updated, and the parameter data will be processed for front-end display; when it is determined to be an outdated or invalid return value, the parameter data will be ignored, and the corresponding network request will be resent based on a preset repetition strategy.
[0064] In one embodiment, when the interface returns parameter data, first ensure that the data has been received completely. This data usually includes the count value we previously attached to the request for subsequent verification. From the received parameter data, extract the previously attached count value. This count value represents the global counter state of the request when it was initiated. At the same time, read the current value of the global variable counter. This value represents the total number of network requests that have been initiated so far (including completed and uncompleted requests).
[0065] Next, the count value in the parameter data is compared with the current value in the global variable counter. Since each request will increase the value of the global counter by one when it is initiated and append this value to the request, theoretically, if the requests are processed sequentially, the count value in each correctly returned response should match the current value of the global counter (taking into account the possible concurrent requests, a reasonable synchronization mechanism or a special design of the counting method is required here to ensure the accuracy of the counting).
[0066] If the count value in the parameter data is equal to the current value in the global variable counter, it is determined that the parameter data is a correct return value, which means that the data corresponds to the most recently initiated request and has not been overwritten or confused by other subsequent requests.
[0067] If the two are not equal, it means that the received parameter data may be an outdated or invalid return value. This may be because there is a delay in the network transmission process, or the request has been replaced by a subsequent request. In this case, you may choose to ignore the return value or perform error handling according to the specific application logic.
[0068] Depending on the validation results, we can take appropriate actions. For correct return values, we pass them on to subsequent processing; for outdated or invalid return values, we may log errors, trigger a retry mechanism, or display error messages to the user.
[0069] The above is an embodiment of the method proposed in this application. Based on the same inventive concept, this application embodiment also provides a front-end multi-level multi-dimensional parameter data request device, whose structure is as follows: Figure 2 shown.
[0070] Figure 2 A schematic diagram of the internal structure of a front-end multi-level and multi-dimensional parameter data request device provided in an embodiment of the present application. Figure 2 As shown, the device includes:
[0071] at least one processor 201;
[0072] and, a memory 202 communicatively connected to the at least one processor;
[0073] The memory 202 stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor 201 to enable at least one processor 201 to:
[0074] Modularize the multi-level and multi-dimensional parameter content of the front end to form reusable functional components;
[0075] Build the data transfer logic between functional components through props, and use the watch mechanism to monitor whether the conditional parameters in the functional components change;
[0076] When a change in conditional parameters is detected, based on the preset setTimeout timer, several network requests generated for the change in conditional parameters are delayed.
[0077] Based on a preset global variable counter, each network request is counted and a corresponding count value is assigned to each network request;
[0078] After the interface returns the parameter data, the count value in the parameter data is compared with the count value in the global variable counter to determine whether it is a correct return value.
[0079] Some embodiments of the present application provide corresponding Figure 1 A non-volatile computer storage medium for front-end multi-level and multi-dimensional parameter data request, storing computer executable instructions, wherein the computer executable instructions are set as:
[0080] Modularize the multi-level and multi-dimensional parameter content of the front end to form reusable functional components;
[0081] Build the data transfer logic between functional components through props, and use the watch mechanism to monitor whether the conditional parameters in the functional components change;
[0082] When a change in conditional parameters is detected, based on the preset setTimeout timer, several network requests generated for the change in conditional parameters are delayed.
[0083] Based on a preset global variable counter, each network request is counted and a corresponding count value is assigned to each network request;
[0084] After the interface returns the parameter data, the count value in the parameter data is compared with the count value in the global variable counter to determine whether it is a correct return value.
[0085] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the IoT device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0086] The system and medium provided in the embodiments of the present application correspond one-to-one to the method. Therefore, the system and medium also have similar beneficial technical effects to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the system and medium will not be repeated here.
[0087] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0088] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0089] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0090] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0092] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0093] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0094] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0095] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A front-end multi-level and multi-dimensional parameter data request method, It is characterized in that The method comprises: Modularize the multi-level and multi-dimensional parameter content of the front end to form reusable functional components; The data transfer logic between the functional components is constructed by props, and the watch mechanism is applied to monitor whether the conditional parameters in the functional components change; When a change in a condition parameter is detected, based on a preset setTimeout timer, a plurality of network requests generated for the change in the condition parameter are delayed; Based on a preset global variable counter, each network request is counted and a corresponding count value is assigned to each network request; After the interface returns the parameter data, the count value in the parameter data is compared with the count value in the global variable counter to determine whether it is a correct return value.
2. According to the front-end multi-level and multi-dimensional parameter data request method of claim 1, It is characterized in that Modularize the multi-level and multi-dimensional parameter content of the front-end to form reusable functional components, including: Identify and extract multi-level and multi-dimensional parameters that are repeatedly used in front-end applications; Encapsulating the multi-level and multi-dimensional parameters into independent and reusable functional components; An interface is defined for the functional component so that it can be integrated and called based on the interface in other parts of the application.
3. According to the front-end multi-level and multi-dimensional parameter data request method of claim 1, It is characterized in that The data transfer logic between the functional components is constructed by props, including: Define the input props of the functional component; In the functional component, configure the conditional parameters passed corresponding to the input props.
4. According to claim 1, a front-end multi-level and multi-dimensional parameter data request method, It is characterized in that The watch mechanism is used to monitor whether the condition parameters in the functional component change, including: In the functional component, set a watch listener for the input props; When the conditional parameters corresponding to the input props change, the watch mechanism triggers the preset callback function; Based on the callback function, ignore the content logic and pass the changed conditional parameters in the input props.
5. According to the front-end multi-level and multi-dimensional parameter data request method of claim 1, It is characterized in that When a change in a condition parameter is detected, based on a preset setTimeout timer, a number of network requests generated for the change in the condition parameter are delayed, specifically including: When a change in the conditional parameter is detected, a periodic timing is set based on the preset setTimeout timer; Each time the preset time of the setTimeout timer is reached periodically, the plurality of network requests are sent accordingly; wherein the plurality of network requests are generated accordingly based on changes in the conditional parameters and multi-level and multi-dimensional parameter changes caused by the changes in the conditional parameters.
6. A front-end multi-level and multi-dimensional parameter data request method according to claim 1, It is characterized in that Based on the preset global variable counter, each network request is counted and a corresponding count value is assigned to each network request, including: Define a global variable counter to record the number of network requests currently initiated; Each time a new network request is initiated, the counter is incremented by one and the new count value is assigned to the request.
7. A front-end multi-level and multi-dimensional parameter data request method according to claim 1, It is characterized in that Comparing the count value in the parameter data with the count value in the global variable counter to determine whether it is a correct return value specifically includes: When receiving the parameter data of the response, comparing the count value in the parameter data with the current value in the global variable counter; If the two are equal, it is determined that the parameter data is a correct return value; If not, it is determined that the parameter data is an outdated or invalid return value.
8. According to claim 1, a front-end multi-level and multi-dimensional parameter data request method, It is characterized in that The method further comprises: If it is determined to be a correct return value, the value of the global variable counter is updated, and the parameter data is processed for front-end display; In the case of determining an outdated or invalid return value, the parameter data is ignored, and the corresponding network request is resent based on a preset repetition strategy.
9. A front-end multi-level and multi-dimensional parameter data request device, It is characterized in that The device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to: Modularize the multi-level and multi-dimensional parameter content of the front end to form reusable functional components; The data transfer logic between the functional components is constructed by props, and the watch mechanism is applied to monitor whether the conditional parameters in the functional components change; When a change in a condition parameter is detected, based on a preset setTimeout timer, a plurality of network requests generated for the change in the condition parameter are delayed; Based on a preset global variable counter, each network request is counted and a corresponding count value is assigned to each network request; After the interface returns the parameter data, the count value in the parameter data is compared with the count value in the global variable counter to determine whether it is a correct return value.
10. A non-volatile computer storage medium for front-end multi-level and multi-dimensional parameter data requests, storing computer executable instructions, It is characterized in that The computer executable instructions are configured to: Modularize the multi-level and multi-dimensional parameter content of the front end to form reusable functional components; The data transfer logic between the functional components is constructed by props, and the watch mechanism is applied to monitor whether the conditional parameters in the functional components change; When a change in a condition parameter is detected, based on a preset setTimeout timer, a plurality of network requests generated for the change in the condition parameter are delayed; Based on a preset global variable counter, each network request is counted and a corresponding count value is assigned to each network request; After the interface returns the parameter data, the count value in the parameter data is compared with the count value in the global variable counter to determine whether it is a correct return value.
Citation Information
Patent Citations
Network interaction function optimization system and method, computer equipment and medium
CN113452721A
