Disclosure of Invention
In order to solve the technical problems that the Charles bale plucking tool charges to increase financial expenses and the Charles bale plucking tool has certain learning cost and non-developers need to spend certain time to learn the Charles bale plucking tool on one hand when the Charles bale plucking tool is used for connecting a test environment, the embodiment of the invention provides a parameter modification method, a parameter modification device, electronic equipment and a storage medium. The specific technical scheme is as follows:
in a first aspect of the embodiments of the present invention, a parameter modification method is provided first, where the method includes:
acquiring a parameter to be modified and a target parameter corresponding to the parameter to be modified in a parameter editing page of a target application;
replacing a default method for initiating a network request in the target application with a target method, wherein both the default method and the target method are used for initiating the network request;
if the default parameter in the target method comprises the parameter to be modified, searching the position of the default parameter corresponding to the parameter to be modified in the target method;
and replacing the default parameters at the position with the target parameters, and calling the target method subjected to parameter replacement to initiate a network request to connect to the environment corresponding to the target parameters.
In an optional embodiment, an edit button is included in the current page of the target application;
the method for acquiring the parameters to be modified and the target parameters corresponding to the parameters to be modified in the parameter editing page of the target application comprises the following steps:
under the condition that the preset operation trigger of the user for the editing button is monitored, jumping from the current page to a parameter editing page;
and acquiring a parameter to be modified and a target parameter corresponding to the parameter to be modified in the parameter editing page.
In an optional embodiment, the parameter editing page includes a save button, and the method further includes:
under the condition that the preset operation trigger of the user for the storage button is monitored, storing the parameter to be modified and the target parameter;
jumping to the current page from the parameter editing page, and displaying the parameter to be modified and the target parameter in the current page.
In an optional embodiment, before performing the replacing of the default method of initiating the network request in the target application with the target method, the method further comprises:
monitoring whether the preset operation of the user for the parameter to be modified and the target parameter is triggered or not in the current page;
and under the condition that the preset operation trigger of the user for the parameter to be modified and the target parameter is monitored, the step of replacing the default method for initiating the network request in the target application with the target method is executed.
In an optional embodiment, in the case that the preset operation trigger of the user for the parameter to be modified and the target parameter is monitored, the step of replacing the default method for initiating the network request in the target application with the target method is executed, and includes:
under the condition that the preset operation trigger of the user for the parameter to be modified and the target parameter is monitored, whether the initiation opportunity of the network request is reached is monitored;
and if the initiation opportunity of the network request arrives, executing the step of replacing the default method for initiating the network request in the target application with the target method.
In an optional embodiment, the method further comprises:
calling the default method to initiate a default network request under the condition that the preset operation trigger of the user for the parameter to be modified and the target parameter is not monitored;
requesting a connection to a corresponding default context through the default network.
In an optional embodiment, the method further comprises:
and if the default parameters in the target method do not contain the parameters to be modified, triggering an alarm that the modification of the related parameters in the network request fails.
In a second aspect of the embodiments of the present invention, there is also provided a parameter modification apparatus, including:
the parameter acquiring module is used for acquiring a parameter to be modified and a target parameter corresponding to the parameter to be modified in a parameter editing page of a target application;
a method switching module, configured to replace a default method for initiating a network request in the target application with a target method, where both the default method and the target method are used for initiating a network request;
a location searching module, configured to search, if a default parameter in the target method includes the parameter to be modified, a location of the default parameter corresponding to the parameter to be modified in the target method;
and the parameter replacing module is used for replacing the default parameters at the position with the target parameters, calling the target method subjected to parameter replacement to initiate a network request so as to be connected to the environment corresponding to the target parameters.
In a third aspect of the embodiments of the present invention, there is further provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the parameter modification method according to any one of the first aspect described above when executing a program stored in a memory.
In a fourth aspect of the embodiments of the present invention, there is also provided a storage medium, in which instructions are stored, and when the instructions are executed on a computer, the instructions cause the computer to execute the parameter modification method according to any one of the first aspect.
In a fifth aspect of the embodiments of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the above-described parameter modification methods.
According to the technical scheme provided by the embodiment of the invention, the parameter to be modified and the target parameter corresponding to the parameter to be modified are obtained in the parameter editing page of the target application, the default method for initiating the network request in the target application is replaced by the target method, wherein both the default method and the target method are used for initiating the network request, if the default parameter in the target method contains the parameter to be modified, the position of the default parameter corresponding to the parameter to be modified in the target method is searched, the default parameter at the position is replaced by the target parameter, and the target method after parameter replacement is called to initiate the network request so as to be connected to the environment corresponding to the target parameter. By providing the target application, acquiring the parameter to be modified and the target parameter corresponding to the parameter to be modified in a parameter editing page of the target application, replacing a default method for initiating the network request in the target application with the target method, replacing the default parameter corresponding to the parameter to be modified in the target method with the target parameter, calling the target method subjected to parameter replacement to initiate the network request so as to be connected to the environment corresponding to the target parameter, and dynamically modifying the related parameter in the network request so as to be connected to the corresponding environment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
As shown in fig. 1, an implementation flow diagram of a parameter modification method provided in an embodiment of the present invention is shown, where the method is applied to an electronic device, and specifically includes the following steps:
s101, acquiring a parameter to be modified and a target parameter corresponding to the parameter to be modified in a parameter editing page of a target application.
In the embodiment of the invention, the iOS application written by the Objective-C language is provided, and the purpose of dynamically modifying the relevant parameters in the network request can be realized through the iOS application written by the Objective-C language. Specifically, in a parameter editing page of the target application, that is, in a parameter editing page of the iOS application written in Objective-C language, a user may input a parameter to be modified and a target parameter corresponding to the parameter to be modified, and thus, the embodiment of the present invention may obtain the parameter to be modified and the target parameter corresponding to the parameter to be modified, which are input by the user.
For example, in a parameter editing page of an iOS application written in Objective-C language, a user may input a domain name host of an original online environment and a domain name host of a test environment, and thus, the embodiment of the present invention may obtain the domain name host of the original online environment and the domain name host of the test environment, which are input by the user. The domain name host of the original online environment and the domain name host of the test environment may be as shown in table 1 below.
| Domain name host of original online environment | Domain name host of test environment |
| Iface.iqiyi.com | 10.130.138.152 |
| Iface2.iqiyi.com | 111.206.13.99 |
| …… | …… |
TABLE 1
Wherein, Apple provides related API to dynamically realize method replacement in Objective-C language, and the bottom layer of the API is the realization of replacing the original function by using the dynamic property of Objective-C language in operation. Therefore, by means of the dynamic property of the Objective-C language, the API is called to dynamically replace the method A which is executed in the iOS application written by the Objective-C language and used for initiating the network request with the method B, and the method A and the method B are both used for initiating the network request. With this feature, an edit portal can be provided in the iOS application written in the Objective-C language, in which a user can edit relevant parameters of a network request, such as modifying information such as a domain name, to connect to a test environment.
The current page of the iOS application written in the Objective-C language therefore includes an edit button, i.e. the above-mentioned edit entry. In the embodiment of the invention, whether the preset operation of the user for the editing button is triggered can be monitored, the current page jumps to the parameter editing page under the condition that the preset operation of the user for the editing button is triggered is monitored, and the parameter to be modified and the target parameter corresponding to the parameter to be modified can be input by the user in the parameter editing page.
For example, as shown in fig. 2, a current page of the iOS application written in the Objective-C language includes an edit button, where the edit button is the edit entry, and the embodiment of the present invention may monitor whether a click operation of a user on the edit button is triggered, and jump from the current page to the parameter edit page when the click operation of the user on the edit button is triggered.
In addition, in the embodiment of the present invention, the parameter editing page of the iOS application written in the Objective-C language includes the save button, so that the user can save the parameter to be modified and the target parameter corresponding to the parameter to be modified after inputting the parameter to be modified and the target parameter corresponding to the parameter to be modified, so as to monitor whether the preset operation of the user for the save button is triggered, and save the parameter to be modified and the target parameter under the condition that the preset operation of the user for the save button is triggered, and jump from the parameter editing page to the current page, and display the parameter to be modified and the target parameter in the current page.
For example, a parameter editing page of an iOS application written in Objective-C language includes a save button, so that a user can save after inputting a domain name host of an original online environment and a domain name host of a test environment, and thus, in the embodiment of the present invention, whether a click operation of the user for the save button is triggered is monitored, and in a case where the click operation of the user for the save button is triggered, the domain name host of the original online environment and the domain name host of the test environment are saved, the parameter editing page jumps to a current page, and the domain name host of the original online environment and the domain name host of the test environment are displayed in the current page, as shown in fig. 3.
The preset operation may be, for example, a click operation, for example, a tap operation, for example, a medium press operation, for example, a heavy press operation, which is not limited in this embodiment of the present invention. In addition, for the network request, a plurality of fields are generally included, each field corresponds to one parameter, and the parameter to be modified and the target parameter may correspond to a certain field in the network request.
S102, replacing a default method for initiating the network request in the target application with a target method, wherein the default method and the target method are both used for initiating the network request.
In the embodiment of the invention, because the Objective-C language has dynamic property, the method a for initiating the network request executed in the iOS application written by the Objective-C language can be dynamically replaced by the method B by utilizing the dynamic property, so that the target method can be replaced by the default method for initiating the network request in the iOS application written by the Objective-C language, wherein the default method and the target method are both used for initiating the network request.
For example, the iOS application written in the Objective-C language includes a method a and a method B for initiating a network request, and both the method a and the method B can initiate the network request in terms of functional implementation, but the difference is that the method a is used for initiating the network request to connect to the online environment, and the method B is used for initiating the network request to connect to the test environment, so the method a for initiating the network request is replaced by the method B in the iOS application written in the Objective-C language.
Before replacing the default method for initiating the network request in the target application (namely the iOS application written by the Objective-C language) with the target method, monitoring whether the preset operation of the user for the parameter to be modified and the target parameter is triggered or not in the current page of the iOS application written by the Objective-C language, and executing the step of replacing the default method for initiating the network request in the target application with the target method under the condition that the preset operation of the user for the parameter to be modified and the target parameter is triggered.
For example, in the current page of the iOS application written in Objective-C language, whether the click operation of the user on the domain name host of the original online environment and the domain name host of the test environment is triggered is monitored, and in the case that the click operation of the user on the domain name host of the original online environment and the domain name host of the test environment is triggered, the domain name host of the original online environment and the domain name host of the test environment are selected, the row where the domain name host of the original online environment and the domain name host of the test environment are located has a check value, as shown in fig. 4, it is described that the relevant domain name in the network request is modified according to the domain name host of the original online environment and the domain name host of the test environment, and at this time, the method a of initiating the network request may be replaced by the method B in the iOS application written in Objective-C language.
It should be noted that, in the embodiment of the present invention, only the relevant parameters in the network request are modified, and the initiation timing of the network request is not changed, so that under the condition that the preset operation trigger of the user for the parameters to be modified and the target parameters is monitored, whether the initiation timing of the network request arrives is monitored, and if the initiation timing of the network request arrives, the step of replacing the default method for initiating the network request in the target application with the target method is executed.
For example, under the condition that the click operation trigger of the user for the domain name host of the original online environment and the domain name host of the test environment is monitored, whether the initiation timing of the network request arrives is monitored, and if the initiation timing of the network request arrives, the method A for initiating the network request can be replaced by the method B in the iOS application written by the Objective-C language, and the method B is called to initiate the network request.
It should be noted that, for the iOS application written in the Objective-C language, some resources, such as video resources, are displayed on the iOS application, and when a user clicks a certain video resource, a network request needs to be initiated at this time, that is, it is considered that the initiation timing of the network request arrives, and certainly, the initiation timing of the network request may also arrive under other conditions, which is not limited in the embodiment of the present invention.
In addition, in a period of time, under the condition that the preset operation trigger of the user for the parameters to be modified and the target parameters is not monitored, it indicates that the user does not intend to modify the relevant parameters in the network request, at this time, a default method for initiating the network request in the iOS application written by the Objective-C language can be called, and the default network request is initiated, so that the user can be connected to the corresponding default environment through the default network request.
For example, when the click operation trigger of the user for the domain name host of the original online environment and the domain name host of the test environment is not monitored, it indicates that the user does not intend to modify the related domain name in the network request, and at this time, the method a for initiating the network request in the iOS application written in the Objective-C language may be invoked to initiate the default network request, so that the user may connect to the corresponding online environment through the default network request.
S103, if the default parameter in the target method comprises the parameter to be modified, searching the position of the default parameter corresponding to the parameter to be modified in the target method.
In the embodiment of the invention, for the target method, whether the default parameter in the target method contains the parameter to be modified is checked, if the default parameter in the target method contains the parameter to be modified, the default parameter which is consistent with the parameter to be modified exists in the default parameter, and at this time, the position of the default parameter corresponding to the parameter to be modified in the target method is searched.
For example, in the embodiment of the present invention, for the target method, it is checked whether the default parameter in the target method includes the domain name host of the original online environment, and if the default parameter in the target method includes the domain name host of the original online environment, the position of the default parameter corresponding to the domain name host of the original online environment in the target method is searched, where the default parameter is consistent with the domain name host of the original online environment.
In addition, if the default parameter in the target method does not contain the parameter to be modified, which indicates that the parameter to be modified may be entered incorrectly, an alarm that the modification of the relevant parameter in the network request fails may be triggered, and then the user may be reminded to edit the parameter to be modified again.
S104, replacing the default parameters at the position with the target parameters, calling the target method subjected to parameter replacement to initiate a network request so as to connect to the environment corresponding to the target parameters.
In the embodiment of the invention, the position of the default parameter corresponding to the parameter to be modified in the target method is searched, so that the default parameter at the position can be replaced by the target parameter, and the target method after parameter replacement is called to initiate a network request so as to be connected to the environment corresponding to the target parameter.
The target method which is replaced by the parameters is called to initiate the network request, the related parameters in the network request are modified completely, the purpose of dynamically modifying the related parameters in the network request is achieved, and therefore the network request can be connected to the environment corresponding to the target parameters.
For example, the location of the default parameter corresponding to the domain name host of the original online environment in method B is searched, so that the default parameter at the location is replaced by the domain name host of the test environment, and method B subjected to parameter replacement is called to initiate a network request to connect to the test environment.
The method B which is replaced by the parameters is called to initiate the network request, and the related parameters in the network request are modified completely, so that the purpose of dynamically modifying the related parameters in the network request is achieved, and the network request can be connected to the corresponding test environment.
Through the above description of the technical solution provided by the embodiment of the present invention, in a parameter editing page of a target application, a parameter to be modified and a target parameter corresponding to the parameter to be modified are obtained, and a default method for initiating a network request in the target application is replaced by a target method, where both the default method and the target method are used to initiate a network request, and if the default parameter in the target method includes the parameter to be modified, a position of the default parameter corresponding to the parameter to be modified in the target method is searched, the default parameter at the position is replaced by the target parameter, and the target method subjected to parameter replacement is called to initiate a network request to connect to an environment corresponding to the target parameter.
By providing the target application, acquiring the parameter to be modified and the target parameter corresponding to the parameter to be modified in a parameter editing page of the target application, replacing a default method for initiating the network request in the target application with the target method, replacing the default parameter corresponding to the parameter to be modified in the target method with the target parameter, calling the target method subjected to parameter replacement to initiate the network request so as to be connected to the environment corresponding to the target parameter, and dynamically modifying the related parameter in the network request so as to be connected to the corresponding environment.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a parameter modification apparatus, as shown in fig. 5, the apparatus may include: aparameter obtaining module 510, amethod switching module 520, alocation searching module 530, and aparameter replacing module 540.
Aparameter obtaining module 510, configured to obtain a parameter to be modified and a target parameter corresponding to the parameter to be modified in a parameter editing page of a target application;
amethod switching module 520, configured to replace a default method for initiating a network request in the target application with a target method, where both the default method and the target method are used for initiating a network request;
alocation searching module 530, configured to search, if the default parameter in the target method includes the parameter to be modified, a location of the default parameter in the target method corresponding to the parameter to be modified;
aparameter replacing module 540, configured to replace the default parameter at the location with the target parameter, and invoke the target method subjected to parameter replacement to initiate a network request to connect to an environment corresponding to the target parameter.
An embodiment of the present invention further provides an electronic device, as shown in fig. 6, including aprocessor 61, acommunication interface 62, amemory 63, and acommunication bus 64, where theprocessor 61, thecommunication interface 62, and thememory 63 complete mutual communication through thecommunication bus 64,
amemory 63 for storing a computer program;
theprocessor 61 is configured to implement the following steps when executing the program stored in the memory 63:
acquiring a parameter to be modified and a target parameter corresponding to the parameter to be modified in a parameter editing page of a target application; replacing a default method for initiating a network request in the target application with a target method, wherein both the default method and the target method are used for initiating the network request; if the default parameters in the target method comprise the parameters to be modified, searching the positions of the default parameters corresponding to the parameters to be modified in the target method; and replacing the default parameters at the position with the target parameters, and calling the target method subjected to parameter replacement to initiate a network request so as to connect to the environment corresponding to the target parameters.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment of the present invention, a storage medium is further provided, which stores instructions that, when executed on a computer, cause the computer to perform the parameter modification method described in any of the above embodiments.
In a further embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the parameter modification method as described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a storage medium or transmitted from one storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The storage medium may be any available medium that can be accessed by a computer or a data storage device including one or more available media integrated servers, data centers, and the like. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the system embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.