Page loading method, device, apparatus and storage medium
By adding configuration attribute information to the route manager, the selective saving and loading of page state information for single-page applications can be achieved, solving the problem of inflexible page state management in existing technologies and improving the flexibility of page loading.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 上海瑞家信息技术有限公司
- Filing Date
- 2021-11-29
- Publication Date
- 2026-04-14
AI Technical Summary
Existing single-page applications cannot meet the flexible requirements of returning to historical and initial states when navigating between pages, resulting in an inflexible way of saving page state information.
Add new configuration attributes to the route manager. By identifying and retaining attributes, selective saving and loading of page state information can be achieved, including the management of persistent and non-persistent page state.
It improves the flexibility of page loading, allowing the page to selectively load its historical or initial state as needed, meeting the requirements of different application scenarios.
Smart Images

Figure CN114217792B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a page loading method, device, apparatus and storage medium. Background Technology
[0002] A single-page web application (SPA) can dynamically rewrite the current page to interact with the user without reloading the entire page. Compared to traditional internet applications, SPAs use a front-end and back-end separation approach, where the back-end is only responsible for processing data and providing interfaces, while the front-end is responsible for page logic and page rendering.
[0003] In front-end single-page application development, it's common to encounter situations where, during page navigation, it's necessary to record the modified state of the previous page to avoid repetitive operations when returning to the previous page. Currently, the main method for saving page history is to utilize the keep-alive component provided by the Vue.js framework. The page whose state information needs to be recorded is written into this component, thus saving the page's historical state information.
[0004] Existing methods for saving page history only allow users to return to the saved historical state when returning to the page, which fails to meet the needs of some application scenarios. For example, scenarios requiring a return to the initial state of a historical page. Therefore, how to selectively load page state information is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] This application provides a page loading method, device, apparatus, and storage medium to selectively load page state information and improve the flexibility of page loading.
[0006] This application provides a page loading method, including:
[0007] Obtain the configuration attribute information of the first page; the first page is the page preceding the currently displayed second page;
[0008] Based on the configuration attribute information, obtain the persistence attributes of the first page;
[0009] If the persistence attribute of the first page is persistent, in response to the return operation from the second page to the first page, the target cached page of the first page is obtained from the configuration attribute information;
[0010] If the target cached page is the second page, the historical state information of the first page is obtained from the cached historical state information according to the identifier of the first page;
[0011] The first page is loaded based on its historical state information.
[0012] This application embodiment also provides a page loading device, including:
[0013] The acquisition module is configured to acquire configuration attribute information of the first page; acquire persistence attributes of the first page based on the configuration attribute information; if the persistence attribute of the first page is persistent, in response to a return operation from the second page to the first page, acquire the target cached page of the first page from the configuration attribute information; and if the target cached page is the second page, acquire the historical state information of the first page from the cached historical state information based on the identifier of the first page; wherein the first page is the previous page of the currently displayed second page.
[0014] The loading module is used to load the second page based on the historical state information of the second page.
[0015] This application also provides an electronic device, including: a memory, a processor, and a display component; wherein the memory is used to store computer programs;
[0016] The processor is coupled to the memory and the display component and is used to execute the computer program to perform the steps in the page loading method described above.
[0017] This application also provides a computer-readable storage medium storing computer instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps in the page loading method described above.
[0018] In this embodiment, new configuration attribute information is added for single-page applications. For scenarios returning from a second page to a first page, the persistence attribute of the first page and its target cached page can be obtained based on the configuration attribute information of the first page. If the persistence attribute of the first page is persistent and the target cached page is the second page, the historical state information of the first page is obtained from the cached historical state information based on the first page's identifier. The first page is then loaded based on this historical state information, enabling selective saving and loading of the historical state information of the first page, thus improving the flexibility of first page loading. Attached Figure Description
[0019] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0020] Figures 1-3 A flowchart illustrating the page loading method provided in this application embodiment;
[0021] Figure 4 This is a schematic diagram of the structure of the page loading device provided in the embodiments of this application;
[0022] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] Existing methods for saving page history only allow users to return to the saved historical state when returning to the same page, which cannot meet the needs of some application scenarios. In some embodiments of this application, new configuration attribute information is added for single-page applications. For scenarios where users return to the first page from the second page, the retention attribute of the first page can be obtained based on its configuration attribute information. If the retention attribute of the first page is persistent and the second page is the target cached page of the first page, the historical state information of the first page is obtained from the cached historical state information based on the identifier of the first page. Then, the first page is loaded based on this historical state information, enabling selective saving and loading of the historical state information of the first page, which helps improve the flexibility of loading the first page.
[0025] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0026] It should be noted that the same reference numerals denote the same object in the following figures and embodiments. Therefore, once an object is defined in one figure or embodiment, it does not need to be discussed further in subsequent figures and embodiments.
[0027] Figure 1 This is a flowchart illustrating a page loading method provided in an embodiment of this application. Figure 1 As shown, the method includes:
[0028] 101. For the currently displayed first page, obtain the configuration attribute information of the first page.
[0029] 102. Based on the configuration attribute information, obtain the persistence attributes of the first page.
[0030] 103. If the persistence attribute of the first page is set to persistent, cache the current state information of the first page as the historical state information of the first page.
[0031] 104. In response to a switch operation from the first page to the second page, navigate from the first page to the second page.
[0032] In this embodiment, both the first page and the second page are single-page applications (SPAs). For SPAs, refreshing the page requests an HTML file, while switching pages does not initiate a new request for an HTML file; only the page content changes. SPAs can be progressive page frameworks, such as the Vue.js framework.
[0033] For a single-page application's (SPA) page framework, a router may be included. In an SPA, the router handles page display and navigation logic, providing modular, component-based route configuration and fine-grained navigation control. In this embodiment, to selectively maintain the SPA's state information, new configuration attributes can be added to the router to indicate that SPA A needs to save its state information when switching to another target page B. The page's state information can be the state information of the page before switching to another target page, and may include: the page's state information corresponding to at least one page operation before switching to another target page, such as the page search state corresponding to a search operation, the page turning state corresponding to a pagination operation, etc.
[0034] The newly added configuration attributes may include: the identifier of page A, the persistence attributes of page A, and the identifier of the target cached page of page A. The identifier of page A can be information that uniquely identifies a single-page application, such as page A's number, code, or name. The persistence attributes of page A may include: persistent persistence (keep-alive) and non-persistent persistence. Persistent persistence means that the state information of page A needs to be saved; non-persistent persistence means that the state information of page A does not need to be saved. For page A with persistent persistence, when returning to page A from other pages, the historical state of page A can be returned based on the cached state information of page A; for page A with non-persistent persistence, the initial state of page A can be returned when returning to page A from other pages.
[0035] In practical applications, some scenarios require returning to the historical state of the first page when returning from other pages, while others do not. For example, in some scenarios, returning to the first page from a specific page requires returning to the initial state of the first page. In this embodiment, to selectively save page state information, a target cache page that requires returning to the historical state of the first page can be added to the route manager. Correspondingly, the newly added configuration attribute information may include: the identifier of the target cache page for page A, etc. Technical personnel can write the identifier of the target cache page that requires returning to the historical state of the first page into the corresponding field of the route manager to add the target cache page that requires returning to the historical state of the first page to the route manager.
[0036] In this embodiment, when switching from page A to the target cached page, the state information of page A needs to be saved; when switching to other pages, the state information of page A does not need to be saved. The code for adding the configuration attribute information is as follows:
[0037]
[0038]
[0039] The above configuration attribute information mainly states that for page A, when switching to the target cache page B, the persistence attribute of page A is persistent, that is, when page A switches to the target cache page B, the historical state information of page A needs to be saved.
[0040] In this embodiment, for any single-page application, the configuration attribute information of the single-page application can be pre-set in the routing manager. Based on the pre-set configuration attribute information, when switching from the first page to the second page, in step 101 of this embodiment, the configuration attribute information of the first page can be obtained in response to the switching operation from the first page to the second page. Here, the first page is the currently displayed page, and the second page is the page to be switched to. Optionally, in response to the switching operation from the first page to the second page, the configuration attribute information of the first page can be obtained from the routing manager according to the identifier of the first page. Specifically, the identifier of the first page can be matched in the routing manager to obtain the configuration attribute information corresponding to the identifier of the first page, which is used as the configuration attribute information of the first page. Based on the code of the above configuration attribute information, the identifier of the first page can be matched in the name field of the routes function in the routing manager, and the attribute value of the name field is the configuration attribute information of the identifier of the first page, which is used as the configuration attribute information of the first page.
[0041] Further, in step 102, the persistence attribute of the first page can be obtained based on the configuration attribute information of the first page. Specifically, it can be determined whether the configuration attribute information of the first page contains a persistent persistence identifier; if the determination result is yes, the persistence attribute of the first page is determined to be persistent. Correspondingly, if the determination result is no, the persistence attribute of the first page is determined to be non-persistent. For the code corresponding to the above configuration attribute information, the attribute value corresponding to the keepAlive attribute can be obtained from the configuration attribute information of the first page; if the attribute value corresponding to the keepAlive attribute is "true", it is determined that the configuration attribute information contains a persistent persistence identifier, indicating that the persistence attribute of the first page is persistent; if the attribute value corresponding to the keepAlive attribute is "false", it is determined that the configuration attribute information does not contain a persistent persistence identifier, indicating that the persistence attribute of the first page is non-persistent, etc.
[0042] Furthermore, if the persistence attribute of the first page is set to persistent, in step 103, the current state information of the first page can be cached as the historical state information of the first page. In this embodiment, the form in which the historical state information of the first page is stored is not limited. In some embodiments, the current state information of the first page can be cached using the data structure of the Document Object Model (DOM), i.e., the historical state information of the first page can be cached. For single-page applications using the Vue.js framework, the current state information of the first page can be cached in the form of vNodes. Here, vNode is a virtual browser Document Object Model, which can be understood as a description object of the Document Object Model, describing how to create real browser Document Object nodes. Vue.js can use this virtual object model to keep track of changes occurring in the real object model.
[0043] In this embodiment, besides caching the historical state information of the first page, the identifier of the first page can also be written to the page cache queue if the persistence property of the first page is set to persistent. For example, in the Vue.js architecture, the identifier of the first page can be written to the page cache queue in the database (Store). The Store is Vue's global state management container, which can uniformly manage and distribute various information. The page cache queue refers to the queue used to cache the page identifier whose persistence property is set to persistent.
[0044] For the Vue.js framework, the hook events of the route manager can be used to determine whether the departing page's identifier needs to be added to or removed from the page cache queue where historical state information needs to be saved. For page identifiers that need to be added to the page cache queue, hook functions can be used to write the page identifiers to the page cache queue. The core code for this logic is as follows:
[0045]
[0046] For the page identifiers in the page cache queue, the keep-alive component can be used to retrieve the page cache queue from a database (such as the Store), and the page routes corresponding to the page identifiers contained in the page cache queue can be written into the corresponding state information saving function. This way, by executing the state information saving function, the state information of pages with the "persistent" attribute can be automatically saved. The logic code for this operation is as follows:
[0047] <keep-alive:include="cachedPageComponentName">
[0048] <router-view>< / router-view>
[0049]
[0050] / / ……
[0051] cachedPageComponentName:this.$store.state.cachedPageComponents
[0052] After caching the historical state information of the first page, in step 104, in response to a switching operation from the first page to the second page, the user can jump from the first page to the second page. Optionally, in response to a switching operation from the first page to the second page, the user can obtain the initialization state information of the second page; further, based on the initialization state information of the second page, the second page can be loaded to display the initialization state effect of the second page, thereby realizing the switching from the first page to the second page.
[0053] The initialization state information of the page refers to the initial state information of the page, which is the default page state information of the application. This state information is generated when no page operation occurs. In this embodiment, the storage format of the page initialization state information is not limited. Optionally, the page initialization state information can be stored in the form of a document object model data structure, or in other data structure formats. In this embodiment, the page initialization state information can be pre-stored in the electronic device executing the page loading method. Optionally, the identifier of the second page can be matched with the pre-stored correspondence between page identifiers and initialization state information to obtain the initialization state information of the second page.
[0054] Of course, if the persistence attribute of the first page is not persistent, the operation of caching the historical state information of the first page in step 103 above will not be performed, nor will the operation of writing the identifier of the first page into the page cache queue be performed. In this case, the user can also jump from the first page to the second page in response to a switching operation from the first page to the second page.
[0055] The page loading method provided in this embodiment mainly describes the page loading process when switching from a first page to a second page. In this process, configuration attribute information of the page, which includes the page's persistence attribute, is added. Based on the page's configuration attribute information, it can be determined whether the persistence attribute of the currently displayed page is persistent. For the first page with the persistence attribute being persistent, the historical state information of the first page is cached. For the first page with the persistence attribute not being persistent, its historical state information is not cached. This achieves selective saving of page state information. In this way, when returning to the first page from the second page, only the persistent first page will load its historical state information, achieving selective loading of page state information and helping to improve the flexibility of page loading.
[0056] The above page loading process mainly describes the page loading process when switching from the first page to the second page. The following is an exemplary description of the page loading process when returning from the second page to the first page.
[0057] Figure 2 This is a flowchart illustrating another page loading method provided in an embodiment of this application. Figure 2 As shown, the method includes:
[0058] 201. Obtain the configuration attribute information of the first page; where the first page is the page preceding the currently displayed second page.
[0059] 202. Based on the configuration attribute information, obtain the persistence attributes of the first page.
[0060] 203. If the persistence attribute of the first page is set to persistent, in response to the return operation from the second page to the first page, the target cached page of the first page is obtained from the configuration attribute information.
[0061] 204. If the target cached page is the second page, retrieve the historical state information of the first page from the cached historical state information based on the identifier of the first page.
[0062] 205. Load the first page based on the historical status information of the first page.
[0063] In this embodiment, the second page is the currently displayed page, and the first page is the page preceding the second page. In this embodiment, when returning from the second page to the first page, the configuration attribute information of the first page can be obtained in step 201. For a description of obtaining the configuration attribute information of the first page in step 201 and step 202, please refer to the relevant content of steps 101 and 102 above, which will not be repeated here.
[0064] Furthermore, if the persistence attribute of the first page is persistent, in step 203, in response to a return operation from the second page to the first page, the target cached page of the first page can be obtained from the configuration attribute information of the first page. The storage format of the target cached page of the first page can be found in the relevant content of the above embodiments, and will not be repeated here. Optionally, the attribute value corresponding to the target cached page attribute can be obtained from the configuration attribute information of the first page. For example, based on the code corresponding to the configuration attribute information shown above, the target cached page attribute is "aliveToName", and the corresponding attribute value is page B.
[0065] Furthermore, if the target cached page of the first page is the second page, in step 204, the historical state information of the first page can be obtained from the cached historical state information according to the identifier of the first page; and in step 205, the first page is loaded according to the historical state information of the first page to display the state effect before the first page switches to the second page.
[0066] Accordingly, if the target cached page of the first page is not the second page, the initialization state information of the first page can be obtained. In this embodiment, the storage format of the page initialization state information is not limited. Optionally, the page initialization state information can be stored in the form of a document object model data structure, or in other data structure formats. In this embodiment, the page initialization state information can be pre-stored in the electronic device executing the page loading method. Optionally, the identifier of the first page can be matched against the pre-stored correspondence between page identifiers and initialization state information to obtain the initialization state information of the first page.
[0067] Furthermore, the first page can be loaded based on its initialization status information to display the initialization status effect of the first page.
[0068] Of course, if the persistence attribute of the first page obtained in step 202 is non-persistent, it means that the historical state information of the first page is not cached. Then the initialization state information of the first page can be obtained, and the first page can be loaded according to the initialization state information of the first page to display the initialization state effect of the first page.
[0069] Of course, in some embodiments, there may be a situation where the persistence attribute of the first page is persistent, but the second page is not the target cached page of the first page. In this case, since the historical state information of the first page has been cached when switching from the first page to the second page, and the identifier of the first page has been written to the page cache queue, when returning from the second page to the first page, the identifier of the first page can be deleted from the page cache queue, and the historical state information of the first page can be deleted from the cached historical state information. Furthermore, the initialization state information of the first page can be obtained, and the first page can be loaded according to the initialization state information of the first page to display the initialization state effect of the first page.
[0070] The page loading method provided in this embodiment is based on the above. Figure 1 The page loading process described in the optional embodiments, when switching from the first page to the second page and then returning from the second page to the first page, allows for the following process: Based on the configuration attribute information of the first page, the persistence attribute of the first page and the target cached page of the first page can be obtained. If the persistence attribute of the first page is persistent and the target cached page of the first page is the second page, the historical state information of the first page can be obtained from the cached historical state information based on the identifier of the first page. Based on the historical state information of the first page, the first page is loaded, thus enabling selective saving and loading of the historical state information of the first page, which helps improve the flexibility of loading the first page.
[0071] To more clearly illustrate the page loading method provided in the embodiments of this application, the following example, using a scenario of switching from page A to page B and then returning from page B to page A, will provide an exemplary description of the page loading method provided in the embodiments of this application. Figure 3 As shown, the page loading method provided in this application mainly includes:
[0072] S1. For the currently displayed page A, obtain the configuration attribute information of page A.
[0073] S2. Determine whether the configuration attribute information contains a persistent identifier. If the result is yes, proceed to steps S3 and S4; if the result is no, proceed to step S5.
[0074] S3. Write the identifier of page A into the page cache queue.
[0075] S4. Cache the current state information of page A using the data structure of the document object model, as the historical state information of page A.
[0076] S5. In response to a switch operation from page A to page B, jump from page A to page B.
[0077] S6. When displaying page B, obtain the configuration attribute information of page A.
[0078] S7. Determine whether the configuration attribute information contains a persistent identifier. If the result is yes, proceed to step S8; if the result is no, proceed to step S12.
[0079] S8. Obtain the target cached page of page A from the configuration attribute information.
[0080] S9. Determine whether page B is the target cached page of page A. If the result is yes, proceed to step S12; if the result is no, proceed to step S10.
[0081] S10. Remove the identifier of page A from the page cache queue.
[0082] S11. Delete the cached historical state information of page A; and then proceed to step S12.
[0083] S12. In response to the return operation from page B to page A, determine whether the identifier of page A exists in the page cache queue. If the determination result is yes, proceed to step S13; if the determination result is no, proceed to step S15.
[0084] S13. Based on the identifier of page A, retrieve the historical state information of page A from the cached historical state information.
[0085] S14. Load page A based on the historical state information of page A.
[0086] S15. Obtain the initialization status information of page A.
[0087] S16. Load page A according to the initialization status information of page A.
[0088] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 101 and 102 can be device A; or the execution subject of step 101 can be device A, and the execution subject of step 102 can be device B; and so on.
[0089] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations that appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel.
[0090] Accordingly, embodiments of this application also provide a computer-readable storage medium storing computer instructions, which, when executed by one or more processors, cause one or more processors to perform the steps in the page loading method described above.
[0091] Figure 4 This is a schematic diagram of the structure of a page loading device provided in an embodiment of this application. Figure 4 As shown, the page loading device includes an acquisition module 40a and a loading module 40b. The acquisition module 40a is used to acquire configuration attribute information of a first page, wherein the first page is the previous page of the currently displayed second page; acquire the persistence attribute of the first page based on the configuration attribute information; if the persistence attribute of the first page is persistent, in response to a return operation from the second page to the first page, acquire the target cached page of the first page from the configuration attribute information; and if the target cached page is the second page, acquire the historical state information of the first page from the cached historical state information based on the identifier of the first page.
[0092] Loading module 40b is used to load the second page based on the historical state information of the second page.
[0093] In some embodiments, the acquisition module 40a is further configured to acquire the initialization state information of the first page if the persistence attribute of the first page is non-persistent or the target cached page is not the first page.
[0094] Accordingly, loading module 40b is used to load the first page based on the initialization status information of the first page.
[0095] In some embodiments, the page loading apparatus further includes a deletion module 40c. The deletion module 40c is configured to, when the persistence attribute of the first page is persistent and the target cached page is not the second page, delete the identifier of the first page from the page cache queue and delete the historical state information of the first page from the cached historical state information.
[0096] Optionally, when obtaining the configuration attribute information of the first page, the acquisition module 40a is specifically used to: match the identifier of the first page in the route manager to obtain the configuration attribute information corresponding to the identifier of the first page, and use it as the configuration attribute information of the first page.
[0097] Optionally, when obtaining the persistence attribute of the first page, the acquisition module 40a is specifically used to: determine whether the configuration attribute information has a persistent persistence identifier; if the determination result is yes, determine that the persistence attribute of the first page is persistent persistence.
[0098] In this embodiment of the application, before obtaining the configuration attribute information of the first page, the obtaining module 40a is further configured to: obtain the configuration attribute information of the first page for the currently displayed first page; and obtain the retention attribute of the first page based on the configuration attribute information.
[0099] Optionally, the page loading device further includes a caching module 40d and a redirection module 40e. Accordingly, the caching module 40d is used to cache the current state information of the first page as historical state information of the first page if the persistence attribute of the first page is persistent. The redirection module 40e is used to redirect from the first page to the second page in response to a switching operation from the first page to the second page.
[0100] Optionally, when caching the current state information of the first page, the caching module 40d is specifically used to: cache the current state information of the first page using the data structure of the document object model.
[0101] In some embodiments, the page loading apparatus further includes a writing module 40f. The writing module 40f is configured to write the identifier of the first page into a page cache queue if the persistence attribute of the first page is persistent.
[0102] The page loading device provided in this embodiment adds new configuration attribute information for single-page applications. For scenarios involving returning to the first page from the second page, the persistence attribute and target cached page of the first page can be obtained based on the configuration attribute information of the first page. If the persistence attribute of the first page is persistent and the target cached page is the second page, the historical state information of the first page is obtained from the cached historical state information based on the identifier of the first page. The first page is then loaded based on this historical state information, enabling selective saving and loading of the historical state information of the first page, thus improving the flexibility of first page loading.
[0103] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device includes: a memory 50a, a processor 50b, and a display component 50c; wherein, the memory 50a is used to store computer programs. The memory 50a also stores configuration attribute information of the first page and historical state information of the page.
[0104] The processor is coupled to a memory and a display component for executing a computer program to: obtain configuration attribute information of a first page; wherein the first page is the previous page of the currently displayed second page; obtain a retention attribute of the first page based on the configuration attribute information; if the retention attribute of the first page is persistent, in response to a return operation from the second page to the first page, obtain a target cached page of the first page from the configuration attribute information; if the target cached page is the second page, obtain historical state information of the first page from cached historical state information based on the identifier of the first page; and load the first page through the display component 50c based on the historical state information of the first page.
[0105] In some embodiments, the processor 50b is further configured to: obtain initialization state information of the first page if the persistence attribute of the first page is non-persistent or the target cached page is not the first page; and load the first page through the display component 50c according to the initialization state information of the first page.
[0106] Optionally, memory 50a also stores a page cache queue. Processor 50b is further configured to: remove the identifier of the first page from the page cache queue and remove the historical state information of the first page from the cached historical state information if the persistence attribute of the first page is persistent and the target cached page is not the second page.
[0107] Optionally, when the processor 50b obtains the configuration attribute information of the first page, it specifically performs the following: matches the identifier of the first page in the route manager to obtain the configuration attribute information corresponding to the identifier of the first page, and uses it as the configuration attribute information of the first page.
[0108] Optionally, when the processor 50b obtains the persistence attribute of the first page, it specifically performs the following: determines whether the configuration attribute information contains a persistent persistence identifier; if the determination result is yes, it determines that the persistence attribute of the first page is persistent persistence.
[0109] In this embodiment of the application, the processor 50b is further configured to: obtain configuration attribute information of the first page for the currently displayed first page before obtaining configuration attribute information of the first page; obtain the retention attribute of the first page according to the configuration attribute information; if the retention attribute of the first page is persistent retention, cache the current state information of the first page to the memory 50a as historical state information of the first page; and, in response to a switching operation from the first page to the second page, jump from the first page to the second page.
[0110] When caching the current state information of the first page, processor 50b specifically caches the current state information of the first page using the data structure of the document object model.
[0111] Optionally, processor 50b is also configured to: write the identifier of the first page to the page cache queue if the persistence attribute of the first page is persistent.
[0112] In some alternative implementations, such as Figure 5 As shown, the electronic device may also include optional components such as a communication component 50d, a power supply component 50e, and an audio component 50f. Figure 5 The diagram only shows some components and does not mean that the electronic device must contain them. Figure 5 The inclusion of all components does not imply that an electronic device can only include... Figure 5 The components shown.
[0113] In the embodiments of this application, the specific implementation form of the electronic device is not limited. Optionally, the electronic device may be implemented as a terminal device such as a mobile phone, computer, or wearable device, or as an Internet of Things (IoT) device such as a speaker, refrigerator, or robot, but is not limited thereto.
[0114] The computer device provided in this embodiment adds new configuration attribute information for single-page applications. For scenarios involving returning to the first page from the second page, the persistence attribute and target cached page of the first page can be obtained based on the configuration attribute information of the first page. If the persistence attribute of the first page is persistent and the target cached page is the second page, the historical state information of the first page is obtained from the cached historical state information based on the identifier of the first page. The first page is then loaded based on this historical state information, enabling selective saving and loading of the historical state information of the first page, thus improving the flexibility of first page loading.
[0115] In this embodiment, the memory is used to store computer programs and can be configured to store various other data to support operation on its host device. The processor can execute the computer programs stored in the memory to implement corresponding control logic. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0116] In the embodiments of this application, the processor can be any hardware processing device capable of executing the above-described method logic. Optionally, the processor can be a central processing unit (CPU), a graphics processing unit (GPU), or a microcontroller unit (MCU); it can also be a field-programmable gate array (FPGA), a programmable array logic (PAL), a general array logic (GAL), a complex programmable logic device (CPLD), or other programmable devices; or it can be an advanced reduced instruction set (RISC) processor (ARM) or a system on chip (SOC), etc., but is not limited thereto.
[0117] In this embodiment, the communication component is configured to facilitate wired or wireless communication between its host device and other devices. The device housing the communication component can access wireless networks based on communication standards, such as WiFi, 2G or 3G, 4G, 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In another exemplary embodiment, the communication component may also be implemented based on Near Field Communication (NFC), Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wideband (UWB), Bluetooth (BT), or other technologies.
[0118] In embodiments of this application, the display component may include a liquid crystal display (LCD) and a touch panel (TP). If the display component includes a touch panel, the display component may be implemented as a touchscreen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation.
[0119] In this embodiment, a power supply component is configured to provide power to various components of the device in which it resides. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply component resides.
[0120] In embodiments of this application, the audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), which is configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals. For example, in devices with voice interaction capabilities, voice interaction with the user can be achieved through the audio component.
[0121] It should be noted that the terms "first" and "second" in this article are used to distinguish different messages, devices, modules, etc., and do not represent a chronological order, nor do they limit "first" and "second" to different types.
[0122] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0123] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0124] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0125] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0126] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0127] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0128] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0129] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0130] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A page loading method, characterized in that, include: Obtain the persistence attributes of the first page and the target cache page identifier. The first page is the previous page of the currently displayed second page. The target cache page identifier is used to specify the target page that needs to load the historical state of the first page when returning to the first page. The persistence attributes include persistent persistence and non-persistent persistence. Persistent persistence means that the state information of the first page needs to be saved, and non-persistent persistence means that the state information of the first page does not need to be saved. If the persistence attribute of the first page is persistent, in response to the return operation from the second page to the first page, it is determined whether the target cache page corresponding to the target cache page identifier is the second page; If the target cache page corresponding to the target cache page identifier is the second page, then the historical state information of the first page is obtained from the cached historical state information according to the identifier of the first page; and the first page is loaded according to the historical state information of the first page. If the persistence attribute of the first page is non-persistent or the target cached page is not the second page, the identifier of the first page is matched in the pre-stored correspondence between page identifiers and initialization state information to obtain the initialization state information of the first page; the first page is loaded according to the initialization state information of the first page. If the persistence attribute of the first page is persistent and the target cache page corresponding to the target cache page identifier is not the second page, the identifier of the first page is deleted from the page cache queue, and the historical state information of the first page is deleted from the cached historical state information. The identifier of the first page is matched in the pre-stored correspondence between page identifiers and initialization state information to obtain the initialization state information of the first page. Based on the initialization state information of the first page, the first page is loaded.
2. The method according to claim 1, characterized in that, The step of obtaining the configuration attribute information of the first page includes: The identifier of the first page is matched in the route manager to obtain the configuration attribute information corresponding to the identifier of the first page, which is then used as the configuration attribute information of the first page.
3. The method according to claim 1, characterized in that, The step of obtaining the persistent attributes of the first page includes: Determine whether the configuration attribute information contains a persistent identifier; If the determination result is yes, then the persistence attribute of the first page is determined to be persistent.
4. The method according to any one of claims 1-3, characterized in that, Before obtaining the configuration attribute information of the first page in response to a switching operation from the first page to the second page, the method further includes: For the currently displayed first page, obtain the configuration attribute information of the first page; Based on the configuration attribute information, obtain the persistence attributes of the first page; If the persistence attribute of the first page is set to persistent, the current state information of the first page is cached as the historical state information of the first page; In response to a switch operation from the first page to the second page, navigate from the first page to the second page.
5. The method according to claim 4, characterized in that, The cached current state information of the first page includes: The current state information of the first page is cached using the data structure of the Document Object Model.
6. The method according to claim 4, characterized in that, Also includes: If the persistence attribute of the first page is set to persistent, the identifier of the first page is written to the page cache queue.
7. A page loading device, characterized in that, include: The acquisition module is used to acquire the persistence attributes of the first page and the target cache page identifier. The first page is the previous page of the currently displayed second page. The target cache page identifier is used to specify the target page that needs to load the historical state of the first page when returning to the first page. The persistence attributes include persistent persistence and non-persistent persistence. Persistent persistence means that the state information of the first page needs to be saved, and non-persistent persistence means that the state information of the first page does not need to be saved. The determination module is used to determine whether the target cache page corresponding to the target cache page identifier is the second page in response to a return operation from the second page to the first page when the persistence attribute of the first page is persistent. The acquisition module is further configured to, when the target cache page corresponding to the target cache page identifier is the second page, obtain the historical state information of the first page from the cached historical state information according to the identifier of the first page; Correspondingly, the loading module is used to load the first page based on the historical state information of the first page; The acquisition module is further configured to, when the persistence attribute of the first page is non-persistent or the target cached page is not the second page, match the identifier of the first page in the pre-stored correspondence between page identifiers and initialization state information to obtain the initialization state information of the first page. Accordingly, the loading module is also used to load the first page according to the initialization state information of the first page; The acquisition module is further configured to, when the persistence attribute of the first page is persistent and the target cache page corresponding to the target cache page identifier is not the second page, delete the identifier of the first page from the page cache queue and delete the historical state information of the first page from the cached historical state information; and match the identifier of the first page in the pre-stored correspondence between page identifiers and initialization state information to obtain the initialization state information of the first page. Accordingly, the loading module is also used to load the first page according to the initialization state information of the first page.
8. An electronic device, characterized in that, include: A memory, a processor, and a display component; wherein the memory is used to store computer programs; The processor is coupled to the memory and the display component for executing the computer program to perform the steps of the method according to any one of claims 1-6.
9. A computer-readable storage medium storing computer instructions, characterized in that, When the computer instructions are executed by one or more processors, the one or more processors cause the processors to perform the steps of the method according to any one of claims 1-6.