Page switching method, apparatus, device, and storage medium
By injecting external scripts and style data into the page file, the problem of pages from different technology stacks being unable to coexist was solved, enabling page switching across technology stacks and improving the maintainability and readability of the application.
Patent Information
- Application Number
- CN202210353396.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-02
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2042-04-02
AI Technical Summary
Because of the different front-end technology stacks, pages based on different technology stacks cannot run simultaneously in the same project, resulting in high application complexity and difficulty in maintenance.
By obtaining the page file corresponding to the page switching request, injecting data from external script files and external style files into the page file, generating the target page, and switching the current page to the target page, cross-technology stack page switching is achieved.
This allows multiple pages based on different technology stacks to run simultaneously within a single project, improving the maintainability and readability of the application.
Smart Images

Figure CN114741158B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the field of microservices technology, specifically to a page switching method, apparatus, device, and storage medium. Background Technology
[0002] The front-end technology ecosystem encompasses many technology stacks, such as Vue, a progressive framework for building user interfaces; React, a scripting language library for building user interfaces; Anglar, a front-end framework for building user interfaces; and jQuery, a JavaScript scripting language framework, etc. Pages based on different technology stacks cannot be applied to the same project. Summary of the Invention
[0003] This disclosure provides a page switching method, apparatus, device, storage medium, and program product.
[0004] According to one aspect of this disclosure, a page switching method is provided, comprising: in response to receiving a page switching request, obtaining a page file corresponding to the page switching request; determining an external script file and an external style file referenced in the page file; injecting script data in the external script file and style data in the external style file into the page file to obtain a target page; and switching the current page to the target page.
[0005] According to another aspect of this disclosure, a page switching device is provided, comprising: an acquisition module, configured to acquire a page file corresponding to the page switching request in response to receiving a page switching request for the current page; a determination module, configured to determine an external script file and an external style file referenced in the page file; an injection module, configured to inject script data from the external script file and style data from the external style file into the page file to obtain a target page; and a switching module, configured to switch the current page to the target page.
[0006] Another aspect of this disclosure provides an electronic device including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods shown in embodiments of this disclosure.
[0007] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to perform the methods shown in the embodiments of the present disclosure.
[0008] According to another aspect of the present disclosure, a computer program product is provided, including a computer program / instructions, characterized in that, when the computer program / instructions are executed by a processor, they implement the steps of the method shown in the embodiments of the present disclosure.
[0009] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0010] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0011] Figure 1 This is a schematic diagram of an application scenario for page switching according to an embodiment of the present disclosure;
[0012] Figure 2 A flowchart illustrating a page switching method according to an embodiment of the present disclosure is shown schematically;
[0013] Figure 3 A flowchart illustrating a method for obtaining a page file corresponding to a page switching request according to an embodiment of the present disclosure is shown schematically.
[0014] Figure 4 A flowchart illustrating a method for obtaining a page file corresponding to a page switching request according to an embodiment of the present disclosure is shown schematically.
[0015] Figure 5 The flowchart illustrating a method for injecting script data and style data into a page file according to an embodiment of the present disclosure is shown schematically.
[0016] Figure 6 The flowchart illustrating a method for injecting script data and style data into a page file according to an embodiment of the present disclosure is shown schematically.
[0017] Figure 7A A flowchart illustrating page switching according to another embodiment of the present disclosure is shown schematically;
[0018] Figure 7B A schematic diagram illustrating page switching according to another embodiment of the present disclosure is shown.
[0019] Figure 8 A block diagram of a page switching device according to an embodiment of the present disclosure is shown schematically;
[0020] Figure 9 A block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is illustrated schematically. Detailed Implementation
[0021] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0022] The following will combine Figure 1 The application scenarios for page switching provided in this disclosure are described.
[0023] Figure 1 This is a schematic diagram illustrating an application scenario for page switching according to an embodiment of this disclosure. It should be noted that... Figure 1 The examples shown are merely examples of application scenarios that can be applied to the embodiments of this disclosure, in order to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments or scenarios.
[0024] like Figure 1 As shown, application scenario 100 includes terminal device 101, servers 102 and 103, and network 104. Network 104 serves as the medium for providing a communication link between terminal device 101 and servers 102 and 103. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0025] Users can use terminal device 101 to interact with servers 102 and 103 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal device 101, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (for example only).
[0026] Terminal device 101 can be various electronic devices with a display screen and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0027] Servers 102 and 103 can be servers that provide various services, such as backend management servers that support websites or applications accessed by users through terminal device 101. The backend management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information, or data obtained or generated based on user requests) to the terminal device.
[0028] Servers 102 and 103 can be cloud servers, also known as cloud computing servers or cloud hosts. They are a host product within the cloud computing service system, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server) services, such as high management difficulty and weak business scalability. Servers 102 and 103 can also be servers for distributed systems or servers integrated with blockchain technology.
[0029] According to embodiments of this disclosure, servers 102 and 103 can provide support for different websites or applications, respectively. The websites or applications supported by servers 102 and 103 can be based on different technology stacks.
[0030] In related technologies, due to differences in technology stacks, servers 102 and 103 require different runtime environments for the websites or applications they support, thus making it impossible for them to run in the same project. This project could include, for example, an application project, a website project, etc.
[0031] According to embodiments of this disclosure, when a user needs to switch to a page based on a different technology stack, they can initiate a page switching request for the current page on the terminal device 101. The terminal device 101 can obtain the page file corresponding to the page switching request, inject the script data and style data referenced in the page file into the page file, and obtain the target page. The script data can be used to change the content, attributes, styles, and elements of the page file. The style data can be used to set the style of the page file. Then, the current page is converted into the target page. The target page can run without relying on a specific runtime environment, thus enabling the simultaneous running of multiple pages based on different technology stacks within a single project. Furthermore, the page switching method according to embodiments of this disclosure can also help teams achieve gradual migration of technology stacks.
[0032] Furthermore, during application development, multiple sub-applications maintained independently by different teams may be integrated into a unified main application. These sub-applications are developed and deployed independently, completely decoupled from each other. As teams change, the application's complexity increases, causing it to become a monolithic application that is difficult to maintain. Therefore, a page switching method according to embodiments of this disclosure can be used to switch from the main application's page to the sub-application's page, thereby improving the maintainability and readability of the monolithic application.
[0033] It should be noted that the page switching method provided in this embodiment can generally be executed by the terminal device 101. Correspondingly, the page switching device provided in this embodiment can generally be installed in the terminal device 101. The page switching method provided in this embodiment can also be executed by other devices different from the terminal device 101 that are capable of communicating with the terminal device 101 and / or the servers 102 and 103. Correspondingly, the page switching device provided in this embodiment can also be installed in other devices different from the terminal device 101 that are capable of communicating with the terminal device 101 and / or the servers 102 and 103.
[0034] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0035] In the technical solution disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of user personal information comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and there is no violation of public order and good morals.
[0036] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.
[0037] The following will combine Figure 2 The page switching method provided in this disclosure is described.
[0038] Figure 2 A flowchart illustrating a page switching method according to an embodiment of the present disclosure is shown schematically.
[0039] like Figure 2 As shown, the page switching method 200 includes operation S210, in response to receiving a page switching request for the current page, obtaining the page file corresponding to the page switching request.
[0040] Then, in operation S220, the external script files and external style files referenced in the page file are identified.
[0041] In operation S230, script data from an external script file and style data from an external style file are injected into the page file to obtain the target page.
[0042] In operation S240, switch the current page to the target page.
[0043] According to embodiments of this disclosure, a page switching request can be used to switch pages on a website or application, for example, to switch the current page to a target page. The page switching request may include a routing address, which can be used to indicate the page to be switched. The page file can be a file associated with the page to be switched. The page file may, for example, include an HTML (HyperText Markup Language) file.
[0044] According to embodiments of this disclosure, an external script file can be a script file used in a page file but located outside the page file. For example, an external script file can be used to change the content, attributes, styles, and elements of the page file. An external script file may include, for example, a JavaScript file.
[0045] External style files can be style files used in a page file but located outside the page file.
[0046] External stylesheet files can be used to style page files, for example. External stylesheet files can include, for example, CSS (Cascading Style Sheets) files.
[0047] According to embodiments of this disclosure, the current page and the page file can be obtained based on the same development technology or on different development technologies. That is, the technology stack used to develop the current page and the page file can be the same or different. The development technologies may include, for example, Vue, React, Angular, and jQuery, etc.
[0048] In related technologies, pages based on different technology stacks cannot coexist in a single project. A project can include, for example, an application project, a website project, and so on.
[0049] According to embodiments of this disclosure, pages based on different technology stacks correspond to different page files. When it is necessary to switch to a page based on another technology stack, the page file corresponding to the page switching request can be obtained, the script data and style data referenced in the page file can be injected into the page file to obtain the target page, and then the current page can be converted into the target page. This allows multiple pages based on different technology stacks to run simultaneously within a single project.
[0050] According to embodiments of this disclosure, the current page can be, for example, the page of the main application, and the page file can be, for example, the page file of a sub-application. By generating a target page based on the page file of the sub-application and switching the current page to the target page, it is possible to switch from the page of the main application to the page of the sub-application, thereby improving the maintainability and readability of the application.
[0051] The following will combine Figure 3 The method for obtaining the page file corresponding to the page switching request provided in this disclosure is described.
[0052] Figure 3 A flowchart illustrating a method for obtaining a page file corresponding to a page switching request according to an embodiment of the present disclosure is shown.
[0053] like Figure 3 As shown, the method 310 for obtaining the page file corresponding to the page switching request includes operation S311, which determines the address of the subsite corresponding to the page switching request.
[0054] According to embodiments of this disclosure, the subsite address may be, for example, the network address corresponding to the page to which the user intends to switch, and may be used to indicate the location of the page file.
[0055] According to embodiments of this disclosure, routing matching rules can be pre-set to record the correspondence between routing addresses and sub-website addresses. When a page switching request is received, it can be determined whether the routing address in the page switching request matches the routing matching rules. If the rules are matched, the corresponding sub-website address can be determined based on the routing address.
[0056] Then, in operation S312, a page retrieval request is sent to the sub-site address in order to retrieve the page file.
[0057] According to embodiments of this disclosure, for example, an HTTP (Hypertext Transfer Protocol) request can be generated based on the subsite address as a page retrieval request.
[0058] For example, in this embodiment, the page file can be obtained via an HTTP request using the GET method. While the page file can be obtained through an HTTP request, page rendering is not triggered.
[0059] The following will combine Figure 4 This disclosure describes the method for obtaining the page file corresponding to the page switching request.
[0060] Figure 4 A flowchart illustrating a method for obtaining a page file corresponding to a page switching request according to an embodiment of the present disclosure is shown.
[0061] like Figure 4 As shown, the method 420 for obtaining the page file corresponding to the page switching request includes operation S421, determining the original link tag data and the original script tag data in the page file.
[0062] According to an embodiment of the present disclosure, the original link tag data may be link tag data originally present in the page file. Herein, the link tag data may be used to link an external style file. The original script tag data may be script tag data originally present in the page file. Herein, the script tag data may be used to link an external script file. The original link tag data may include, for example, link tag data, and the original script tag data may include, for example, script tag data.
[0063] According to an embodiment of the present disclosure, for example, the string "<link" and the nearest " / >" subsequent to the "<link" may be looked up in the page file, and the data between the "<link" and the " / >" is determined as the original link tag data. For example, the string "<script" and the nearest " / >" subsequent to the "<script" may be looked up in the page file, and the data between the "<script" and the " / >" is determined as the original script tag data.
[0064] Then, in operation S422, an external script file referenced in the original script tag data and an external style file referenced in the original link tag data are acquired.
[0065] According to an embodiment of the present disclosure, for example, the src attribute in the original script tag data may be determined, wherein the src attribute is used for the name of the external script file. Then the file name of the external script file may be obtained according to the value of the src attribute, and then the external script file is acquired according to the file name.
[0066] According to an embodiment of the present disclosure, for example, the href attribute in the original link tag data may be determined, wherein the href attribute is used for specifying the location of the linked document. Then the file location of the external style file may be obtained according to the value of the href attribute, and then the external style file is acquired according to the file location.
[0067] The method for injecting script data and style data into a page file provided by the present disclosure will be described below in conjunction with Figure 5 .
[0068] Figure 5 schematically illustrates a flowchart of a method for injecting script data and style data into a page file according to an embodiment of the present disclosure.
[0069] As shown in Figure 5 , the method 530 for injecting script data and style data into a page file includes, in operation S531, determining target style tag data according to style data.
[0070] According to embodiments of this disclosure, for example, one or more style tag data can be determined as target style tag data based on style data. The style tag data can be used to set the style of a page file. The style tag data may, for example, include style tag data.
[0071] Then, in operation S532, the original link tag data in the page file is replaced with the target style tag data.
[0072] According to embodiments of this disclosure, for example, the original link tag data in the page file can be deleted, and then the target style tag data can be injected into the page file to replace the original link tag data.
[0073] According to another embodiment of this disclosure, for example, the original link tag data in the page file can be set as a comment, and then the target style tag data can be injected into the page file to replace the original link tag data.
[0074] When operating S533, the target script tag data is determined based on the script data.
[0075] According to embodiments of this disclosure, for example, one or more script tag data can be determined as target script tag data based on script data.
[0076] In operation S534, the original script tag data in the page file is replaced with the target script tag data.
[0077] According to embodiments of this disclosure, for example, the original script tag data in the page file can be deleted, and then the target script tag data can be injected into the page file to replace the original script tag data.
[0078] According to another embodiment of this disclosure, for example, the original script tag data in the page file can be set as a comment, and then the target script tag data can be injected into the page file to replace the original script tag data.
[0079] The following will combine Figure 6 The method for injecting script data and style data into a page file, as provided in this disclosure, is described.
[0080] Figure 6 The flowchart illustrating a method for injecting script data and style data into a page file according to an embodiment of the present disclosure is shown schematically.
[0081] like Figure 6 As shown, the method 640 for injecting script data and style data into the page file includes operation S641, which obtains the original runtime environment of the current page.
[0082] When operating S642, load the target page in the original runtime environment.
[0083] According to embodiments of this disclosure, the current page can be completely cleared before loading the target page.
[0084] According to embodiments of this disclosure, during the loading of a target page, the execution environment of the script data in the target page can be set to the window object in the current execution environment, and then the script data in the target page can be executed in the current execution environment.
[0085] According to embodiments of this disclosure, when a pre-defined operation is performed on the current page for the runtime environment, the corresponding operation content can be recorded. The pre-defined operation may include, for example, adding, deleting, modifying, or querying global window object properties, global listener methods, timers, etc.
[0086] Based on this, obtaining the original runtime environment of the current page can include, for example, restoring the current runtime environment according to the operation record, that is, restoring the runtime environment to the state before the operation, so as to obtain the original runtime environment.
[0087] According to other embodiments of this disclosure, it can also be determined whether image tag data exists in the page file. If image tag data is determined to exist in the page file, it can be further determined whether the image tag data contains an image relative address. Here, the image relative address refers to the file address of the referenced image relative to the page file itself. If it is determined that the image tag data in the page file contains an image relative address, the target image is obtained based on the image relative address. Then, the target image is stored locally based on the image relative address. This allows the target page to obtain the corresponding image locally and execute without relying on a specific runtime environment.
[0088] The following is for reference. Figures 7A-7B The page switching method described above will be further explained with reference to specific embodiments. Those skilled in the art will understand that the following example embodiments are only for understanding this disclosure, and this disclosure is not limited thereto.
[0089] Figure 7A A flowchart illustrating page switching according to another embodiment of this disclosure is shown schematically.
[0090] like Figure 7AAs shown, according to embodiments of this disclosure, routing matching rules for the main website can be pre-set, recording the correspondence between routing addresses and sub-website addresses. When a route switch occurs on the main website, a page switching request is received. It is then determined whether the routing address in the page switching request matches the routing matching rules. If it matches, it can be determined that the page switching request intends to switch to a page on a sub-website. The corresponding sub-website address can be determined based on the routing address, and then a page retrieval request is sent to the corresponding sub-website address.
[0091] For example, in this embodiment, the routing matching rules can be as shown in Table 1.
[0092] Routing address Subsite address xxx.com / A A.com / xxx xxx.com / B B.com / xxx
[0093] Table 1
[0094] As shown in Table 1, when the route address is determined to be xxx.com / A, a page retrieval request can be sent to the website address A.com / xxx of sub-website A. When the route address is determined to be xxx.com / B, a page retrieval request can be sent to the website address B.com / xxx of sub-website B.
[0095] According to embodiments of this disclosure, link tag data and script tag data in an HTTP file can be obtained, and then the link tag data and script tag data in the HTTP file can be set as comments to obtain a reconstructed HTTP file.
[0096] Next, we can retrieve the external style file links from all the `link` tag data, resulting in a set of external style file links. For each link in this set, we can extract the external style file referenced in the `link` tag data, obtaining all the style code content from that external style file, i.e., the style data. Additionally, we can retrieve the external script file links from all the `script` tag data, resulting in a set of external script file links. For each link in this set, we can extract the external script file referenced in the `script` tag data, obtaining all the script code content from that external script file, i.e., the script data.
[0097] Next, you can replace the `link` tags that were previously set as comments in the HTML file with `style` tags, and inject the corresponding style code into these `style` tags, thus converting external styles into inline styles. Additionally, you can replace the `script` tags that were previously set as comments in the HTML file with script code.
[0098] Next, the main website clears the content of the current page and restores the current page's runtime environment. The main website loads the HTML file of the sub-website that it has retrieved and processed. The execution context of the script files in the HTML file is set to the main website's window object, and the sub-website's script files are executed.
[0099] Figure 7B A schematic diagram illustrating page switching according to another embodiment of the present disclosure is shown.
[0100] exist Figure 7B The diagram shows that the link tag data 721 and script tag data 722 in the HTTP file 710 can be obtained, cached in a specified space, and then the link tag data 721 and script tag data 722 in the HTTP file 710 can be set as comments.
[0101] Next, we can retrieve all external style file links from the `link` tag data 721, resulting in a set of external style file links. For each link in this set, we use an HTTP request to retrieve the external style file 731 referenced by the `link` tag data 721, obtaining all the style code content (i.e., style data) of the external style file 731. The external style file 732 can be a CSS file. Additionally, we can retrieve all external script file links from the `script` tag data 721, resulting in a set of external script file links. For each link in this set, we use an HTTP request to retrieve the external script file 732 referenced by the `script` tag data 731, obtaining all the script code content (i.e., script data) of the external script file 732. The external script file 732 can be a JavaScript file. Furthermore, we retrieve the image tag data (img tag data) 723 with relative addresses from the HTML file 710, download the image (image) 733 referenced in the image tag data 723, and store it locally.
[0102] Next, by looping through HTML file 710, the `link` tag data 721, previously set as a comment in HTML file 710, can be replaced with `style` tag data, and the corresponding style code can be injected into the `style` tag data, thus converting external styles into inline styles. Because the path to the external CSS file is a relative path, converting external styles to inline styles avoids the inability to access the external CSS file. Additionally, the `script` tag data 731, previously set as a comment in HTML file 710, can be replaced with script code content. Then, the execution context of the script data can be set as needed to expose the script execution method. After the above processing, the sub-website's HTML file 740 is obtained.
[0103] Next, the main website clears the content of the current page 750, i.e., the HTML content. The main website restores the runtime environment of the current page 750, including restoring global window object properties, global listener methods, and timer CRUD operations. The main website loads the HTML file 740 from the sub-website that it has retrieved and processed. During loading, the corresponding images are read from the local machine and displayed at their respective locations in the HTML file 740. Additionally, the runtime environment of the script files in the HTML file 740 is set to the main website's window object, and the sub-website's script files are executed.
[0104] The page switching method according to embodiments of this disclosure involves obtaining a page file corresponding to a page switching request, injecting script data and style data referenced in the page file into the page file to obtain a target page, and then converting the current page into the target page. This allows multiple pages based on different technology stacks to run simultaneously within a single project. Furthermore, the page switching method according to embodiments of this disclosure can also be used to improve the maintainability and readability of applications.
[0105] The following will combine Figure 8 The page switching device provided in this disclosure will be described.
[0106] Figure 8 A block diagram of a page switching device according to an embodiment of the present disclosure is shown schematically.
[0107] like Figure 8 As shown, the page switching device 800 includes an acquisition module 810, a determination module 820, an injection module 830, and a switching module 840.
[0108] The acquisition module 810 is used to obtain the page file corresponding to the page switching request in response to receiving a page switching request for the current page.
[0109] Module 820 is used to determine the external script files and external style files referenced in the page file.
[0110] The injection module 830 is used to inject script data from an external script file and style data from an external style file into the page file to obtain the target page.
[0111] Switching module 840 is used to switch the current page to the target page.
[0112] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0113] Figure 9 A block diagram of an example electronic device 900 that can be used to implement embodiments of the present disclosure is illustrated schematically. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0114] like Figure 9 As shown, device 900 includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 902 or a computer program loaded from storage unit 908 into random access memory (RAM) 903. RAM 903 may also store various programs and data required for the operation of device 900. The computing unit 901, ROM 902, and RAM 903 are interconnected via bus 904. Input / output (I / O) interface 905 is also connected to bus 904.
[0115] Multiple components in device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, etc.; output unit 907, such as various types of monitors, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0116] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above, such as page switching methods. For example, in some embodiments, the page switching method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by the computing unit 901, one or more steps of the page switching method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform page switching methods by any other suitable means (e.g., by means of firmware).
[0117] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0118] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0119] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0120] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0121] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0122] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.
[0123] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0124] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A page switching method, comprising: In response to receiving a page switching request for the current page, obtain the page file corresponding to the page switching request; The current page and the page file are different pages obtained from the same project based on different development technologies; Identify the external script files and external style files referenced in the page file; The script data from the external script file and the style data from the external style file are injected into the page file to obtain the target page; The script data is used to modify the page file, and the style data is used to set the style of the page file; as well as Switch the current page to the target page; The step of injecting script data from the external script file and style data from the external style file into the page file to obtain the target page includes: determining target style tag data based on the style data; replacing the original link tag data in the page file with the target style tag data; determining target script tag data based on the script data; and replacing the original script tag data in the page file with the target script tag data. Switching the current page to the target page includes: clearing the current page and obtaining the original runtime environment of the current page; loading the target page in the original runtime environment; The method further includes: recording the operation records received by the current page for the runtime environment; wherein, obtaining the original runtime environment of the current page includes: performing a restoration operation on the current runtime environment based on the operation records to obtain the original runtime environment; The method further includes: if it is determined that the image tag data in the page file contains an image relative address, obtaining the target image according to the image relative address; and storing the target image locally according to the image relative address.
2. The method according to claim 1, wherein, The step of obtaining the page file corresponding to the page switching request includes: Determine the subsite address corresponding to the page switching request; and Send a page retrieval request to the sub-website address in order to retrieve the page file.
3. The method according to claim 2, further comprising: Based on the sub-website address, a Hypertext Transfer Protocol request is generated as the page retrieval request.
4. The method according to claim 1, wherein, The determination of the external script files and external style files referenced in the page file includes: Determine the original link tag data and the original script tag data in the page file; and Obtain the external script files referenced in the original script tag data and the external style files referenced in the original link tag data.
5. A page switching device, comprising: The acquisition module is used to acquire the page file corresponding to the page switching request in response to receiving a page switching request for the current page. The current page and the page file are different pages obtained from the same project based on different development technologies; The determination module is used to determine the external script files and external style files referenced in the page file; An injection module is used to inject script data from the external script file and style data from the external style file into the page file to obtain the target page; The script data is used to modify the page file, and the style data is used to set the style of the page file; as well as A switching module is used to switch the current page to the target page; The injection module is configured to: determine target style tag data based on the style data; replace the original link tag data in the page file with the target style tag data; determine target script tag data based on the script data; and replace the original script tag data in the page file with the target script tag data. The switching module is used to clear the current page and obtain the original running environment of the current page; and load the target page in the original running environment. The switching module is further configured to: record the operation records received by the current page for the operating environment; the switching module is configured to: perform a restoration operation on the current operating environment according to the operation records to obtain the original operating environment; The injection module is further configured to: if it is determined that the image tag data in the page file contains an image relative address, obtain the target image according to the image relative address; and store the target image locally according to the image relative address.
6. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.
7. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-4.
8. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method described in any one of claims 1-4.
Citation Information
Patent Citations
Application page generation system and method
CN112073511A
Method for improving webpage screenshot definition based on WEB technology
CN112784202A
Page processing method, storage medium and equipment
CN113076501A
