Address generation method and device, equipment and medium
By parsing the proxy configuration file of the Vue project and generating and displaying the target proxy address, the problem of inefficient verification of the correctness of the proxy configuration is solved and development efficiency is improved.
Patent Information
- Application Number
- CN202411203430.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-24
AI Technical Summary
When developing Vue projects, verifying the correctness of the proxy configuration requires frequent restart of the project, which leads to inefficiency because the complete proxy address cannot be seen immediately.
By parsing the proxy configuration file of the Vue project, obtain the path prefix, path rewriting rules and target address, generate a reference path and determine the target proxy address, and display it to developers to avoid frequent restarting of the project.
It realizes instant and intuitive verification of the correctness of the proxy configuration, improves the development efficiency of the Vue project, and reduces the number of restarts of the project.
Smart Images

Figure CN119182750A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an address generation method, device, equipment and medium. Background Art
[0002] With the development of mobile Internet, more and more front-end applications use Vue framework to draw website pages, complete page interactions, etc. When debugging the development environment, it is usually necessary to modify the proxy configuration in vue.config.js in the root directory of the Vue project to connect to the server to complete the data request.
[0003] In order to verify whether the proxy configuration is modified correctly, you need to restart the Vue project to make the proxy configuration take effect. Because the complete proxy address cannot be seen during the process, you may need to restart the Vue project frequently to verify the correctness of the proxy configuration. Restarting the Vue project is time-consuming and the correctness of the proxy configuration cannot be verified immediately, which reduces development efficiency. Summary of the invention
[0004] The embodiments of the present application provide an address generation method, apparatus, device and medium for instantly verifying the correctness of proxy configuration and improving development efficiency.
[0005] In a first aspect, an embodiment of the present application provides an address generation method, the method comprising:
[0006] Respond to the address generation request entered by the user and obtain the configuration file of the proxy configuration of the Vue project;
[0007] The configuration file is parsed through a parsing function to obtain configuration information of the proxy configuration; the configuration information includes a path prefix, a path rewriting rule and a target address of the proxy configuration;
[0008] Based on the path prefix, generating a reference path of the proxy configuration;
[0009] Based on the reference path, the path rewriting rule, and the target address, a target proxy address of the proxy configuration is determined, and the target proxy address is displayed.
[0010] In a possible implementation, parsing the configuration file through a parsing function to obtain configuration information of the proxy configuration includes:
[0011] By introducing a file function, the configuration file is loaded and executed to obtain field information of the configuration file;
[0012] The field information of the configuration file is parsed through the proxy server interface to obtain the configuration information of the proxy configuration.
[0013] In a possible implementation, generating the reference path of the proxy configuration based on the path prefix includes:
[0014] Based on a preset format condition and the path prefix, determining type information of the path prefix; wherein the type information includes a regular expression or a common string;
[0015] If the type information of the path prefix is a common character string, generating a reference path of the proxy configuration based on the first generation method;
[0016] If the type information of the path prefix is a regular expression, a reference path of the proxy configuration is generated based on a second generation method.
[0017] In a possible implementation, determining the type information of the path prefix based on a preset format condition and the path prefix includes:
[0018] If the path prefix does not meet the preset format condition, the type information of the path prefix is a common character string;
[0019] If the path prefix satisfies the preset format condition, the type information of the path prefix is a regular expression.
[0020] In a possible implementation, the step of generating the reference path of the proxy configuration based on the first generation method includes:
[0021] Add the target character at the end of the path prefix to obtain the reference path of the proxy configuration.
[0022] In a possible implementation, the step of generating the reference path of the proxy configuration based on the second generation method includes:
[0023] Based on the regular expression replacement rule, the regular expression in the path prefix is replaced with characters that conform to the regular expression replacement rule to obtain a reference path for the proxy configuration.
[0024] In a possible implementation manner, determining the target proxy address of the proxy configuration based on the reference path, the path rewriting rule, and the target address includes:
[0025] Rewriting the reference path based on the path rewriting rule to obtain a rewritten reference path;
[0026] Based on the target address and the rewritten reference path, a target proxy address of the proxy configuration is obtained.
[0027] In a second aspect, an embodiment of the present application provides an address generation device, the device comprising:
[0028] The acquisition module is used to respond to the address generation request input by the user and obtain the configuration file of the proxy configuration of the Vue project;
[0029] A parsing module, used to parse the configuration file through a parsing function to obtain configuration information of the proxy configuration; the configuration information includes a path prefix, a path rewriting rule and a target address of the proxy configuration;
[0030] A generating module, configured to generate a reference path of the proxy configuration based on the path prefix;
[0031] The determination module is used to determine the target proxy address of the proxy configuration based on the reference path, the path rewriting rule and the target address, and display the target proxy address.
[0032] In a possible implementation, the parsing module is specifically used to:
[0033] By introducing a file function, the configuration file is loaded and executed to obtain field information of the configuration file;
[0034] The field information of the configuration file is parsed through the proxy server interface to obtain the configuration information of the proxy configuration.
[0035] In a possible implementation manner, the generating module is specifically used to:
[0036] Based on a preset format condition and the path prefix, determining type information of the path prefix; wherein the type information includes a regular expression or a common string;
[0037] If the type information of the path prefix is a common character string, generating a reference path of the proxy configuration based on the first generation method;
[0038] If the type information of the path prefix is a regular expression, a reference path of the proxy configuration is generated based on a second generation method.
[0039] In a possible implementation manner, the generating module is specifically used to:
[0040] If the path prefix does not meet the preset format condition, the type information of the path prefix is a common character string;
[0041] If the path prefix satisfies the preset format condition, the type information of the path prefix is a regular expression.
[0042] In a possible implementation manner, the generating module is specifically used to:
[0043] Add the target character at the end of the path prefix to obtain the reference path of the proxy configuration.
[0044] In a possible implementation manner, the generating module is specifically used to:
[0045] Based on the regular expression replacement rule, the regular expression in the path prefix is replaced with characters that conform to the regular expression replacement rule to obtain a reference path for the proxy configuration.
[0046] In a possible implementation manner, the determining module is specifically configured to:
[0047] Rewriting the reference path based on the path rewriting rule to obtain a rewritten reference path;
[0048] Based on the target address and the rewritten reference path, a target proxy address of the proxy configuration is obtained.
[0049] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the processor implements any one of the address generation methods in the first aspect.
[0050] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the address generation method of any one of the first aspects is implemented.
[0051] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which is executed by a processor to implement an address generation method as described in any one of the first aspects above.
[0052] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:
[0053] In the embodiment of the present application, in response to the address generation request input by the user, the configuration file of the proxy configuration of the Vue project is obtained; the configuration file is parsed through the parsing function to obtain the configuration information of the proxy configuration; the configuration information includes the path prefix, path rewriting rules and target address of the proxy configuration; based on the path prefix, the reference path of the proxy configuration is generated; based on the reference path, the path rewriting rules and the target address, the target proxy address of the proxy configuration is determined, and the target proxy address is displayed. Therefore, when developing a Vue project, only the middle terminal needs to input the address generation request to obtain the target proxy address of the proxy configuration, allowing developers to instantly and intuitively verify the correctness of the proxy configuration, without the need to frequently restart the Vue project, thereby improving the development efficiency of the Vue project.
[0054] The technical effects brought about by any one of the implementation methods in the second to fifth aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A schematic diagram of an application scenario of an address generation method provided in an embodiment of the present application;
[0056] Figure 2 A flowchart of an address generation method provided in an embodiment of the present application;
[0057] Figure 3 A schematic diagram of a reference path generation method provided in an embodiment of the present application;
[0058] Figure 4 A flowchart of a method for determining a target proxy address provided in an embodiment of the present application;
[0059] Figure 5 A schematic diagram of the structure of an address generation device provided in an embodiment of the present application;
[0060] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0062] The terms "first" and "second" in the specification and claims of the present application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive protection. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in the present application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0063] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0064] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.
[0065] Before introducing the address generation method provided in the embodiment of the present application, in order to facilitate understanding, the professional terms required to be used in the embodiment of the present application are first explained below.
[0066] A path prefix is a leading part of a file path or network path that points to a specific location or resource. A path prefix can be a folder name, drive name, server name, etc., which is used to identify the starting point of the path. The meaning and purpose of a path prefix vary in different contexts.
[0067] Target address: The target API (Application Programming Interface) address is a set of predefined Windows functions used to control the appearance and behavior of various components of Windows (from the appearance of the desktop to the memory allocated for a new process).
[0068] URL (Uniform Resource Locator) path: On the WWW, every information resource has a unified address on the Internet. This address is called URL, which is the uniform resource locator of the WWW, that is, the network address.
[0069] To facilitate understanding, the technical background of the embodiments of the present application is first introduced in detail below.
[0070] With the development of mobile Internet, more and more front-end applications use Vue framework to draw website pages, complete page interactions, etc. When debugging the development environment, it is usually necessary to modify the proxy configuration in vue.config.js in the root directory of the Vue project to connect to the server to complete the data request.
[0071] In order to verify whether the proxy configuration is modified correctly, you need to restart the Vue project to make the proxy configuration take effect. Because the complete proxy address cannot be seen during the process, you may need to restart the Vue project frequently to verify the correctness of the proxy configuration. Restarting the Vue project is time-consuming and the correctness of the proxy configuration cannot be verified immediately, which reduces development efficiency.
[0072] In view of this, the embodiments of the present application provide an address generation method, apparatus, device and medium for instantly verifying the correctness of the proxy configuration and improving development efficiency.
[0073] The inventive concept of the present application can be summarized as follows: respond to the address generation request input by the user, obtain the configuration file of the proxy configuration of the Vue project; parse the configuration file through the parsing function to obtain the configuration information of the proxy configuration; the configuration information includes the path prefix, path rewriting rules and target address of the proxy configuration; based on the path prefix, generate the reference path of the proxy configuration; based on the reference path, path rewriting rules and target address, determine the target proxy address of the proxy configuration, and display the target proxy address. Therefore, when developing a Vue project, you only need to input the address generation request in the terminal to obtain the target proxy address of the proxy configuration, so that developers can instantly and intuitively verify the correctness of the proxy configuration, without the need to frequently restart the Vue project, which improves the development efficiency of the Vue project.
[0074] After introducing the inventive concept of this application, Figure 1 , the application scenarios of the embodiments of the present application are introduced.
[0075] Reference Figure 1 , is a schematic diagram of an application scenario of an address generation method provided in an embodiment of the present application. Figure 1 As shown, the scenario includes: a terminal device 110 and a server 120, and the terminal device 110 and the server 120 can communicate with each other through a communication network.
[0076] In an optional implementation, the communication network may be a wired network or a wireless network. Therefore, the terminal device 110 and the server 120 may be directly or indirectly connected via a wired or wireless communication. For example, the terminal device 110 may be indirectly connected to the server 120 via a wireless access point, or the terminal device 110 may be directly connected to the server 120 via the Internet, and this application does not limit this.
[0077] In the embodiment of the present application, the terminal device 110 includes but is not limited to mobile phones, tablet computers, laptop computers, desktop computers, e-book readers, intelligent voice interaction devices, smart home appliances, car terminals and other devices.
[0078] The server 120 is a background server corresponding to the terminal device 110. The server 120 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0079] It should be noted that the address generation method in the embodiment of the present application can be deployed in an electronic device, which may be a server or a terminal device.
[0080] The server can be Figure 1 The server 120 shown in FIG. Figure 1 The terminal device may be other servers other than the server 120 shown in FIG. Figure 1 The terminal device 110 shown in FIG. 1 may also be Figure 1 Other terminal devices other than the terminal device 110 shown in FIG.
[0081] Figure 1 The figure is only an example. In fact, the number of terminal devices 110 and servers 120 is not limited and is not specifically limited in the embodiments of the present application.
[0082] Based on the above application scenarios, the address generation method provided by the exemplary embodiment of the present application is described below in combination with the application scenarios described above according to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation methods of the present application are not limited in this regard.
[0083] refer to Figure 2 , Figure 2 An address generation method in an embodiment of the present application is exemplarily provided. The method can be executed by an electronic device, and includes the following steps:
[0084] Step S201, in response to the address generation request input by the user, obtain the configuration file of the proxy configuration of the Vue project.
[0085] Specifically, the configuration file of the proxy configuration of the Vue project is vue.config.js. During implementation, you can use path.resolve(_dirname,vueConfigPath) to get the absolute path of vue.config.js, and save the returned result in the configPath variable to get the configuration file of the proxy configuration of the Vue project.
[0086] Step S202, parsing the configuration file through a parsing function to obtain configuration information of the proxy configuration; the configuration information includes a path prefix, a path rewriting rule and a target address of the proxy configuration.
[0087] In a possible implementation, in step S202, the configuration file is parsed by a parsing function to obtain configuration information of the proxy configuration, which is executed as follows:
[0088] By introducing the file function, the configuration file is loaded and executed to obtain the field information of the configuration file;
[0089] Through the proxy server interface, parse the field information of the configuration file to obtain the configuration information of the proxy configuration.
[0090] The file import function is the require function built into Node.js. You can use the require function built into Node.js to read and parse the configuration file to get the field information of the configuration file. The configuration file vue.config.js will be parsed into a JavaScript object.
[0091] Specifically, get the absolute path of vue.config.js through path.resolve(_dirname,vueConfigPath) and save the returned result in the configPath variable. You can then load and execute the configuration file vue.config.js through require(configPath), and then save the returned configuration object in the vueConfig variable, that is, save the field information of the configuration file in the vueConfig variable.
[0092] The configuration file vue.config.js contains the proxy server (devServer) interface. You can obtain the field information of the proxy through the proxy server interface to obtain the configuration information of the proxy configuration. The specific execution is:
[0093] Get the proxy configuration from vueConfig.devServer and store the returned information in proxyConfig.
[0094] It should be emphasized that if the configuration file of the proxy configuration of the Vue project includes multiple proxy configurations, Object.entries(proxyConfig).forEach can be used to traverse the configuration file to obtain the configuration information of each proxy configuration. Then, for each proxy configuration, steps S203 and S204 are executed based on the configuration information of the proxy configuration to generate the target proxy address of each proxy configuration and display it.
[0095] Step S203: Generate a reference path for the proxy configuration based on the path prefix.
[0096] In one possible implementation, generating a reference path for proxy configuration based on the path prefix may be performed as follows: Figure 3 Steps shown:
[0097] Step S301, based on a preset format condition and the path prefix, determine the type information of the path prefix; wherein the type information includes a regular expression or a common character string.
[0098] Before generating a reference path for proxy configuration based on a path prefix, it is first necessary to determine the type information of the path prefix.
[0099] Specifically, if the path prefix does not meet the preset format condition, the type information of the path prefix is an ordinary string; if the path prefix meets the preset format condition, the type information of the path prefix is a regular expression.
[0100] The preset format condition is a condition that can determine that a string is a regular expression. For example, the preset format condition includes but is not limited to at least one of the following format conditions:
[0101] The path prefix starts with ^;
[0102] The path prefix contains \d (matching numbers);
[0103] The path prefix contains brackets ( and ) (matching group);
[0104] The path prefix contains .* (matches any character);
[0105] The path prefix contains .+ (matches at least one character).
[0106] In an embodiment of the present application, if the path prefix satisfies at least one of the above-mentioned preset format conditions, the type information of the path prefix is determined to be a regular expression, otherwise the type information of the path prefix is determined to be an ordinary string.
[0107] Step S302: If the type information of the path prefix is a common character string, a reference path of the proxy configuration is generated based on the first generation method.
[0108] Wherein, based on the first generation method, generating the reference path of the proxy configuration can be implemented as follows: adding the target character at the end of the path prefix to obtain the reference path of the proxy configuration.
[0109] When the path prefix is a normal string, the path format is fixed, so simply adding the target string after it will generate a suitable reference path.
[0110] The target character may be / example.
[0111] Specifically, if the type information of the path prefix is a common string, the generateExamplePathForString method is called to generate a reference path for the proxy configuration.
[0112] The execution logic of the generateExamplePathForString method is: first receive a path prefix (path) in the form of a normal string; then if there is a slash at the end of the path prefix, remove the slash at the end of the path prefix to ensure the uniform path format; then add the target character to the end of the path prefix to generate a reference path, and finally return the generated reference path.
[0113] For example, assuming that the path prefix is a common string and the path prefix is / api, calling the generateExamplePathForString method generates a reference path for the proxy configuration as / api / example.
[0114] Step S303: If the type information of the path prefix is a regular expression, a reference path of the proxy configuration is generated based on the second generation method.
[0115] Wherein, based on the second generation method, the reference path of the proxy configuration is generated, which can be implemented as follows:
[0116] Remove the start symbol of the regular expression in the path prefix;
[0117] Based on the regular expression replacement rule, the regular expression in the path prefix is replaced with characters that comply with the regular expression replacement rule to obtain a reference path for the proxy configuration.
[0118] When the path prefix is a regular expression, the path may contain dynamic parts, such as numbers and arbitrary characters. These dynamic parts need to be replaced by regular expression replacement rules to generate a suitable reference path.
[0119] Among them, the regular expression replacement rules can be set as needed, for example:
[0120] Remove the leading ^ character from the regular expression in the path prefix.
[0121] Replace the part of the path prefix that matches numbers (such as \d+) with specific numbers (such as 123).
[0122] Replace the part of the path prefix that matches any character (such as (.*)) with a specific string (such as example).
[0123] Replace the file extension part in the path prefix (such as (jpg|png|gif)) with the specific file name (such as image.jpg).
[0124] Specifically, if the type information of the path prefix is a regular expression, the generateExamplePathsFromRegexString method is called to generate a reference path for the proxy configuration.
[0125] The execution logic of the generateExamplePathsFromRegexString method is as follows: first receive a path prefix (regexStr) in string form containing a regular expression, then use a series of regular expression replacement rules to replace the regular expression in the path prefix with characters that conform to the regular expression replacement rules to generate a reference path for the proxy configuration; finally, return the generated reference path.
[0126] Exemplarily, assuming that the type information of the path prefix is a regular expression, and the path prefix is ^ / product / \d+$, calling the generateExamplePathsFromRegexString method generates a reference path of the proxy configuration as / product / 123.
[0127] Step S204, based on the reference path, the path rewriting rule and the target address, determine the target proxy address of the proxy configuration, and display the target proxy address.
[0128] In a possible implementation, determining the target proxy address of the proxy configuration based on the reference path, the path rewriting rule, and the target address may be performed as follows: Figure 4 Steps shown:
[0129] Step S401, rewriting the reference path based on the path rewriting rule to obtain a rewritten reference path;
[0130] Step S402: obtaining a target proxy address of the proxy configuration based on the target address and the rewritten reference path.
[0131] In specific implementation, the calculateRealUrl method is called to determine the target proxy address of the proxy configuration. The calculateRealUrl method receives three parameters: path (reference path), target (target address), and pathRewrite (path rewriting rule).
[0132] This method contains a variable realUrl, whose initial value is the reference path path. If there is a path rewriting rule pathRewrite, the rule is traversed, and the part of the reference path path that matches the path rewriting rule is replaced with the corresponding characters in the path rewriting rule to complete the rewriting of the reference path. Finally, the rewritten reference path is assigned to realUrl; then the target address target is connected with realUrl to obtain the target proxy address of the proxy configuration. Here, realUrl is the rewritten reference path.
[0133] Exemplarily, the path rewriting rule '^ / api':" means rewriting the part of the URL path (reference path) that matches the regular expression '^ / api' to an empty string.
[0134] To facilitate understanding of the address generation method provided in the embodiment of the present application, an example is provided below to illustrate the address generation method provided in the embodiment of the present application.
[0135] Create readProxy.js in the root directory of the vue project. The main function of readProxy.js is to read the configuration information of the proxy configuration in the configuration file vue.config.js, and determine the target proxy address of the proxy configuration based on the configuration information of the proxy configuration, so that developers can instantly and intuitively verify the correctness of the proxy configuration.
[0136] For example, the configuration information of the proxy configuration in the configuration file vue.config.js is:
[0137] proxy:{
[0138] ' / api':{
[0139] target:'http: / / localhost:3000',
[0140] pathRewrite:{
[0141] '^ / api':"
[0142] }
[0143] }
[0144] }
[0145] Among them, ' / api' is the path prefix configured by the proxy; target is the target address configured by the proxy; pathRewrite is the path rewriting rule: "'^ / api':" means rewriting the part of the URL path that matches the regular expression '^ / api' to an empty string.
[0146] For example, if the front end initiates a request / api / users, after passing through the above proxy, the request will be proxied to the target proxy address http: / / localhost:3000 / users. In order to allow developers to instantly and intuitively verify the correctness of the proxy configuration, after modifying the proxy configuration, execute readProxy.js:node readProxy.js (address generation request) in the terminal command line, and the target proxy address http: / / localhost:3000 / users of the proxy configuration can be determined according to the address generation method provided in this application, and the target proxy address can be displayed.
[0147] Furthermore, in addition to displaying the target proxy address of the proxy configuration, the configuration information, reference path and other information of the proxy configuration may also be displayed.
[0148] If the configuration file of the proxy configuration of the Vue project includes multiple proxy configurations, the corresponding configuration information, reference path, and target proxy address can be printed for each proxy configuration, so that developers can instantly and intuitively verify the correctness of each proxy configuration.
[0149] Based on the foregoing description, in the embodiment of the present application, the address generation request input by the user is responded to, and the configuration file of the proxy configuration of the Vue project is obtained; the configuration file is parsed through the parsing function to obtain the configuration information of the proxy configuration; the configuration information includes the path prefix, path rewriting rules and target address of the proxy configuration; based on the path prefix, the reference path of the proxy configuration is generated; based on the reference path, the path rewriting rules and the target address, the target proxy address of the proxy configuration is determined, and the target proxy address is displayed. Therefore, when developing a Vue project, you only need to input an address generation request in the terminal to obtain the target proxy address of the proxy configuration, allowing developers to instantly and intuitively verify the correctness of the proxy configuration, without the need to frequently restart the Vue project, thereby improving the development efficiency of the Vue project.
[0150] Based on the same inventive concept, the present application embodiment provides an address generation device, please refer to Figure 5 The device includes: an acquisition module 501, a parsing module 502, a generation module 503 and a determination module 504, wherein:
[0151] The acquisition module 501 is used to respond to the address generation request input by the user and obtain the configuration file of the proxy configuration of the Vue project;
[0152] The parsing module 502 is used to parse the configuration file through a parsing function to obtain configuration information of the proxy configuration; the configuration information includes a path prefix, a path rewriting rule and a target address of the proxy configuration;
[0153] A generating module 503, configured to generate a reference path of the proxy configuration based on the path prefix;
[0154] The determination module 504 is configured to determine a target proxy address of the proxy configuration based on the reference path, the path rewriting rule, and the target address, and display the target proxy address.
[0155] In a possible implementation, the parsing module 502 is specifically configured to:
[0156] By introducing a file function, the configuration file is loaded and executed to obtain field information of the configuration file;
[0157] The field information of the configuration file is parsed through the proxy server interface to obtain the configuration information of the proxy configuration.
[0158] In a possible implementation manner, the generating module 503 is specifically configured to:
[0159] Based on a preset format condition and the path prefix, determining type information of the path prefix; wherein the type information includes a regular expression or a common string;
[0160] If the type information of the path prefix is a common character string, generating a reference path of the proxy configuration based on the first generation method;
[0161] If the type information of the path prefix is a regular expression, a reference path of the proxy configuration is generated based on a second generation method.
[0162] In a possible implementation manner, the generating module 503 is specifically configured to:
[0163] If the path prefix does not meet the preset format condition, the type information of the path prefix is a common character string;
[0164] If the path prefix satisfies the preset format condition, the type information of the path prefix is a regular expression.
[0165] In a possible implementation manner, the generating module 503 is specifically configured to:
[0166] Add the target character at the end of the path prefix to obtain the reference path of the proxy configuration.
[0167] In a possible implementation manner, the generating module 503 is specifically configured to:
[0168] Based on the regular expression replacement rule, the regular expression in the path prefix is replaced with characters that conform to the regular expression replacement rule to obtain a reference path for the proxy configuration.
[0169] In a possible implementation manner, the determining module 504 is specifically configured to:
[0170] Rewriting the reference path based on the path rewriting rule to obtain a rewritten reference path;
[0171] Based on the target address and the rewritten reference path, a target proxy address of the proxy configuration is obtained.
[0172] The address generation device provided in the embodiment of the present application has the same beneficial effects as the address generation method in the above embodiment, which will not be described one by one here.
[0173] After introducing the address generation method and the address generation device according to the exemplary embodiments of the present application, next, an electronic device provided according to the embodiment of the present application is introduced.
[0174] The present application embodiment provides an electronic device, which can implement the address generation method discussed above, please refer to Figure 6 , the device includes a memory 601, a processor 602 and a bus 603.
[0175] The memory 601 is used to store computer programs executed by the processor 602. The memory 601 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0176] The memory 601 may be a volatile memory, such as a random-access memory (RAM); the memory 601 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 601 may be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 601 may be a combination of the above memories.
[0177] The processor 602 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 602 is used to implement the address generation method in the above embodiment when calling the computer program stored in the memory 601 .
[0178] The specific connection medium between the memory 601 and the processor 602 is not limited in the embodiment of the present application. Figure 6 In the embodiment, the memory 601 and the processor 602 are connected via a bus 603. The bus 603 is connected to the processor 602 via a bus 603. Figure 6 The connections between other components are shown in bold lines, which are only for illustration and are not intended to be limiting. Bus 603 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0179] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, and the computer program product includes: computer program code, when the computer program code is run on a computer, the computer executes any of the address generation methods discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the address generation method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0180] Based on the same inventive concept, the embodiment of the present application further provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the address generation methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of the address generation method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0181] It should be understood by those skilled in the art that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0182] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0183] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0184] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of user-operated steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0185] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for generating an address, characterized in that: The method comprises: Respond to the address generation request entered by the user and obtain the configuration file of the proxy configuration of the Vue project; The configuration file is parsed through a parsing function to obtain configuration information of the proxy configuration; the configuration information includes a path prefix, a path rewriting rule and a target address of the proxy configuration; Based on the path prefix, generating a reference path of the proxy configuration; Based on the reference path, the path rewriting rule, and the target address, a target proxy address of the proxy configuration is determined, and the target proxy address is displayed.
2. The method according to claim 1, characterized in that The step of generating a reference path for the proxy configuration based on the path prefix comprises: Based on a preset format condition and the path prefix, determining type information of the path prefix; wherein the type information includes a regular expression or a common string; If the type information of the path prefix is a common character string, generating a reference path of the proxy configuration based on the first generation method; If the type information of the path prefix is a regular expression, a reference path of the proxy configuration is generated based on a second generation method.
3. The method according to claim 2, characterized in that The determining the type information of the path prefix based on the preset format condition and the path prefix includes: If the path prefix does not meet the preset format condition, the type information of the path prefix is a common character string; If the path prefix satisfies the preset format condition, the type information of the path prefix is a regular expression.
4. The method according to claim 2, characterized in that The step of generating the reference path of the proxy configuration based on the first generating method includes: Add the target character at the end of the path prefix to obtain the reference path of the proxy configuration.
5. The method according to claim 2, characterized in that The step of generating the reference path of the proxy configuration based on the second generation method includes: Based on the regular expression replacement rule, the regular expression in the path prefix is replaced with characters that conform to the regular expression replacement rule to obtain a reference path for the proxy configuration.
6. The method according to claim 1, characterized in that The determining, based on the reference path, the path rewriting rule, and the target address, a target proxy address of the proxy configuration includes: Rewriting the reference path based on the path rewriting rule to obtain a rewritten reference path; Based on the target address and the rewritten reference path, a target proxy address of the proxy configuration is obtained.
7. An address generating device, characterized in that: The device comprises: The acquisition module is used to respond to the address generation request input by the user and obtain the configuration file of the proxy configuration of the Vue project; A parsing module, used to parse the configuration file through a parsing function to obtain configuration information of the proxy configuration; the configuration information includes a path prefix, a path rewriting rule and a target address of the proxy configuration; A generating module, configured to generate a reference path of the proxy configuration based on the path prefix; The determination module is used to determine the target proxy address of the proxy configuration based on the reference path, the path rewriting rule and the target address, and display the target proxy address.
8. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is used to cause the computer to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that When the computer program product is called by a computer, the computer executes the method according to any one of claims 1 to 6.
