Method and device for accessing pre-sending environment, electronic equipment and storage medium
By obtaining the user ID and static resource path in the QR code, monitoring and modifying the resource path of the target page, it solves the problem of high professional knowledge requirements and complex operations when accessing the pre-release environment on the mobile terminal, and realizes convenient access without configuring an agent. Improved user experience and security.
Patent Information
- Application Number
- CN202310342083.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-31
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, when the mobile terminal accesses the pre-release environment, the user needs to manually modify the network proxy, which has problems such as high professional knowledge requirements and complex operations.
By obtaining the user ID in the QR code and redirecting the static resource path, monitoring the display elements of the target page, modifying the resource path to obtain static resources, and determining the target page of the pre-release environment based on the static resources and interface data, it is possible to achieve the goal without configuring a proxy. Access to the pre-release environment.
It reduces the complexity of manual operations, improves user experience, and ensures the security and convenience of accessing the pre-release environment.
Smart Images

Figure CN118740762A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a method, device, electronic device and storage medium for accessing a pre-release environment. Background Art
[0002] In the process of researching and developing projects, it is usually necessary to deploy the projects to be launched on a pre-release environment (i.e., server) for sufficient testing to ensure that there are no problems before deploying the projects on the online server. At present, the existing method of accessing projects deployed in the pre-release environment on a mobile terminal is usually to configure a host proxy on the computer and mobile terminals when the mobile terminal and the computer terminal are in the same network, specify the IP (Internet Protocol) address of the domain name access, and force the mobile terminal to jump to the pre-release server URL when accessing the online URL.
[0003] When implementing the technical solution based on the above method, the inventor found the following problems:
[0004] Currently, when accessing the pre-release environment on a mobile device, users are required to configure the host proxy on the computer and manually modify the network proxy on the mobile device. When configuring the proxy, some network expertise is involved, which requires a high level of user expertise and results in high labor costs and complex operations. Summary of the invention
[0005] The present invention provides a method, device, electronic device and storage medium for accessing a pre-release environment, so as to achieve the effect of accessing the pre-release environment on the mobile terminal without configuring an agent on the mobile terminal, reducing the complexity of configuration operations.
[0006] In a first aspect, an embodiment of the present invention provides a method for accessing a pre-release environment, the method comprising:
[0007] Obtaining a user identifier corresponding to an access request; wherein the access request is generated based on a scanning operation of a QR code, wherein the QR code includes a project identifier, a user identifier, and a redirection static resource path;
[0008] When the user identifier and the cached user identifier are consistent, calling pre-generated interface data corresponding to the user identifier and the project identifier; and,
[0009] Monitoring a display element on a target page corresponding to the access request, and when a target tag of the display element is consistent with a preset tag, modifying a resource path of the display element to the redirected static resource path, so as to obtain a static resource corresponding to the display element;
[0010] Based on the static resources of the display element and the interface data, a target page in a pre-release environment is determined.
[0011] In a second aspect, an embodiment of the present invention further provides a device for accessing a pre-release environment, the device comprising:
[0012] A user identification acquisition module, used to acquire a user identification corresponding to an access request; wherein the access request is generated based on a scanning operation of a QR code, wherein the QR code includes a project identification, a user identification, and a redirection static resource path;
[0013] A user identification judgment module is used to retrieve pre-generated interface data corresponding to the user identification and project identification when the user identification and the cached user identification are consistent; and
[0014] Monitoring a display element on a target page corresponding to the access request, and when a target tag of the display element is consistent with a preset tag, modifying a resource path of the display element to the redirected static resource path, so as to obtain a static resource corresponding to the display element;
[0015] The target page determination module is used to determine the target page in the pre-release environment based on the static resources of the display element and the interface data.
[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0017] one or more processors;
[0018] a storage device for storing one or more programs,
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for accessing the pre-release environment as described in any one of the embodiments of the present invention.
[0020] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the method for accessing a pre-release environment as described in any one of the embodiments of the present invention.
[0021] The technical solution of the embodiment of the present invention obtains a user identifier corresponding to an access request, and when the user identifier is consistent with a cached user identifier, retrieves pre-generated interface data corresponding to the user identifier and the project identifier; monitors the display element on the target page corresponding to the access request, and when the target tag of the display element is consistent with a preset tag, modifies the resource path of the display element to a redirected static resource path, so as to obtain the static resource corresponding to the display element; based on the static resource of the display element and the interface data, determines the target page in the pre-release environment, solves the technical problems in the prior art that the user needs to manually modify the network proxy on the mobile terminal, has high requirements for professional knowledge and complex configuration operations, and realizes the acquisition of the user identifier in the QR code by scanning the QR code, and then determines whether the mobile terminal has the authority to access the pre-release environment based on the user identifier, and determines the target page in the pre-release environment based on the user identifier and the cached user identifier. When the stored user ID is consistent, the interface data corresponding to the user ID and the project ID is retrieved, thereby ensuring the security of accessing the pre-release environment. At the same time, by monitoring the target tag of the display element on the target page, when the target tag is consistent with the preset tag, the resource path of the display element is modified to the redirected static resource path to redirect the static resource. The advantage of redirecting static resources is that the redirected static resources are equivalent to the business static resource scripts of the pre-release environment. These pre-release environment scripts can be placed on the public Internet to form a link, thereby achieving the effect of accessing the front-end static resource scripts of the pre-release environment. Further, based on the static resources and interface data, the target page in the pre-release environment is determined, thereby achieving access to the pre-release environment on the mobile terminal without configuring a proxy on the mobile terminal, thereby reducing the complexity of manual operations, improving the effect of accessing the pre-release environment, and achieving the technical effect of improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 A flowchart of a method for accessing a pre-release environment provided by an embodiment of the present invention;
[0024] Figure 2 A schematic diagram of a method for generating a two-dimensional code provided by an embodiment of the present invention;
[0025] Figure 3 A schematic diagram of a method for executing logic for accessing a pre-release environment provided by an embodiment of the present invention;
[0026] Figure 4A schematic diagram of a method for accessing a pre-release environment provided by an embodiment of the present invention;
[0027] Figure 5 A schematic diagram of the structure of a device for accessing a pre-release environment provided by an embodiment of the present invention;
[0028] Figure 6 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0030] Before introducing this technical solution, an example of the application scenario can be explained. This technical solution can be applied to scenarios based on mobile terminals accessing project pages in any pre-release environment. For example, a user can access project A in a pre-release environment on a mobile terminal. This technical solution can be used to achieve the technical effect of mobile terminals accessing projects in a pre-release environment without configuring a host proxy on the mobile terminal.
[0031] Figure 1 A flow chart of a method for accessing a pre-release environment provided in an embodiment of the present invention. This embodiment is applicable to the case of accessing a pre-release environment. The method can be executed by a device for accessing a pre-release environment. The device for accessing a pre-release environment can be implemented in the form of hardware and / or software. The device for accessing a pre-release environment can be configured in a mobile terminal.
[0032] like Figure 1 The method of this embodiment specifically includes the following steps:
[0033] S110: Obtain a user identifier corresponding to the access request.
[0034] Among them, the access request can be an instruction or code for accessing a certain page, etc., which is used to request access to a page. For example, if a user wants to test project A, the page requested to be accessed can be the page of project A. The pre-release environment can refer to an environment used to test a project before it goes online, which is different from the online environment that external network users can officially access. The access request is generated based on the scanning operation of the QR code. The QR code includes a project identifier, a user identifier, and a redirected static resource path. The project identifier can be used to characterize the uniqueness of the development project, and the development project can include program code for completing its project functions. The user identifier can be used to characterize the uniqueness of the visitor. The user identifier can be a PIN (Personal identification number) used to authenticate the identity of the visitor and authorize the visitor to enter the pre-release environment. Generally speaking, the access user is a developer or tester. The redirected static resource path can be used to characterize the path that redirects a network request to another location.
[0035] In actual applications, when a user uses a mobile device to scan a QR code including a project identifier, a user identifier, and a redirected static resource path, the system is considered to have received a request for accessing a pre-release environment uploaded by the mobile device, that is, to have obtained an access request. The access request can be parsed to extract the user identifier carried in the access request, or when scanning the QR code, the QR code can be parsed to obtain the user identifier contained in the QR code. Specifically, the method for obtaining the user identifier corresponding to the access request can be: based on scanning the QR code on the mobile terminal, to obtain the user identifier contained in the QR code.
[0036] Among them, the mobile terminal can be a smart handheld device, such as a mobile phone, a tablet iPad, a smart watch, etc.
[0037] In this embodiment, the user can use the mobile terminal to scan the QR code, scan and identify the QR code, and obtain the user identification contained in the QR code. At this time, it is considered that the user identification corresponding to the access request has been obtained. For example, the user can use the mobile terminal of the mobile phone to scan the QR code corresponding to the pre-release environment website, parse the QR code during scanning, and obtain the user identification contained in the QR code, so as to determine whether the user's mobile device is a device that can access the pre-release environment based on the user identification, thereby ensuring the security of the pre-release environment access.
[0038] It should be noted that in order to improve the convenience of accessing the pre-release environment, after the user scans the QR code based on the mobile terminal, the user identifier contained in the QR code can be stored in the local cache, so that the stored user identifier can be directly retrieved from the local cache later. For example, when the user wants to access the pre-release environment on the mobile terminal, the user identifier in the pre-stored QR code can be directly extracted from the local cache of the mobile device as the user identifier corresponding to the access request.
[0039] S120: When the user identifier and the cached user identifier are consistent, retrieve pre-generated interface data corresponding to the user identifier and the project identifier.
[0040] The cache user identifier may be user identifier information that can access the pre-release environment, and may be stored in a cache location. The interface data refers to interface information that can be used to access the pre-release environment.
[0041] In this embodiment, the user identifier can be compared with the cached user identifier. If the two are consistent, it can be considered that the mobile terminal has the authority to access the pre-launch environment. At this time, the interface data corresponding to the user identifier and the project identifier can be retrieved to access the pre-launch environment based on the interface data. It should be noted that there can be multiple cached user identifiers, and it can be determined from the multiple cached user identifiers whether a user identifier consistent with the user identifier is included. If so, the interface data corresponding to the user identifier and the project identifier can be retrieved. Optionally, when the user identifier and the cached user identifier are consistent, the pre-generated interface data corresponding to the user identifier and the project identifier are retrieved, including: determining whether the cached user identifier in the cache is consistent with the user identifier; if so, retrieving the interface data corresponding to the user identifier and the project identifier from the database corresponding to the server.
[0042] The cache may be a data access storage device, for example, a Cache, a cookie, or a localStorage.
[0043] Specifically, the user identifier can be compared and analyzed with the cached user identifier in the cache to determine whether there is a cached user identifier consistent with the user identifier in the cache. If so, it means that the user identifier is in the whitelist for accessing the pre-release environment, that is, the mobile terminal that scans and obtains the user identifier has the authority to access the pre-release environment, and can retrieve the interface data corresponding to the user identifier and project identifier from the server database.
[0044] It should be noted that in order to improve the convenience of accessing the pre-release environment and avoid cumbersome operations and inconvenient access caused by modifying the pre-release environment URL on the server, before retrieving the interface data corresponding to the user ID and project ID, you can also pre-access the pre-release environment through the computer side, so that during the access process, you can pull the interface data required to access the pre-release environment, and store the interface data on the server side so that it can be directly called by the mobile side later.
[0045] Optionally, before retrieving the pre-generated interface data corresponding to the user ID and project ID, it also includes: executing the logic of accessing the pre-release environment based on the computer side to store the interface data corresponding to the user ID and project ID to the server side, so that the mobile side can retrieve the interface data.
[0046] The computer terminal may be a PC (personal computer) terminal. The logic may refer to a program code for executing access to the pre-release environment, and may optionally be a js script.
[0047] In actual applications, before calling the interface data corresponding to the user ID and project ID, the logic of accessing the pre-launch environment can be executed on the computer side. During the access process, the user ID and project ID contained in the logic code can be called out. When accessing the pre-launch environment, the accessed interface data is obtained, and the interface data is stored in the server side in correspondence with the user ID and project ID in the logic code. So that the mobile terminal can call the interface data corresponding to the user ID and project ID from the server. For example, the computer side can configure the URL for accessing the pre-launch environment through the host agent, and configure the corresponding project ID and user ID for the project in the pre-launch environment. When the computer side accesses the pre-launch environment based on the URL, the interface data when accessing the pre-launch environment, the project ID and the user ID can be stored on the server side.
[0048] In order to ensure that the access interface data can be pulled based on the computer-side access to the pre-release environment, an interception can be set when pulling the data to obtain the access response data, that is, the interface data, by intercepting the data. Optionally, the logic of accessing the pre-release environment is executed based on the computer to store the interface data corresponding to the user ID and the project ID to the server, including: obtaining the user ID and project ID set in the business code, and intercepting the corresponding interface data; sending the user ID, project ID and interface data to the server, so that the server stores the interface data in the database according to the user ID and project ID.
[0049] In this embodiment, when the computer executes the logic of accessing the pre-release environment, the business website of the pre-release environment, such as sdk.html, will be accessed, and the user ID and project ID carried on the business website can be obtained. At this time, it is considered that the user ID and project ID set in the business code have been obtained. At the same time, when accessing the pre-release environment based on the computer, the access request can be intercepted, and the requested link, parameters, response data, etc. are sent to the server as interface data, and then the interface data is saved under this project ID and user ID, that is, stored in the database accordingly. Exemplarily, the logic for executing access to the pre-release environment can be an sdk.js file. Then the sdk.js file can be introduced in the head tag of the html of the business code, so that the logic of the sdk.js is executed on the PC side (computer side) first, and the business website of the pre-release environment is accessed through the host proxy. The PC side pre-release environment will set the user ID (such as U1) and project ID (such as I1) in the reported business code, and when the PC side intercepts the http / https request corresponding to the access to the pre-release environment, the requested link, parameters, response data, etc. are sent to the server as interface data and saved under U1 and I1, that is, the interface data of the http request is reported to the specified database and saved in correspondence with the corresponding user ID and project ID.
[0050] It can be understood that when the PC accesses the pre-launch environment of the configured host and submits the interface data of the pre-launch environment to the server, the access request of the mobile terminal can be intercepted when the mobile terminal accesses the pre-launch environment, and the interface data stored in the server database is returned. For example, in actual applications, when a user uses a mobile terminal to scan a QR code to access the URL of the pre-launch environment, the logic in the pre-launch environment URL will be executed first to obtain the project ID and user ID carried on the URL. If the user ID is empty, it means that the local cache is to be deleted, that is, the user ID in the mobile terminal is cleared, and the online logic is accessed at this time; if the user ID has a value, the user ID and project ID can be saved in the local cache, and the local cache can be a cookie or a localStorage, so that the user ID and project ID can be obtained later without scanning the QR code. And the server interface can be requested through the user ID and project ID, and the server is requested to retrieve the interface data corresponding to the user ID and project ID from the server based on the interface data previously saved on the computer. This interface data is the interface data stored on the server when the PC accesses the pre-launch environment of the configured host.
[0051] It should be noted that this technical solution executes the logic of accessing the pre-release environment based on the computer side. It only needs to configure the host on the computer side to access the pre-release environment URL. For example, the whistle agent can be installed on the computer side. The advantage of this setting is that the implementation method of configuring the host agent on the computer side to access the pre-release environment is simple and easy to operate. At the same time, there is no need to configure cumbersome and professional host agents on the mobile side, nor is there any need to modify the server-side pre-release environment URL, thereby improving the convenience of operation.
[0052] S130. Monitor the display element on the target page corresponding to the access request, and when the target tag of the display element is consistent with the preset tag, modify the resource path of the display element to a redirected static resource path to obtain the static resource corresponding to the display element.
[0053] Among them, the target page corresponds to the page that the access request wants to access, which can be a business display page or a development page. For example, if the user wants to access page A, then page A can be used as the target page. Display elements refer to page elements in a web page, such as DOM (Document Object Model) elements, CSS (Cascading Style Sheets) elements, body elements, div elements, etc. The preset tag can be a preset HTML tag, such as a script tag for defining a script. It should be noted that in HTML, the src attribute of the script tag can be used to specify an external file path, and the src attribute value can be used as a resource path. Static resources can be static resource data of the front end, such as JS data and CSS data of the front end.
[0054] In actual applications, the file monitoring mode can be turned on to monitor the changes of display elements on the target page corresponding to the access request. When the target tag of the display element is consistent with the preset tag, it can be considered that the preset tag is monitored. At this time, the resource path of the display element can be modified to a redirected static resource path to jump to the redirected static resource path to obtain the static resource corresponding to the display element. Exemplarily, the display element is a DOM element, and the preset tag is a script tag. The file monitoring mode can be turned on to monitor the changes of DOM elements in the target page html accessed by scanning the QR code. If the target tag in the DOM element is a script tag, the src request path of the script tag can be modified, and the src request path can be modified to a redirected static resource path, redirected to the static resource path developed for this demand, so as to realize the redirection of static resources, solving the problem of difficult access to the pre-release environment of front-end static resources.
[0055] In order to protect the original data and improve the accuracy of accessing the pre-release environment, the display elements on the target page corresponding to the access request can be monitored, so that when the target tag of the display element is consistent with the preset tag, the resource path of the display element is modified to the redirected static resource path before storing the redirected static resource path in a temporary variable, so that when the target tag is consistent with the preset tag, the resource path of the display element is modified to the redirected static resource path based on the temporary variable.
[0056] In actual applications, the redirection static resource path obtained from the QR code or the redirection static resource path obtained from the cache can be saved in a temporary variable. When the display element changes on the target page are monitored and the target tag is consistent with the preset tag, the redirection static resource path in the temporary variable is called, and the resource path of the display element is modified to the redirection static resource path.
[0057] It should be noted that in order to ensure that the redirected static resources are rendered and displayed after obtaining the interface data, thereby improving the rationality of the page display, optionally, before modifying the resource path of the display element to the redirected static resource path to obtain the static resources corresponding to the display element, it also includes: setting the tag attribute of the display element to a delayed processing attribute, so as to render the display element corresponding to the static resource after rendering other display elements.
[0058] In actual applications, you can add delayed processing attributes to the tags of display elements, such as the defer attribute, which stipulates that the script will be executed only after the page has been loaded. After rendering other display elements, the display elements corresponding to static resources can be rendered. For example, when a script tag is detected, you can add the defer attribute to it. The advantage of setting this attribute is that the display elements corresponding to the rendered static resources can be executed last. In this way, when executing the business code, after obtaining the http request content of the dynamically generated script tag, the display elements corresponding to the static resources can be rendered last.
[0059] It should be noted that the above S120 to S130 can be executed sequentially or in parallel, and the specific execution order is not limited. The above order is only the order for explaining the technical solutions in each step, not the execution order of each step.
[0060] S140: Determine a target page in a pre-release environment based on static resources and interface data of display elements.
[0061] Specifically, the pre-release environment can be accessed normally through the interface data, and all element information in the static resources of the rendering display element can be used to generate a target page, and the target page can be displayed in the pre-release environment.
[0062] Based on the above scheme, the corresponding project ID, user ID and redirected static resource path can be configured in advance for the developed project, and a QR code can be generated based on these configuration information, so that the project ID, user ID and redirected static resource path in the QR code can be obtained by scanning the QR code later, so that the mobile terminal can test the developed project in a pre-release environment through these data in the QR code.
[0063] Optionally, the method for accessing the pre-release environment also includes: determining the project identifier corresponding to the target project, the user identifier, and the redirected static resource path of the static resource corresponding to the user identifier; based on the trigger operation for generating a QR code, generating a QR code based on the project identifier, the user tag, and the redirected static resource path.
[0064] The triggering operation may include but is not limited to operations such as clicking, touching, sliding, dragging, etc. The target project may be understood as a project for which attributes such as a project identifier and a user identifier need to be configured.
[0065] In this embodiment, the corresponding project identification, user identification and redirection static resource path of the static resource corresponding to the user identification can be configured for the target project in the system page. For example, the user can create a project in the platform page of the project development, and for the target project A, the corresponding project identification is generated as project id1, the user identification is user pin1, and the redirection static resource path is url1. Further, when the user clicks the generate QR code control, it is considered that the trigger operation for generating the QR code is detected, and the project identification, user tag and redirection static resource path can be bound to generate a QR code. Exemplarily, the project identification, user identification and redirection static resource path corresponding to the target project can be attached to the link of the url by clicking the generate QR code button in the system page to generate a QR code, which refers to the link website for accessing the pre-release environment. Subsequent users only need to use the mobile terminal to scan the QR code, access the business link based on the data in the QR code, and the page of the pre-release environment can be displayed.
[0066] The technical solution of the embodiment of the present invention obtains a user identifier corresponding to an access request, and when the user identifier is consistent with a cached user identifier, retrieves pre-generated interface data corresponding to the user identifier and the project identifier; monitors the display element on the target page corresponding to the access request, and when the target tag of the display element is consistent with a preset tag, modifies the resource path of the display element to a redirected static resource path, so as to obtain the static resource corresponding to the display element; based on the static resource and interface data of the display element, determines the target page in a pre-release environment, solves the technical problems in the prior art that users need to manually modify the network proxy on the mobile terminal, have high requirements for professional knowledge and complex configuration operations, and realizes the The QR code obtains the user ID in the QR code, and then determines whether the mobile terminal has the authority to access the pre-release environment based on the user ID. When the user ID and the cached user ID are consistent, the interface data corresponding to the user ID and the project ID are retrieved to ensure the security of access to the pre-release environment. At the same time, by monitoring the target tag of the display element on the target page, when the target tag is consistent with the preset tag, the resource path of the display element is modified to a redirected static resource path to redirect the static resource. Then, based on the static resource and the interface data, the target page in the pre-release environment is determined, so that the pre-release environment can be accessed on the mobile terminal without configuring a proxy on the mobile terminal, reducing the complexity of manual operations and achieving the technical effect of improving user experience.
[0067] As an alternative embodiment of the above embodiments, Figure 2 This is a schematic diagram of a QR code generation method provided by an embodiment of the present invention. Based on the above embodiments, this embodiment can create a target project and then configure the corresponding project identifier, user identifier, and redirection static resource path and other data for the target project to generate a QR code based on these data. The specific implementation method can refer to the technical solution of this embodiment. The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here.
[0068] like Figure 2As shown, the implementation method of generating a QR code by creating a target project can be: a user can create a project on the web page platform of the R&D project as a target project, and then generate a project identifier (such as a project id) of the target project, and create a whitelist under the project, including at least one user identifier in the whitelist. And set the rules for static resource redirection, such as setting the redirection static resource path of the static resource corresponding to the whitelist, click the Generate QR Code button on the platform page, put the set project identifier and each user identifier in the whitelist and the redirection static resource path on the url link of the pre-launch environment, and generate a QR code, where the url refers to the link website after the pre-launch environment is deployed. The configured project identifier and each user identifier in the whitelist and the redirection static resource path can be saved in the database of the server through the request interface. So that subsequent users can scan the QR code, based on the project identifier, user identifier and redirection static resource path in the QR code to access the business link, and display the page of the pre-launch environment.
[0069] Based on the above scheme, after generating a QR code based on the project identifier, each user identifier in the whitelist, and the redirected static resource path, the logic of accessing the pre-release environment can be executed based on the computer side to obtain the interface data, so as to store the interface data corresponding to the user identifier and the project identifier to the server side, so that the mobile side can retrieve the interface data corresponding to the user identifier and the project identifier from the server side.
[0070] Figure 3 A schematic diagram of a method for executing the logic of accessing a pre-release environment provided by an embodiment of the present invention, see Figure 3 , the specific implementation method of executing the logic of accessing the pre-launch environment can be: by rewriting the fetch request and XMLHttpRequest, listening to the interface call, when the business code initiates an http request (such as a request to access the pre-launch environment), it is considered that the listening is successful. For example, the logic file for executing access to the pre-launch environment can be introduced in the head tag of the html in the business code, so that the computer can access the business website of the pre-launch environment through the host proxy and execute the logic of accessing the pre-launch environment. Further, it can be determined whether the user ID in the cache is consistent with the user ID corresponding to the access request. If not, the user ID and project ID set in the business code are obtained. The computer intercepts the http / https request and sends the requested link, parameters, response data and other interface data to the server to be saved under the user ID and project ID. At this time, the computer accesses the pre-launch environment, and the interface data of the http request can be reported to the specified database for storage.
[0071] Based on the above scheme, after the interface data is saved in the database of the server, the interface data can be obtained from the server by scanning the QR code based on the mobile terminal when the user ID is consistent with the cached user ID in the cache, and the static data corresponding to the display elements can be obtained by monitoring the changes of the display elements on the target page, so as to display the target page in the pre-release environment based on the interface data and the static data.
[0072] Figure 4 A schematic diagram of a method for accessing a pre-release environment provided by an embodiment of the present invention, see Figure 4, users can use mobile devices (such as mobile phones) to scan the QR code to access the URL of the pre-release environment (such as sdk.html). At this time, the logic in sdk.html begins to execute, and the parameters on the pre-release environment URL link are obtained, such as the project ID carried on the url and the user ID in the whitelist. Further, it is determined whether there is a value in the user ID. If not, it means that the user ID is empty, which means that the local cache is to be deleted, that is, the whitelist in the mobile terminal is cleared, that is, the proxy data in the local cache is deleted. At this time, the online logic is accessed. If there is a value in the user ID, the project ID and user ID are saved in the local cache. The cache can be a cookie or localStorage. If there is a value in the user ID, the server interface can be requested through the user ID and project ID, and the interface data corresponding to the user ID and project ID stored in the server database is obtained and saved in the local cache. For example, when the user ID and the cached user ID in the cache are consistent, a script tag can be dynamically generated, and the src request of the tag is a js request, requesting interface data. According to the user ID and project ID, the server database can be requested, and the server puts the http request data previously saved on the computer, that is, the interface data, in the js file and returns it to the mobile terminal, so that the mobile terminal obtains the interface data corresponding to the user ID and the project ID. When the user uses the mobile terminal to scan the QR code, the user ID contained in the QR code can be obtained as the user ID of the current logged-in user. Further, it is determined whether the user ID and the cached user ID in the cache are consistent. If not, it ends. If so, the redirection static resource path is obtained from the cache or QR code, and the redirection static resource path is stored in a temporary variable. At the same time, the file monitoring mode is turned on to monitor the changes of the display elements (DOM elements) in the target page html. When the target tag in the page is monitored as a script tag, the attributes of the script tag are set to the delayed processing attributes (such as the defer attribute) and dynamic parameters. The advantage of setting the delayed processing attribute is that the script tag can be executed last, so that the http request content of the dynamically generated script tag can be obtained when the business code is executed. Further, determine whether the src request resource path of the script tag is consistent with the redirected static resource path corresponding to the whitelist in the cache. If not, continue to monitor. If so, modify the resource path of the display element to the redirected static resource path, and then request the redirected static resource path to obtain the static resource, so as to determine the target page in the pre-release environment based on the static resource and interface data. It should be noted that the benefit of redirecting static resources is: for example, redirecting a.js in the page to b.js. The reason for redirecting static resources is that a.js introduced in the link URL html is the path of the online static resource, and if you want to access the front-end static resources of the pre-release environment, you can deploy the link URL to b.js that can be directly accessed.To modify the static resource path on the front end, you only need to modify the static resource path introduced in the corresponding HTML. There is no need to change the URL of the online HTML, thus avoiding the hidden dangers caused by modifying the online URL.
[0073] This technical solution associates the computer and mobile terminals through project identification and user identification. The computer terminal accesses the pre-release environment of the configured host and submits the pre-release data (i.e., interface data) to the server. When the mobile terminal accesses, the http / https request is intercepted and the pre-release data stored in the server is returned, solving the problem of pre-release data on the server. At the same time, by monitoring the changes in DOM elements, redirecting to the static resource path developed for this demand, obtaining the front-end JS and CSS static resources, solving the problem of difficult access to the pre-release environment of the front-end static resources.
[0074] In order to further clearly introduce the technical solution and give a specific application example, the specific implementation method of accessing the pre-launch environment can be: create a project on the system platform of the R&D project, generate the project ID and user ID of the project, and the corresponding redirection static resource path url, and generate a QR code containing the project ID, user ID and the corresponding redirection static resource path; introduce the logic of accessing the pre-launch environment in the business HTML; after the computer configures the host pre-launch environment, set the project ID and user ID of the project to be uploaded, and access the pre-launch environment; the mobile terminal scans the QR code, saves the user ID in the QR code in the local cache, and the computer terminal automatically executes the logic of accessing the pre-launch environment, and reports the interface data to the specified database for storage; after obtaining the user ID in the QR code, if the user ID is consistent with the cached user ID of the cache, both the static resource path can be redirected and the interface data of the pre-launch environment corresponding to the user ID can be obtained, and the target page of the pre-launch environment can be displayed.
[0075] The technical solution of this embodiment is to introduce a logic file for executing access to the pre-launch environment in the head tag of HTML in the business code before the server side calls the interface data corresponding to the user ID and the project ID, thereby obtaining the interface data saved on the server side when accessing the pre-launch environment based on the computer side, improving the convenience of obtaining the interface data, and further improving the effect of accessing the pre-launch environment.
[0076] The technical solution of the embodiment of the present invention creates a project on the system platform, sets the user ID and project ID of the project, and sets the corresponding redirection static resource path, and generates a QR code based on the user ID, project ID, and the corresponding redirection static resource path. When a user accesses the pre-release environment on a mobile terminal, by scanning the QR code, the page of the pre-release environment can be displayed when accessing the business link, which solves the technical problem that the user needs to manually modify the network proxy on the mobile terminal to access the pre-release environment, which has high requirements for professional knowledge and low configuration efficiency in the prior art, and improves the efficiency of accessing the pre-release environment, reduces the complexity of manual operations, and achieves the technical effect of improving user experience.
[0077] Figure 5 A schematic diagram of the structure of a device for accessing a pre-release environment provided by an embodiment of the present invention, the device comprises: a user identification acquisition module 210, a user identification determination module 220 and a target page determination module 230.
[0078] Among them, the user identification acquisition module 210 is used to obtain the user identification corresponding to the access request; wherein the access request is generated based on the scanning operation of the QR code, and the QR code includes the project identification, the user identification and the redirected static resource path; the user identification judgment module 220 is used to call the pre-generated interface data corresponding to the user identification and the project identification when the user identification is consistent with the cached user identification; and monitor the display element on the target page corresponding to the access request, so as to modify the resource path of the display element to the redirected static resource path when the target tag of the display element is consistent with the preset tag, so as to obtain the static resource corresponding to the display element; the target page determination module 230 is used to determine the target page in the pre-release environment based on the static resources of the display element and the interface data.
[0079] Optionally, the device further includes a two-dimensional code generation module, and the two-dimensional code generation module includes a data determination unit and a two-dimensional code generation unit.
[0080] A data determination unit, used to determine a project identifier corresponding to a target project, a user identifier, and a redirected static resource path of a static resource corresponding to the user identifier;
[0081] A QR code generating unit is used to generate the QR code based on a triggering operation for generating the QR code, based on the project identifier, the user tag and the redirected static resource path.
[0082] Optionally, the device also includes an interface data storage module, which is used to execute logic for accessing the pre-release environment based on the computer side to store interface data corresponding to the user identifier and the project identifier to the server side, so that the mobile side can retrieve the interface data.
[0083] Optionally, the interface data storage module includes an interface data determination unit and an interface data storage unit.
[0084] An interface data determination unit, used to obtain a user identifier and a project identifier set in the business code, and intercept corresponding interface data;
[0085] The interface data storage unit is used to send the user identification, project identification and the interface data to the server, so that the server stores the interface data in a database according to the user identification and project identification.
[0086] Optionally, the user identification acquisition module 210 is specifically configured to scan the QR code based on a mobile terminal to acquire the user identification contained in the QR code.
[0087] Optionally, the user identification determination module 220 includes a user identification determination unit and an interface data retrieving unit.
[0088] A user identification determination unit, used to determine whether a cached user identification in the cache is consistent with the user identification;
[0089] The interface data retrieving unit is used to retrieve the interface data corresponding to the user identifier and the project identifier from the database corresponding to the server.
[0090] Optionally, the user identification judgment module 220 also includes a path storage unit, which is used to store the redirected static resource path in a temporary variable, so that when the target tag is consistent with the preset tag, the resource path of the display element is modified to the redirected static resource path based on the temporary variable.
[0091] Optionally, the user identification determination module 220 further includes an attribute setting unit, and the attribute setting unit is used to set the tag attribute of the display element to a delayed processing attribute, so as to render the display element corresponding to the static resource after rendering other display elements.
[0092] The technical solution of the embodiment of the present invention obtains a user identifier corresponding to an access request, and when the user identifier is consistent with a cached user identifier, retrieves pre-generated interface data corresponding to the user identifier and the project identifier; monitors the display element on the target page corresponding to the access request, and when the target tag of the display element is consistent with a preset tag, modifies the resource path of the display element to a redirected static resource path, so as to obtain the static resource corresponding to the display element; based on the static resource and interface data of the display element, determines the target page in a pre-release environment, solves the technical problems in the prior art that users need to manually modify the network proxy on the mobile terminal, have high requirements for professional knowledge and complex configuration operations, and realizes the The QR code obtains the user ID in the QR code, and then determines whether the mobile terminal has the authority to access the pre-release environment based on the user ID. When the user ID and the cached user ID are consistent, the interface data corresponding to the user ID and the project ID are retrieved to ensure the security of access to the pre-release environment. At the same time, by monitoring the target tag of the display element on the target page, when the target tag is consistent with the preset tag, the resource path of the display element is modified to a redirected static resource path to redirect the static resource. Then, based on the static resource and the interface data, the target page in the pre-release environment is determined, so that the pre-release environment can be accessed on the mobile terminal without configuring a proxy on the mobile terminal, reducing the complexity of manual operations and achieving the technical effect of improving user experience.
[0093] The device for accessing a pre-release environment provided by the embodiment of the present invention can execute the method for accessing a pre-release environment provided by any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0094] It is worth noting that the various units and modules included in the above system are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention.
[0095] Figure 6 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 6 A block diagram of an exemplary electronic device 30 suitable for implementing exemplary embodiments of the present invention is shown. Figure 6 The electronic device 30 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0096] like Figure 6As shown, the electronic device 30 is in the form of a general computing device. The components of the electronic device 30 may include but are not limited to: one or more processors or processing units 301, a system memory 302, and a bus 303 connecting different system components (including the system memory 302 and the processing unit 301).
[0097] Bus 303 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.
[0098] The electronic device 30 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 30, including volatile and non-volatile media, removable and non-removable media.
[0099] The system memory 302 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 304 and / or cache memory 305. The electronic device 30 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 306 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 not shown, usually called a "hard drive"). Although Figure 6 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 303 via one or more data medium interfaces. The memory 302 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0100] A program / utility 308 having a set (at least one) of program modules 307 may be stored, for example, in the memory 302, such program modules 307 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 307 generally perform the functions and / or methods of the embodiments described herein.
[0101] The electronic device 30 may also communicate with one or more external devices 309 (e.g., keyboards, pointing devices, displays 310, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 30, and / or may communicate with any device that enables the electronic device 30 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed through an input / output (I / O) interface 311. Furthermore, the electronic device 30 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 312. As shown, the network adapter 312 communicates with other modules of the electronic device 30 through the bus 303. It should be understood that although Figure 6 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 30, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0102] The processing unit 301 executes various functional applications and data processing by running the programs stored in the system memory 302, for example, implementing the method for accessing the pre-release environment provided in the embodiment of the present invention.
[0103] An embodiment of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a method for accessing a pre-release environment when executed by a computer processor, and the method is applied in a mobile terminal, and the method includes:
[0104] Obtaining a user identifier corresponding to an access request; wherein the access request is generated based on a scanning operation of a QR code, wherein the QR code includes a project identifier, a user identifier, and a redirection static resource path;
[0105] When the user identifier and the cached user identifier are consistent, calling pre-generated interface data corresponding to the user identifier and the project identifier; and,
[0106] Monitoring a display element on a target page corresponding to the access request, and when a target tag of the display element is consistent with a preset tag, modifying a resource path of the display element to the redirected static resource path, so as to obtain a static resource corresponding to the display element;
[0107] Based on the static resources of the display element and the interface data, a target page in a pre-release environment is determined.
[0108] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0109] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0110] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0111] Computer program code for performing the operation of embodiments of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0112] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for accessing a pre-release environment, characterized in that: Applied in a mobile terminal, the method includes: Obtaining a user identifier corresponding to an access request; wherein the access request is generated based on a scanning operation of a QR code, wherein the QR code includes a project identifier, a user identifier, and a redirection static resource path; When the user identifier and the cached user identifier are consistent, calling pre-generated interface data corresponding to the user identifier and the project identifier; and, Monitoring a display element on a target page corresponding to the access request, and when a target tag of the display element is consistent with a preset tag, modifying a resource path of the display element to the redirected static resource path, so as to obtain a static resource corresponding to the display element; Based on the static resources of the display element and the interface data, a target page in a pre-release environment is determined.
2. The method according to claim 1, characterized in that Also includes: Determine a project identifier corresponding to the target project, a user identifier, and a redirected static resource path of a static resource corresponding to the user identifier; Based on the triggering operation for generating the QR code, the QR code is generated based on the project identifier, the user tag and the redirected static resource path.
3. The method according to claim 1, characterized in that: Before calling the pre-generated interface data corresponding to the user identifier and the project identifier, the method further includes: The logic of accessing the pre-release environment is executed based on the computer side to store the interface data corresponding to the user identifier and the project identifier to the server side, so that the mobile side can retrieve the interface data.
4. The method according to claim 3, characterized in that The computer-based logic of executing access to the pre-release environment to store the interface data corresponding to the user identifier and the project identifier to the server includes: Get the user ID and project ID set in the business code, and intercept the corresponding interface data; The user identification, project identification and the interface data are sent to the server, so that the server stores the interface data in a database according to the user identification and project identification.
5. The method according to claim 1, characterized in that The obtaining of a user identifier corresponding to the access request includes: The two-dimensional code is scanned based on a mobile terminal to obtain the user identification contained in the two-dimensional code.
6. The method according to claim 1, characterized in that When the user identifier and the cached user identifier are consistent, calling pre-generated interface data corresponding to the user identifier and the project identifier includes: Determining whether the cached user identifier in the cache is consistent with the user identifier; If so, the interface data corresponding to the user ID and the project ID are retrieved from the database corresponding to the server.
7. The method according to claim 1, characterized in that Before monitoring the display element on the target page corresponding to the access request and modifying the resource path of the display element to the redirected static resource path when the target tag of the display element is consistent with the preset tag, the method further includes: The redirected static resource path is stored in a temporary variable, so that when the target tag is consistent with the preset tag, the resource path of the display element is modified to the redirected static resource path based on the temporary variable.
8. The method according to claim 1, characterized in that Before modifying the resource path of the display element to the redirected static resource path to obtain the static resource corresponding to the display element, the method further includes: The tag attribute of the display element is set to a delayed processing attribute, so as to render the display element corresponding to the static resource after rendering other display elements.
9. A device for accessing a pre-release environment, characterized in that: Applied in a mobile terminal, the device comprises: A user identification acquisition module, used to acquire a user identification corresponding to an access request; wherein the access request is generated based on a scanning operation of a QR code, wherein the QR code includes a project identification, a user identification, and a redirection static resource path; A user identification judgment module is used to retrieve pre-generated interface data corresponding to the user identification and project identification when the user identification and the cached user identification are consistent; and Monitoring a display element on a target page corresponding to the access request, and when a target tag of the display element is consistent with a preset tag, modifying a resource path of the display element to the redirected static resource path, so as to obtain a static resource corresponding to the display element; The target page determination module is used to determine the target page in the pre-release environment based on the static resources of the display element and the interface data.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method for accessing a pre-release environment as described in any one of claims 1 to 8.
11. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the method for accessing a pre-release environment as claimed in any one of claims 1 to 8 when executed by a computer processor.
Citation Information
Cited By
Dynamic resource loading method and related device
CN120950147A
