Method and device for accessing single page application
By analyzing and converting the search engine specification address to the single-page application code specification address, the development complexity and maintenance problems of single-page application access to the search engine are solved, and SEO optimization of single-page applications and accurate access without perception of users are achieved.
Patent Information
- Application Number
- CN202310820842.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-05
- Publication Date
- 2025-01-07
AI Technical Summary
When the prior art uses a single page application to search engines, it is complex to develop and difficult to maintain, and it is difficult to achieve access addresses that comply with SEO rules at low cost, resulting in users being unable to access pages through search engines accurately.
By parsing the search engine specification address in the request for access to the page, convert it into the code specification address of a single page application, and display the original address in the target page, using preset conversion rules (such as domain name and path mapping relationship) to achieve address conversion and Render.
It realizes fast, flexible and efficient search engine optimization for single-page applications, reduces development complexity, and ensures page access accuracy and SEO compatibility without users' perception.
Smart Images

Figure CN119271910A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of front-end technology, and in particular to a method and device for accessing a single-page application. Background Art
[0002] Search engine optimization (SEO) is a technology that analyzes the ranking rules of search engines to improve the natural ranking of websites in relevant search engines. By optimizing the content of the web page, its search engine ranking can be improved without affecting the user experience. For single-page applications that do not take SEO rules into account during project development, the existing technology generally reconstructs the single-page application or customizes each page in the single-page application so that it can be accessed at the access address of the SEO rules.
[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:
[0004] Regardless of the reconstruction and development of a single-page application or the customized development of each page, the development work is complex and requires a large amount of development resources. In addition, reconstruction and development are more difficult to maintain later. Therefore, how to connect a single-page application that does not meet SEO rules to the search engine with the least development cost, so that users can accurately access the page through the access address that meets SEO rules, has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for accessing a single-page application. To achieve the above object, according to one aspect of an embodiment of the present invention, a method for accessing a single-page application is provided, comprising:
[0006] In response to a page access request of a single page application, a first access address that complies with a search engine specification is parsed from the page access request;
[0007] Sending the first access address to a server, and receiving a page file returned by the server in response to the first access address;
[0008] According to a preset conversion rule, the first access address is converted into a second access address that complies with the code specification of the single-page application, and based on the second access address and the page file, the target page corresponding to the page access request is rendered, and the first access address is displayed in the address bar of the target page.
[0009] Optionally, the page file includes the preset conversion rule; before converting the first access address into a second access address that complies with the code specification of the single-page application according to the preset conversion rule, the method further includes: parsing the preset conversion rule from the page file.
[0010] Optionally, the preset conversion rules include: a domain name mapping relationship and a path mapping relationship; the first access address includes a first access domain name, a first access path and a first query parameter; according to the preset conversion rules, the first access address is converted into a second access address that complies with the code specifications of the single-page application, including: determining a second access domain name corresponding to the first access domain name according to the domain name mapping relationship, and converting the first access domain name in the first access address into the second access domain name; determining a second access path that complies with the code specifications of the single-page application corresponding to the first access path according to the path mapping relationship, converting the first access path in the first access address into the second access path, and filling the first query parameter in the second access path.
[0011] Optionally, the method also includes: in response to a jump access request of the target page, according to the second access address, parsing from the jump access request a first jump address corresponding to the jump page that complies with the code specification of the single-page application; rendering the jump page according to the first jump address and the page file; according to the conversion rule, converting the first jump address into a second jump address that complies with the search engine specification, and displaying the second jump address in the address bar of the jump page.
[0012] Optionally, the method includes: after receiving the page file returned by the server in response to the first access address, saving the page file to a local cache; and obtaining the page file from the local cache before rendering the jump page based on the first jump address and the page file.
[0013] Optionally, before converting the first jump address into a second jump address that complies with a search engine specification, the method includes: determining whether a mapping relationship corresponding to the first jump address exists in the conversion rule.
[0014] Optionally, the preset conversion rules include: a domain name mapping relationship and a path mapping relationship; the first jump address includes: a first jump domain name, a first jump path and a second query parameter; converting the first jump address into a second jump address that complies with search engine specifications, including: determining a second jump domain name corresponding to the first jump domain name according to the domain name mapping relationship, and converting the first jump domain name in the first jump address into the second jump domain name; determining a second jump path that complies with search engine specifications and corresponds to the first jump path according to the path mapping relationship, converting the first jump path in the first jump address into the second jump path, and filling the second query parameter in the second jump path.
[0015] According to a second aspect of an embodiment of the present invention, there is provided a device for accessing a single-page application, comprising:
[0016] An address acquisition module, configured to respond to a page access request of a single-page application and parse a first access address that complies with a search engine specification from the page access request;
[0017] An address sending module, used for sending the first access address to a server, and receiving a page file returned by the server in response to the first access address;
[0018] The address conversion module is used to convert the first access address into a second access address that complies with the code specification of the single-page application according to a preset conversion rule, render a target page corresponding to the page access request according to the second access address and the page file, and display the first access address in the address bar of the target page.
[0019] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for a single-page application, including:
[0020] one or more processors;
[0021] a storage device for storing one or more programs,
[0022] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0023] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0024] One embodiment of the invention has the following advantages or beneficial effects: by responding to a page access request of a single-page application, a first access address that meets the search engine specification is parsed from the page access request; the first access address is sent to the server, and a page file returned by the server in response to the first access address is received; according to a preset conversion rule, the first access address is converted into a second access address that meets the code specification of the single-page application, and according to the second access address and the page file, the target page corresponding to the page access request is rendered, and the first access address is displayed in the address bar of the target page. The technical solution realizes the conversion of the first access address that meets the search engine specification in the page access request into the second access address that meets the code specification of the single-page application, and according to the second access address and the page file determined by the first access address, the corresponding target page is rendered, and then the first access address is displayed in the address bar of the target page. By converting access addresses of different specifications, the search engine optimization problem of the single-page application can be realized quickly, flexibly and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0026] Figure 1 is a schematic diagram of the main process of the method for accessing a single-page application according to an embodiment of the present invention;
[0027] Figure 2 is a detailed flow chart of a method for accessing a single-page application according to an embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of main modules of a single-page application access device according to an embodiment of the present invention;
[0029] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0030] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0031] It should be noted that in the technical solution of the present invention, the collection / collection, update, analysis, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, leaked or sold outside of these legal uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken for user personal information to selectively block the use or access to personal information data to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. In addition, once these user personal information data are no longer needed, the risks should be minimized by limiting or even prohibiting data collection and / or deleting data.
[0032] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0033] At present, the SEO requirements for single-page applications, whether for the reconstruction and development of single-page applications or the customized development of each page, are faced with the problem of complex development work and the need to consume a large amount of development resources. In addition, reconstruction and development are more difficult to maintain later. Therefore, how to connect single-page applications that do not meet SEO rules to search engines with the least development cost, so that users can accurately access pages through access addresses that meet SEO rules, has become an urgent problem to be solved.
[0034] In order to solve the above problems existing in the prior art, the present invention proposes a single-page application access method, which converts a first access address in a page access request that complies with the search engine specification into a second access address that complies with the code specification of the single-page application, renders the corresponding target page according to the second access address and the page file determined by the first access address, and then displays the first access address in the address bar of the target page. By converting access addresses of different specifications, the search engine optimization problem of the single-page application can be achieved quickly, flexibly and efficiently.
[0035] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:
[0036] React is a front-end framework for developing web pages. It is a single-page application. The so-called single-page application means that the actual page is the same page, but by intercepting the request for address bar route changes, it implements the method of switching routes locally to switch multiple pages without requesting to the server. Single page is the main choice architecture for front-end development at this stage;
[0037] meta: a code identifier of the front-end page, which is invisible and used to identify some agreed data or rules;
[0038] Intercepting browsers: JavaScript comes with an Api history object, which has two built-in methods, pushState and replaceState. These two methods can manipulate the display of the address bar synchronously without causing the page to jump, thus achieving the jump to different pages within the application. With the help of these two methods, the address bar can be changed, and the display of the page content can be synchronously processed, thus achieving the effect of synchronously changing the URL and the page, but not actually jumping to the page, that is, a single-page application;
[0039] History State: The visible characters in the address bar of a web page are actually some states stored. This state can be intercepted and edited manually to achieve arbitrary changes and control of the address bar.
[0040] Memory History: A way to implement routing in React, which also uses History State to intercept the address bar.
[0041] Figure 1 is a schematic diagram of the main process of the access method of the single-page application according to an embodiment of the present invention, such as Figure 1 As shown, the single-page application access method of the embodiment of the present invention includes the following steps S101 to S103.
[0042] Step S101: In response to a page access request of a single page application, a first access address that complies with a search engine specification is parsed from the page access request.
[0043] Specifically, if SEO rules are not considered during the development phase of a single-page application, the definition of the access address may be arbitrary, that is, as long as it complies with the code specifications of the single-page application. With the popularity of search engines, the development of single-page applications needs to take into account search engine optimization so that they can be included in search engines and obtain more access traffic. However, for some single-page applications that have been developed for a long time, SEO rules may not have been considered at the time. Although users can access them by entering the access address, the search engine cannot actively capture it. For example, the access address of a single-page application includes " / yonghu?userId=12345", where the content after "?" is the query parameter, that is, "userId=12345" represents the query parameter, and the query parameter in the SEO rule is usually after the " / " symbol. The search engine cannot capture the single-page application. In addition, considering that the single-page application has been running externally and cannot be offline, it can only be gradually compatible, which requires retaining the existing logic to achieve no perception of users. When users search through a browser, they can access the default search engine through a third-party interface or directly through the search engine to send a page access request for a single-page application in a manner that complies with the search engine specifications. The front end parses the received page access request and obtains the first access address that complies with the search engine specifications.
[0044] Step S102: sending the first access address to a server, and receiving a page file returned by the server in response to the first access address.
[0045] According to an embodiment of the present invention, the page file includes the preset conversion rule.
[0046] Specifically, before the server receives the first access address, it is necessary to define a set of address file conversion rules including the first access address, and establish a mapping relationship between the received access address and the page file according to the rules, so as to obtain the page file of the single-page application corresponding to the first access address according to the first access address. Furthermore, the single-page application has an access address that complies with its code specification, that is, the second access address of the embodiment of the present invention. The relevant information in the second access address can be used as the identifier of the page file, and part or all of the information in the first access address can be converted into the identifier of the page file to determine the page file of the single-page application corresponding to the access request. In the embodiment of the present invention, the page file is a necessary resource file for accessing the single-page application. Preferably, the front-end and the server can agree in advance on a set of access address conversion rules, and the server will use them as address file conversion rules. This can optimize the code, reduce unnecessary processing logic, and improve execution efficiency. When performing address file conversion based on the first access address, according to the definition of the page file identifier, only part of the information in the first access address can be converted to obtain the page file identifier. For example, only the domain name in the first access address can be converted. When the page file to be obtained is determined, the conversion rules are transmitted to the front-end through the page file. In order to further improve efficiency, the conversion rules can be injected into the page file in the form of a meta tag. The server obtains the processed page file and returns the processed page file to the front-end as a response result of the page access request.
[0047] Step S103: According to a preset conversion rule, convert the first access address into a second access address that complies with the code specification of the single-page application; render a target page corresponding to the page access request according to the second access address and the page file; and display the first access address in the address bar of the target page.
[0048] According to an embodiment of the present invention, before converting the first access address into a second access address that complies with the code specification of the single-page application according to a preset conversion rule, the method further includes: parsing the preset conversion rule from the page file.
[0049] According to another embodiment of the present invention, the preset conversion rule includes: a domain name mapping relationship and a path mapping relationship.
[0050] Specifically, the front end receives the page file returned from the server, and parses the preset conversion rules from the page file. Considering that the page access needs to be processed and rendered based on the page file, and the page file complies with the code specification, it is necessary to convert the first access address into a second access address that complies with the code specification according to the conversion rule.
[0051] For example, assume that the second access address of a page in a single-page application that complies with the code specification is www.a.com / page1?id=1. To achieve SEO, its first access address that complies with the search engine specification is agreed to be www.b.com / page2 / 1. Correspondingly, the conversion rules preset in the form of meta tags are as follows:
[0052] (1) Domain name host mapping relationship: If www.b.com corresponds to www.a.com, then the label uses <meta name="host”,source="www.a.com”,seo="www.b.com”> , where source is the second access address domain name, and seo is the first access address domain name that complies with SEO rules
[0053] (2) Path mapping relationship: If / page2 corresponds to / page1, then use <meta name="route”,source=" page1”,seo=" page2 {id}”> , where source is the second access address path, seo is the first access address path that complies with SEO rules. Note that the query parameter "{id}" in seo corresponds to the query parameter id=1 of the second access address, that is, the corresponding first access address path that complies with SEO rules is actually / page2 / 1.
[0054] According to another embodiment of the present invention, the first access address includes a first access domain name, a first access path and a first query parameter; according to a preset conversion rule, the first access address is converted into a second access address that conforms to the code specification of the single-page application, including: determining a second access domain name corresponding to the first access domain name according to the domain name mapping relationship, and converting the first access domain name in the first access address into the second access domain name; determining a second access path that conforms to the code specification of the single-page application corresponding to the first access path according to the path mapping relationship, converting the first access path in the first access address into the second access path, and filling the first query parameter in the second access path.
[0055] Specifically, the first access address generally includes a first access domain name, a first access path and a first query parameter. According to the domain name mapping relationship in the conversion rule, the second access domain name corresponding to the first access domain name is determined, and the first access domain name is replaced with the second access domain name; similarly, according to the path mapping relationship in the conversion rule, the second access path is determined, and the first access path is replaced with the second access path; in addition, in order to ensure that the first access address that complies with SEO specifications can accurately access the corresponding single-page application page, it is necessary to ensure the consistency of the query parameters to achieve good compatibility with the single-page application, fill the first query parameter in the second access path, and finally combine the second access domain name and the second access path to obtain the second access address.
[0056] Furthermore, based on the second access address obtained by conversion and in combination with the received page file, the front-end renders the target page corresponding to the page access request, and intercepts the second access address that complies with the code specification to be displayed in the address bar of the target page, controls the page content to be displayed as the target page, and displays the first access address in the page address bar. By intercepting the changes in the History State of the browser, such as the Memory History in React, the first access address that complies with the search engine specification is displayed in the address bar of the target page, and the second access address is stored in the browser's memory for subsequent use. In other words, the page content and the page address bar in the target page visited by the user are two independent units with their own processing logic.
[0057] Through the address conversion method of the embodiment of the present invention, it is achieved that page access can be accurately performed through the access address that complies with SEO rules, and it is imperceptible to the user. In addition, when new business access is needed in the future, the embodiment of the present invention can flexibly implement page access by configuring new adaptive conversion rules, which greatly reduces development complexity and improves efficiency.
[0058] According to another embodiment of the present invention, the method also includes: in response to a jump access request of the target page, according to the second access address, parsing from the jump access request a first jump address corresponding to the jump page that complies with the code specification of the single-page application; rendering the jump page according to the first jump address and the page file; according to the conversion rule, converting the first jump address into a second jump address that complies with the search engine specification, and displaying the second jump address in the address bar of the jump page.
[0059] Specifically, after obtaining the target page of the above-mentioned single-page application, the user can browse the target page and perform a jump operation on the target page when necessary, and issue a jump access request. Considering that the single-page application only has one request response with the server, based on the above-mentioned conversion of the first access address to the second access address, the second access address is stored in the browser memory. When receiving the jump access request of the user, the second access address of the stored target page is obtained, and according to the second access address, the first jump address that complies with the code specification corresponding to this jump access is parsed from the jump access request.
[0060] According to another embodiment of the present invention, the method includes: after receiving the page file returned by the server in response to the first access address, saving the page file to the local cache; according to the first jump address and the page file, before rendering the jump page, obtaining the page file from the local cache.
[0061] Specifically, after obtaining the page file from the server, the page file can be saved in the local cache, and when processing the jump access request, it can be obtained from the cache as needed. According to the first jump address that meets the code specification obtained by parsing, combined with the page file obtained from the cache, the corresponding jump page is rendered to obtain the jump page content.
[0062] According to another embodiment of the present invention, the preset conversion rules include: a domain name mapping relationship and a path mapping relationship; the first jump address includes: a first jump domain name, a first jump path and a second query parameter; converting the first jump address to a second jump address that complies with search engine specifications, including: determining a second jump domain name corresponding to the first jump domain name according to the domain name mapping relationship, and converting the first jump domain name in the first jump address to the second jump domain name; determining a second jump path that complies with search engine specifications and corresponds to the first jump path according to the path mapping relationship, converting the first jump path in the first jump address to the second jump path, and filling the second query parameter in the second jump path.
[0063] According to another embodiment of the present invention, before converting the first jump address into a second jump address that complies with a search engine specification, the method includes: determining that a mapping relationship corresponding to the first jump address exists in the conversion rule.
[0064] Specifically, the embodiments of the present invention are mainly based on single-page applications. The jump operation of the target web page may be a jump within the single-page application, or it may jump outside the single-page application. For the jump outside the single-page application, the embodiments of the present invention do not process it, and directly display the jump path of the jump page that complies with the code specification. Therefore, before converting the first jump address to the second jump address that complies with the search engine specification, it is necessary to determine whether there is a mapping relationship corresponding to the first jump address in the preset conversion rule. Only when it is determined that there is a mapping relationship corresponding to the first jump address in the conversion rule, that is, the jump within the single-page application, is the situation that the embodiments of the present invention focus on.
[0065] Further, similar to the above-mentioned first access address and second access address, the conversion rules may include a domain name mapping relationship and a path mapping relationship of the jump. According to the domain name mapping relationship in the conversion rule, the second jump domain name corresponding to the first jump domain name is determined, and the first jump domain name is replaced with the second jump domain name; similarly, according to the path mapping relationship in the conversion rule, the second jump path is determined, and the first jump path is replaced with the second jump path; in addition, in order to ensure the consistency of the query parameters and to achieve good compatibility with single-page applications, the second query parameter is filled in the second jump path, and finally the second jump domain name and the second jump path are combined to obtain the second jump address. The specific conversion rules are distinguished by the "meta name" and the "meta name" of the mapping relationship in the above-mentioned page access, for example, the first jump address www.a.com / page3? id=2. Referring to the above conversion, it can be known that the domain name after conversion is www.b.com / . Then determine the second jump path page4 / corresponding to page3 that complies with the search engine specification. Fill the second query parameter id=2 into the second jump path, and then combine the second jump domain name and the second jump path to obtain the second jump address www.b.com / page4 / 2.
[0066] In addition, after obtaining the second jump address, for the above-mentioned rendered jump page, the first jump address that complies with the code specification to be displayed in the address bar of the jump page is intercepted, the page content is controlled to be displayed as the jump page, and the page address bar displays the second jump address. By intercepting the changes of the browser's History State, such as the Memory History in React, the second jump address that complies with the search engine specification is displayed in the address bar of the jump page, thereby ensuring that the jump address displayed in the address bar complies with the search engine specification, that is, the jump page content and the page address bar are two independent units with their own processing logic.
[0067] Figure 2It is a detailed flowchart of the access method of the single-page application of the embodiment of the present invention. The embodiment of the present invention selects the preferred solution. The front end and the server agree in advance on the same set of access address conversion rules. The embodiment of the present invention uses the domain name that complies with the code specification as the identifier of the server page file, so the server only needs to convert the domain name in the first access address that complies with the search engine specification into a domain name that complies with the code specification according to the conversion rule to determine the corresponding page file. The user issues a page access request for the single-page application by entering the first access address (www.b.com / page2 / 1) that complies with the search engine specification; the front end parses the first access address (www.b.com / page2 / 1) based on the received access request, and sends the first access address (www.b.com / page2 / 1) to the server. The server receives the first access address (www.b.com / page2 / 1), and according to the preset conversion rule, determines that the domain name mapping relationship corresponding to the first access address (www.b.com / page2 / 1) is www.a.com, Determine the corresponding page file according to www.a.com, inject the preset conversion rules into the page file, obtain the processed page file of www.a.com, and return it to the front end; the front end converts the first access address (www.b.com / page2 / 1) into a second access address (www.a.com / page1?id=1) that complies with the code specification of the single-page application according to the preset conversion rules; render and display the target page according to the second access address and the page file, intercept the address bar of the target page, and display the first access address (www.b.com / page2 / 1) in the address bar of the target page.
[0068] Furthermore, in response to a jump click operation on an internal link of the target page, based on the jump access request of the target page, according to the second access address (www.a.com / page1?id=1), a first jump address (www.a.com / page3?id=2) corresponding to the jump page and conforming to the code specification of the single-page application is parsed from the jump access request; according to the first jump address and the page file, the jump page is rendered, and through a preset conversion rule, the first jump address is converted into a second jump address (www.b.com / page4 / 2) that conforms to the search engine specification; the jump page is displayed and the address bar of the jump page is intercepted, and the second jump address (www.b.com / page4 / 2) is displayed in the address bar of the jump page; receiving a refresh operation from the user is equivalent to re-initiating a page access request, thereby completing a complete single-page application access process.
[0069] Through the method of the embodiment of the present invention, the page content and the page address bar are regarded as two independent units with their own processing logic. Through the preset conversion rules and the interception of the address bar, it is achieved that the user can accurately access the target page through the access address that complies with the SEO rules, and when the page jumps within the single-page application, the correct jump page is rendered through the jump guidance of the page file, and the jump address that complies with the SEO rules is displayed to the user, which is unaware of the user and can be effectively compatible with single-page applications that do not consider SEO rules.
[0070] Figure 3 Schematic diagram of the main modules of the access device of the single-page application according to the embodiment of the present invention. Figure 3 As shown, the access device 300 for a single-page application mainly includes an address acquisition module 301 , an address sending module 302 and an address conversion module 303 .
[0071] The address acquisition module 301 is used to respond to a page access request of a single page application and parse a first access address that complies with a search engine specification from the page access request;
[0072] An address sending module 302 is used to send the first access address to the server, and receive a page file returned by the server in response to the first access address;
[0073] The address conversion module 303 is used to convert the first access address into a second access address that complies with the code specification of the single-page application according to a preset conversion rule, render the target page corresponding to the page access request according to the second access address and the page file, and display the first access address in the address bar of the target page.
[0074] According to one embodiment of the present invention, the page file includes the preset conversion rules; the access device 300 of the single-page application also includes a parsing module (not shown in the figure), which is used to: before converting the first access address into a second access address that complies with the code specification of the single-page application according to the preset conversion rules, parse the preset conversion rules from the page file.
[0075] According to another embodiment of the present invention, the preset conversion rules include: a domain name mapping relationship and a path mapping relationship; the first access address includes a first access domain name, a first access path and a first query parameter; the address conversion module 303 is also used to: determine a second access domain name corresponding to the first access domain name according to the domain name mapping relationship, and convert the first access domain name in the first access address into the second access domain name; determine a second access path corresponding to the first access path and conforming to the code specification of the single-page application according to the path mapping relationship, convert the first access path in the first access address into the second access path, and fill the first query parameter in the second access path.
[0076] According to another embodiment of the present invention, the access device 300 of the single-page application also includes a jump access module (not shown in the figure), which is used to: respond to the jump access request of the target page, and according to the second access address, parse out from the jump access request a first jump address corresponding to the jump page that complies with the code specification of the single-page application; render the jump page according to the first jump address and the page file; and according to the conversion rule, convert the first jump address into a second jump address that complies with the search engine specification, and display the second jump address in the address bar of the jump page.
[0077] According to another embodiment of the present invention, the access device 300 of the single-page application also includes a page file storage module (not shown in the figure), which is used to: after receiving the page file returned by the server in response to the first access address, save the page file to the local cache; the access device 300 of the single-page application also includes a page file extraction module (not shown in the figure), which is used to: according to the first jump address and the page file, before rendering the jump page, obtain the page file from the local cache.
[0078] According to one embodiment of the present invention, the access device 300 for the single-page application also includes a conversion determination module (not shown in the figure), which is used to: before converting the first jump address into a second jump address that complies with the search engine specification, determine whether there is a mapping relationship corresponding to the first jump address in the conversion rule.
[0079] According to another embodiment of the present invention, the preset conversion rules include: a domain name mapping relationship and a path mapping relationship; the first jump address includes: a first jump domain name, a first jump path and a second query parameter; the jump access module (not shown in the figure) is also used to: determine the second jump domain name corresponding to the first jump domain name according to the domain name mapping relationship, and convert the first jump domain name in the first jump address into the second jump domain name; determine the second jump path that complies with the search engine specification and corresponds to the first jump path according to the path mapping relationship, convert the first jump path in the first jump address into the second jump path, and fill the second query parameter in the second jump path.
[0080] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.
[0081] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0082] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Terminal devices 401, 402, 403 can be installed with various communication client applications, such as single page access applications, etc. (only as an example).
[0083] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0084] The server in the embodiment of the present invention is located in the server 405, and is used to provide a corresponding page file according to a single-page application access request. The terminal device can respond to the page access request of the single-page application, parse the first access address that meets the search engine specification from the page access request; send the first access address to the server, receive the page file returned by the server in response to the first access address; according to a preset conversion rule, convert the first access address into a second access address that meets the code specification of the single-page application, render the target page corresponding to the page access request according to the second access address and the page file, display the first access address in the address bar of the target page, and process, and feed back the processing result to the terminal device.
[0085] It should be noted that the single-page application access method provided in the embodiment of the present invention is generally executed by the terminal devices 401 , 402 , 403 , and accordingly, the single-page application access device is generally provided in the terminal devices 401 , 402 , 403 .
[0086] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0087] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5 The terminal device or server 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.
[0088] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0089] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0090] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0091] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may 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 of computer-readable storage media may include, but are not limited to: 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 the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal 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 computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.
[0092] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0093] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be arranged in a processor, for example, it may be described as follows: a processor includes an address acquisition module, an address sending module and an address conversion module.
[0094] Among them, the names of these modules do not constitute a limitation on the modules themselves in some cases. For example, the address sending module can also be described as "a module for sending the first access address to the server and receiving the page file returned by the server in response to the first access address."
[0095] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or it may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by a device, the device includes: responding to a page access request of a single-page application, parsing a first access address that complies with the search engine specification from the page access request; sending the first access address to a server, and receiving a page file returned by the server in response to the first access address; according to a preset conversion rule, converting the first access address into a second access address that complies with the code specification of the single-page application, rendering a target page corresponding to the page access request according to the second access address and the page file, and displaying the first access address in the address bar of the target page.
[0096] According to the technical solution of the embodiment of the present invention, there are the following advantages or beneficial effects: by responding to the page access request of the single-page application, a first access address that meets the search engine specification is parsed from the page access request; the first access address is sent to the server, and the page file returned by the server in response to the first access address is received; according to the preset conversion rule, the first access address is converted into a second access address that meets the code specification of the single-page application, and according to the second access address and the page file, the target page corresponding to the page access request is rendered, and the first access address is displayed in the address bar of the target page. The technical solution realizes the conversion of the first access address that meets the search engine specification in the page access request into the second access address that meets the code specification of the single-page application, and according to the second access address and the page file determined by the first access address, the corresponding target page is rendered, and then the first access address is displayed in the address bar of the target page. By converting access addresses of different specifications, the search engine optimization problem of the single-page application can be realized quickly, flexibly and efficiently.
[0097] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method for accessing a single-page application, characterized in that: include: In response to a page access request of a single page application, a first access address that complies with a search engine specification is parsed from the page access request; Sending the first access address to a server, and receiving a page file returned by the server in response to the first access address; According to a preset conversion rule, the first access address is converted into a second access address that complies with the code specification of the single-page application, and based on the second access address and the page file, the target page corresponding to the page access request is rendered, and the first access address is displayed in the address bar of the target page.
2. The method according to claim 1, characterized in that The page file includes the preset conversion rule; Before converting the first access address into a second access address that complies with the code specification of the single-page application according to a preset conversion rule, the method further includes: parsing the preset conversion rule from the page file.
3. The method according to claim 1, characterized in that The preset conversion rule includes: a domain name mapping relationship and a path mapping relationship; the first access address includes a first access domain name, a first access path and a first query parameter; according to the preset conversion rule, converting the first access address into a second access address that complies with the code specification of the single-page application includes: Determine a second access domain name corresponding to the first access domain name according to the domain name mapping relationship, and convert the first access domain name in the first access address into the second access domain name; Determine a second access path corresponding to the first access path and conforming to the code specification of the single-page application according to the path mapping relationship, convert the first access path in the first access address into the second access path, and fill the first query parameter in the second access path.
4. The method according to claim 1, characterized in that The method further comprises: In response to the jump access request of the target page, according to the second access address, a first jump address that corresponds to the jump page and complies with the code specification of the single-page application is parsed from the jump access request; Rendering the jump page according to the first jump address and the page file; According to the conversion rule, the first jump address is converted into a second jump address that complies with a search engine specification, and the second jump address is displayed in the address bar of the jump page.
5. The method according to claim 4, characterized in that The method comprises: After receiving the page file returned by the server in response to the first access address, saving the page file to a local cache; According to the first jump address and the page file, before rendering the jump page, the page file is obtained from the local cache.
6. The method according to claim 4, characterized in that Before converting the first jump address into a second jump address that complies with a search engine specification, the method includes: It is determined that a mapping relationship corresponding to the first jump address exists in the conversion rule.
7. The method according to claim 4, characterized in that The preset conversion rule includes: a domain name mapping relationship and a path mapping relationship; the first jump address includes: a first jump domain name, a first jump path and a second query parameter; converting the first jump address into a second jump address that complies with the search engine specification includes: Determine a second jump domain name corresponding to the first jump domain name according to the domain name mapping relationship, and convert the first jump domain name in the first jump address into the second jump domain name; A second jump path that corresponds to the first jump path and complies with search engine specifications is determined according to the path mapping relationship, the first jump path in the first jump address is converted into the second jump path, and the second query parameter is filled in the second jump path.
8. A single-page application access device, characterized in that: include: An address acquisition module, for responding to a page access request of a single page application, and parsing a first access address that complies with a search engine specification from the page access request; An address sending module, used for sending the first access address to a server, and receiving a page file returned by the server in response to the first access address; The address conversion module is used to convert the first access address into a second access address that complies with the code specification of the single-page application according to a preset conversion rule, render a target page corresponding to the page access request according to the second access address and the page file, and display the first access address in the address bar of the target page.
9. A mobile electronic device terminal, characterized in that: include: 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 according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.