A method, device, equipment and readable medium for accessing static demo
Patent Information
- Application Number
- CN202110840540.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-24
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-07-24
AI Technical Summary
但是这种Demo基本上都需要启动Server服务,需借助Tomcat、Node等
[0036] The memory stores computer instructions that can be run on the processor. When the instructions are executed by the processor, the steps of any of the above methods are implemented.
Smart Images

Figure CN113626063B_ABST
Abstract
Description
Technical Field
[0001] The technical field relates to the computer field, and more specifically to a method, apparatus, device and readable medium for accessing a static demo. Background Art
[0002] At present, basically all web applications will implement a demo based on the web application after they are released online in order to facilitate the demonstration of product functions. The demo generally has the following characteristics: 1. It contains all product functions, 2. Anyone can access it, 3. No need to interact with the database, all page data is built-in data, 4. It can be carried and copied. However, this kind of demo basically needs to start the server service, which requires the help of Tomcat, Node, etc. At this time, more issues need to be considered, such as whether there is a deployment environment for the demonstration, whether the deployed environment is compatible with the current service, and the person demonstrating needs to master some relevant professional knowledge. The demo needs to have a built-in Tomcat or Node installation package. Summary of the invention
[0003] In view of this, the purpose of the embodiments of the present invention is to propose a method, device, equipment and readable medium for accessing static Demo. By using the technical solution of the present invention, it is possible to achieve direct access to static Demo (referring to the sum of some static resources that can be placed in any location of any system, without starting the Server service, but can directly access the current static resource Demo through the local browser (through the local file transfer protocol) just like accessing a real Web application) without deployment, simplifying the deployment and installation package of Demo, improving ease of use, and lowering the threshold for Demo application.
[0004] Based on the above purpose, an aspect of an embodiment of the present invention provides a method for accessing a static Demo, comprising the following steps:
[0005] Intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result;
[0006] Create a data.js file in the cache folder and write the parsed input parameters and response return values into the data.js file in the preset format;
[0007] Copy the cache folder to the Demo application and modify the data request method of the Demo application;
[0008] Modify the cookie reading method of the Demo application to enable the browser to access the Demo application.
[0009] According to an embodiment of the present invention, intercepting a response return value of a normally accessible web application, parsing the requested URL, and creating a cache folder based on the parsing result includes:
[0010] Parse the requested URL and split the URL path to get several names;
[0011] Create a cache folder and create a folder corresponding to the first name in the cache folder according to the order of the names obtained after the splitting;
[0012] Create a folder corresponding to the second name within the folder corresponding to the first name;
[0013] A folder corresponding to the third name is created within the folder corresponding to the second name until all folders corresponding to the names are created.
[0014] According to one embodiment of the present invention, creating a data.js file in a cache folder includes:
[0015] Create data.js file in the folder corresponding to the last name.
[0016] According to one embodiment of the present invention, writing the parsed input parameters and response return values into the data.js file in a preset format includes:
[0017] Write the input parameters and response return values obtained by parsing the URL into the data.js file in the format of window[url]={url input parameters: response return value}.
[0018] According to an embodiment of the present invention, copying the cache folder to the Demo application and modifying the data request method of the Demo application includes:
[0019] Copy the cache folder to the Demo application;
[0020] Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method;
[0021] Bind the onload event to the script object, and obtain the data in the data.js file according to the requested URL in the event;
[0022] Remove the newly added script object and the global variables generated by running the data.js file.
[0023] According to an embodiment of the present invention, parsing a relative path according to the requested URL and the data file location corresponding to the request, and replacing the http data request mode with the script request mode includes:
[0024] Create a script object and set the src path of the script object to the relative path of the data source;
[0025] Add the script object to the header tag.
[0026] According to an embodiment of the present invention, modifying the cookie reading method of the Demo application so that the browser can access the Demo application includes:
[0027] Change the procedures for setting and reading cookies into global variables;
[0028] Use a browser to open the static resource entry file index.html to access the static Demo.
[0029] Another aspect of an embodiment of the present invention further provides a device for accessing a static demo, the device comprising:
[0030] A parsing module, the parsing module is configured to intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result;
[0031] Create a module. The module configuration is to create a data.js file in the cache folder and write the parsed input parameters and response return values into the data.js file in the preset format.
[0032] Modify the module, modify the module configuration to copy the cache folder to the Demo application, and modify the data request method of the Demo application;
[0033] The transformation module is configured to transform the cookie reading method of the Demo application so that the browser can access the Demo application.
[0034] Another aspect of the embodiments of the present invention further provides a computer device, the computer device comprising:
[0035] at least one processor; and
[0036] The memory stores computer instructions executable on the processor, and the instructions implement the steps of any one of the above methods when executed by the processor.
[0037] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above methods are implemented.
[0038] The present invention has the following beneficial technical effects: the method for accessing a static Demo provided by an embodiment of the present invention intercepts the response return value of a normally accessible web application, parses the requested URL and creates a cache folder based on the parsing result; creates a data.js file in the cache folder, and writes the parsed input parameters and response return value into the data.js file in a preset format; copies the cache folder to a Demo application, and transforms the data request method of the Demo application; and transforms the Cookie reading method of the Demo application so that the browser can access the Demo application. The technical solution can achieve direct access to the static Demo with a browser without deployment, simplifies the deployment and installation package of the Demo, improves ease of use, and lowers the threshold of the Demo application. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.
[0040] Figure 1 is a schematic flow chart of a method for accessing a static Demo according to an embodiment of the present invention;
[0041] Figure 2 A schematic diagram of a device for accessing a static demo according to an embodiment of the present invention;
[0042] Figure 3 is a schematic diagram of a computer device according to an embodiment of the present invention;
[0043] Figure 4 FIG. 1 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0045] Based on the above purpose, a first aspect of an embodiment of the present invention provides an embodiment of a method for accessing a static Demo. Figure 1 Shown is a schematic flow chart of the method.
[0046] like Figure 1 As shown in , the method may include the following steps:
[0047] S1 intercepts the response return value of the normally accessible web application, parses the requested URL and creates a cache folder based on the parsing result.
[0048] Prepare a set of deployed Web applications (hereinafter referred to as A applications) that can be accessed normally. Copy the static resource files of A applications to other locations. The directory structure should be consistent with that of A applications. Please note that since Demo does not need to be deployed and has no server, all requests must be changed to relative path requests. For example, A applications are packaged using Webpack. Check the Webpack configuration items and change the publicPath attribute to a relative path, such as changing ' / ' to '. / '. When a user accesses A applications, the browser sends a request to the server. The server intercepts the response request before returning data, obtains the return value, parses the requested URL, splits the URL path, creates a cache folder (top-level directory mockData folder) to save cache data, and creates folders under the mockData folder in the order of splitting. The folder names are the same as the URL split paths. For example, if the requested URL path is / base / user / info? userId=XXX, then create a base folder under the mockData folder, a user folder under the base folder, and an info folder under the user folder.
[0049] S2 creates the data.js file in the cache folder and writes the parsed input parameters and response return values into the data.js file in the preset format.
[0050] Create a data.js file in the info folder. This file is used to save cached data. When this request reads and writes the data.js file, in order to prevent multiple asynchronous requests from reading and writing the data.js file at the same time, causing data confusion and abnormality, add a read-write lock to the data.js file. When other asynchronous requests arrive and require reading and writing the current data.js file, a loop waits until the reading and writing of the data.js file is completed. The input parameters of the url are parsed, and the written content of the data.js file is organized in combination with the response return value. The writing format is window[url]={url input parameter: response return value}. For example, the requested url path is / base / user / info? userId=XXX, and the return value is
[0051]
[0052]
[0053] After writing this time, release the data.js read-write lock. If the URL of other subsequent requests is different from the URL of the above request, repeat the above steps. If the requested URL is the same and the URL input parameter is also the same, overwrite the written content. If the requested URL is the same and the URL input parameter is different, read the data.js file content and merge it with the current content. For example:
[0054] The requested URL is / base / user / info?userId=YYY, then the content written is:
[0055]
[0056] S3 copies the cache folder to the Demo application and transforms the data request method of the Demo application.
[0057] Then copy the mockData folder to the Demo application, parse the relative path according to the requested url and the location of the data file corresponding to the request, replace the http data request methods such as Ajax, Axios, Fetch with script requests. The replacement method is to create a script object, set the src path of the script object to the relative path of the data source, and add the script object to the header tag, for example, / base / user / info? userId=XXX request is replaced with <script src=”. base user info data.js”>< / script> , then bind the onload event to the script object, and in the event, get the data in data.js according to the request URL. For example, get the data of / base / user / info?userId=XXX as window[' / base / user / info']['userId=XXX']. After returning the acquired data, remove the newly added script object and the global variables generated by running data.js.
[0058] S4 modifies the cookie reading method of the Demo application to enable the browser to access the Demo application.
[0059] Since the Demo application is not deployed and has no server, the Cookie mechanism cannot be used. The program for setting and reading Cookies needs to be changed to a global variable form. For example, change setCookie("userId","XXX") to window.cookieObj = {"userId":"XXX"}, and change getCookie("userId") to window.cookieObj['userId']. Finally, double-click the static resource entry file index.html and use a browser to open this static resource to access the static Demo.
[0060] Through the technical solution of the present invention, it is possible to directly access static Demos with a browser without deployment, which simplifies the deployment and installation package of Demos, improves usability, and lowers the threshold for Demo applications.
[0061] In a preferred embodiment of the present invention, intercepting the response return value of a normally accessible web application, parsing the requested URL and creating a cache folder based on the parsing result includes:
[0062] Parse the requested URL and split the URL path to get several names;
[0063] Create a cache folder and create a folder corresponding to the first name in the cache folder according to the order of the names obtained after the splitting;
[0064] Create a folder corresponding to the second name within the folder corresponding to the first name;
[0065] Create a folder corresponding to the third name in the folder corresponding to the second name until all folders corresponding to the names are created. For example: the requested URL path is / base / user / info? userId=XXX, then create a base folder in the cache folder, create a user folder in the base folder, and create an info folder in the user folder.
[0066] In a preferred embodiment of the present invention, creating a data.js file in a cache folder includes:
[0067] Create a data.js file in the folder corresponding to the last name. As in the above example, create a data.js file in the info folder to save cache data.
[0068] In a preferred embodiment of the present invention, writing the parsed input parameters and response return values into the data.js file in a preset format includes:
[0069] Write the input parameters and response return values obtained by parsing the URL into the data.js file in the format of window[url]={url input parameters: response return value}. For example, if the requested URL path is / base / user / info? userId=XXX, the return value is
[0070]
[0071] In a preferred embodiment of the present invention, copying the cache folder to the Demo application and modifying the data request method of the Demo application includes:
[0072] Copy the cache folder to the Demo application;
[0073] Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method;
[0074] Bind the onload event to the script object, and obtain the data in the data.js file according to the requested URL in the event;
[0075] Remove the newly added script object and the global variables generated by running the data.js file.
[0076] In a preferred embodiment of the present invention, the relative path is parsed according to the requested URL and the data file location corresponding to the request, and the http data request mode is replaced with the script request mode, including:
[0077] Create a script object and set the src path of the script object to the relative path of the data source;
[0078] Add the script object to the header tag.
[0079] In a preferred embodiment of the present invention, modifying the cookie reading method of the Demo application so that the browser can access the Demo application includes:
[0080] Change the procedures for setting and reading cookies into global variables;
[0081] Use a browser to open the static resource entry file index.html to access the static Demo.
[0082] Through the technical solution of the present invention, it is possible to directly access static Demos with a browser without deployment, which simplifies the deployment and installation package of Demos, improves usability, and lowers the threshold for Demo applications.
[0083] It should be noted that a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be implemented by instructing the relevant hardware through a computer program, and the above-mentioned program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. The above-mentioned computer program embodiment can achieve the same or similar effect as any of the above-mentioned method embodiments corresponding thereto.
[0084] In addition, the method disclosed in the embodiment of the present invention can also be implemented as a computer program executed by a CPU, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the CPU, the above functions defined in the method disclosed in the embodiment of the present invention are performed.
[0085] Based on the above purpose, a second aspect of the embodiment of the present invention provides a device for accessing a static demo, such as Figure 2 As shown, the device 200 includes:
[0086] A parsing module, the parsing module is configured to intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result;
[0087] Create a module. The module configuration is to create a data.js file in the cache folder and write the parsed input parameters and response return values into the data.js file in the preset format.
[0088] Modify the module, modify the module configuration to copy the cache folder to the Demo application, and modify the data request method of the Demo application;
[0089] The transformation module is configured to transform the cookie reading method of the Demo application so that the browser can access the Demo application.
[0090] In a preferred embodiment of the present invention, the parsing module is further configured to:
[0091] Parse the requested URL and split the URL path to get several names;
[0092] Create a cache folder and create a folder corresponding to the first name in the cache folder according to the order of the names obtained after the splitting;
[0093] Create a folder corresponding to the second name within the folder corresponding to the first name;
[0094] A folder corresponding to the third name is created within the folder corresponding to the second name until all folders corresponding to the names are created.
[0095] In a preferred embodiment of the present invention, the creation module is further configured to:
[0096] Create data.js file in the folder corresponding to the last name.
[0097] In a preferred embodiment of the present invention, the creation module is further configured to:
[0098] Write the input parameters and response return values obtained by parsing the URL into the data.js file in the format of window[url]={url input parameters: response return value}.
[0099] In a preferred embodiment of the present invention, the modification module is further configured to:
[0100] Copy the cache folder to the Demo application;
[0101] Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method;
[0102] Bind the onload event to the script object, and obtain the data in the data.js file according to the requested URL in the event;
[0103] Remove the newly added script object and the global variables generated by running the data.js file.
[0104] In a preferred embodiment of the present invention, the modification module is further configured to:
[0105] Create a script object and set the src path of the script object to the relative path of the data source;
[0106] Add the script object to the header tag.
[0107] In a preferred embodiment of the present invention, the transformation module is further configured as:
[0108] Change the procedures for setting and reading cookies into global variables;
[0109] Use a browser to open the static resource entry file index.html to access the static Demo.
[0110] Based on the above purpose, a third aspect of an embodiment of the present invention provides a computer device. Figure 3FIG. 2 is a schematic diagram of an embodiment of a computer device provided by the present invention. Figure 3 As shown, the embodiment of the present invention includes the following apparatus: at least one processor S21; and a memory S22, the memory S22 stores computer instructions S23 that can be run on the processor, and when the instructions are executed by the processor, the following method is implemented:
[0111] Intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result;
[0112] Create a data.js file in the cache folder and write the parsed input parameters and response return values into the data.js file in the preset format;
[0113] Copy the cache folder to the Demo application and modify the data request method of the Demo application;
[0114] Modify the cookie reading method of the Demo application to enable the browser to access the Demo application.
[0115] In a preferred embodiment of the present invention, intercepting the response return value of a normally accessible web application, parsing the requested URL and creating a cache folder based on the parsing result includes:
[0116] Parse the requested URL and split the URL path to get several names;
[0117] Create a cache folder and create a folder corresponding to the first name in the cache folder according to the order of the names obtained after the splitting;
[0118] Create a folder corresponding to the second name within the folder corresponding to the first name;
[0119] A folder corresponding to the third name is created within the folder corresponding to the second name until all folders corresponding to the names are created.
[0120] In a preferred embodiment of the present invention, creating a data.js file in a cache folder includes:
[0121] Create data.js file in the folder corresponding to the last name.
[0122] In a preferred embodiment of the present invention, writing the parsed input parameters and response return values into the data.js file in a preset format includes:
[0123] Write the input parameters and response return values obtained by parsing the URL into the data.js file in the format of window[url]={url input parameters: response return value}.
[0124] In a preferred embodiment of the present invention, copying the cache folder to the Demo application and modifying the data request method of the Demo application includes:
[0125] Copy the cache folder to the Demo application;
[0126] Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method;
[0127] Bind the onload event to the script object, and obtain the data in the data.js file according to the requested URL in the event;
[0128] Remove the newly added script object and the global variables generated by running the data.js file.
[0129] In a preferred embodiment of the present invention, the relative path is parsed according to the requested URL and the data file location corresponding to the request, and the http data request mode is replaced with the script request mode, including:
[0130] Create a script object and set the src path of the script object to the relative path of the data source;
[0131] Add the script object to the header tag.
[0132] In a preferred embodiment of the present invention, modifying the cookie reading method of the Demo application so that the browser can access the Demo application includes:
[0133] Change the procedures for setting and reading cookies into global variables;
[0134] Use a browser to open the static resource entry file index.html to access the static Demo.
[0135] Based on the above purpose, a fourth aspect of an embodiment of the present invention provides a computer-readable storage medium. Figure 4 FIG. 2 is a schematic diagram of an embodiment of a computer-readable storage medium provided by the present invention. Figure 4 As shown, the computer readable storage medium S31 stores a computer program S32 that performs the following method when executed by the processor:
[0136] Intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result;
[0137] Create a data.js file in the cache folder and write the parsed input parameters and response return values into the data.js file in the preset format;
[0138] Copy the cache folder to the Demo application and modify the data request method of the Demo application;
[0139] Modify the cookie reading method of the Demo application to enable the browser to access the Demo application.
[0140] In a preferred embodiment of the present invention, intercepting the response return value of a normally accessible web application, parsing the requested URL and creating a cache folder based on the parsing result includes:
[0141] Parse the requested URL and split the URL path to get several names;
[0142] Create a cache folder and create a folder corresponding to the first name in the cache folder according to the order of the names obtained after the splitting;
[0143] Create a folder corresponding to the second name within the folder corresponding to the first name;
[0144] A folder corresponding to the third name is created within the folder corresponding to the second name until all folders corresponding to the names are created.
[0145] In a preferred embodiment of the present invention, creating a data.js file in a cache folder includes:
[0146] Create data.js file in the folder corresponding to the last name.
[0147] In a preferred embodiment of the present invention, writing the parsed input parameters and response return values into the data.js file in a preset format includes:
[0148] Write the input parameters and response return values obtained by parsing the URL into the data.js file in the format of window[url]={url input parameters: response return value}.
[0149] In a preferred embodiment of the present invention, copying the cache folder to the Demo application and modifying the data request method of the Demo application includes:
[0150] Copy the cache folder to the Demo application;
[0151] Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method;
[0152] Bind the onload event to the script object, and obtain the data in the data.js file according to the requested URL in the event;
[0153] Remove the newly added script object and the global variables generated by running the data.js file.
[0154] In a preferred embodiment of the present invention, the relative path is parsed according to the requested URL and the data file location corresponding to the request, and the http data request mode is replaced with the script request mode, including:
[0155] Create a script object and set the src path of the script object to the relative path of the data source;
[0156] Add the script object to the header tag.
[0157] In a preferred embodiment of the present invention, modifying the cookie reading method of the Demo application so that the browser can access the Demo application includes:
[0158] Change the procedures for setting and reading cookies into global variables;
[0159] Use a browser to open the static resource entry file index.html to access the static Demo.
[0160] In addition, the method disclosed in the embodiment of the present invention can also be implemented as a computer program executed by a processor, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the above functions defined in the method disclosed in the embodiment of the present invention are performed.
[0161] In addition, the above method steps and system units may also be implemented using a controller and a computer-readable storage medium for storing a computer program that enables the controller to implement the above steps or unit functions.
[0162] It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.
[0163] In one or more exemplary designs, the function can be implemented in hardware, software, firmware or any combination thereof. If implemented in software, the function can be stored on a computer-readable medium or transmitted by a computer-readable medium as one or more instructions or codes. Computer-readable media include computer storage media and communication media, and the communication media include any media that helps to transfer a computer program from one location to another. The storage medium can be any available medium that can be accessed by a general or special computer. As an example and not limiting, the computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage devices, disk storage devices or other magnetic storage devices, or any other medium that can be used to carry or store the required program code in the form of an instruction or data structure and can be accessed by a general or special computer or a general or special processor. In addition, any connection can be appropriately referred to as a computer-readable medium. For example, if a coaxial cable, optical fiber cable, twisted pair, digital subscriber line (DSL) or wireless technologies such as infrared, radio and microwaves are used to send software from a website, server or other remote source, the above-mentioned coaxial cable, optical fiber cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwaves are all included in the definition of the medium. As used herein, disk and disc include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk, Blu-ray disc, wherein disks usually reproduce data magnetically, while optical discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0164] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope disclosed in the embodiments of the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.
[0165] It should be understood that, as used herein, the singular forms "a", "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations including one or more of the associated listed items.
[0166] The serial numbers of the embodiments disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0167] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0168] A person skilled in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the concept of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the embodiments of the present invention as above, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.
Claims
1. A method for accessing a static demo, characterized in that: The following steps are involved: Intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result; Create a data.js file in the cache folder, and write the parsed input parameters and the response return value into the data.js file in a preset format; Copy the cache folder to the Demo application, and modify the data request method of the Demo application; Modify the cookie reading method of the Demo application so that the browser can access the Demo application; Among them, modifying the cookie reading method of the Demo application so that the browser can access the Demo application includes: changing the program for setting and reading cookies into a global variable form; using the browser to open the static resource entry file index.html to achieve access to the static Demo.
2. The method according to claim 1, characterized in that: Intercept the response return value of the normally accessible web application, parse the requested URL and create a cache folder based on the parsing result, including: Parse the requested URL and split the URL path to get several names; Create the cache folder and create a folder corresponding to the first name in the cache folder according to the order of the names obtained after the splitting; Creating a folder corresponding to the second name within the folder corresponding to the first name; A folder corresponding to a third name is created within the folder corresponding to the second name until folders corresponding to all names are created.
3. The method according to claim 2, characterized in that Creating a data.js file in the cache folder includes: Create data.js file in the folder corresponding to the last name.
4. The method according to claim 1, characterized in that: Writing the parsed input parameters and the response return value into the data.js file in a preset format includes: The input parameters obtained by parsing the url and the response return value are written into the data.js file in the format of window[url]={url input parameters: response return value}.
5. The method according to claim 1, characterized in that Copying the cache folder to the Demo application and modifying the data request method of the Demo application includes: Copy the cache folder to the Demo application; Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method; Bind the onload event to the script object, and obtain the data in the data.js file according to the requested URL in the event; Remove the newly added script object and the global variables generated by running the data.js file.
6. The method according to claim 5, characterized in that Parse the relative path based on the requested URL and the data file location corresponding to the request, and replace the http data request method with the script request method, including: Create a script object and set the src path of the script object to the relative path of the data source; Add the script object to the header tag.
7. A device for accessing a static demo, characterized in that: The device comprises: A parsing module, wherein the parsing module is configured to intercept a response return value of a normally accessible web application, parse the requested URL, and create a cache folder based on the parsing result; A creation module is configured to create a data.js file in the cache folder, and write the parsed input parameters and the response return value into the data.js file according to a preset format; A modification module, wherein the modification module is configured to copy the cache folder to a Demo application and modify a data request method of the Demo application; A transformation module, wherein the transformation module is configured to transform a cookie reading method of a Demo application so that a browser can access the Demo application; The transformation module is further configured to change the program for setting and reading Cookies into a global variable form; and use a browser to open the static resource entry file index.html to access the static Demo.
8. A computer device, characterized in that: include: at least one processor; as well as A memory storing computer instructions executable on the processor, wherein the instructions, when executed by the processor, implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method, system, device and terminal for providing webpages
CN102360380A
Implementation method, device and system for static storage of dynamic webpage
CN103428243A
