Disclosure of Invention
The embodiment of the application provides a function management method, a management device, a terminal device and a readable storage medium, which can solve the problem of low execution efficiency of functions in front-end development to a certain extent.
In a first aspect, an embodiment of the present application provides a function management method, including:
receiving a function execution instruction, and searching a first target function corresponding to the function execution instruction in a first target global variable;
and if the first target function exists in the target global variable, returning a first target execution result, wherein the first target execution result is an execution result corresponding to the first target function in the first target global variable.
In a possible implementation manner of the first aspect, the method further includes:
and if the first target global variable does not have the first target function, executing the first target function to obtain a first target execution result, and storing the first target function and the first target execution result in the first target global variable in an associated manner.
In another possible implementation manner of the first aspect, the method further includes:
obtaining a target parameter value, and searching a second target function corresponding to the target parameter value in a second target global variable;
and if the second target global variable has the second target function, operating the second target function according to the target parameter value to obtain a second target execution result.
In another possible implementation manner of the first aspect, the method further includes:
acquiring a construction instruction;
and constructing the first target global variable and/or the second target global variable according to the construction instruction.
In a second aspect, an embodiment of the present application provides a function management apparatus, including:
the instruction receiving module is used for receiving a function execution instruction and searching a first target function corresponding to the function execution instruction in a first target global variable;
and a result returning module, configured to return a first target execution result if the first target function exists in the target global variable, where the first target execution result is an execution result corresponding to the first target function in the first target global variable.
In a third aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method according to the first aspect when executing the computer program.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and the computer program implements the steps of the method according to the first aspect when executed by a processor.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to execute the function management method described in any one of the above first aspects.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Compared with the prior art, the embodiment of the application has the advantages that:
the application provides a function management method, which comprises the steps of firstly, receiving a function execution instruction, and searching a first target function corresponding to the function execution instruction in a first target global variable. And if the first target function exists in the target global variable, returning a first target execution result, wherein the first target execution result is an execution result corresponding to the first target function in the first target global variable. In the present application, the first target execution result of the first target function is stored in the target global variable. Therefore, when the first target execution result corresponding to the first target function needs to be repeatedly obtained, the first target execution result can be directly obtained from the target global variable, and the first target function does not need to be operated to obtain the first target execution result. The first target execution result can be directly obtained from the target global variable, so that the first target function does not need to be repeatedly operated. Therefore, the first target execution result can be acquired more quickly.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The function management method provided by the embodiment of the application can be applied to terminal devices such as a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), and the like, and the embodiment of the application does not limit the specific types of the terminal devices.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
Example one
Referring to fig. 1, a method for managing a function according to an embodiment of the present application is described below, where the method includes:
step S101, receiving a function execution instruction, and searching a first target function corresponding to the function execution instruction in a first target global variable.
In step S101, when a function execution instruction is received, a first target function corresponding to the function execution instruction is first searched for in a first target global variable. The first objective function is a function that needs to be executed. The first target global variable is a pre-constructed variable, and the first target global variable comprises fields of function names, function content descriptions and function execution results.
And S102, if the first target function exists in the target global variable, returning a first target execution result, wherein the first target execution result is an execution result corresponding to the first target function in the first target global variable.
In step S102, if there is a first objective function in the target global variable, it indicates that the first objective function has already been run, so at this time, the first target execution result corresponding to the first objective function in the first target global variable may be directly returned without running the first objective function again.
In some embodiments, if the first objective function is not present in the first target global variable, it is indicated that the first objective function has not been run. Therefore, at this time, the first objective function needs to be run to obtain the first objective execution result. And then, the first target function and the first target execution result are stored in the first target global variable in an associated manner, so that the first target execution result can be directly obtained from the first target global variable when the first target execution result needs to be obtained next time, and the first target function does not need to be operated.
The first target function and the first target execution result association are stored in the first target global variable. Therefore, before the first objective function is executed, the first target global variable needs to be constructed according to the construction instruction.
In other embodiments, the method further comprises: acquiring a target parameter value, and searching a second target function corresponding to the target parameter value in a second target global variable; and if the second target global variable has the second target function, operating the second target function according to the target parameter value to obtain a second target execution result.
At present, if a component a needs to transmit a parameter value to a component B, the component B generally monitors a route of the component a, and when the route of the component a obtains a new parameter value, the component B obtains the new parameter value according to a preset template. Under this approach, when multiple components are present, the components can be rendered out of service.
In this embodiment, a second objective function that runs the target parameter values is first stored in a second target global variable. When the component a transfers the target parameter value, the terminal device may first determine whether the second target function exists in the second target global variable, and if so, it indicates that the target parameter value is transferred to the component B. Therefore, if the second target global variable has the second target function, the second target function is directly operated according to the target parameter value, and therefore the second target execution result is obtained.
The second target global variable is a pre-constructed variable, and the second target global variable comprises fields of function name, function content description and function execution result. Since the second objective function for operating the target parameter value needs to be stored in the second target global variable, the second target global variable needs to be constructed according to the construction instruction before the target parameter value is obtained.
In this embodiment, if the second target global variable has the second target function, it indicates that the target parameter value is transmitted to the component B, the component B is not required to monitor the route of the component a, and a template is not required to be set in advance.
To sum up, the present application provides a function management method, which first receives a function execution instruction, and searches a first target function corresponding to the function execution instruction in a first target global variable. And if the first target function exists in the target global variable, returning a first target execution result, wherein the first target execution result is an execution result corresponding to the first target function in the first target global variable. In the present application, the first target execution result of the first target function is stored in the target global variable. Therefore, when the first target execution result corresponding to the first target function needs to be repeatedly obtained, the first target execution result can be directly obtained from the target global variable, and the first target function does not need to be operated to obtain the first target execution result. The first target execution result can be directly obtained from the target global variable, so that the first target function does not need to be repeatedly operated. Therefore, the first target execution result can be acquired more quickly.
Further, the cache of Vue currently has a limit on the size of data to be stored, and cannot be stored if the size of data that needs to be stored exceeds a preset size. In the application, the first target execution result is stored in the first target global variable, and the size of the stored data is not limited, so that the problem that the data cannot be stored due to the cache of Vue is solved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Example two
Fig. 2 shows an example of a function management apparatus, and for convenience of explanation, only the portions related to the embodiments of the present application are shown. Theapparatus 200 comprises:
theinstruction receiving module 201 is configured to receive a function execution instruction, and search a first target function corresponding to the function execution instruction in the first target global variable.
Aresult returning module 202, configured to return a first target execution result if the first target function exists in the target global variable, where the first target execution result is an execution result corresponding to the first target function in the first target global variable.
Optionally, theapparatus 200 further comprises:
and the function execution module is used for executing the first target function to obtain a first target execution result if the first target global variable does not have the first target function, and storing the first target function and the first target execution result in the first target global variable in an associated manner.
Optionally, theapparatus 200 further comprises:
and the obtaining module is used for obtaining the target parameter value and searching a second target function corresponding to the target parameter value in the second target global variable.
Accordingly, the function execution module is further configured to perform:
and if the second target global variable has a second target function, operating the second target function according to the target parameter value to obtain a second target execution result.
Optionally, theapparatus 200 further comprises:
and the construction instruction acquisition module is used for acquiring construction instructions.
And the variable construction module is used for constructing the first target global variable and/or the second target global variable according to the construction instruction.
It should be noted that, for the information interaction, execution process, and other contents between the above-mentioned devices/units, the specific functions and technical effects thereof are based on the same concept as those of the method embodiment of the present application, and specific reference may be made to a part of the method embodiment, which is not described herein again.
EXAMPLE III
Fig. 3 is a schematic diagram of a terminal device provided in the third embodiment of the present application. As shown in fig. 3, theterminal device 300 of this embodiment includes: aprocessor 301, amemory 302, and acomputer program 303 stored in thememory 302 and operable on theprocessor 301. Theprocessor 301 implements the steps of the above-described method embodiments when executing thecomputer program 303. Alternatively, theprocessor 301 implements the functions of the modules/units in the device embodiments when executing thecomputer program 303.
Illustratively, thecomputer program 303 may be divided into one or more modules/units, which are stored in thememory 302 and executed by theprocessor 301 to complete the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of thecomputer program 303 in theterminal device 300. For example, thecomputer program 303 may be divided into an instruction receiving module and a result returning module, and the specific functions of the modules are as follows:
receiving a function execution instruction, and searching a first target function corresponding to the function execution instruction in a first target global variable;
if the first target function exists in the target global variable, returning a first target execution result, wherein the first target execution result is an execution result corresponding to the first target function in the first target global variable.
The terminal device may include, but is not limited to, aprocessor 301 and amemory 302. Those skilled in the art will appreciate that fig. 3 is merely an example of theterminal device 300 and does not constitute a limitation of theterminal device 300 and may include more or less components than those shown, or combine certain components, or different components, for example, the terminal device may further include input and output devices, network access devices, buses, etc.
TheProcessor 301 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware card, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Thestorage 302 may be an internal storage unit of theterminal device 300, such as a hard disk or a memory of theterminal device 300. Thememory 302 may also be an external storage device of theterminal device 300, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on theterminal device 300. Further, thememory 302 may include both an internal storage unit and an external storage device of theterminal device 300. Thememory 302 is used for storing the computer programs and other programs and data required by the terminal device. Thememory 302 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the apparatus may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the above modules or units is only one logical function division, and there may be other division manners in actual implementation, for example, a plurality of units or plug-ins may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units described above, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above method embodiments may be implemented by a computer program, which may be stored in a computer readable storage medium and executed by a processor, so as to implement the steps of the above method embodiments. The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file or some intermediate form. The computer readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium described above may include content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media that does not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.