Customized client construction method and device, computer equipment and storage medium
By listening to the Second-Instance incident and introducing customized configuration files in the Electron's main process, the problem of high cost and efficiency of high cost and low efficiency of cloud computer private clouds when building customized clients is solved. User experience and application scalability.
Patent Information
- Application Number
- CN202411647014.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-01-28
AI Technical Summary
The existing cloud computer private cloud has problems such as high cost, low efficiency and inflexibility when building customized clients.
By listening to the Second-Instance incident in the Electron's main process, call the startup parameter method, traverse all startup parameters, and introduce the customized configuration file ENV.JSON in the case of environmental parameter ENV, and based on its constructing customized clients Essence
It has significantly improved development efficiency, reduced construction costs, and enhanced the flexibility and scalability of applications. Users can customize client functions according to demand, improve user experience, and simplify deployment and maintenance.
Smart Images

Figure CN119376712A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud computing technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for building a customized client. Background Art
[0002] With the rapid development of Internet technology, cloud computer technology is becoming more and more popular. As a cloud computing solution, cloud computer allows users to remotely access a complete desktop operating system and its related applications through a network connection. Cloud computer private cloud technology has gradually become the choice of enterprises due to its security and flexibility. Electron is an open source framework built with HTML, CSS and JavaScript for building cross-platform desktop applications. The cloud computer client developed based on Electron has the advantages of cross-platform support, fast running speed and strong stability.
[0003] However, with the development of cloud computing private cloud, many private cloud users have put forward customized requirements for cloud computing service providers, hoping that cloud computing clients can support on-demand configuration. However, the current cloud computing clients need to be developed according to different requirements, and different private clouds need to develop different codes. After the development is completed, different build packages need to be built, which has high construction costs, low efficiency and lack of flexibility.
[0004] Therefore, there is an urgent need for a customized client construction method, apparatus, computer equipment, computer-readable storage medium and computer program product that can solve the problems of high cost, low efficiency and lack of flexibility in building customized clients in existing cloud computer private clouds. Summary of the invention
[0005] Based on this, it is necessary to provide a customized client construction method, device, computer equipment, computer-readable storage medium and computer program product to address the above technical problems, which can solve the problems of high cost, low efficiency and lack of flexibility in building customized clients in existing cloud computer private clouds.
[0006] In a first aspect, the present application provides a method for building a customized client, comprising:
[0007] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0008] Using the startup parameter checking method, traverse all startup parameters;
[0009] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0010] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0011] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0012] In one embodiment, before monitoring the second-instance event in the Electron main process, the process further includes:
[0013] Write a method to check startup parameters;
[0014] By using the startup parameter checking method, all startup parameters are traversed to determine whether the environment parameter env exists in the startup parameters.
[0015] In one embodiment, after traversing all startup parameters, the method further includes:
[0016] When the environment parameter env exists in the startup parameters, write a method to introduce environment variables;
[0017] The method of introducing environment variables is used to introduce a customized configuration file env.json, and the storage location of the customized configuration file env.json is determined according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the support status of the customized function.
[0018] In one embodiment, after introducing the customized configuration file env.json, the method further includes:
[0019] Write the operating environment method;
[0020] By using the operating environment method, the Boolean value of the required configuration item in the customized configuration file env.json is assigned to the operating environment variable, and a customized client is constructed according to the assigned operating environment variable.
[0021] In one embodiment, after the method for writing the operating environment, the method further includes:
[0022] The operating environment method is used to build a customized client according to the blank configuration items in the customized configuration file env.json and the unassigned operating environment variables.
[0023] In one embodiment, the second-instance event is monitored in the Electron main process, and after the second-instance event is triggered, a method for checking startup parameters is called, including:
[0024] Listen to the second-instance event in the Electron main process to analyze whether the current application allows multiple instances to run simultaneously;
[0025] When the current application allows multiple instances to run simultaneously and the first instance is already running, start the second instance and trigger the second-instance event;
[0026] After the second-instance event is triggered, the check startup parameter method is called.
[0027] In a second aspect, the present application also provides a customized client construction device, including:
[0028] The monitoring module is used to monitor second-instance events in the Electron main process;
[0029] The process execution module is used to call the method to check the startup parameters after the second-instance event is triggered;
[0030] The process execution module is also used to traverse all startup parameters using the startup parameter checking method;
[0031] The process execution module is also used to call the runtime environment method in the Electron rendering process;
[0032] The process execution module is also used to introduce the customized configuration file env.json by using the method of introducing environment variables, and assign the customized configuration file env.json to the running environment variables;
[0033] The customized client building module is used to build a customized client based on the assigned running environment variables using the running environment method.
[0034] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0035] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0036] Using the startup parameter checking method, traverse all startup parameters;
[0037] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0038] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0039] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0040] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0041] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0042] Using the startup parameter checking method, traverse all startup parameters;
[0043] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0044] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0045] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0046] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0047] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0048] Using the startup parameter checking method, traverse all startup parameters;
[0049] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0050] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0051] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0052] The above-mentioned customized client construction method, device, computer equipment, computer-readable storage medium and computer program product adapt different construction packages through a set of codes, avoiding the tedious process of repeatedly developing and building different codes for different needs, thereby significantly improving development efficiency; since only one construction package needs to be built and it can be automatically adapted to the required functions at startup, the need to build different versions of clients is reduced, thereby reducing construction costs; the client can dynamically load different configurations according to startup parameters, so that the same application can adapt to a variety of different operating environments and user needs, enhancing the flexibility and scalability of the application; users can customize client functions according to their specific needs, improving user experience, because users can obtain more personalized and specific It can be used to implement applications with fixed workflows; because there is no need to maintain multiple versions of the client for each configuration, development and maintenance resources can be used more effectively; by listening to the second-instance event, you can control whether the application allows multiple instances to run at the same time, which helps avoid resource conflicts and duplications and ensure the stable operation of the application; the deployment and management of a single build package is simpler than that of multiple versions of build packages, which simplifies deployment and maintenance; when the client needs to be updated or new features need to be added, iterations can be performed faster because only a single build package needs to be updated; by controlling instance operation and customized configuration, unauthorized access and configuration errors can be reduced, thereby improving the security of the application, and customized clients can adapt to different business scenarios and meet the special needs of different customers. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0054] FIG1 is an application environment diagram of a customized client construction method in one embodiment;
[0055] FIG2 is a schematic diagram of a process of building a customized client in one embodiment;
[0056] FIG3 is a schematic diagram of a process of building a customized client in another embodiment;
[0057] FIG4 is a schematic diagram of a process of building a customized client in another embodiment;
[0058] FIG5 is a schematic diagram of a process of building a customized client in another embodiment;
[0059] FIG6 is a schematic diagram of a process of building a customized client in the most detailed embodiment;
[0060] FIG7 is a structural block diagram of a customized client construction device in one embodiment;
[0061] FIG8 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0063] In an exemplary embodiment, as shown in FIG1 , a customized client construction method is provided, including the following steps S102 to S110. In which:
[0064] Step S102, monitor the second-instance event in the Electron main process, and after the second-instance event is triggered, call the startup parameter check method.
[0065] Specifically, Electron applications can obtain a single instance lock through the app.requestSingleInstanceLock() method. This means that only one instance of the application can be running at the same time. In the main process code of Electron, developers will add an event listener to listen for the second-instance event. This event is specifically used to handle the situation when there is an attempt to start a second instance of the application.
[0066] If the user tries to start a second instance of the application (for example, by double-clicking the desktop icon or starting it again from the command line), and the application has already acquired a single instance lock through app.requestSingleInstanceLock(), Electron will not start a new instance of the application, but will trigger the second-instance event in the currently running application instance. When the second-instance event is triggered, the Electron main process calls a predefined method (for example, named checkAppStartParam) to check the startup parameters carried by the new startup request.
[0067] Step S104, using the startup parameter checking method to traverse all startup parameters.
[0068] Specifically, startup parameters refer to command line parameters or startup configurations passed to the application when starting the Electron application. These parameters can be specified by the user in the command line or defined in the application's configuration file. In the checkAppStartParam method, the developer will write code to traverse (i.e. check one by one) all startup parameters passed to the application. Traversal is usually implemented using a loop structure, such as the for loop in JavaScript or the Array.prototype.forEach method.
[0069] For each startup parameter, the method checks its value and performs different operations depending on the parameter. For example, if the parameter is --env=production, the application may load the configuration of the production environment; if it is --env=development, it loads the configuration of the development environment. By checking these parameters, the application can dynamically adjust its configuration and behavior to meet different operating requirements. This includes loading different configuration files, starting different functional modules, setting different operating modes, etc.
[0070] Step S106, when the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process.
[0071] Specifically, in the checkAppStartParam method, the application checks whether the startup parameters contain the environment parameter env. This parameter is usually used to specify the application's operating environment, such as the development environment, test environment, or production environment.
[0072] If the environment parameter env is found in the startup parameters, the application will call the importRunningEnv method to load the corresponding environment configuration according to this parameter. This method reads a predefined configuration file (such as env.json), which contains configuration items for different environments, such as API endpoints, database connection information, etc.
[0073] Step S108, using the method of introducing environment variables, introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variables.
[0074] Specifically, the env.json file is a JSON-formatted file that contains a series of key-value pairs that define the behavior and configuration of the application in a specific environment, such as the API URL, database connection information, function switches, etc. The importRunningEnv method reads the contents of the env.json file. This is usually achieved through file system operations, such as using the Node.js fs module to read files.
[0075] Once the env.json file is successfully read, the importRunningEnv method assigns the contents of the file to a running environment variable, which is usually a global variable or a variable defined in a certain part of the application, such as _runningEnv. After the assignment is completed, other parts of the application can access this running environment variable to obtain configuration information and adjust the behavior of the application based on this information.
[0076] Step S110, using the operating environment method, constructing a customized client according to the assigned operating environment variables.
[0077] Specifically, a runtime method usually refers to a method defined in an Electron application, such as runningEnv, which is used to adjust the behavior and configuration of the application based on the runtime environment variables.
[0078] Running environment variables are read and set from configuration files (such as env.json) by importing environment variable methods (such as importRunningEnv) when the application starts. They contain configuration information required by the application in a specific environment.
[0079] Customized client refers to adjusting the functions and interface of Electron application according to specific configurations and requirements to meet the needs of different users or scenarios.
[0080] During the application build or startup process, the runningEnv method is called to check the configuration in the _runningEnv variable and adjust the application based on these configurations. Depending on the configuration in _runningEnv, the runningEnv method can perform a variety of operations, such as:
[0081] Enable or disable specific functional modules; change the layout and style of the application interface; set the connection information of API endpoints and other backend services; adjust the logging level; configure security and permission settings.
[0082] In the above customized client construction method, a set of codes is used to adapt different build packages, which avoids the tedious process of repeatedly developing and building different codes for different needs, thereby significantly improving development efficiency. Since only one build package needs to be built, and it can automatically adapt to the required functions at startup, the need to build different versions of clients is reduced, thereby reducing construction costs. The client can dynamically load different configurations according to the startup parameters, so that the same application can adapt to a variety of different operating environments and user needs, enhancing the flexibility and scalability of the application. Users can customize client functions according to their specific needs, which improves the user experience because users can get more personalized and specific workflow-compliant applications. Since there is no need to maintain multiple versions of the client for each configuration, development and maintenance resources can be used more effectively. By listening to the second-instance event, it is possible to control whether the application allows multiple instances to run simultaneously, which helps to avoid resource conflicts and duplications and ensure the stable operation of the application. The deployment and management of a single build package is simpler than that of multiple versions of build packages, simplifying deployment and maintenance work.
[0083] In an exemplary embodiment, as shown in FIG2 , before monitoring the second-instance event in the Electron main process, the following steps are also included:
[0084] Step S202, write a method for checking startup parameters;
[0085] Step S204: traverse all startup parameters using the startup parameter checking method to determine whether the environment parameter env exists in the startup parameters.
[0086] Specifically, the startup parameter check method is usually named checkAppStartParam, and its purpose is to check the parameters passed when starting the application. This method is the core of processing startup parameters, and it receives startup parameters as input. It traverses these startup parameters to find specific flags or configurations, such as the environment parameter env.
[0087] Then use the check startup parameter method to traverse all startup parameters, which usually involves: using a loop structure (such as a for loop or forEach method) to check each parameter one by one. For each parameter, check whether it contains a specific prefix or keyword, such as --env=, which indicates that the parameter is an environment parameter. In the process of traversing the parameters, the checkAppStartParam method needs to determine whether there is an environment parameter env. If a parameter starting with --env= is found, the value of the parameter (for example, production, development, etc.) will be extracted. This value will be used to determine which environment configuration the application should load.
[0088] In this embodiment, by checking the startup parameters and adjusting the configuration according to the parameters, the flexibility, configurability and user experience of the Electron application are improved, while the deployment and maintenance of the application are simplified.
[0089] In an exemplary embodiment, as shown in FIG3 , after traversing all startup parameters, the process further includes:
[0090] Step S302, when the environment parameter env exists in the startup parameters, write a method for introducing environment variables;
[0091] Step S304, using the method of introducing environment variables, introduce the customized configuration file env.json, and determine the storage location of the customized configuration file env.json according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the customized function support status.
[0092] Specifically, the purpose of introducing the environment variable method importRunningEnv is to load a customized configuration file, usually named env.json, which contains the configuration items required by the application in different environments. After checking the startup parameters, if it is found that the startup parameters contain the environment parameter env, this method is called to load the corresponding environment configuration.
[0093] The importRunningEnv method determines the location of the env.json file based on the value of the environment parameter env and loads the file. The environment parameter env may contain information about the location of the configuration file, or the naming convention of the configuration file (such as env.development.json, env.production.json). Based on the value of the env parameter, the full path of the configuration file can be constructed and the corresponding file can be loaded.
[0094] The env.json file contains required configuration items and blank configuration items. Required configuration items are those that directly affect the application functions and behaviors, while blank configuration items may be used for future expansion or backup. Each required configuration item contains a Boolean value to indicate whether the corresponding customized function is supported or enabled.
[0095] In this embodiment, by dynamically loading and applying different configuration files according to the environment parameter env in the startup parameters in the Electron application, the application can adjust its behavior and functions according to different operating environments, thereby improving the flexibility and adaptability of the application. By using Boolean values in the configuration file to indicate the enabled state of a function, the customized functions of the application can be easily controlled.
[0096] In an exemplary embodiment, as shown in FIG4 , after the customized configuration file env.json is introduced, the following is further included:
[0097] Step S402, writing an operating environment method;
[0098] Step S404, using the operating environment method, assigning the Boolean value of the required configuration item in the customized configuration file env.json to the operating environment variable, and building a customized client according to the assigned operating environment variable.
[0099] Specifically, the purpose of the running environment method runningEnv is to provide an interface for adjusting the behavior and functionality of the application based on the required configuration items in the configuration file. This method will be used to access the configuration loaded in env.json and set the state or behavior of the application based on these configurations. It may accept parameters, such as the key name of the configuration item, and return the corresponding Boolean value or other configuration value.
[0100] Use the runningEnv method to assign Boolean or other configuration values to running environment variables based on the configuration items in env.json. These running environment variables can be global variables, properties in state management objects, or configuration objects that can be directly accessed by other parts of the application.
[0101] Once the runtime environment variables are correctly assigned, the application can adjust its interface, functions, and behaviors based on these variables to build a customized client experience. For example, if there is a configuration item "featureXEnabled":true in env.json, the application may enable a feature called Feature X.
[0102] In this embodiment, by writing a runtime method and using the method to assign runtime variables, the application can flexibly adjust its functions and interfaces according to different configuration requirements, thereby meeting the needs of different users or different environments. This method improves the adaptability of the application and the user experience.
[0103] In an exemplary embodiment, after writing the operating environment method, the method further includes:
[0104] Use the runtime environment method to build a customized client based on the blank configuration items in the customized configuration file env.json and the unassigned runtime environment variables.
[0105] Specifically, in env.json, blank configuration items refer to configuration items that have not yet been defined with specific values, or configuration items that are reserved for possible future needs. Unassigned runtime environment variables are variables that have not been explicitly assigned during application startup and configuration loading.
[0106] Running environment methods (such as runningEnv) are not only used to return the values of defined configuration items, but can also be used to handle undefined or blank configuration items. For blank configuration items, this method can provide default values or perform default behaviors to ensure the stability and consistency of the application.
[0107] Based on the configuration items in env.json (both defined and undefined), the application will adjust its functions and interface to meet specific customization requirements. For unassigned runtime environment variables, the application can use the preset default configuration or build the client based on the default behavior of the application.
[0108] In this embodiment, through this method, the Electron application can flexibly handle all configuration items in env.json, whether defined or undefined. This ensures that the application can flexibly adjust its behavior and interface according to the provided configuration, while also ensuring the stability and consistency of the application through the default values.
[0109] In an exemplary embodiment, as shown in FIG5 , the second-instance event is listened to in the Electron main process, and after the second-instance event is triggered, the startup parameter checking method is called, including:
[0110] Step S502, monitoring the second-instance event in the Electron main process, and analyzing whether the current application allows multiple instances to run simultaneously;
[0111] Step S504, when the current application allows multiple instances to run simultaneously and the first instance is already in the running state, start the second instance and trigger the second-instance event;
[0112] Step S506: After the second-instance event is triggered, a method for checking startup parameters is called.
[0113] Specifically, in the main process of Electron, developers listen for an event called second-instance. This event is specifically used to handle situations when there is an attempt to start a second instance of an application. By listening to the second-instance event, the application can analyze the current configuration or state to determine whether to allow multiple instances to run simultaneously. This is usually based on the design and needs of the application.
[0114] If the design of the application allows multiple instances to run simultaneously, then when the user tries to start a second instance, the application will not block the new launch request. When the second instance is started and the main process checks that the first instance is already running through app.requestSingleInstanceLock(), the second-instance event will be triggered.
[0115] Once the second-instance event is triggered, the main process calls a predefined method (such as checkAppStartParam) to check the startup parameters passed when the new instance attempts to start. The checkAppStartParam method checks these parameters and performs corresponding operations based on the parameter content, such as loading a specific configuration file, opening a specific window, or performing specific initialization operations.
[0116] In this embodiment, the steps describe how the Electron application handles startup requests for multiple instances and how to dynamically adjust the behavior of the application based on startup parameters. By listening to the second-instance event, the application can control whether to allow multiple instances to run simultaneously and adjust its behavior based on the passed parameters when the new instance is started.
[0117] At the application level, as shown in FIG6 , at least the following two embodiments are included:
[0118] Example 1: Start via command line:
[0119] Install the Cloud PC Client: Users first need to install the Cloud PC Client software on their system.
[0120] Open the system command line tool: The user opens the command line interface (such as cmd, PowerShell, or terminal).
[0121] Enter the client startup program and parameters: The user enters the full path and startup parameters of the client. For example:
[0122] "C:\Program Files
[0123] (x86)\CtyunClouddeskUniversal\CtyunClouddeskUniversal.exe"
[0124] CtyunClouddeskUniversal: / / token / token123 / ?env=gannan
[0125] This command contains the protocol (CtyunClouddeskUniversal: / / ), token (token / token123), and environment parameters (env=gannan).
[0126] Start the client program: The user presses the Enter key to execute the command and start the cloud computer client program.
[0127] Triggering a second-instance event: If the client application is already running and is configured to listen for second-instance events, a new startup attempt will trigger that event.
[0128] Execute customized startup method: After the second-instance event is triggered, the Electron main process will call the method to check the startup parameters, analyze the startup parameters, and load the corresponding configuration according to the parameters (such as env=gannan) to build a customized client.
[0129] Example 2: Start via a browser or file manager:
[0130] Enter the startup parameters in the browser or file manager: The user enters the URL containing the startup parameters in the address bar of the browser or file manager. For example:
[0131] CtyunClouddeskUniversal: / / token / token123 / ?env=gannan
[0132] This URL also contains the protocol, token, and environment parameters.
[0133] Press Enter to confirm the launch: When the user presses the Enter key or clicks OK, the system will launch the cloud computer client according to the protocol and parameters in the URL.
[0134] Trigger second-instance event: If the client program is already running and is configured to listen for second-instance events, this operation will trigger the event.
[0135] Execute customized startup method: After the second-instance event is triggered, the Electron main process will call the method to check the startup parameters, analyze the startup parameters, load the corresponding configuration according to the parameters, and build a customized client.
[0136] Third-party system call: If a third-party system or service can call a browser to open a specific URL, it can also start the cloud computer client as long as the URL follows the predetermined protocol and parameter format.
[0137] These two examples show how to start the Electron cloud computer client through different methods and dynamically adjust the client's behavior and configuration according to the startup parameters. Whether it is started through the command line or through the URL, as long as the client program is configured to listen to and process the second-instance event, it can execute a customized startup process based on the passed in parameters. This method improves the flexibility and adaptability of the client, allowing it to be customized according to different operating environments and user needs.
[0138] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0139] Based on the same inventive concept, the embodiment of the present application also provides a customized client construction device for implementing the customized client construction method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more customized client construction device embodiments provided below can refer to the limitations of the customized client construction method above, and will not be repeated here.
[0140] In an exemplary embodiment, as shown in FIG7 , a customized client construction device is provided, including:
[0141] The monitoring module 704 is used to monitor the second-instance event in the Electron main process;
[0142] The process execution module 706 is used to call the method for checking startup parameters after the second-instance event is triggered;
[0143] The process execution module 706 is further used to traverse all startup parameters using the startup parameter checking method;
[0144] The process execution module 706 is also used to call the running environment method in the Electron rendering process;
[0145] The process execution module 706 is further used to introduce the customized configuration file env.json by using the method of introducing environment variables, and assign the customized configuration file env.json to the running environment variables;
[0146] The customized client construction module 708 is used to construct a customized client according to the assigned operating environment variables using the operating environment method.
[0147] In an exemplary embodiment, the preprocessing module 702 is used to write a method for checking startup parameters;
[0148] Using the startup parameter check method, all startup parameters are traversed to determine whether the environment parameter env exists in the startup parameters.
[0149] In an exemplary embodiment, the preprocessing module 702 is further used to write a method for introducing environment variables when the environment parameter env exists in the startup parameters;
[0150] The customized configuration file env.json is introduced by using the method of introducing environment variables, and the storage location of the customized configuration file env.json is determined according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the support status of the customized function.
[0151] In an exemplary embodiment, the preprocessing module 702 is also used to write an operating environment method;
[0152] Using the runtime environment method, assign the Boolean value of the required configuration item in the customized configuration file env.json to the runtime environment variable, and build a customized client based on the assigned runtime environment variable.
[0153] In an exemplary embodiment, the customized client construction module 708 is specifically used to construct a customized client using a running environment method according to blank configuration items in a customized configuration file env.json and unassigned running environment variables.
[0154] In an exemplary embodiment, the monitoring module 704 is specifically used to monitor the second-instance event in the Electron main process, analyze whether the current application allows multiple instances to run simultaneously; if the current application allows multiple instances to run simultaneously and the first instance is already in the running state, start the second instance and trigger the second-instance event;
[0155] The process execution module 706 is used to call the method for checking startup parameters after the second-instance event is triggered.
[0156] Each module in the above-mentioned customized client construction device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module above.
[0157] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG8. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store customized configuration file data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a customized client construction method is implemented.
[0158] Those skilled in the art will understand that the structure shown in FIG. 8 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0159] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0160] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0161] Use the startup parameter check method to traverse all startup parameters;
[0162] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0163] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0164] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0165] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0166] Write a method to check startup parameters;
[0167] Using the startup parameter check method, all startup parameters are traversed to determine whether the environment parameter env exists in the startup parameters.
[0168] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0169] When the environment parameter env exists in the startup parameters, write a method to introduce environment variables;
[0170] The customized configuration file env.json is introduced by using the method of introducing environment variables, and the storage location of the customized configuration file env.json is determined according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the support status of the customized function.
[0171] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0172] Write the operating environment method;
[0173] Using the runtime environment method, assign the Boolean value of the required configuration item in the customized configuration file env.json to the runtime environment variable, and build a customized client based on the assigned runtime environment variable.
[0174] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0175] Use the runtime environment method to build a customized client based on the blank configuration items in the customized configuration file env.json and the unassigned runtime environment variables.
[0176] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0177] Listen to the second-instance event in the Electron main process to analyze whether the current application allows multiple instances to run simultaneously;
[0178] When the current application allows multiple instances to run simultaneously and the first instance is already running, start the second instance and trigger the second-instance event;
[0179] After the second-instance event is triggered, the check startup parameter method is called.
[0180] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0181] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0182] Use the startup parameter check method to traverse all startup parameters;
[0183] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0184] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0185] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0186] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0187] Write a method to check startup parameters;
[0188] Using the startup parameter check method, all startup parameters are traversed to determine whether the environment parameter env exists in the startup parameters.
[0189] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0190] When the environment parameter env exists in the startup parameters, write a method to introduce environment variables;
[0191] The customized configuration file env.json is introduced by using the method of introducing environment variables, and the storage location of the customized configuration file env.json is determined according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the support status of the customized function.
[0192] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0193] Write the operating environment method;
[0194] Using the runtime environment method, assign the Boolean value of the required configuration item in the customized configuration file env.json to the runtime environment variable, and build a customized client based on the assigned runtime environment variable.
[0195] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0196] Use the runtime environment method to build a customized client based on the blank configuration items in the customized configuration file env.json and the unassigned runtime environment variables.
[0197] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0198] Listen to the second-instance event in the Electron main process to analyze whether the current application allows multiple instances to run simultaneously;
[0199] When the current application allows multiple instances to run simultaneously and the first instance is already running, start the second instance and trigger the second-instance event;
[0200] After the second-instance event is triggered, the check startup parameter method is called.
[0201] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0202] Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters;
[0203] Use the startup parameter check method to traverse all startup parameters;
[0204] When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process;
[0205] Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable;
[0206] Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
[0207] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0208] Write a method to check startup parameters;
[0209] Using the startup parameter check method, all startup parameters are traversed to determine whether the environment parameter env exists in the startup parameters.
[0210] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0211] When the environment parameter env exists in the startup parameters, write a method to introduce environment variables;
[0212] The customized configuration file env.json is introduced by using the method of introducing environment variables, and the storage location of the customized configuration file env.json is determined according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the support status of the customized function.
[0213] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0214] Write the operating environment method;
[0215] Using the runtime environment method, assign the Boolean value of the required configuration item in the customized configuration file env.json to the runtime environment variable, and build a customized client based on the assigned runtime environment variable.
[0216] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0217] Use the runtime environment method to build a customized client based on the blank configuration items in the customized configuration file env.json and the unassigned runtime environment variables.
[0218] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0219] Listen to the second-instance event in the Electron main process to analyze whether the current application allows multiple instances to run simultaneously;
[0220] When the current application allows multiple instances to run simultaneously and the first instance is already running, start the second instance and trigger the second-instance event;
[0221] After the second-instance event is triggered, the check startup parameter method is called.
[0222] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0223] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0224] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0225] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for building a customized client, characterized in that: The method comprises: Listen to the second-instance event in the Electron main process, and after the second-instance event is triggered, call the method to check the startup parameters; Using the startup parameter checking method, traverse all startup parameters; When the environment parameter env exists in the startup parameters, the method of introducing environment variables is called, and the running environment method is called in the Electron rendering process; Use the environment variable introduction method to introduce the customized configuration file env.json, and assign the customized configuration file env.json to the running environment variable; Use the runtime environment method to build a customized client based on the assigned runtime environment variables.
2. The method according to claim 1, characterized in that Before listening to the second-instance event in the Electron main process, it also includes: Write a method to check startup parameters; By using the startup parameter checking method, all startup parameters are traversed to determine whether the environment parameter env exists in the startup parameters.
3. The method according to claim 2, characterized in that After traversing all startup parameters, the following steps are also included: When the environment parameter env exists in the startup parameters, write a method to introduce environment variables; The method of introducing environment variables is used to introduce a customized configuration file env.json, and the storage location of the customized configuration file env.json is determined according to the environment parameter env; wherein the customized configuration file env.json contains required configuration items and blank configuration items, and each required configuration item is filled with a Boolean value used to indicate the support status of the customized function.
4. The method according to claim 3, characterized in that After introducing the customized configuration file env.json, it also includes: Write the operating environment method; By using the operating environment method, the Boolean value of the required configuration item in the customized configuration file env.json is assigned to the operating environment variable, and a customized client is constructed according to the assigned operating environment variable.
5. The method according to claim 4, characterized in that After the method for writing the operating environment, the method further includes: The operating environment method is used to build a customized client according to the blank configuration items in the customized configuration file env.json and the unassigned operating environment variables.
6. The method according to claim 1, characterized in that The second-instance event is listened to in the main process of Electron, and after the second-instance event is triggered, a method for checking startup parameters is called, including: Listen to the second-instance event in the Electron main process to analyze whether the current application allows multiple instances to run simultaneously; When the current application allows multiple instances to run simultaneously and the first instance is already running, start the second instance and trigger the second-instance event; After the second-instance event is triggered, the check startup parameter method is called.
7. A customized client construction device, characterized in that: The device comprises: The monitoring module is used to monitor second-instance events in the Electron main process; The process execution module is used to call the method to check the startup parameters after the second-instance event is triggered; The process execution module is also used to traverse all startup parameters using the startup parameter checking method; The process execution module is also used to call the runtime environment method in the Electron rendering process; The process execution module is also used to introduce the customized configuration file env.json by using the method of introducing environment variables, and assign the customized configuration file env.json to the running environment variables; The customized client building module is used to build a customized client based on the assigned running environment variables using the running environment method.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.