Server domain name switching method and device

文档序号:1956856 发布日期:2021-12-10 浏览:17次 中文

阅读说明:本技术 一种服务器域名切换的方法及装置 (Server domain name switching method and device ) 是由 骆少猛 金敏健 严贤林 林堃 李嘉文 黄洋洋 于 2021-07-26 设计创作,主要内容包括:本发明提供的一种服务器域名切换的方法及装置,通过获取当前界面的url参数,并生成相应的域名输入框;接收所述域名输入框中输入的域名值,并存储至本地;发送请求时,先请求获取本地存储的域名值,并根据所述域名值对服务器域名进行切换,提高了服务器域名切换的实用性和通用性。(According to the method and the device for switching the domain name of the server, the url parameter of the current interface is obtained, and the corresponding domain name input box is generated; receiving the domain name value input in the domain name input box and storing the domain name value to the local; when the request is sent, the locally stored domain name value is requested to be acquired, and the server domain name is switched according to the domain name value, so that the practicability and the universality of the server domain name switching are improved.)

1. A method for switching server domain names is characterized by comprising the following steps:

s1, acquiring url parameters of the current interface and generating a corresponding domain name input box;

s2, receiving the domain name value input in the domain name input box and storing the domain name value to local;

and S3, when sending the request, firstly requesting to acquire the locally stored domain name value, and switching the server domain name according to the domain name value.

2. The method for switching the domain name of the server according to claim 1, wherein the step S1 specifically includes:

and acquiring a url parameter of the current interface, judging whether the url parameter accords with a preset format, and if so, generating a corresponding domain name input box.

3. The method for switching the domain name of the server according to claim 1, wherein the step S2 specifically includes:

and receiving the domain name value input in the domain name input box and storing the domain name value into a localStorage local cache.

4. The method for switching the server domain name according to claim 3, wherein the switching the server domain name according to the domain name value specifically comprises:

and judging whether the domain name value stored locally is empty, if so, calling the original domain name configured in the global environment variable file, otherwise, taking out the domain name from the localStorage local cache, and replacing the stored domain name value to the beginning of the current domain name for splicing and replacing to complete the switching of the server domain name.

5. An apparatus for switching a domain name of a server, comprising a memory, a processor and a computer program stored in the memory and operable on the processor, wherein the processor executes the computer program to perform the following steps:

s1, acquiring url parameters of the current interface and generating a corresponding domain name input box;

s2, receiving the domain name value input in the domain name input box and storing the domain name value to local;

and S3, when sending the request, firstly requesting to acquire the locally stored domain name value, and switching the server domain name according to the domain name value.

6. The apparatus for switching a domain name of a server according to claim 5, wherein the step S1 specifically includes:

and acquiring a url parameter of the current interface, judging whether the url parameter accords with a preset format, and if so, generating a corresponding domain name input box.

7. The apparatus for switching a domain name of a server according to claim 5, wherein the step S2 specifically includes:

receiving the domain name value input in the domain name input box, and storing the domain name value in a local cache Storage.

8. The apparatus for switching a server domain name according to claim 7, wherein the switching a server domain name according to the domain name value specifically comprises:

and judging whether the domain name value stored locally is empty, if so, calling the original domain name configured in the global environment variable file, otherwise, taking out the domain name from the localStorage local cache, and replacing the stored domain name value to the beginning of the current domain name for splicing and replacing to complete the switching of the server domain name.

Technical Field

The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for switching a server domain name.

Background

Conventional Vue packing tools such as webpack and rollup are standard packing methods using node. Based on the front-end and back-end interaction technology, the back-end production environment needs to interact with the front end through json format transmission data. Because the back end does not have a visual debugging page similar to the front end, the back end cannot perform dynamic domain name switching between the local environment and the production environment. At this time, the front end is required to set the environment variable when the packaging tool is run, but the domain name corresponding to the environment variable is fixed after packaging.

And when the front end wants to realize the dynamic switching of the domain name, the relevant environment configuration codes need to be changed and then are deployed to a test environment and a production environment, so that other developers who use a Git code hosting and research and development cooperation platform are easily affected, and the problem of online codes is caused.

Disclosure of Invention

Technical problem to be solved

In order to solve the above problems in the prior art, the present invention provides a method and an apparatus for switching a server domain name, which can improve the accuracy and comprehensiveness of policy pushing.

(II) technical scheme

In order to achieve the purpose, the invention adopts a technical scheme that:

a method for switching server domain names comprises the following steps:

s1, acquiring url parameters of the current interface and generating a corresponding domain name input box;

s2, receiving the domain name value input in the domain name input box and storing the domain name value to local;

and S3, when sending the request, firstly requesting to acquire the locally stored domain name value, and switching the server domain name according to the domain name value.

In order to achieve the purpose, the invention adopts another technical scheme as follows:

an apparatus for switching a domain name of a server, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the program:

s1, acquiring url parameters of the current interface and generating a corresponding domain name input box;

s2, receiving the domain name value input in the domain name input box and storing the domain name value to local;

and S3, when sending the request, firstly requesting to acquire the locally stored domain name value, and switching the server domain name according to the domain name value.

The invention has the beneficial effects that: obtaining url parameters of a current interface and generating a corresponding domain name input box; receiving the domain name value input in the domain name input box and storing the domain name value to the local; when the request is sent, the locally stored domain name value is requested to be acquired, and the server domain name is switched according to the domain name value, so that the practicability and the universality of the server domain name switching are improved.

Drawings

Fig. 1 is a flowchart of a method for switching a server domain name according to an embodiment of the present invention;

fig. 2 is a schematic overall structure diagram of a server domain name switching apparatus according to an embodiment of the present invention.

[ description of reference ]

1: a server domain name switching device;

2: a memory;

3: a processor.

Detailed Description

For the purpose of better explaining the present invention and to facilitate understanding, the present invention will be described in detail by way of specific embodiments with reference to the accompanying drawings.

Example one

Referring to fig. 1, a method for switching a server domain name includes the steps of:

s1, acquiring url parameters of the current interface and generating a corresponding domain name input box;

step S1 specifically includes:

and acquiring a url parameter of the current interface, judging whether the url parameter accords with a preset format, and if so, generating a corresponding domain name input box.

S2, receiving the domain name value input in the domain name input box and storing the domain name value to local;

step S2 specifically includes:

receiving the domain name value input in the domain name input box and storing the domain name value in a local Storage local cache.

And S3, when sending the request, firstly requesting to acquire the locally stored domain name value, and switching the server domain name according to the domain name value.

The switching of the server domain name according to the domain name value specifically comprises:

and judging whether the domain name value stored locally is empty, if so, calling the original domain name configured in the global environment variable file, otherwise, taking out the domain name from the local Storage local cache, and replacing the stored domain name value to the beginning of the current domain name for splicing and replacing to complete the switching of the server domain name.

Example two

The difference between this embodiment and the first embodiment is that this embodiment will further explain how the above method for switching a server domain name is implemented in combination with a specific application scenario:

1. and acquiring a url parameter of the current interface, judging whether the url parameter accords with a preset format, and if so, generating a corresponding domain name input box.

Specifically, the current interface is a designated interface, such as a login interface;

2. receiving the domain name value input in the domain name input box and storing the domain name value in a local Storage local cache;

specifically, when the login button is clicked, the value input by the domain name input box is stored in a Storage medium, such as a local Storage local cache, so that the data is not easily lost.

3. When a request is sent, a locally stored domain name value is requested to be acquired, whether the locally stored domain name value is empty or not is judged, if yes, an original domain name configured in a global environment variable file is called, otherwise, the domain name is taken out from a local Storage local cache, the domain name Storage value is replaced to the beginning of the current domain name for splicing replacement, and the switching of the server domain name is completed.

Specifically, each time an Ajax request is initiated, a locally stored domain name value is requested to be acquired, judgment is carried out through an if-else condition judgment structure, and if the current domain name storage value is empty, the original domain name configured in the default packed env global environment variable file is called; otherwise, the domain name is taken out from the localStorage local cache, and the domain name storage value is replaced to the beginning of the current domain name for splicing replacement.

EXAMPLE III

Referring to fig. 2, an apparatus 1 for switching a server domain name includes a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3, wherein the processor 3 implements the steps of the first embodiment when executing the computer program.

The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种NAT端口分配在多核下对数据流免锁的实现方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类