CN111625239A - Method and component for updating virtual page instance state in SPA - Google Patents

Method and component for updating virtual page instance state in SPA Download PDF

Info

Publication number
CN111625239A
CN111625239A CN202010388536.0A CN202010388536A CN111625239A CN 111625239 A CN111625239 A CN 111625239A CN 202010388536 A CN202010388536 A CN 202010388536A CN 111625239 A CN111625239 A CN 111625239A
Authority
CN
China
Prior art keywords
instance
virtual page
spa
memory
page instance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010388536.0A
Other languages
Chinese (zh)
Other versions
CN111625239B (en
Inventor
唐溢泓
崔伟毅
傅腾
徐啸
胡鹏
彭茜
杨雯雯
王俊龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Renke Interactive Network Technology Co Ltd
Original Assignee
Beijing Renke Interactive Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Renke Interactive Network Technology Co Ltd filed Critical Beijing Renke Interactive Network Technology Co Ltd
Priority to CN202010388536.0A priority Critical patent/CN111625239B/en
Publication of CN111625239A publication Critical patent/CN111625239A/en
Application granted granted Critical
Publication of CN111625239B publication Critical patent/CN111625239B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The embodiment of the invention provides a method and a component for updating a virtual page instance state in an SPA, wherein the method comprises the following steps: receiving a page request of a user, and creating a virtual page instance of the SPA; receiving a real-time detection result of a memory monitor component in an SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; and if the intermediate input of the user is received, instructing a notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service. The method and the component provided by the embodiment of the invention realize that the states of all the virtual page instances in the SPA are updated no matter the storage mode of the virtual page instances, and the storage of the virtual page instances in the SPA reasonably utilizes the memory.

Description

Method and component for updating virtual page instance state in SPA
Technical Field
The invention relates to the technical field of single-page application programs, in particular to a method and a component for updating a virtual page instance state in an SPA.
Background
In modern business single-page applications, complex situations cannot be avoided, and more user interactions will result in more memory usage. In particular, all resources of the mobile device are limited and memory is shared with all running applications/Operating Systems (OS).
In a Single Page Application (SPA), all UIs are in one browser window and cannot benefit from OS memory management, if there is not enough system memory to support the SPA in maintaining the correct state, the SPA may crash and the end user may not get a better user experience. From the browser's perspective, it can only trigger garbage collection when there is insufficient memory, but it does not help in the fact that the SPA must use more memory but cannot do garbage collection.
One problem in the current SPA is that the pages that can be stored in the memory are limited, and therefore, some pages need to be stored in other locations except the memory, and when the content of a certain page is updated due to user operation, the corresponding content of all pages related to the page needs to be updated, but the current SPA only supports updating the page related to the page stored in the memory, and cannot update the page state stored in other memories other than the memory in real time.
Therefore, how to avoid the situation that the updating of the states of all the virtual page instances in the existing SPA is limited by the storage location and the storage of the virtual page instances in the SPA does not reasonably utilize the memory is still a problem to be solved by those skilled in the art.
Disclosure of Invention
The embodiment of the invention provides a method and a device for detecting pronation of feet based on plantar pressure, which are used for solving the problem that the existing method for detecting pronation of feet is high in precision, complete in function and difficult in cost balance.
In a first aspect, an embodiment of the present invention provides a method for updating a virtual page instance state in an SPA, including:
receiving a page request of a user, and creating a virtual page instance of the SPA;
receiving a real-time detection result of a memory monitor component in an SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
and if the intermediate input of the user is received, instructing a notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
Preferably, in the method, the creating a virtual page instance of the SPA specifically includes:
if the page request is not instantiated, downloading resources to create a first UI style instance and a first UI domain instance, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resources comprise a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
Preferably, in the method, the receiving a real-time detection result of a memory monitor component in the SPA determines a storage manner of the virtual page instance, where the storage manner includes foreground internal memory storage, background internal memory storage, and external memory storage, and specifically includes:
if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor component in the SPA indicates that the internal memory shortage warning exists in the system or the number of virtual page instances in the internal memory exceeds a preset threshold value.
Preferably, in the method, the storing the virtual page instance by using the external memory specifically includes:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and the state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the external memory type based on the application platform specifically includes:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
Preferably, in the method, if receiving an intermediate input from a user, instructing a notification service component in the SPA to issue a status update message to a virtual page instance of the subscription notification service, and updating a status of the virtual page instance of the subscription notification service according to a storage manner of the virtual page instance of the subscription notification service, specifically includes:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
and if the virtual page instance of the subscription notification service is stored in a background internal memory or an external memory, updating the UI domain data and the state data of the virtual page instance based on the intermediate input without UI rendering updating.
In a second aspect, an embodiment of the present invention provides a component for updating a virtual page instance state in an SPA, where the component is characterized in that the component includes:
a receiving unit, configured to create a virtual page instance of an SPA;
the allocation unit is used for receiving a real-time detection result of a memory monitor component in the SPA and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
and the updating unit is used for commanding the notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service if the intermediate input of the user is received, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
Preferably, in the apparatus, the creating a virtual page instance of the SPA specifically includes:
if the page request is not instantiated, downloading resources to create a first UI style instance and a first UI domain instance, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resources comprise a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
Preferably, in the apparatus, the blending unit is specifically configured to:
if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor component in the SPA indicates that the internal memory shortage warning exists in the system or the number of virtual page instances in the internal memory exceeds a preset threshold value.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method for updating the virtual page instance state in the SPA according to the first aspect when executing the program.
In a fourth aspect, an embodiment of the present invention provides a non-transitory computer readable storage medium, on which a computer program is stored, the computer program, when executed by a processor, implementing the steps of the method for updating a virtual page instance state in an SPA, as provided in the first aspect.
According to the method and the component provided by the embodiment of the invention, when the page request of a user is received, the virtual page instance of the SPA is created; then determining a storage mode of the virtual page instance according to a real-time detection result of a memory monitor component in the SPA, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; when receiving the intermediate input of the user, instructing a notification service component in the SPA to issue a state update message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service. Therefore, the method can achieve the purposes of allocating the virtual page instances stored in the internal memory or the external memory and updating the virtual pages subscribed to the notification service according to the storage mode of the virtual page instances subscribed to the notification service. Therefore, the method and the component provided by the embodiment of the invention realize that the states of all the virtual page instances in the SPA are updated no matter the storage mode of the virtual page instances, and the storage of the virtual page instances in the SPA reasonably utilizes the memory.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a method for updating a virtual page instance state in an SPA according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of creating a virtual page instance according to an embodiment of the present invention;
FIG. 3 is a memory state transition diagram of an example virtual page provided by an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a component for updating a virtual page instance state in an SPA according to an embodiment of the present invention;
fig. 5 is a schematic physical structure diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive effort based on the embodiments of the present invention, are within the scope of the present invention.
The existing SPA has the problems that the updating of the states of all virtual page instances is limited by storage positions and the storage of the virtual page instances in the SPA does not reasonably utilize the memory. Therefore, the embodiment of the invention provides a method for updating the virtual page instance state in the SPA. Fig. 1 is a schematic flowchart of a method for updating a virtual page instance state in an SPA according to an embodiment of the present invention, where as shown in fig. 1, an execution subject of the method is a component in the SPA, and the method includes:
step 110, receiving a page request of a user, and creating a virtual page instance of the SPA.
Specifically, when a component in the SPA that updates the state of a virtual page instance (which may be referred to as a navigation container component) receives a page request from a user, the component first creates a virtual page instance corresponding to the page request. For the virtual page instance in the SPA, three types are distinguished: a first type of virtual page instance is stored in foreground internal memory, i.e., the virtual page instance is visible on the current screen application; the second type of virtual page instance is stored in the background internal memory, is invisible in the current application state, but is usually closely related to the page displayed by the current application, such as a previous page or a next page of the current page, and is also present in the internal memory for fast switching with the current page; a third type of virtual page instance is stored in external memory and is of a type that is not always requested by a user. When a page request of a user occurs, a component for updating the state of a virtual page instance in an SPA creates a corresponding virtual page instance according to the condition whether the page request is instantiated or not, and if the page request is not instantiated, resources are downloaded to create the virtual page instance; and if the page request is instantiated, restoring the virtual page instance from the stored data content of the instantiated virtual page instance.
And step 120, receiving a real-time detection result of a memory monitor component in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage.
Specifically, the state of the internal memory needs to be considered to determine the storage mode of the virtual page instance, and the state of the internal memory is monitored in real time by a memory monitor component in the SPA, if the virtual page instance is a user using instance, the storage mode of the virtual page instance is foreground internal memory storage, if the virtual page instance is not a user using instance but the internal memory space is sufficient, the storage mode of the virtual page instance is background internal memory storage, and if the virtual page instance is not a user using instance and the internal memory space is insufficient, the storage mode of the virtual page instance is external memory storage. Therefore, the component in the SPA updating the state of the virtual page instance allocates the virtual page instance among the storage locations according to the real-time occupation state of the memory.
Step 130, if receiving the intermediate input of the user, instructing the notification service component in the SPA to issue a state update message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
Specifically, when an intermediate input of the user is received, where the intermediate input includes that the user inputs in an input box of the current page or clicks a link of the current page, the component in the SPA that updates the state of the virtual page instance may instruct the notification service component in the SPA to issue a state update message to the virtual page instance subscribed to the notification service. It should be noted here that, at present, all the virtual page instances are subscribed to the notification service by default when initially created, and the subscription state of a virtual page instance does not change with the transition of its storage manner. Then, the component for updating the state of the virtual page instance in the SPA updates the state of the virtual page instance subscribed to the notification service according to the storage manner of the virtual page instance subscribed to the notification service, and the storage contents of the virtual page instances stored in different storage manners are different, so that when the state of the virtual page instance is updated, different contents of the virtual page instance are updated due to the storage manners of the different virtual page instances, for example, rendering inevitably exists in the virtual page instance stored in the foreground internal memory due to displaying, so UI rendering needs to be updated during updating, and rendering does not exist in the virtual page instances stored in the background internal memory and the external memory because none is displayed, so that updating of UI rendering is not needed.
According to the method provided by the embodiment of the invention, when a page request of a user is received, a virtual page instance of an SPA is created; then determining a storage mode of the virtual page instance according to a real-time detection result of a memory monitor component in the SPA, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; when receiving the intermediate input of the user, instructing a notification service component in the SPA to issue a state update message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service. Therefore, the method can achieve the purposes of allocating the virtual page instances stored in the internal memory or the external memory and updating the virtual pages subscribed to the notification service according to the storage mode of the virtual page instances subscribed to the notification service. Therefore, the method provided by the embodiment of the invention realizes that the states of all the virtual page instances in the SPA are updated no matter the storage mode of the virtual page instances, and the storage of the virtual page instances in the SPA reasonably utilizes the memory.
Based on the above embodiment, in the method, the creating a virtual page instance of the SPA specifically includes:
if the page request is not instantiated, downloading resources to create a first UI style instance and a first UI domain instance, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resources comprise a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
Specifically, fig. 2 is a schematic flowchart of a process for creating a virtual page instance according to an embodiment of the present invention, and as shown in fig. 2, a virtual page corresponding to a page request is first created, if the virtual page is instantiated, that is, if the page request is instantiated, a resource is downloaded, a first UI style instance and a first UI domain instance are created using the resource, a first state data instance matching the first UI style instance and the first UI domain instance is constructed, and a virtual page instance is finally created based on the first UI style instance, the first UI domain instance, and the first state data instance, where the resource includes a UI domain model, a virtual page js, and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring the page from the external memory, namely replying UI domain data and state data in page content, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and finally creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
The composition of the virtual page is introduced, and one virtual page can be split into a UI domain model, a virtual page model, a data model and a style, wherein the UI domain model is used for an HTML presentation domain language, the main function of the UI domain model is serialization, and a data and event listener can be set through a binding mechanism; the virtual page model is UI logic at a virtual page level, comprises a UI interaction processing program and data binding, and finally updates the UI by changing the UI domain model; the data model is a JSON object in the service response and can be used in the virtual page model; styles are a virtual page-wide CSS that can be added and deleted via the page state.
Based on any of the above embodiments, in the method, the receiving a real-time detection result of a memory monitor component in the SPA, and determining a storage manner of the virtual page instance, where the storage manner includes foreground internal memory storage, background internal memory storage, and external memory storage, specifically includes:
if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor component in the SPA indicates that the internal memory shortage warning exists in the system or the number of virtual page instances in the internal memory exceeds a preset threshold value.
Specifically, fig. 3 is a storage state transition diagram of a virtual page instance provided by the embodiment of the present invention, and as shown in fig. 3, three states, namely, visible state, invisible state and persistent state in fig. 3, respectively correspond to states of the virtual page instance stored in three storage modes, namely, foreground internal memory, background internal memory and external memory, of the virtual page instance. The arrows in fig. 3 also indicate the direction of transition between the states. When the state of a virtual page instance needs to be changed, the condition that whether the virtual page instance is used by a user and the current memory need to be considered in a combined manner, if the virtual page instance is the user instance, the storage mode of the virtual page instance is the storage mode of a foreground internal memory; if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage; and if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage. The method for determining the result of real-time monitoring of the memory by the memory monitor component in the SPA is to monitor the warning of insufficient memory of the system and to monitor whether the number of virtual page instances in the memory exceeds a maximum value, and if one of the conditions occurs, for example, the warning of insufficient memory of the system occurs or the detected number of virtual page instances in the memory exceeds a preset maximum value, the result of real-time monitoring of the memory is determined to be required to be reported to the component for updating the state of the virtual page instances in the SPA, so that the storage mode of the virtual page instances is determined.
Based on any of the above embodiments, in the method, the storing the virtual page instance by using the external memory specifically includes:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and the state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the external memory type based on the application platform specifically includes:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
Specifically, after determining that the virtual page instance needs to be stored using external memory, the application platform based on the current SPA needs to select the external memory type. The types of external memories corresponding to different application platforms are different, and for a browser application platform, the external memory used is a local memory (local storage) or an index database (indexed DB), while for a hybrid mobile application platform, the external memory used is a native memory (native storage). Then, splitting the virtual page instance into content data which can be stored in an external memory, wherein the content data are UI domain data and state data; and after the external memory is stored, the associated information of the virtual page instance is cleared from the internal memory, and the memory space occupied by the associated information is completely released.
Based on any of the embodiments, in the method, the updating the state of the virtual page instance of the subscription notification service according to the storage manner of the virtual page instance of the subscription notification service specifically includes:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
and if the virtual page instance of the subscription notification service is stored in a background internal memory or an external memory, updating the UI domain data and the state data of the virtual page instance based on the intermediate input without UI rendering updating.
Specifically, the storage manners of the different virtual page instances are also different for the content stored in the virtual page instance, for example, if the virtual page instance of the subscription notification service is stored in the foreground internal memory, the UI domain data, the state data, and the UI rendering of the virtual page instance of the subscription notification service are updated based on the intermediate input; and if the virtual page instance of the subscription notification service is stored in a background internal memory or an external memory, updating the UI domain data and the state data of the virtual page instance based on the intermediate input without UI rendering updating.
Based on any of the above embodiments, an embodiment of the present invention provides a component for updating a virtual page instance state in an SPA, and fig. 4 is a schematic structural diagram of the component for updating the virtual page instance state in the SPA according to the embodiment of the present invention. As shown in fig. 4, the apparatus includes a receiving unit 410, a scheduling unit 420, and an updating unit 430, wherein,
the receiving unit 410 is configured to create a virtual page instance of an SPA;
the allocating unit 420 is configured to receive a real-time detection result of a memory monitor component in the SPA, and determine a storage manner of the virtual page instance, where the storage manner includes foreground internal memory storage, background internal memory storage, and external memory storage;
the updating unit 430 is configured to, if an intermediate input of the user is received, instruct the notification service component in the SPA to issue a state update message to the virtual page instance of the subscription notification service, and update the state of the virtual page instance of the subscription notification service according to the storage manner of the virtual page instance of the subscription notification service.
According to the component provided by the embodiment of the invention, when a page request of a user is received, a virtual page instance of an SPA is created; then determining a storage mode of the virtual page instance according to a real-time detection result of a memory monitor component in the SPA, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; when receiving the intermediate input of the user, instructing a notification service component in the SPA to issue a state update message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service. Therefore, the method can achieve the purposes of allocating the virtual page instances stored in the internal memory or the external memory and updating the virtual pages subscribed to the notification service according to the storage mode of the virtual page instances subscribed to the notification service. Therefore, the component provided by the embodiment of the invention realizes that the states of all the virtual page instances in the SPA are updated no matter the storage mode of the virtual page instances, and the storage of the virtual page instances in the SPA reasonably utilizes the memory.
Based on any of the above embodiments, in the apparatus, the creating a virtual page instance of an SPA specifically includes:
if the page request is not instantiated, downloading resources to create a first UI style instance and a first UI domain instance, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resources comprise a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
In the device according to any of the above embodiments, the dispensing unit is specifically configured to,
if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor component in the SPA indicates that the internal memory shortage warning exists in the system or the number of virtual page instances in the internal memory exceeds a preset threshold value.
In accordance with any of the above embodiments, in the apparatus,
the storing the virtual page instance by using the external memory specifically includes:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and the state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the external memory type based on the application platform specifically includes:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
Based on any of the above embodiments, in the apparatus, the updating the state of the virtual page instance of the subscription notification service according to the storage manner of the virtual page instance of the subscription notification service specifically includes:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
and if the virtual page instance of the subscription notification service is stored in a background internal memory or an external memory, updating the UI domain data and the state data of the virtual page instance based on the intermediate input without UI rendering updating.
Fig. 5 is a schematic entity structure diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 5, the electronic device may include: a processor (processor)501, a communication Interface (Communications Interface)502, a memory (memory)503, and a communication bus 504, wherein the processor 501, the communication Interface 502, and the memory 503 are configured to communicate with each other via the communication bus 504. The processor 501 may call a computer program stored on the memory 503 and operable on the processor 501 to perform the method for updating the virtual page instance state in the SPA provided by the above embodiments, for example, including: receiving a page request of a user, and creating a virtual page instance of the SPA; receiving a real-time detection result of a memory monitor component in an SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; and if the intermediate input of the user is received, instructing a notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
In addition, the logic instructions in the memory 503 may be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or make a contribution to the prior art, or may be implemented in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Embodiments of the present invention further provide a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, is implemented to perform the method for updating a virtual page instance state in an SPA provided in the foregoing embodiments, for example, the method includes: receiving a page request of a user, and creating a virtual page instance of the SPA; receiving a real-time detection result of a memory monitor component in an SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; and if the intermediate input of the user is received, instructing a notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
The above-described system embodiments are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for updating the state of a virtual page instance in an SPA, comprising:
receiving a page request of a user, and creating a virtual page instance of the SPA;
receiving a real-time detection result of a memory monitor component in an SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
and if the intermediate input of the user is received, instructing a notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
2. The method for updating the state of the virtual page instance in the SPA of claim 1, wherein the creating the virtual page instance of the SPA specifically comprises:
if the page request is not instantiated, downloading resources to create a first UI style instance and a first UI domain instance, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resources comprise a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
3. The method for updating the state of the virtual page instance in the SPA of claim 1, wherein the receiving the real-time detection result of the memory monitor component in the SPA determines the storage mode of the virtual page instance, wherein the storage mode includes foreground internal memory storage, background internal memory storage, and external memory storage, and specifically comprises:
if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor component in the SPA indicates that the internal memory shortage warning exists in the system or the number of virtual page instances in the internal memory exceeds a preset threshold value.
4. The method for updating the state of the virtual page instance in the SPA of claim 3, wherein storing the virtual page instance with an external memory specifically comprises:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and the state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the external memory type based on the application platform specifically includes:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
5. The method for updating the state of the virtual page instance in the SPA of claim 1, wherein the updating the state of the virtual page instance of the subscription notification service according to the storage manner of the virtual page instance of the subscription notification service specifically comprises:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
and if the virtual page instance of the subscription notification service is stored in a background internal memory or an external memory, updating the UI domain data and the state data of the virtual page instance based on the intermediate input without UI rendering updating.
6. A component in an SPA for updating the state of a virtual page instance, comprising:
a receiving unit, configured to create a virtual page instance of an SPA;
the allocation unit is used for receiving a real-time detection result of a memory monitor component in the SPA and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
and the updating unit is used for commanding the notification service component in the SPA to issue a state updating message to the virtual page instance of the subscription notification service if the intermediate input of the user is received, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
7. The component in the SPA of claim 6, wherein the creating a virtual page instance of the SPA comprises:
if the page request is not instantiated, downloading resources to create a first UI style instance and a first UI domain instance, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resources comprise a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and a virtual page instance corresponding to the page request is stored in an external memory, restoring UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
and if the page request is instantiated and the virtual page instance corresponding to the page request is stored in a background internal memory, directly switching to the virtual page instance.
8. The component of claim 6, wherein the deployment unit is further configured to:
if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not the user using instance and the real-time detection result of the memory monitor component in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor component in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor component in the SPA indicates that the internal memory shortage warning exists in the system or the number of virtual page instances in the internal memory exceeds a preset threshold value.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program implements the steps of the method for updating virtual page instance state in an SPA according to any one of claims 1-5.
10. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the steps of the method for updating a virtual page instance state in an SPA according to any one of claims 1-5.
CN202010388536.0A 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA Active CN111625239B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010388536.0A CN111625239B (en) 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010388536.0A CN111625239B (en) 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA

Publications (2)

Publication Number Publication Date
CN111625239A true CN111625239A (en) 2020-09-04
CN111625239B CN111625239B (en) 2023-05-02

Family

ID=72259895

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010388536.0A Active CN111625239B (en) 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA

Country Status (1)

Country Link
CN (1) CN111625239B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283920A (en) * 2013-07-05 2015-01-14 腾讯科技(深圳)有限公司 Use method, server, terminal and system for Webapp router
CN106294365A (en) * 2015-05-15 2017-01-04 阿里巴巴集团控股有限公司 The page data processing method of a kind of single page web application and equipment
CN107291449A (en) * 2017-05-22 2017-10-24 北京奇艺世纪科技有限公司 A kind of page rendering method, device and equipment
CN109739604A (en) * 2018-12-28 2019-05-10 北京城市网邻信息技术有限公司 Page rendering method, apparatus, server and storage medium
US20190235843A1 (en) * 2018-01-29 2019-08-01 Q2 Software, Inc. Single-page web application builder system and method based on a finite-state machine
CN110457024A (en) * 2019-07-29 2019-11-15 南京控维通信科技有限公司 The plug-in unit iwebData implementation method of front end request and more new data based on VUE
CN110928545A (en) * 2019-12-04 2020-03-27 北京小米移动软件有限公司 Component distribution method, single-page application development method, device and storage medium
CN111090823A (en) * 2019-12-23 2020-05-01 广州市百果园信息技术有限公司 Integration platform of page application and application access method, device and equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283920A (en) * 2013-07-05 2015-01-14 腾讯科技(深圳)有限公司 Use method, server, terminal and system for Webapp router
CN106294365A (en) * 2015-05-15 2017-01-04 阿里巴巴集团控股有限公司 The page data processing method of a kind of single page web application and equipment
CN107291449A (en) * 2017-05-22 2017-10-24 北京奇艺世纪科技有限公司 A kind of page rendering method, device and equipment
US20190235843A1 (en) * 2018-01-29 2019-08-01 Q2 Software, Inc. Single-page web application builder system and method based on a finite-state machine
CN109739604A (en) * 2018-12-28 2019-05-10 北京城市网邻信息技术有限公司 Page rendering method, apparatus, server and storage medium
CN110457024A (en) * 2019-07-29 2019-11-15 南京控维通信科技有限公司 The plug-in unit iwebData implementation method of front end request and more new data based on VUE
CN110928545A (en) * 2019-12-04 2020-03-27 北京小米移动软件有限公司 Component distribution method, single-page application development method, device and storage medium
CN111090823A (en) * 2019-12-23 2020-05-01 广州市百果园信息技术有限公司 Integration platform of page application and application access method, device and equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
PANAGIOTIS G. TSALAPORTAS等: "Solar Lab Notebook (SLN): An Ultra-Portable Web-Based System for Heliophysics and High-Security Labs" *
吴德林: "容器PaaS平台系统WEB前端的设计与实现" *

Also Published As

Publication number Publication date
CN111625239B (en) 2023-05-02

Similar Documents

Publication Publication Date Title
EP3270300A1 (en) Method and device for form verification
CN109726076B (en) Applet life cycle management method and system
CN113094136A (en) Page display control method and device, storage medium and electronic equipment
CN111190673B (en) Page display method and device based on operation monitoring and electronic equipment
CN108200132B (en) Resource acquisition method, device, equipment and computer readable storage medium
CN109298960A (en) Application crashes processing method, device, computer installation and storage medium
CN114168239B (en) Window display method, device, equipment and storage medium
CN114116092A (en) Cloud desktop system processing method, cloud desktop system control method and related equipment
CN108933947B (en) Bullet screen display method and device
CN114490126A (en) Page processing method and device, electronic equipment and storage medium
CN114257550A (en) Automatic control method and device for interface access flow, storage medium and server
CN113741754A (en) Task creation method and device, electronic equipment and computer-readable storage medium
CN111625239A (en) Method and component for updating virtual page instance state in SPA
CN110599112B (en) Network page development and maintenance method and device
CN113536168B (en) Component processing method and device
CN114090118A (en) Method, device and equipment for starting small program and storage medium
US20200356720A1 (en) Rendering Based on a Document Object Model
CN114415993A (en) Screen splitting method and device for multi-system application, electronic equipment and storage medium
CN114117274A (en) Data rendering method and device, computer equipment and storage medium
CN107704491B (en) Message processing method and device
CN112799558A (en) Information processing method, information processing device, electronic equipment and storage medium
US10542119B2 (en) Multi-geographical processing of user requests
CN112035133A (en) Homepage upgrading method and terminal
CN106844502B (en) Data consistency processing method and equipment
CN113515328A (en) Page rendering method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant