Method and device for realizing and controlling front-end shortcut key, and computer storage medium
By preprocessing and real-time monitoring before the target plug-in is run, multiple shortcut key monitoring complexity and browser kernel compatibility issues are solved, efficient shortcut key management and response are achieved, and the reliability and convenience of plug-in are improved. .
Patent Information
- Application Number
- CN202410877257.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-11-22
AI Technical Summary
In the prior art, multiple shortcut key listening processes are complex, and there are problems such as response conflicts and memory leaks, making it difficult to effectively manage and compatible with shortcut key trigger identifiers of different browser cores.
Before the target plug-in is run, the shortcut key compatible identification list and browser type dictionary are generated, real-time monitoring and response are achieved through event listening functions, browser shortcut key status is managed, and different browser kernels are compatible.
It improves the complexity and response speed of shortcut key monitoring, reduces the risk of memory leakage, enhances the operation reliability and convenience of plug-ins, and is compatible with shortcut key trigger identifiers of different browser kernels.
Smart Images

Figure CN119003041A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of plug-in control technology, and in particular to a method and device for realizing and controlling front-end shortcut keys, and a computer storage medium. Background Art
[0002] The implementation scheme of the front-end keyboard shortcuts is currently mainly applied to the bottom layer of web browsers, and is implemented through the two APIs of key-down and key-up in the browser events. Based on these two APIs, the monitoring of single or multiple shortcut keys can be realized, and there are also differences in the implementation. For the monitoring of a single shortcut key, the monitoring and execution complexity of the action is relatively low. However, for the monitoring of multiple shortcut keys, it is necessary to comprehensively consider the compatibility of the key response identification, the conflict of multiple program shortcut keys, and the coordination between the key states every time the key is pressed or released, and the monitored events need to be destroyed in time to avoid problems such as memory leaks caused by the inability to recycle the program's memory. It can be seen that it is particularly important to provide a corresponding solution to the problems of difficulty and high complexity of monitoring in the process of monitoring multiple shortcut keys in the prior art. Summary of the invention
[0003] The present invention provides a method and device for realizing and controlling a front-end shortcut key, and a computer storage medium, which can solve the problem of response conflict of shortcut keys when multiple programs are opened and reduce the complexity of monitoring the shortcut keys.
[0004] In order to solve the above technical problems, the first aspect of the present invention discloses a method for implementing and managing front-end shortcut keys, which is applied to a preset target plug-in and includes:
[0005] After determining that the target plug-in meets the preset running conditions, determining the kernel type corresponding to the browser currently applied by the target plug-in and its corresponding current application environment, and performing a running preprocessing operation for the current application environment, wherein the running preprocessing operation includes at least one of generating a shortcut key compatible identification list, generating a browser type dictionary, and registering a browser event;
[0006] Calling the event listening function set in the target plug-in, and switching the function state of the event listening function to the real-time listening state;
[0007] When it is determined that the event monitoring function is in the real-time monitoring state, a monitoring operation is performed on the shortcut key triggering event according to the event monitoring function to obtain a monitoring result for the shortcut key triggering event; the shortcut key triggering event includes a first event corresponding to pressing the shortcut key or a second event corresponding to lifting the shortcut key;
[0008] When the monitoring result indicates the existence of the first event, a preset event response processing is performed on the first event to obtain an event response processing result for the first event; the event response processing includes at least one of generating a response list for the first event, event loop comparison based on a preset response list, callback for the first event, and event registration based on the event monitoring function.
[0009] As an optional implementation manner, in the first aspect of the present invention, performing a preset event response process on the first event to obtain an event response process result for the first event includes:
[0010] Determine whether the target plug-in has a first response list for responding to the first event, and when it is determined that the target plug-in does not have a first response list for responding to the first event, generate the first response list, and add the first event to the first response list according to a dictionary attribute corresponding to a preset browser type dictionary;
[0011] Taking the first event identifier corresponding to the first event as a comparison target, performing a preset circular comparison operation on the first response list to obtain a first comparison result for the first response list;
[0012] When the first comparison result indicates that the first event identifier has a matching recorded event identifier in the first response list, calling the callback function in the event listening function to perform a key trigger operation for the first event, and determining that the first event has been triggered;
[0013] When the first comparison result indicates that the first event identifier does not have a matching recorded event identifier in the first response list, the process returns to execute the monitoring operation on the shortcut key trigger event according to the event monitoring function, and obtains the operation corresponding to the monitoring result of the shortcut key trigger event.
[0014] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0015] When a run trigger instruction for the target plug-in is detected, performing plug-in initialization on the target plug-in;
[0016] Determine the current use environment corresponding to the target plug-in, and judge whether the current use environment is a browser. When it is judged that the current use environment is a browser, determine that the target plug-in meets the preset running conditions, and trigger the execution of the operation corresponding to the kernel type corresponding to the browser currently used by the target plug-in;
[0017] When it is determined that the current usage environment is not a browser, an operation exception processing is performed on the target plug-in to obtain an exception processing result for the target plug-in, wherein the operation exception processing includes an exception prompt and an end operation control for the target plug-in; the exception processing result is used to prompt the user that the current usage environment is not suitable for the target plug-in.
[0018] As an optional implementation, in the first aspect of the present invention, performing operation exception processing on the target plug-in to obtain an exception processing result for the target plug-in includes:
[0019] Determine whether the event listening function has registered an error handling hook. When it is determined that the error handling hook is not registered, throw an exception for the target plug-in and terminate the operation of the target plug-in as an exception handling result for the target plug-in.
[0020] When it is determined that the error handling hook has been registered, generating exception information for the target plug-in and the current use environment according to the error handling hook;
[0021] The exception information is fed back to the user through the error handling hook, and the operation of the target plug-in is terminated at the same time as the exception handling result for the target plug-in.
[0022] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0023] When the monitoring result indicates that the second event exists, deleting the second event identifier corresponding to the second event recorded in the second response list from the generated second response list;
[0024] Taking the second event identifier as a comparison target, performing a circular comparison on the second response list to obtain a second comparison result for the second response list;
[0025] When the second comparison result indicates that the deletion operation for the second event identifier in the second response list has been completed, the function state of the event monitoring function is switched to the real-time monitoring state.
[0026] As an optional implementation, in the first aspect of the present invention, the event monitoring function includes a path monitoring parameter, and the path monitoring parameter is used to monitor whether the path of the browser is switched; the method further includes:
[0027] When it is determined that the event monitoring function is in the real-time monitoring state, analyzing the path monitoring parameter to obtain a parameter type corresponding to the path monitoring parameter, where the parameter type includes any one of a first type, a second type, and a third type;
[0028] When it is determined that the parameter type is the first type, it is determined that there is no need to pass the path monitoring parameter;
[0029] When it is determined that the parameter type is the second type, according to the preset event clearing function, event clearing and function state switching are performed on the event listening function, and the event clearing is used to clear all listening events corresponding to the records of the event listening function; the function state switching is used to switch the function state of the event listening function to the end listening state.
[0030] As an optional embodiment, in the first aspect of the present invention, the method further comprises:
[0031] When it is determined that the parameter type is the third type, the environment path of the current application environment is obtained, and it is determined whether the path monitoring parameter is consistent with the environment path; when it is determined that the path monitoring parameter is inconsistent with the environment path, according to the event clearing function, the event clearing and the function state switching are performed on the event listening function;
[0032] The event monitoring function also includes a focus monitoring parameter, and the method also includes:
[0033] Determine a parameter state of the focus monitoring parameter, wherein the parameter state includes a first state or a non-first state indicating triggering of a focus event;
[0034] When it is determined that the parameter state is the first state, an event clearing operation is performed on the generated third response list to clear the third response list.
[0035] A second aspect of the present invention discloses a device for implementing and controlling front-end shortcut keys, the device being applied to a preset target plug-in, and comprising:
[0036] A determination module, configured to determine, after determining that the target plug-in meets a preset operating condition, a kernel type corresponding to a browser currently applied by the target plug-in and a corresponding current application environment;
[0037] A preprocessing module, used to perform a run preprocessing operation for the current application environment, wherein the run preprocessing operation includes at least one of generating a shortcut key compatible identifier list, generating a browser type dictionary, and registering a browser event;
[0038] A function calling module, used to call the event listening function set in the target plug-in;
[0039] A state switching module, used to switch the function state of the event monitoring function to a real-time monitoring state;
[0040] A monitoring processing module, for, when it is determined that the event monitoring function is in the real-time monitoring state, performing a monitoring operation on the shortcut key triggering event according to the event monitoring function, and obtaining a monitoring result for the shortcut key triggering event; the shortcut key triggering event includes a first event corresponding to pressing the shortcut key or a second event corresponding to lifting the shortcut key;
[0041] An event response module is used to perform preset event response processing on the first event when the monitoring result indicates the existence of the first event, so as to obtain an event response processing result for the first event; the event response processing includes generating a response list for the first event, event loop comparison based on the preset response list, callback for the first event, and event registration based on the event monitoring function.
[0042] As an optional implementation, in the second aspect of the present invention, the event response module performs a preset event response process on the first event, and a manner of obtaining an event response process result for the first event specifically includes:
[0043] Determine whether the target plug-in has a first response list for responding to the first event, and when it is determined that the target plug-in does not have a first response list for responding to the first event, generate the first response list, and add the first event to the first response list according to a dictionary attribute corresponding to a preset browser type dictionary;
[0044] Taking the first event identifier corresponding to the first event as a comparison target, performing a preset circular comparison operation on the first response list to obtain a first comparison result for the first response list;
[0045] When the first comparison result indicates that the first event identifier has a matching recorded event identifier in the first response list, calling the callback function in the event listening function to perform a key trigger operation for the first event, and determining that the first event has been triggered;
[0046] When the first comparison result indicates that the first event identifier does not have a matching recorded event identifier in the first response list, the process returns to execute the monitoring operation on the shortcut key trigger event according to the event monitoring function, and obtains the operation corresponding to the monitoring result of the shortcut key trigger event.
[0047] As an optional implementation, in the second aspect of the present invention, the device further includes:
[0048] An initialization module, configured to perform plug-in initialization on the target plug-in when a run trigger instruction for the target plug-in is detected;
[0049] The determination module is further used to determine the current usage environment corresponding to the target plug-in;
[0050] A determination module, used to determine whether the current use environment is a browser, and when it is determined that the current use environment is a browser, determine whether the target plug-in meets the preset running conditions, and trigger the determination module to perform the operation corresponding to the kernel type corresponding to the browser currently used by the target plug-in;
[0051] The exception handling module is used to perform operation exception handling on the target plug-in when the judgment module determines that the current usage environment is not a browser, and obtain an exception handling result for the target plug-in, wherein the operation exception handling includes an exception prompt and an end operation control for the target plug-in; the exception handling result is used to prompt the user that the current usage environment is not suitable for the target plug-in.
[0052] As an optional implementation, in the second aspect of the present invention, the exception handling module performs operation exception handling on the target plug-in, and a method of obtaining an exception handling result for the target plug-in specifically includes:
[0053] Determine whether the event listening function has registered an error handling hook. When it is determined that the error handling hook is not registered, throw an exception for the target plug-in and terminate the operation of the target plug-in as an exception handling result for the target plug-in.
[0054] When it is determined that the error handling hook has been registered, generating exception information for the target plug-in and the current use environment according to the error handling hook;
[0055] The exception information is fed back to the user through the error handling hook, and the operation of the target plug-in is terminated at the same time as the exception handling result for the target plug-in.
[0056] As an optional implementation, in the second aspect of the present invention, the device further includes:
[0057] A second monitoring module, configured to delete, from a generated second response list, a second event identifier corresponding to the second event recorded in the second response list when the monitoring result indicates that the second event exists;
[0058] The second monitoring module is further configured to perform a circular comparison on the second response list using the second event identifier as a comparison target to obtain a second comparison result for the second response list;
[0059] The second monitoring module is further configured to switch the function state of the event monitoring function to the real-time monitoring state when the second comparison result indicates that the deletion operation for the second event identifier in the second response list has been completed.
[0060] As an optional implementation, in the second aspect of the present invention, the event monitoring function includes a path monitoring parameter, and the path monitoring parameter is used to monitor whether the path of the browser is switched; the device also includes:
[0061] A third monitoring module is used to analyze the path monitoring parameter when it is determined that the event monitoring function is in the real-time monitoring state, and obtain a parameter type corresponding to the path monitoring parameter, wherein the parameter type includes any one of the first type, the second type and the third type;
[0062] The third monitoring module is further configured to determine that there is no need to transmit the path monitoring parameter when it is determined that the parameter type is the first type;
[0063] The third monitoring module is also used to, when it is determined that the parameter type is the second type, perform event clearing and function state switching on the event monitoring function according to a preset event clearing function, wherein the event clearing is used to clear all monitoring events corresponding to the records of the event monitoring function; and the function state switching is used to switch the function state of the event monitoring function to the end monitoring state.
[0064] As an optional implementation, in the second aspect of the present invention, the third monitoring module is further used to, when it is determined that the parameter type is the third type, obtain the environment path of the current application environment, and determine whether the path monitoring parameter is consistent with the environment path; when it is determined that the path monitoring parameter is inconsistent with the environment path, execute the event clearing and the function state switching on the event monitoring function according to the event clearing function;
[0065] The event monitoring function also includes a focus monitoring parameter, and the device also includes:
[0066] A focus processing module, used to determine a parameter state of the focus monitoring parameter, wherein the parameter state includes a first state or a non-first state indicating triggering a focus event;
[0067] The focus processing module is further configured to, when it is determined that the parameter state is the first state, perform an event clearing operation on the generated third response list to clear the third response list.
[0068] The third aspect of the present invention discloses another device for implementing and controlling front-end shortcut keys, the device comprising:
[0069] A memory storing executable program code;
[0070] a processor coupled to the memory;
[0071] The processor calls the executable program code stored in the memory to execute the implementation and control method of the front-end shortcut keys disclosed in the first aspect of the present invention.
[0072] The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute the implementation and control method of the front-end shortcut keys disclosed in the first aspect of the present invention.
[0073] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0074] In implementing the present invention, a scheme for realizing shortcut key functions based on a separate plug-in is designed. Before running the target plug-in, corresponding operation preprocessing is performed to provide reliable operation conditions for the operation of the target plug-in, thereby reducing the probability of the target plug-in failing to run, reporting operation errors, etc. due to the incompatibility of the operation environment with the target plug-in and / or incomplete loading of related functions of the target plug-in. That is, the setting of the operation preprocessing is conducive to improving the operation reliability of the target plug-in; in addition, after determining to execute the operation preprocessing, the real-time monitoring function of the shortcut key triggering event is realized through the event monitoring function set in the target plug-in, and the corresponding response process is set for the first event, thereby improving the response speed and response reliability of the first event; and the application of the target plug-in realizes the centralized management of the browser shortcut key status, which is conducive to improving the user's convenience of use and reducing the user's maintenance cost; at the same time, because the target plug-in can be compatible with different browser kernels, it can solve the problem of shortcut key triggering identification differences caused by different browser kernels. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0076] Figure 1 It is a flowchart of a method for implementing and controlling a front-end shortcut key disclosed in an embodiment of the present invention;
[0077] Figure 2 It is a flowchart of another method for realizing and controlling front-end shortcut keys disclosed in an embodiment of the present invention;
[0078] Figure 3It is a structural schematic diagram of a front-end shortcut key implementation and control device disclosed in an embodiment of the present invention;
[0079] Figure 4 It is a structural schematic diagram of another front-end shortcut key implementation and control device disclosed in an embodiment of the present invention;
[0080] Figure 5 It is a structural schematic diagram of another front-end shortcut key implementation and control device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0081] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0082] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product or end including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or ends.
[0083] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0084] The present invention discloses a method and device for realizing and controlling front-end shortcut keys, and a computer storage medium. A shortcut key function realization scheme based on a separate plug-in is designed. Before running a target plug-in, a corresponding operation preprocessing is performed to provide reliable operation conditions for the operation of the target plug-in, and the probability of the target plug-in failing to run, reporting an error, etc. due to the incompatibility of the operation environment with the target plug-in and / or the incomplete loading of the relevant functions of the target plug-in is reduced, that is, the setting of the operation preprocessing is conducive to improving the operation reliability of the target plug-in; in addition, after determining to execute the operation preprocessing, the real-time monitoring function of the shortcut key triggering event is realized through the event monitoring function set in the target plug-in, and the corresponding response process is set for the first event, which improves the response speed and response reliability of the first event; and the application of the target plug-in realizes the centralized management of the browser shortcut key status, which is conducive to improving the user's convenience of use and reducing the user's maintenance cost; at the same time, because the target plug-in can be compatible with different browser kernels, it can solve the problem of the difference in shortcut key triggering identification caused by different browser kernels. The following are described in detail.
[0085] Embodiment 1
[0086] See also Figure 1 , Figure 1 It is a flowchart of a method for implementing and controlling a front-end shortcut key disclosed in an embodiment of the present invention. Figure 1 The implementation and control method of the front-end shortcut keys described above can be applied to the implementation and control device of the front-end shortcut keys, and the implementation and control method of the front-end shortcut keys can also be applied to the integrated target plug-in, which is not limited in the embodiment of the present invention. Figure 1 As shown, the implementation and control method of the front-end shortcut keys may include the following operations:
[0087] 101. After determining that the target plug-in meets the preset running conditions, determine the kernel type corresponding to the browser currently applied by the target plug-in and its corresponding current application environment.
[0088] In the embodiment of the present invention, the target plug-in is actually applied as a singleton, and all configuration parameters and logics are logically executed through this singleton.
[0089] In the embodiment of the present invention, the target plug-in meeting the preset running condition may include: the target plug-in completes the initialization of the plug-in, and the current running environment / application environment of the target plug-in supports the event response function of the shortcut key event integrated in the target plug-in by default.
[0090] 102. Execute a pre-processing operation for the current application environment, where the pre-processing operation includes at least one of generating a shortcut key compatible identifier list, generating a browser type dictionary, and registering a browser event.
[0091] In an embodiment of the present invention, after completing the initialization of the target plug-in and determining that the current application environment supports the normal operation of the target plug-in and its related functions, before the target plug-in is officially run, a series of "running pre-processing" preparations need to be performed, including generating a shortcut key compatible identification list, which can be a key identification record list, and also includes the generation of a browser type dictionary (Browser type Dictionary), the generation of which needs to adapt to the kernel type of the browser currently applied by the target plug-in and depends on the shortcut key compatible identification list generated in advance.
[0092] In an embodiment of the present invention, optionally, when the target plug-in is initially run, the relevant necessary data (referring to the relevant functions / data that can support the normal operation of the target plug-in) have not been loaded and registered. At this time, it is necessary to perform a registration operation on the browser event, and the browser event includes at least one of the key-down, key-up, focus, and popstate events.
[0093] 103. Call the event monitoring function set in the target plug-in, and switch the function state of the event monitoring function to the real-time monitoring state.
[0094] In the embodiment of the present invention, there are various ways to perform event monitoring. Event monitoring based on the Register function can be used here. Specifically, shortcut key monitoring is registered through the Register function. Therefore, the event monitoring function refers to the Register function or refers to other functions with shortcut key monitoring function defined by the Register function.
[0095] 104. When it is determined that the event monitoring function is in the real-time monitoring state, a monitoring operation is performed on the shortcut key triggering event according to the event monitoring function to obtain a monitoring result for the shortcut key triggering event.
[0096] In an embodiment of the present invention, the shortcut key trigger event includes a first event corresponding to pressing the shortcut key or a second event corresponding to lifting the shortcut key, wherein the first event may be an event corresponding to key-down, and the second event may be an event corresponding to key-up.
[0097] 105. When the monitoring result indicates that the first event exists, perform a preset event response process on the first event to obtain an event response process result for the first event.
[0098] In an embodiment of the present invention, event response processing includes at least one of generating a response list for a first event, event loop comparison based on a preset response list, callback for the first event, and event registration based on an event listening function.
[0099] It can be seen that implementation Figure 1 The described front-end shortcut key implementation and control method designs a shortcut key function implementation scheme based on a separate plug-in, performs corresponding operation preprocessing before running the target plug-in, provides reliable operation conditions for the operation of the target plug-in, reduces the probability of the target plug-in failing to run, reporting errors, etc. due to the incompatibility of the operation environment with the target plug-in and / or incomplete loading of related functions of the target plug-in, that is, the setting of the operation preprocessing is conducive to improving the operation reliability of the target plug-in; in addition, after determining to execute the operation preprocessing, the real-time monitoring function of the shortcut key triggering event is realized through the event monitoring function set in the target plug-in, and the corresponding response process is set for the first event, which improves the response speed and response reliability of the first event; and the application of the target plug-in realizes the centralized management of the browser shortcut key status, which is conducive to improving the user's convenience and reducing the user's maintenance cost; at the same time, because the target plug-in can be compatible with different browser kernels, it can solve the problem of shortcut key triggering identification differences caused by different browser kernels.
[0100] In an optional embodiment, the above step 105 performs a preset event response process on the first event, and a method of obtaining an event response process result for the first event specifically includes:
[0101] Determine whether the target plug-in has a first response list for responding to the first event. When it is determined that the target plug-in does not have a first response list for responding to the first event, generate the first response list, and add the first event to the first response list according to a dictionary attribute corresponding to a preset browser type dictionary;
[0102] Taking the first event identifier corresponding to the first event as a comparison target, performing a preset circular comparison operation on the first response list to obtain a first comparison result for the first response list;
[0103] When the first comparison result indicates that the first event identifier has a matching recorded event identifier in the first response list, calling the callback function in the event listening function to perform a key trigger operation for the first event, and determining that the first event has been triggered;
[0104] When the first comparison result indicates that there is no matching recorded event identifier for the first event identifier in the first response list, the process returns to execute the above-mentioned event monitoring function, performs the monitoring operation on the shortcut key triggering event, and obtains the operation corresponding to the monitoring result of the shortcut key triggering event.
[0105] In this optional embodiment, the first response list can be a KeyDownList list in actual application; for the trigger event of detecting a key being pressed, after the first event is listened to by the event listening function, the first event will be recorded in the KeyDownList list, so that the first event identifier of the first event is used as the comparison target, and a circular comparison is performed in sequence in the KeyDownList list to check whether there is a record for the first event in the KeyDownList list. If so, the key trigger operation matching the first event is executed through the callback function; if not, it returns to the event listening function.
[0106] It can be seen that in this optional embodiment, the processing mechanism for the first event corresponding to the pressing of the shortcut key is integrated through the event monitoring function, which improves the timeliness of monitoring the first event and the response processing speed and reliability; thereby improving the applicability of shortcut key management based on target plug-in integration.
[0107] In another optional embodiment, the method further comprises:
[0108] When the monitoring result indicates that the second event exists, deleting the second event identifier corresponding to the second event recorded in the second response list from the generated second response list;
[0109] Taking the second event identifier as a comparison target, performing a circular comparison on the second response list to obtain a second comparison result for the second response list;
[0110] When the second comparison result indicates that the deletion operation for the second event identifier in the second response list has been completed, the function state of the event monitoring function is switched to a real-time monitoring state.
[0111] In this optional embodiment, the second event is an event corresponding to the lifting of a key, recorded as a key-up event, and the second response list can be a KeyDownList list. Among them, the first response list and the second response list can be the same list or different lists. When the page / path of the browser has not changed, and the adjacent listening time of the first event and the second event is within the preset listening time, such as 2 seconds, the first response list and the second response list can be the same KeyDownList list; otherwise, when the page / path of the browser has changed, or the adjacent listening time of the first event and the second event is outside the preset listening time, such as 60 seconds, multiple response lists have been newly created and deleted at this time, and correspondingly, the first response list and the second response list refer to different KeyDownList lists, and the specific situation is adjusted according to the actual application situation, and the embodiment of the present invention is not limited.
[0112] For the second event, the corresponding event monitoring and response process is also set up. When the event monitoring function monitors the second event, it is necessary to respond to and delete the event in a timely manner. The operation process is the same as the processing process type of the first event. The difference is that for the second event, it is necessary to delete the event from the second response list.
[0113] It can be seen that in this optional embodiment, a corresponding event monitoring and response mechanism is also designed for the second event of the shortcut key being lifted, which improves the timeliness of monitoring the second event as well as the speed and reliability of response processing; it is conducive to improving the applicability of shortcut key management and control based on target plug-in integration.
[0114] In yet another optional embodiment, the event monitoring function includes a path monitoring parameter, and the path monitoring parameter is used to monitor whether the path of the browser is switched;
[0115] The method further includes:
[0116] When it is determined that the event monitoring function is in the real-time monitoring state, the path monitoring parameter is analyzed to obtain a parameter type corresponding to the path monitoring parameter, where the parameter type includes any one of the first type, the second type, and the third type;
[0117] When it is determined that the parameter type is the first type, it is determined that there is no need to pass the path monitoring parameter;
[0118] When it is determined that the parameter type is the second type, according to the preset event clearing function, event clearing and function state switching are performed on the event listening function. Event clearing is used to clear all listening events recorded corresponding to the event listening function; function state switching is used to switch the function state of the event listening function to the end listening state.
[0119] In this optional embodiment, optionally, the method further includes:
[0120] When it is determined that the parameter type is the third type, the environment path of the current application environment is obtained, and it is determined whether the path monitoring parameters are consistent with the environment path; when it is determined that the path monitoring parameters are inconsistent with the environment path, according to the event clearing function, the event listening function is executed event clearing and function state switching.
[0121] In this optional embodiment, when using the Register function of the target plug-in to register a shortcut key listener, at least three parameters are set. The first parameter of the three parameters includes a response list for recording shortcut keys, that is, the first response list, the second response list, and the shortcut key compatibility identification list mentioned above; the second parameter is a callback function for executing parameter callback and event response execution; the third parameter is used to perform path management of the browser page currently applied by the target plug-in, that is, the third parameter is the above-mentioned path listening parameter. In actual application, the path listening parameter corresponds to the management of popstate events.
[0122] In this optional embodiment, when the parameter type is the first type, the parameter value corresponding to the path listening parameter can be set to False; when the parameter type is the second type, the parameter value corresponding to the path listening parameter can be set to True; when the parameter type is the third type, the parameter value corresponding to the path listening parameter can be set to a string.
[0123] In this optional embodiment, when the parameter type is the first type, that is, the parameter value of the path listening parameter is False, this parameter value does not require parameter passing by default, and no other additional operations need to be performed; when the parameter type is the second type, that is, the parameter value of the path listening parameter is True, under this parameter value, the target plug-in will automatically remove the listening of the event listening function Register function by calling the Remove function, thereby triggering the browser's memory recovery; when the parameter type is the third type, that is, the parameter value of the path listening parameter is a string, at this time, the path Path Name of the current page of the browser needs to be compared with the string. If they are consistent, no other operations are performed. If they are inconsistent, the listening of the Register function needs to be removed and the browser's memory recovery is triggered.
[0124] It can be seen that in this optional embodiment, a path management mechanism is set up for the browser page, and timely monitoring and response can be performed for the situation where the path of the browser page changes, thereby correspondingly executing the removal of the Register function monitoring, and realizing the recovery of the browser memory in a timely and rapid manner, which is beneficial to improving the accuracy of releasing the browser memory; it is also beneficial to improve the applicability of shortcut key management and control based on the integration of the target plug-in.
[0125] In this optional embodiment, optionally, the event monitoring function further includes a focus monitoring parameter, and the method further includes:
[0126] Determine a parameter state of a focus monitoring parameter, where the parameter state includes a first state or a non-first state indicating triggering of a focus event;
[0127] When it is determined that the parameter state is the first state, an event clearing operation is performed on the generated third response list to clear the third response list.
[0128] In this optional embodiment, after initialization, the plug-in will listen to the focus event of the browser. Due to the multitasking of the operating system, multiple programs can be opened at the same time. When the background program conflicts with the current plug-in registered shortcut key, the plug-in shortcut key will not be triggered. Therefore, when the browser's focus event is triggered, it means that the carrier program of this plug-in is not in the activated state, and the focus of the carrier program will disappear. Therefore, the plug-in will clear the KeyDown List in the properties, thereby avoiding state inconsistency.
[0129] It can be seen that in this optional embodiment, a monitoring and response mechanism for the browser focus event is set up, which solves the problem of shortcut key status confusion caused by the monitoring shortcut key not being triggered when multiple programs are running due to the priority concept of shortcut key processing and the single termination mechanism of the operating system, and improves the applicability of shortcut key management and control based on target plug-in integration.
[0130] Embodiment 2
[0131] See also Figure 2 , Figure 2 It is a flowchart of another method for implementing and controlling front-end shortcut keys disclosed in an embodiment of the present invention. Figure 2 The described method for implementing and controlling the front-end shortcut keys can be applied to the implementation and control device for the front-end shortcut keys, and the embodiments of the present invention are not limited thereto. Figure 2 As shown, the implementation and control method of the front-end shortcut keys may include the following operations:
[0132] 201. When a run trigger instruction for a target plug-in is detected, plug-in initialization is performed on the target plug-in.
[0133] 202. Determine the current usage environment corresponding to the target plug-in, and judge whether the current usage environment is a browser.
[0134] In the embodiment of the present invention, when step 202 determines that the current use environment is a browser, it is determined that the target plug-in meets the preset running conditions, and step 204 is triggered. When step 202 determines that the current use environment is a browser, step 203 is triggered.
[0135] 203. Perform operation exception processing on the target plug-in to obtain an exception processing result for the target plug-in.
[0136] In the embodiment of the present invention, the operation exception processing includes an exception prompt and an end operation control for the target plug-in; the exception processing result is used to prompt the user that the current use environment is not suitable for the target plug-in.
[0137] In the embodiment of the present invention, optionally, after step 202 determines that the current usage environment is a browser, the method further includes:
[0138] The key identifier to be currently registered is obtained, and the key identifier is matched and compared with the preset browser type to obtain a corresponding matching result. When the key identifier does not have a corresponding matching record in the attribute corresponding to the browser type, step 203 is triggered to be executed. When the key identifier has a corresponding matching record in the attribute corresponding to the browser type, step 204 is triggered to be executed.
[0139] 204. After determining that the target plug-in meets the preset running condition, determine the kernel type corresponding to the browser currently applied by the target plug-in and its corresponding current application environment.
[0140] 205. Execute a pre-processing operation for the current application environment, where the pre-processing operation includes at least one of generating a shortcut key compatible identifier list, generating a browser type dictionary, and registering a browser event.
[0141] 206. Call the event monitoring function set in the target plug-in, and switch the function state of the event monitoring function to the real-time monitoring state.
[0142] 207. When it is determined that the event monitoring function is in the real-time monitoring state, a monitoring operation is performed on the shortcut key triggering event according to the event monitoring function to obtain a monitoring result for the shortcut key triggering event.
[0143] 208. When the monitoring result indicates that the first event exists, perform a preset event response process on the first event to obtain an event response process result for the first event.
[0144] In the embodiment of the present invention, for other descriptions of step 201 and steps 204 to 208, please refer to other specific descriptions of step 101 to 105 in the first embodiment, which will not be repeated in the embodiment of the present invention.
[0145] It can be seen that implementation Figure 2The implementation and control method of the front-end shortcut keys described sets up an identification mechanism for the current use environment of the target plug-in. At the same time, different processing procedures are set for the situation where the current use environment is not compatible with the target plug-in. For the situation where the user has registered an ErrorHandler hook, the user is notified based on the ErrorHandler hook that the target plug-in is not compatible with the current use environment. For the situation where the user has not registered an ErrorHandler hook, an exception message is directly thrown; thereby enabling the user to quickly discover whether the target plug-in is compatible with the current use environment, improving the applicability of the target plug-in.
[0146] In an optional embodiment, the above step 203 performs operation exception processing on the target plug-in, and the method of obtaining the exception processing result for the target plug-in specifically includes:
[0147] Determine whether the event listening function has registered an error handling hook. If it is determined that the error handling hook is not registered, throw an exception for the target plug-in and terminate the operation of the target plug-in as the exception handling result for the target plug-in.
[0148] When it is determined that an error handling hook has been registered, exception information for the target plug-in and the current usage environment is generated according to the error handling hook;
[0149] The exception information is fed back to the user through the error handling hook, and the operation of the target plug-in is terminated as the exception handling result for the target plug-in.
[0150] In the embodiment of the present invention, the error handling hook can be an ErrorHandler hook function, which is used to execute specific error handling logic. Generally speaking, the Browser Type property will contain all shortcut keys, unless the user deliberately enters an incorrect shortcut key name when registering. If the user needs to query the shortcut keys supported by the plug-in, the Names property of Browser Type can also be obtained through the Get Shortcut Names method.
[0151] It can be seen that in this optional embodiment, a corresponding exception handling mechanism is set up for registering / unregistering the error handling hook, so that the user can quickly find out whether the target plug-in is compatible with the current usage environment. If the target plug-in is not compatible with the current usage environment, the operation of the target plug-in is terminated in time, thereby reducing the occurrence of the target plug-in not matching the current usage environment but continuing to run and occupying the running memory, which is beneficial to improving the applicability of the target plug-in to a certain extent.
[0152] In another optional embodiment, the method further comprises:
[0153] Detecting whether a target removal instruction for the event listening function is received, where the target removal instruction is an instruction generated based on a preset removal function;
[0154] When it is detected that a target removal instruction for the event monitoring function is received, determining a target removal event corresponding to the target removal instruction, the target removal event including a first event and / or a second event;
[0155] According to the target removal instruction, combined with the set removal function, the removal processing is performed on the target removal event.
[0156] In this optional embodiment, the removal function may be a Remove function, or a function with a removal function derived from the Remove function, which is not limited in this optional embodiment.
[0157] In this optional embodiment, the target plug-in provides a Remove method, which is exposed to the user. When using this target plug-in, the user can flexibly adjust and remove the monitoring event of any shortcut key according to the complexity of the development project business. For example, when there is a need for the plug-in to remove the monitoring event of the shortcut key not because of a path change, the user can also remove the monitoring of the shortcut key event according to the business scenario. Flexible addition and deletion of shortcut key event monitoring is possible through the Register and Remove methods.
[0158] It can be seen that in this optional embodiment, by using the target plug-in, the monitoring events of the shortcut keys can be flexibly adjusted, thereby improving the flexibility and convenience of using the target plug-in.
[0159] Embodiment 3
[0160] See also Figure 3 , Figure 3 It is a schematic diagram of the structure of a front-end shortcut key implementation and control device disclosed in an embodiment of the present invention. The front-end shortcut key implementation and control device can be a front-end shortcut key implementation and control terminal, device, system or server. The server can be a local server, a remote server, or a cloud server (also known as a cloud server). When the server is a non-cloud server, the non-cloud server can communicate with the cloud server, which is not limited in the embodiment of the present invention. Figure 3 As shown, the front-end shortcut key implementation and control device may include a determination module 301, a preprocessing module 302, a function call module 303, a state switching module 304, a monitoring processing module 305 and an event response module 306, wherein:
[0161] The determination module 301 is used to determine the kernel type corresponding to the browser currently applied by the target plug-in and its corresponding current application environment after determining that the target plug-in meets the preset running conditions;
[0162] A preprocessing module 302, used to perform a running preprocessing operation for the current application environment, the running preprocessing operation including at least one of generating a shortcut key compatible identifier list, generating a browser type dictionary, and registering a browser event;
[0163] Function calling module 303, used to call the event monitoring function set in the target plug-in;
[0164] A state switching module 304 is used to switch the function state of the event monitoring function to a real-time monitoring state;
[0165] The monitoring processing module 305 is used to perform a monitoring operation on the shortcut key triggering event according to the event monitoring function when it is determined that the event monitoring function is in a real-time monitoring state, and obtain a monitoring result for the shortcut key triggering event; the shortcut key triggering event includes a first event corresponding to pressing the shortcut key or a second event corresponding to lifting the shortcut key;
[0166] The event response module 306 is used to perform preset event response processing on the first event when the monitoring result indicates the existence of the first event, and obtain the event response processing result for the first event; the event response processing includes generating a response list for the first event, comparing the event loop based on the preset response list, calling back the first event, and registering the event based on the event monitoring function.
[0167] It can be seen that implementation Figure 3 The front-end shortcut key implementation and control device described is designed to implement a shortcut key function implementation scheme based on a separate plug-in. Before running the target plug-in, the corresponding operation preprocessing is performed to provide reliable operating conditions for the operation of the target plug-in, reducing the probability of the target plug-in failing to run, running errors, etc. due to the incompatibility of the operating environment with the target plug-in and / or incomplete loading of related functions of the target plug-in. That is, the setting of the operation preprocessing is conducive to improving the operation reliability of the target plug-in; in addition, after determining to execute the operation preprocessing, the real-time monitoring function of the shortcut key triggering event is realized through the event monitoring function set in the target plug-in, and the corresponding response process is set for the first event, which improves the response speed and response reliability of the first event; and the application of the target plug-in realizes the centralized management of the browser shortcut key status, which is conducive to improving the user's convenience and reducing the user's maintenance cost; at the same time, because the target plug-in can be compatible with different browser kernels, it can solve the problem of shortcut key triggering identification differences caused by different browser kernels.
[0168] In an optional embodiment, the event response module 306 performs a preset event response process on the first event, and a method of obtaining an event response process result for the first event specifically includes:
[0169] Determine whether the target plug-in has a first response list for responding to the first event. When it is determined that the target plug-in does not have a first response list for responding to the first event, generate the first response list, and add the first event to the first response list according to a dictionary attribute corresponding to a preset browser type dictionary;
[0170] Taking the first event identifier corresponding to the first event as a comparison target, performing a preset circular comparison operation on the first response list to obtain a first comparison result for the first response list;
[0171] When the first comparison result indicates that the first event identifier has a matching recorded event identifier in the first response list, calling the callback function in the event listening function to perform a key trigger operation for the first event, and determining that the first event has been triggered;
[0172] When the first comparison result indicates that there is no matching recorded event identifier for the first event identifier in the first response list, the process returns to execute the above-mentioned event monitoring function, performs the monitoring operation on the shortcut key triggering event, and obtains the operation corresponding to the monitoring result of the shortcut key triggering event.
[0173] It can be seen that in this optional embodiment, the processing mechanism for the first event corresponding to the pressing of the shortcut key is integrated through the event monitoring function, which improves the timeliness of monitoring the first event and the response processing speed and reliability; thereby improving the applicability of shortcut key management based on target plug-in integration.
[0174] In another alternative embodiment, see Figure 4 , Figure 4 is a schematic diagram of the structure of another front-end shortcut key implementation and control device disclosed in an embodiment of the present invention; Figure 4 As shown, the device also includes an initialization module 307, a judgment module 308 and an exception handling module 309, wherein:
[0175] Initialization module 307, used to perform plug-in initialization on the target plug-in when a run trigger instruction for the target plug-in is detected;
[0176] The determination module 301 is further used to determine the current usage environment corresponding to the target plug-in;
[0177] The judging module 308 is used to judge whether the current use environment is a browser. When it is judged that the current use environment is a browser, it is determined that the target plug-in meets the preset running conditions, and the determining module 301 is triggered to perform an operation corresponding to the kernel type corresponding to the browser currently used by the target plug-in;
[0178] The exception handling module 309 is used to perform operation exception handling on the target plug-in when the judgment module 308 determines that the current usage environment is not a browser, and obtain the exception handling result for the target plug-in. The operation exception handling includes an exception prompt and end operation control for the target plug-in; the exception handling result is used to prompt the user that the current usage environment is not suitable for the target plug-in.
[0179] It can be seen that in this optional embodiment, an identification mechanism for the current use environment of the target plug-in is set. At the same time, different processing procedures are set for the situation where the current use environment is not compatible with the target plug-in. For the situation where the user has registered the ErrorHandler hook, the user is notified based on the ErrorHandler hook that the target plug-in is not compatible with the current use environment. For the situation where the user has not registered the ErrorHandler hook, an exception message is directly thrown; thereby enabling the user to quickly discover whether the target plug-in is compatible with the current use environment, improving the applicability of the target plug-in.
[0180] In another optional embodiment, the exception handling module 309 performs operation exception handling on the target plug-in, and the manner of obtaining the exception handling result for the target plug-in specifically includes:
[0181] Determine whether the event listening function has registered an error handling hook. If it is determined that the error handling hook is not registered, throw an exception for the target plug-in and terminate the operation of the target plug-in as the exception handling result for the target plug-in.
[0182] When it is determined that an error handling hook has been registered, exception information for the target plug-in and the current usage environment is generated according to the error handling hook;
[0183] The exception information is fed back to the user through the error handling hook, and the operation of the target plug-in is terminated as the exception handling result for the target plug-in.
[0184] It can be seen that in this optional embodiment, a corresponding exception handling mechanism is set up for registering / unregistering the error handling hook, so that the user can quickly find out whether the target plug-in is compatible with the current usage environment. If the target plug-in is not compatible with the current usage environment, the operation of the target plug-in is terminated in time, thereby reducing the occurrence of the target plug-in not matching the current usage environment but continuing to run and occupying the running memory, which is beneficial to improving the applicability of the target plug-in to a certain extent.
[0185] In another optional embodiment, Figure 4 As shown, the device also includes a second monitoring module 310, wherein:
[0186] The second monitoring module 310 is configured to delete the second event identifier corresponding to the second event recorded in the second response list from the generated second response list when the monitoring result indicates that the second event exists;
[0187] The second monitoring module 310 is further used to perform a circular comparison on the second response list with the second event identifier as a comparison target to obtain a second comparison result for the second response list;
[0188] The second monitoring module 310 is further configured to switch the function state of the event monitoring function to the real-time monitoring state when the second comparison result indicates that the deletion operation for the second event identifier in the second response list has been completed.
[0189] It can be seen that in this optional embodiment, a corresponding event monitoring and response mechanism is also designed for the second event of the shortcut key being lifted, which improves the timeliness of monitoring the second event as well as the speed and reliability of response processing; it is conducive to improving the applicability of shortcut key management and control based on target plug-in integration.
[0190] In another optional embodiment, the event monitoring function includes a path monitoring parameter, and the path monitoring parameter is used to monitor whether the path of the browser is switched; Figure 4 As shown, the device also includes a third monitoring module 311, wherein:
[0191] The third monitoring module 311 is used to analyze the path monitoring parameter when it is determined that the event monitoring function is in the real-time monitoring state, and obtain the parameter type corresponding to the path monitoring parameter, where the parameter type includes any one of the first type, the second type and the third type;
[0192] The third monitoring module 311 is further configured to determine that there is no need to transmit the path monitoring parameter when it is determined that the parameter type is the first type;
[0193] The third monitoring module 311 is also used to perform event clearing and function state switching on the event monitoring function according to a preset event clearing function when it is determined that the parameter type is the second type. Event clearing is used to clear all monitoring events recorded corresponding to the event monitoring function; function state switching is used to switch the function state of the event monitoring function to the end monitoring state.
[0194] In this optional embodiment, the third monitoring module 311 is also used to obtain the environment path of the current application environment and determine whether the path monitoring parameters are consistent with the environment path when it is determined that the parameter type is the third type; when it is determined that the path monitoring parameters are inconsistent with the environment path, according to the event clearing function, the event monitoring function is executed event clearing and function state switching.
[0195] In this optional embodiment, optionally, the event monitoring function also includes a focus monitoring parameter, such as Figure 4 As shown, the device also includes a focus processing module 312, wherein:
[0196] A focus processing module 312, used to determine a parameter state of a focus monitoring parameter, where the parameter state includes a first state or a non-first state indicating a triggering of a focus event;
[0197] The focus processing module 312 is further configured to, when it is determined that the parameter state is the first state, perform an event clearing operation on the generated third response list to clear the third response list.
[0198] It can be seen that in this optional embodiment, a path management mechanism for the browser page is set up, and timely monitoring and response can be performed for the situation where the path of the browser page changes, so as to correspondingly execute the removal of the Register function monitoring, and timely and quickly realize the recovery of the browser memory, which is conducive to improving the accuracy of the release of the browser memory; it is also conducive to improving the applicability of shortcut key management and control based on the target plug-in integration. In addition, a monitoring and response mechanism for the browser focus event is also set up, which solves the problem of the confusion of the shortcut key state caused by the fact that the monitoring shortcut key will not be triggered when multiple programs are running due to the priority concept of the operating system's shortcut key processing and the single termination mechanism, and improves the applicability of shortcut key management and control based on the target plug-in integration.
[0199] Embodiment 4
[0200] See also Figure 5 , Figure 5 Schematic diagram of another implementation and control device of front-end shortcut keys disclosed in an embodiment of the present invention. Figure 5 As shown, the implementation and control device of the front-end shortcut key may include:
[0201] A memory 401 storing executable program codes;
[0202] a processor 402 coupled to the memory 401;
[0203] The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the method for implementing and controlling the front-end shortcut keys described in the first embodiment of the present invention or the second embodiment of the present invention.
[0204] Embodiment 5
[0205] An embodiment of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute the steps in the method for implementing and controlling front-end shortcut keys described in Embodiment 1 or Embodiment 2 of the present invention.
[0206] Embodiment 6
[0207] An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer storage medium storing a computer program, and the computer program is operable to enable a computer to execute the steps in the method for implementing and controlling front-end shortcut keys described in Example 1 or Example 2.
[0208] The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, i.e., they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative work.
[0209] Through the specific description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the above technical solution can be essentially or partly contributed to the prior art in the form of a software product, and the computer software product can be stored in a computer storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0210] Finally, it should be noted that the front-end shortcut key implementation and control method and device, and computer storage medium disclosed in the embodiment of the present invention are only preferred embodiments of the present invention, and are only used to illustrate the technical solution of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for implementing and controlling front-end shortcut keys, characterized in that: The method is applied to a preset target plug-in, and the method includes: After determining that the target plug-in meets the preset running conditions, determining the kernel type corresponding to the browser currently applied by the target plug-in and its corresponding current application environment, and performing a running preprocessing operation for the current application environment, wherein the running preprocessing operation includes at least one of generating a shortcut key compatible identification list, generating a browser type dictionary, and registering a browser event; Calling the event listening function set in the target plug-in, and switching the function state of the event listening function to the real-time listening state; When it is determined that the event monitoring function is in the real-time monitoring state, a monitoring operation is performed on the shortcut key triggering event according to the event monitoring function to obtain a monitoring result for the shortcut key triggering event; the shortcut key triggering event includes a first event corresponding to pressing the shortcut key or a second event corresponding to lifting the shortcut key; When the monitoring result indicates the existence of the first event, a preset event response processing is performed on the first event to obtain an event response processing result for the first event; the event response processing includes at least one of generating a response list for the first event, event loop comparison based on a preset response list, callback for the first event, and event registration based on the event monitoring function.
2. The method for implementing and controlling front-end shortcut keys according to claim 1, characterized in that: The performing a preset event response process on the first event to obtain an event response process result for the first event includes: Determine whether the target plug-in has a first response list for responding to the first event, and when it is determined that the target plug-in does not have a first response list for responding to the first event, generate the first response list, and add the first event to the first response list according to a dictionary attribute corresponding to a preset browser type dictionary; Taking the first event identifier corresponding to the first event as a comparison target, performing a preset circular comparison operation on the first response list to obtain a first comparison result for the first response list; When the first comparison result indicates that the first event identifier has a matching recorded event identifier in the first response list, calling the callback function in the event listening function to perform a key trigger operation for the first event, and determining that the first event has been triggered; When the first comparison result indicates that the first event identifier does not have a matching recorded event identifier in the first response list, the process returns to execute the monitoring operation on the shortcut key trigger event according to the event monitoring function, and obtains the operation corresponding to the monitoring result of the shortcut key trigger event.
3. The method for implementing and controlling front-end shortcut keys according to claim 1 or 2, characterized in that: The method further comprises: When a run trigger instruction for the target plug-in is detected, performing plug-in initialization on the target plug-in; Determine the current use environment corresponding to the target plug-in, and judge whether the current use environment is a browser. When it is judged that the current use environment is a browser, determine that the target plug-in meets the preset running conditions, and trigger the execution of the operation corresponding to the kernel type corresponding to the browser currently used by the target plug-in; When it is determined that the current usage environment is not a browser, an operation exception processing is performed on the target plug-in to obtain an exception processing result for the target plug-in, wherein the operation exception processing includes an exception prompt and an end operation control for the target plug-in; the exception processing result is used to prompt the user that the current usage environment is not suitable for the target plug-in.
4. The method for implementing and controlling front-end shortcut keys according to claim 3, characterized in that: The performing operation exception processing on the target plug-in to obtain an exception processing result for the target plug-in includes: Determine whether the event listening function has registered an error handling hook. When it is determined that the error handling hook is not registered, throw an exception for the target plug-in and terminate the operation of the target plug-in as an exception handling result for the target plug-in. When it is determined that the error handling hook has been registered, generating exception information for the target plug-in and the current use environment according to the error handling hook; The exception information is fed back to the user through the error handling hook, and the operation of the target plug-in is terminated at the same time as the exception handling result for the target plug-in.
5. The method for implementing and controlling front-end shortcut keys according to claim 1, 2 or 4, characterized in that: The method further comprises: When the monitoring result indicates that the second event exists, deleting the second event identifier corresponding to the second event recorded in the second response list from the generated second response list; Taking the second event identifier as a comparison target, performing a circular comparison on the second response list to obtain a second comparison result for the second response list; When the second comparison result indicates that the deletion operation for the second event identifier in the second response list has been completed, the function state of the event monitoring function is switched to the real-time monitoring state.
6. The method for implementing and controlling front-end shortcut keys according to claim 5, characterized in that: The event monitoring function includes a path monitoring parameter, and the path monitoring parameter is used to monitor whether the path of the browser is switched; the method also includes: When it is determined that the event monitoring function is in the real-time monitoring state, analyzing the path monitoring parameter to obtain a parameter type corresponding to the path monitoring parameter, where the parameter type includes any one of a first type, a second type, and a third type; When it is determined that the parameter type is the first type, it is determined that there is no need to pass the path monitoring parameter; When it is determined that the parameter type is the second type, according to the preset event clearing function, event clearing and function state switching are performed on the event listening function, and the event clearing is used to clear all listening events corresponding to the records of the event listening function; the function state switching is used to switch the function state of the event listening function to the end listening state.
7. The method for implementing and controlling front-end shortcut keys according to claim 6, characterized in that: The method further comprises: When it is determined that the parameter type is the third type, the environment path of the current application environment is obtained, and it is determined whether the path monitoring parameter is consistent with the environment path; when it is determined that the path monitoring parameter is inconsistent with the environment path, according to the event clearing function, the event clearing and the function state switching are performed on the event listening function; The event monitoring function also includes a focus monitoring parameter, and the method also includes: Determine a parameter state of the focus monitoring parameter, wherein the parameter state includes a first state or a non-first state indicating triggering of a focus event; When it is determined that the parameter state is the first state, an event clearing operation is performed on the generated third response list to clear the third response list.
8. A front-end shortcut key implementation and control device, characterized in that: The device is applied to a preset target plug-in, and the device includes: A determination module, configured to determine, after determining that the target plug-in meets a preset operating condition, a kernel type corresponding to a browser currently applied by the target plug-in and a corresponding current application environment; A preprocessing module, used to perform a run preprocessing operation for the current application environment, wherein the run preprocessing operation includes at least one of generating a shortcut key compatible identifier list, generating a browser type dictionary, and registering a browser event; A function calling module, used to call the event listening function set in the target plug-in; A state switching module, used to switch the function state of the event monitoring function to a real-time monitoring state; A monitoring processing module, for, when it is determined that the event monitoring function is in the real-time monitoring state, performing a monitoring operation on the shortcut key triggering event according to the event monitoring function, and obtaining a monitoring result for the shortcut key triggering event; the shortcut key triggering event includes a first event corresponding to pressing the shortcut key or a second event corresponding to lifting the shortcut key; An event response module is used to perform preset event response processing on the first event when the monitoring result indicates the existence of the first event, so as to obtain an event response processing result for the first event; the event response processing includes generating a response list for the first event, event loop comparison based on the preset response list, callback for the first event, and event registration based on the event monitoring function.
9. A front-end shortcut key implementation and control device, characterized in that: The device comprises: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the front-end shortcut key implementation and control method as described in any one of claims 1-7.
10. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, which, when called, are used to execute the front-end shortcut key implementation and control method as described in any one of claims 1-7.
